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

📄 dockareaseditor.cs

📁 Fireball.CodeEditor is an source code editor control derived from the best compona SyntaxBox Control
💻 CS
字号:
#region Fireball License
//    Copyright (C) 2005  Sebastian Faltoni sebastian{at}dotnetfireball{dot}net
//
//    This library is free software; you can redistribute it and/or
//    modify it under the terms of the GNU Lesser General Public
//    License as published by the Free Software Foundation; either
//    version 2.1 of the License, or (at your option) any later version.
//
//    This library is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//    Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public
//    License along with this library; if not, write to the Free Software
//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#endregion
#region Original License
// *****************************************************************************
// 
//  Copyright 2004, Weifen Luo
//  All rights reserved. The software and associated documentation 
//  supplied hereunder are the proprietary information of Weifen Luo
//  and are supplied subject to licence terms.
// 
//  WinFormsUI Library Version 1.0
// *****************************************************************************
#endregion


using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;


namespace Fireball.Docking
{	
	internal class DockAreasEditor : UITypeEditor
	{
		private class DockAreasEditorControl : System.Windows.Forms.UserControl
		{
			private IWindowsFormsEditorService m_edSvc;
			private CheckBox checkBoxFloat;
			private CheckBox checkBoxDockLeft;
			private CheckBox checkBoxDockRight;
			private CheckBox checkBoxDockTop;
			private CheckBox checkBoxDockBottom;
			private CheckBox checkBoxDockFill;
			private DockAreas m_oldDockAreas;

			public DockAreas DockAreas
			{
				get
				{
					DockAreas dockAreas = 0;
					if (checkBoxFloat.Checked)
						dockAreas |= DockAreas.Float;
					if (checkBoxDockLeft.Checked)
						dockAreas |= DockAreas.DockLeft;
					if (checkBoxDockRight.Checked)
						dockAreas |= DockAreas.DockRight;
					if (checkBoxDockTop.Checked)
						dockAreas |= DockAreas.DockTop;
					if (checkBoxDockBottom.Checked)
						dockAreas |= DockAreas.DockBottom;
					if (checkBoxDockFill.Checked)
						dockAreas |= DockAreas.Document;

					if (dockAreas == 0)
						return m_oldDockAreas;
					else
						return dockAreas;
				}
			}

			public DockAreasEditorControl()
			{
				checkBoxFloat = new CheckBox();
				checkBoxDockLeft = new CheckBox();
				checkBoxDockRight = new CheckBox();
				checkBoxDockTop = new CheckBox();
				checkBoxDockBottom = new CheckBox();
				checkBoxDockFill = new CheckBox();

				SuspendLayout();

				checkBoxFloat.Appearance = Appearance.Button;
				checkBoxFloat.Dock = DockStyle.Top;
				checkBoxFloat.Height = 24;
				checkBoxFloat.Text = "(Float)";
				checkBoxFloat.TextAlign = ContentAlignment.MiddleCenter;
				checkBoxFloat.FlatStyle = FlatStyle.System;
			
				checkBoxDockLeft.Appearance = System.Windows.Forms.Appearance.Button;
				checkBoxDockLeft.Dock = System.Windows.Forms.DockStyle.Left;
				checkBoxDockLeft.Width = 24;
				checkBoxDockLeft.FlatStyle = FlatStyle.System;

				checkBoxDockRight.Appearance = System.Windows.Forms.Appearance.Button;
				checkBoxDockRight.Dock = System.Windows.Forms.DockStyle.Right;
				checkBoxDockRight.Width = 24;
				checkBoxDockRight.FlatStyle = FlatStyle.System;

				checkBoxDockTop.Appearance = System.Windows.Forms.Appearance.Button;
				checkBoxDockTop.Dock = System.Windows.Forms.DockStyle.Top;
				checkBoxDockTop.Height = 24;
				checkBoxDockTop.FlatStyle = FlatStyle.System;

				checkBoxDockBottom.Appearance = System.Windows.Forms.Appearance.Button;
				checkBoxDockBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
				checkBoxDockBottom.Height = 24;
				checkBoxDockBottom.FlatStyle = FlatStyle.System;
			
				checkBoxDockFill.Appearance = System.Windows.Forms.Appearance.Button;
				checkBoxDockFill.Dock = System.Windows.Forms.DockStyle.Fill;
				checkBoxDockFill.FlatStyle = FlatStyle.System;

				this.Controls.AddRange(new Control[] {
														 checkBoxDockFill,
														 checkBoxDockBottom,
														 checkBoxDockTop,
														 checkBoxDockRight,
														 checkBoxDockLeft,
														 checkBoxFloat});

				Size = new System.Drawing.Size(160, 144);
				BackColor = SystemColors.Control;
				ResumeLayout();
			}

			public void SetStates(IWindowsFormsEditorService edSvc, DockAreas dockAreas)
			{
				m_edSvc = edSvc;
				m_oldDockAreas = dockAreas;
				if ((dockAreas & DockAreas.DockLeft) != 0)
					checkBoxDockLeft.Checked = true;
				if ((dockAreas & DockAreas.DockRight) != 0)
					checkBoxDockRight.Checked = true;
				if ((dockAreas & DockAreas.DockTop) != 0)
					checkBoxDockTop.Checked = true;
				if ((dockAreas & DockAreas.DockTop) != 0)
					checkBoxDockTop.Checked = true;
				if ((dockAreas & DockAreas.DockBottom) != 0)
					checkBoxDockBottom.Checked = true;
				if ((dockAreas & DockAreas.Document) != 0)
					checkBoxDockFill.Checked = true;
				if ((dockAreas & DockAreas.Float) != 0)
					checkBoxFloat.Checked = true;
			}
		}

		private DockAreasEditor.DockAreasEditorControl m_ui = null;

		public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
		{
			return UITypeEditorEditStyle.DropDown;
		}

		public override object EditValue(ITypeDescriptorContext context, IServiceProvider sp, object value)
		{
			IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)sp.GetService(typeof(IWindowsFormsEditorService));

			if (m_ui == null)
				m_ui = new DockAreasEditor.DockAreasEditorControl();

			m_ui.SetStates(edSvc, (DockAreas)value);
			edSvc.DropDownControl(m_ui);

			return m_ui.DockAreas;
		}
	}
}

⌨️ 快捷键说明

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