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

📄 dockindicator.cs

📁 Fireball.CodeEditor is an source code editor control derived from the best compona SyntaxBox Control
💻 CS
📖 第 1 页 / 共 2 页
字号:
			Region = new Region(Rectangle.Empty);
		}

		private PaneIndicator m_paneDiamond = null;
		private PaneIndicator PaneDiamond
		{
			get
			{
				if (m_paneDiamond == null)
					m_paneDiamond = new PaneIndicator();

				return m_paneDiamond;
			}
		}

		private PanelIndicator m_panelLeft = null;
		private PanelIndicator PanelLeft
		{
			get
			{
				if (m_panelLeft == null)
					m_panelLeft = new PanelIndicator(DockStyle.Left);

				return m_panelLeft;
			}
		}

		private PanelIndicator m_panelRight = null;
		private PanelIndicator PanelRight
		{
			get
			{
				if (m_panelRight == null)
					m_panelRight = new PanelIndicator(DockStyle.Right);

				return m_panelRight;
			}
		}

		private PanelIndicator m_panelTop = null;
		private PanelIndicator PanelTop
		{
			get
			{
				if (m_panelTop == null)
					m_panelTop = new PanelIndicator(DockStyle.Top);

				return m_panelTop;
			}
		}

		private PanelIndicator m_panelBottom = null;
		private PanelIndicator PanelBottom
		{
			get
			{
				if (m_panelBottom == null)
					m_panelBottom = new PanelIndicator(DockStyle.Bottom);

				return m_panelBottom;
			}
		}

		private PanelIndicator m_panelFill = null;
		private PanelIndicator PanelFill
		{
			get
			{
				if (m_panelFill == null)
					m_panelFill = new PanelIndicator(DockStyle.Fill);

				return m_panelFill;
			}
		}

		private bool m_fullPanelEdge = false;
		public bool FullPanelEdge
		{
			get	{	return m_fullPanelEdge;	}
			set
			{	
				if (m_fullPanelEdge == value)
					return;

				m_fullPanelEdge = value;
				RefreshChanges();
			}
		}

		private DragHandler m_dragHandler;
		public DragHandler DragHandler
		{
			get	{	return m_dragHandler;	}
		}

		public DockContainer DockPanel
		{
			get	{	return DragHandler.DockPanel;	}
		}

		private DockPane m_dockPane = null;
		public DockPane DockPane
		{
			get	{	return m_dockPane;	}
			set
			{
				if (m_dockPane == value)
					return;

				DockPane oldDisplayingPane = DisplayingPane;
				m_dockPane = value;
				if (oldDisplayingPane != DisplayingPane)
					RefreshChanges();
			}
		}

		private IHitTest m_hitTest = null;
		private IHitTest HitTestResult
		{
			get	{	return m_hitTest;	}
			set
			{
				if (m_hitTest == value)
					return;

				if (m_hitTest != null)
					m_hitTest.Status = DockStyle.None;

				m_hitTest = value;
			}
		}

		private DockPane DisplayingPane
		{
			get	{	return ShouldPaneDiamondVisible() ? DockPane : null;	}
		}

		private void RefreshChanges()
		{
			Region region = new Region(Rectangle.Empty);
			Rectangle rectDockArea = FullPanelEdge ? DockPanel.DockArea : DockPanel.DocumentWindowBounds;

			rectDockArea.Location = DockPanel.PointToScreen(rectDockArea.Location);
			if (ShouldPanelIndicatorVisible(DockState.DockLeft))
			{
				PanelLeft.Location = new Point(rectDockArea.X + _PanelIndicatorMargin, rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2);
				PanelLeft.Visible = true;
				region.Union(PanelLeft.Bounds);
			}
			else
				PanelLeft.Visible = false;

			if (ShouldPanelIndicatorVisible(DockState.DockRight))
			{
				PanelRight.Location = new Point(rectDockArea.X + rectDockArea.Width - PanelRight.Width - _PanelIndicatorMargin, rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2);
				PanelRight.Visible = true;
				region.Union(PanelRight.Bounds);
			}
			else
				PanelRight.Visible = false;

			if (ShouldPanelIndicatorVisible(DockState.DockTop))
			{
				PanelTop.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelTop.Width) / 2, rectDockArea.Y + _PanelIndicatorMargin);
				PanelTop.Visible = true;
				region.Union(PanelTop.Bounds);
			}
			else
				PanelTop.Visible = false;

			if (ShouldPanelIndicatorVisible(DockState.DockBottom))
			{
				PanelBottom.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelBottom.Width) / 2, rectDockArea.Y + rectDockArea.Height - PanelBottom.Height - _PanelIndicatorMargin);
				PanelBottom.Visible = true;
				region.Union(PanelBottom.Bounds);
			}
			else
				PanelBottom.Visible = false;

			if (ShouldPanelIndicatorVisible(DockState.Document))
			{
				Rectangle rectDocumentWindow = DockPanel.DocumentWindowBounds;
				rectDocumentWindow.Location = DockPanel.PointToScreen(rectDocumentWindow.Location);
				PanelFill.Location = new Point(rectDocumentWindow.X + (rectDocumentWindow.Width - PanelFill.Width) / 2, rectDocumentWindow.Y + (rectDocumentWindow.Height - PanelFill.Height) / 2);
				PanelFill.Visible = true;
				region.Union(PanelFill.Bounds);
			}
			else
				PanelFill.Visible = false;

			if (ShouldPaneDiamondVisible())
			{
				Rectangle rect = DockPane.ClientRectangle;
				rect.Location = DockPane.PointToScreen(rect.Location);
				PaneDiamond.Location = new Point(rect.Left + (rect.Width - PaneDiamond.Width) / 2, rect.Top + (rect.Height - PaneDiamond.Height) / 2);
				PaneDiamond.Visible = true;
				using (GraphicsPath graphicsPath = PaneDiamond.DisplayingGraphicsPath.Clone() as GraphicsPath)
				{
					Point[] pts = new Point[]
						{
							new Point(PaneDiamond.Left, PaneDiamond.Top),
							new Point(PaneDiamond.Right, PaneDiamond.Top),
							new Point(PaneDiamond.Left, PaneDiamond.Bottom)
						};
					using (Matrix matrix = new Matrix(PaneDiamond.ClientRectangle, pts))
					{
						graphicsPath.Transform(matrix);
					}
					region.Union(graphicsPath);
				}
			}
			else
				PaneDiamond.Visible = false;

			Region = region;
		}

		private bool ShouldPanelIndicatorVisible(DockState dockState)
		{
			if (!Visible)
				return false;

			if (DockPanel.DockWindows[dockState].Visible)
				return false;

			return DragHandler.IsDockStateValid(dockState);
		}

		private bool ShouldPaneDiamondVisible()
		{
			if (DockPane == null)
				return false;

			if (DragHandler.DragControl == DockPane)
				return false;

			if (DragHandler.DragControl == DockPane.DockListContainer)
				return false;

			IDockableWindow content = DragHandler.DragControl as IDockableWindow;
			if (content != null && DockPane.Contents.Contains(content) && DockPane.DisplayingContents.Count == 1)
				return false;

			return DragHandler.IsDockStateValid(DockPane.DockState);
		}

		public override void Show(bool bActivate)
		{
			base.Show (bActivate);
			RefreshChanges();
		}

		public void TestDrop()
		{
			Point pt = Control.MousePosition;
			DockPane = DockHelper.PaneAtPoint(pt, DockPanel);

			if (TestDrop(PanelLeft, pt) != DockStyle.None)
				HitTestResult = PanelLeft;
			else if (TestDrop(PanelRight, pt) != DockStyle.None)
				HitTestResult = PanelRight;
			else if (TestDrop(PanelTop, pt) != DockStyle.None)
				HitTestResult = PanelTop;
			else if (TestDrop(PanelBottom, pt) != DockStyle.None)
				HitTestResult = PanelBottom;
			else if (TestDrop(PanelFill, pt) != DockStyle.None)
				HitTestResult = PanelFill;
			else if (TestDrop(PaneDiamond, pt) != DockStyle.None)
				HitTestResult = PaneDiamond;
			else
				HitTestResult = null;

			if (HitTestResult != null)
			{
				if (HitTestResult is PaneIndicator)
					DragHandler.DockOutline.Show(DockPane, HitTestResult.Status);
				else
					DragHandler.DockOutline.Show(DockPanel, HitTestResult.Status, FullPanelEdge);
			}
		}

		private DockStyle TestDrop(IHitTest hitTest, Point pt)
		{
			return hitTest.Status = hitTest.HitTest(pt);
		}

		private Rectangle GetAllScreenBounds() 
		{ 
			Rectangle rect = new Rectangle(0, 0, 0, 0); 
			foreach (Screen screen in Screen.AllScreens) 
			{ 
				Rectangle rectScreen = screen.Bounds; 
				if (rectScreen.Left < rect.Left) 
				{ 
					rect.Width += (rect.Left - rectScreen.Left); 
					rect.X = rectScreen.X; 
				} 
				if (rectScreen.Right > rect.Right) 
					rect.Width += (rectScreen.Right - rect.Right); 
				if (rectScreen.Top < rect.Top) 
				{ 
					rect.Height += (rect.Top - rectScreen.Top); 
					rect.Y = rectScreen.Y; 
				} 
				if (rectScreen.Bottom > rect.Bottom) 
					rect.Height += (rectScreen.Bottom - rect.Bottom); 
			} 
 
			return rect; 
		} 
	}
}

⌨️ 快捷键说明

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