⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modecontrol.cs

📁 树的简单使用方法和基本操作,这是一个CS程序.
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Reflection;
using System.Windows.Forms;

using Common;

namespace TreeTest
{
	public partial class ModeControl : ModeBase
	{
		private List<ModeBase> _Controls = new List<ModeBase>();

		private ModeCounts _Counts = new ModeCounts();
		private ModeRelationships _Relationships = new ModeRelationships();
		private ModeProperties _Properties = new ModeProperties();
		private ModeAddElement _AddElement = new ModeAddElement();
		private ModeAddTree _AddTree = new ModeAddTree();
		private ModeMove _Move = new ModeMove();
		private ModeNode _Node = new ModeNode();
		private ModeElement _Element = new ModeElement();
		private ModeEnumerators _Enumerators = new ModeEnumerators();
		private ModeSerialization _Serialization = new ModeSerialization();
		private ModeMemory _Memory = new ModeMemory();
        private ModeValue _Value = new ModeValue();

		private Setting _Operation = new Setting( "Operation", ( int ) Mode.Counts );

		public ModeControl()
		{
			InitializeComponent();

			FieldInfo[] fields = GetType().GetFields( BindingFlags.Instance | BindingFlags.NonPublic );
			
			foreach ( FieldInfo field in fields )
				if ( field.FieldType.IsSubclassOf( typeof ( ModeBase ) ) )
					_Controls.Add( ( ModeBase ) field.GetValue( this ) );

			foreach ( ModeBase control in _Controls )
			{
				control.Location = _Panel.Location;
				control.Size = _Panel.Size;
				Controls.Add( control );

				control.RefreshTree += delegate( object sender, EventArgs args ) { OnRefreshTree(); };
				control.SetTreeClipboard += delegate( object sender, TreeEventArgs args ) { OnSetTreeClipboard( args.Tree ); };
			}

			foreach ( Mode mode in Enum.GetValues( typeof( Mode ) ) )
				if ( mode != Mode.None )
					_Mode.Items.Add( mode );

			_Mode.SelectedItem = ( Mode ) _Operation.Int;

			SetVisible();
		}

		private void ModeControl_Load( object sender, EventArgs e )
		{
		}

		public override INode<Element> CurrentNode
		{
			set
			{
				base.CurrentNode = value;

				foreach ( ModeBase control in _Controls ) control.CurrentNode = value;
			}
		}

		public override ITree<Element> TreeClipboard
		{
			set
			{
				base.TreeClipboard = value;

				foreach ( ModeBase control in _Controls ) control.TreeClipboard = value;
			}
		}

		public override void OnNewTree()
		{
			foreach ( ModeBase control in _Controls ) control.OnNewTree();
		}

		private void _Mode_SelectedIndexChanged( object sender, EventArgs e )
		{
			SetVisible();
		}

		private void SetVisible()
		{
			Mode mode = ( Mode ) _Mode.SelectedItem;

			_Operation.Set( ( int ) mode );

			foreach ( ModeBase control in _Controls ) control.Visible = ( control.Mode == mode );
		}
	}

	public enum Mode
	{
		None,
		Counts,
		Relationships,
		Properties,
		AddElement,
		AddTree,
		Move,
		Node,
		Element,
		Enumerators,
		Serialization,
		Memory,
        Value,
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -