| | using System; |
| | using System.ComponentModel; |
| | using System.Drawing; |
| | using System.Drawing.Drawing2D; |
| | using System.Windows.Forms; |
| |
|
| | namespace WeifenLuo.WinFormsUI.Docking |
| | { |
| | using WeifenLuo.WinFormsUI.ThemeVS2012Light; |
| |
|
| | |
| | |
| | |
| | public class VS2012LightTheme : ThemeBase |
| | { |
| | |
| | |
| | |
| | |
| | public override void Apply(DockPanel dockPanel) |
| | { |
| | if (dockPanel == null) |
| | { |
| | throw new NullReferenceException("dockPanel"); |
| | } |
| |
|
| | Measures.SplitterSize = 6; |
| | dockPanel.Extender.DockPaneCaptionFactory = new VS2012LightDockPaneCaptionFactory(); |
| | dockPanel.Extender.AutoHideStripFactory = new VS2012LightAutoHideStripFactory(); |
| | dockPanel.Extender.AutoHideWindowFactory = new VS2012LightAutoHideWindowFactory(); |
| | dockPanel.Extender.DockPaneStripFactory = new VS2012LightDockPaneStripFactory(); |
| | dockPanel.Extender.DockPaneSplitterControlFactory = new VS2012LightDockPaneSplitterControlFactory(); |
| | dockPanel.Extender.DockWindowSplitterControlFactory = new VS2012LightDockWindowSplitterControlFactory(); |
| | dockPanel.Extender.DockWindowFactory = new VS2012LightDockWindowFactory(); |
| | dockPanel.Extender.PaneIndicatorFactory = new VS2012LightPaneIndicatorFactory(); |
| | dockPanel.Extender.PanelIndicatorFactory = new VS2012LightPanelIndicatorFactory(); |
| | dockPanel.Extender.DockOutlineFactory = new VS2012LightDockOutlineFactory(); |
| | dockPanel.Skin = CreateVisualStudio2012Light(); |
| | } |
| |
|
| | private class VS2012LightDockOutlineFactory : DockPanelExtender.IDockOutlineFactory |
| | { |
| | public DockOutlineBase CreateDockOutline() |
| | { |
| | return new VS2012LightDockOutline(); |
| | } |
| |
|
| | private class VS2012LightDockOutline : DockOutlineBase |
| | { |
| | public VS2012LightDockOutline() |
| | { |
| | m_dragForm = new DragForm(); |
| | SetDragForm(Rectangle.Empty); |
| | DragForm.BackColor = Color.FromArgb(0xff, 91, 173, 255); |
| | DragForm.Opacity = 0.5; |
| | DragForm.Show(false); |
| | } |
| |
|
| | DragForm m_dragForm; |
| | private DragForm DragForm |
| | { |
| | get { return m_dragForm; } |
| | } |
| |
|
| | protected override void OnShow() |
| | { |
| | CalculateRegion(); |
| | } |
| |
|
| | protected override void OnClose() |
| | { |
| | DragForm.Close(); |
| | } |
| |
|
| | private void CalculateRegion() |
| | { |
| | if (SameAsOldValue) |
| | return; |
| |
|
| | if (!FloatWindowBounds.IsEmpty) |
| | SetOutline(FloatWindowBounds); |
| | else if (DockTo is DockPanel) |
| | SetOutline(DockTo as DockPanel, Dock, (ContentIndex != 0)); |
| | else if (DockTo is DockPane) |
| | SetOutline(DockTo as DockPane, Dock, ContentIndex); |
| | else |
| | SetOutline(); |
| | } |
| |
|
| | private void SetOutline() |
| | { |
| | SetDragForm(Rectangle.Empty); |
| | } |
| |
|
| | private void SetOutline(Rectangle floatWindowBounds) |
| | { |
| | SetDragForm(floatWindowBounds); |
| | } |
| |
|
| | private void SetOutline(DockPanel dockPanel, DockStyle dock, bool fullPanelEdge) |
| | { |
| | Rectangle rect = fullPanelEdge ? dockPanel.DockArea : dockPanel.DocumentWindowBounds; |
| | rect.Location = dockPanel.PointToScreen(rect.Location); |
| | if (dock == DockStyle.Top) |
| | { |
| | int height = dockPanel.GetDockWindowSize(DockState.DockTop); |
| | rect = new Rectangle(rect.X, rect.Y, rect.Width, height); |
| | } |
| | else if (dock == DockStyle.Bottom) |
| | { |
| | int height = dockPanel.GetDockWindowSize(DockState.DockBottom); |
| | rect = new Rectangle(rect.X, rect.Bottom - height, rect.Width, height); |
| | } |
| | else if (dock == DockStyle.Left) |
| | { |
| | int width = dockPanel.GetDockWindowSize(DockState.DockLeft); |
| | rect = new Rectangle(rect.X, rect.Y, width, rect.Height); |
| | } |
| | else if (dock == DockStyle.Right) |
| | { |
| | int width = dockPanel.GetDockWindowSize(DockState.DockRight); |
| | rect = new Rectangle(rect.Right - width, rect.Y, width, rect.Height); |
| | } |
| | else if (dock == DockStyle.Fill) |
| | { |
| | rect = dockPanel.DocumentWindowBounds; |
| | rect.Location = dockPanel.PointToScreen(rect.Location); |
| | } |
| |
|
| | SetDragForm(rect); |
| | } |
| |
|
| | private void SetOutline(DockPane pane, DockStyle dock, int contentIndex) |
| | { |
| | if (dock != DockStyle.Fill) |
| | { |
| | Rectangle rect = pane.DisplayingRectangle; |
| | if (dock == DockStyle.Right) |
| | rect.X += rect.Width / 2; |
| | if (dock == DockStyle.Bottom) |
| | rect.Y += rect.Height / 2; |
| | if (dock == DockStyle.Left || dock == DockStyle.Right) |
| | rect.Width -= rect.Width / 2; |
| | if (dock == DockStyle.Top || dock == DockStyle.Bottom) |
| | rect.Height -= rect.Height / 2; |
| | rect.Location = pane.PointToScreen(rect.Location); |
| |
|
| | SetDragForm(rect); |
| | } |
| | else if (contentIndex == -1) |
| | { |
| | Rectangle rect = pane.DisplayingRectangle; |
| | rect.Location = pane.PointToScreen(rect.Location); |
| | SetDragForm(rect); |
| | } |
| | else |
| | { |
| | using (GraphicsPath path = pane.TabStripControl.GetOutline(contentIndex)) |
| | { |
| | RectangleF rectF = path.GetBounds(); |
| | Rectangle rect = new Rectangle((int)rectF.X, (int)rectF.Y, (int)rectF.Width, (int)rectF.Height); |
| | using (Matrix matrix = new Matrix(rect, new Point[] { new Point(0, 0), new Point(rect.Width, 0), new Point(0, rect.Height) })) |
| | { |
| | path.Transform(matrix); |
| | } |
| |
|
| | Region region = new Region(path); |
| | SetDragForm(rect, region); |
| | } |
| | } |
| | } |
| |
|
| | private void SetDragForm(Rectangle rect) |
| | { |
| | DragForm.Bounds = rect; |
| | if (rect == Rectangle.Empty) |
| | { |
| | if (DragForm.Region != null) |
| | { |
| | DragForm.Region.Dispose(); |
| | } |
| |
|
| | DragForm.Region = new Region(Rectangle.Empty); |
| | } |
| | else if (DragForm.Region != null) |
| | { |
| | DragForm.Region.Dispose(); |
| | DragForm.Region = null; |
| | } |
| | } |
| |
|
| | private void SetDragForm(Rectangle rect, Region region) |
| | { |
| | DragForm.Bounds = rect; |
| | if (DragForm.Region != null) |
| | { |
| | DragForm.Region.Dispose(); |
| | } |
| |
|
| | DragForm.Region = region; |
| | } |
| | } |
| | } |
| |
|
| | private class VS2012LightPanelIndicatorFactory : DockPanelExtender.IPanelIndicatorFactory |
| | { |
| | public DockPanel.IPanelIndicator CreatePanelIndicator(DockStyle style) |
| | { |
| | return new VS2012LightPanelIndicator(style); |
| | } |
| |
|
| | private class VS2012LightPanelIndicator : PictureBox, DockPanel.IPanelIndicator |
| | { |
| | private static Image _imagePanelLeft = Resources.DockIndicator_PanelLeft; |
| | private static Image _imagePanelRight = Resources.DockIndicator_PanelRight; |
| | private static Image _imagePanelTop = Resources.DockIndicator_PanelTop; |
| | private static Image _imagePanelBottom = Resources.DockIndicator_PanelBottom; |
| | private static Image _imagePanelFill = Resources.DockIndicator_PanelFill; |
| | private static Image _imagePanelLeftActive = Resources.DockIndicator_PanelLeft; |
| | private static Image _imagePanelRightActive = Resources.DockIndicator_PanelRight; |
| | private static Image _imagePanelTopActive = Resources.DockIndicator_PanelTop; |
| | private static Image _imagePanelBottomActive = Resources.DockIndicator_PanelBottom; |
| | private static Image _imagePanelFillActive = Resources.DockIndicator_PanelFill; |
| |
|
| | public VS2012LightPanelIndicator(DockStyle dockStyle) |
| | { |
| | m_dockStyle = dockStyle; |
| | SizeMode = PictureBoxSizeMode.AutoSize; |
| | Image = ImageInactive; |
| | } |
| |
|
| | private DockStyle m_dockStyle; |
| |
|
| | private DockStyle DockStyle |
| | { |
| | get { return m_dockStyle; } |
| | } |
| |
|
| | private DockStyle m_status; |
| |
|
| | public DockStyle Status |
| | { |
| | get { return m_status; } |
| | set |
| | { |
| | if (value != DockStyle && value != DockStyle.None) |
| | throw new InvalidEnumArgumentException(); |
| |
|
| | if (m_status == value) |
| | return; |
| |
|
| | m_status = value; |
| | IsActivated = (m_status != DockStyle.None); |
| | } |
| | } |
| |
|
| | private Image ImageInactive |
| | { |
| | get |
| | { |
| | if (DockStyle == DockStyle.Left) |
| | return _imagePanelLeft; |
| | else if (DockStyle == DockStyle.Right) |
| | return _imagePanelRight; |
| | else if (DockStyle == DockStyle.Top) |
| | return _imagePanelTop; |
| | else if (DockStyle == DockStyle.Bottom) |
| | return _imagePanelBottom; |
| | else if (DockStyle == DockStyle.Fill) |
| | return _imagePanelFill; |
| | else |
| | return null; |
| | } |
| | } |
| |
|
| | private Image ImageActive |
| | { |
| | get |
| | { |
| | if (DockStyle == DockStyle.Left) |
| | return _imagePanelLeftActive; |
| | else if (DockStyle == DockStyle.Right) |
| | return _imagePanelRightActive; |
| | else if (DockStyle == DockStyle.Top) |
| | return _imagePanelTopActive; |
| | else if (DockStyle == DockStyle.Bottom) |
| | return _imagePanelBottomActive; |
| | else if (DockStyle == DockStyle.Fill) |
| | return _imagePanelFillActive; |
| | else |
| | return null; |
| | } |
| | } |
| |
|
| | private bool m_isActivated = false; |
| |
|
| | private bool IsActivated |
| | { |
| | get { return m_isActivated; } |
| | set |
| | { |
| | m_isActivated = value; |
| | Image = IsActivated ? ImageActive : ImageInactive; |
| | } |
| | } |
| |
|
| | public DockStyle HitTest(Point pt) |
| | { |
| | return this.Visible && ClientRectangle.Contains(PointToClient(pt)) ? DockStyle : DockStyle.None; |
| | } |
| | } |
| | } |
| |
|
| | private class VS2012LightPaneIndicatorFactory : DockPanelExtender.IPaneIndicatorFactory |
| | { |
| | public DockPanel.IPaneIndicator CreatePaneIndicator() |
| | { |
| | return new VS2012LightPaneIndicator(); |
| | } |
| |
|
| | private class VS2012LightPaneIndicator : PictureBox, DockPanel.IPaneIndicator |
| | { |
| | private static Bitmap _bitmapPaneDiamond = Resources.Dockindicator_PaneDiamond; |
| | private static Bitmap _bitmapPaneDiamondLeft = Resources.Dockindicator_PaneDiamond_Fill; |
| | private static Bitmap _bitmapPaneDiamondRight = Resources.Dockindicator_PaneDiamond_Fill; |
| | private static Bitmap _bitmapPaneDiamondTop = Resources.Dockindicator_PaneDiamond_Fill; |
| | private static Bitmap _bitmapPaneDiamondBottom = Resources.Dockindicator_PaneDiamond_Fill; |
| | private static Bitmap _bitmapPaneDiamondFill = Resources.Dockindicator_PaneDiamond_Fill; |
| | private static Bitmap _bitmapPaneDiamondHotSpot = Resources.Dockindicator_PaneDiamond_Hotspot; |
| | private static Bitmap _bitmapPaneDiamondHotSpotIndex = Resources.DockIndicator_PaneDiamond_HotspotIndex; |
| |
|
| | private static DockPanel.HotSpotIndex[] _hotSpots = new[] |
| | { |
| | new DockPanel.HotSpotIndex(1, 0, DockStyle.Top), |
| | new DockPanel.HotSpotIndex(0, 1, DockStyle.Left), |
| | new DockPanel.HotSpotIndex(1, 1, DockStyle.Fill), |
| | new DockPanel.HotSpotIndex(2, 1, DockStyle.Right), |
| | new DockPanel.HotSpotIndex(1, 2, DockStyle.Bottom) |
| | }; |
| |
|
| | private GraphicsPath _displayingGraphicsPath = DrawHelper.CalculateGraphicsPathFromBitmap(_bitmapPaneDiamond); |
| |
|
| | public VS2012LightPaneIndicator() |
| | { |
| | SizeMode = PictureBoxSizeMode.AutoSize; |
| | Image = _bitmapPaneDiamond; |
| | Region = new Region(DisplayingGraphicsPath); |
| | } |
| |
|
| | public GraphicsPath DisplayingGraphicsPath |
| | { |
| | get { return _displayingGraphicsPath; } |
| | } |
| |
|
| | public DockStyle HitTest(Point pt) |
| | { |
| | if (!Visible) |
| | return DockStyle.None; |
| |
|
| | pt = PointToClient(pt); |
| | if (!ClientRectangle.Contains(pt)) |
| | return DockStyle.None; |
| |
|
| | for (int i = _hotSpots.GetLowerBound(0); i <= _hotSpots.GetUpperBound(0); i++) |
| | { |
| | if (_bitmapPaneDiamondHotSpot.GetPixel(pt.X, pt.Y) == _bitmapPaneDiamondHotSpotIndex.GetPixel(_hotSpots[i].X, _hotSpots[i].Y)) |
| | return _hotSpots[i].DockStyle; |
| | } |
| |
|
| | return DockStyle.None; |
| | } |
| |
|
| | private DockStyle m_status = DockStyle.None; |
| |
|
| | public DockStyle Status |
| | { |
| | get { return m_status; } |
| | set |
| | { |
| | m_status = value; |
| | if (m_status == DockStyle.None) |
| | Image = _bitmapPaneDiamond; |
| | else if (m_status == DockStyle.Left) |
| | Image = _bitmapPaneDiamondLeft; |
| | else if (m_status == DockStyle.Right) |
| | Image = _bitmapPaneDiamondRight; |
| | else if (m_status == DockStyle.Top) |
| | Image = _bitmapPaneDiamondTop; |
| | else if (m_status == DockStyle.Bottom) |
| | Image = _bitmapPaneDiamondBottom; |
| | else if (m_status == DockStyle.Fill) |
| | Image = _bitmapPaneDiamondFill; |
| | } |
| | } |
| | } |
| | } |
| |
|
| | private class VS2012LightAutoHideWindowFactory : DockPanelExtender.IAutoHideWindowFactory |
| | { |
| | public DockPanel.AutoHideWindowControl CreateAutoHideWindow(DockPanel panel) |
| | { |
| | return new VS2012LightAutoHideWindowControl(panel); |
| | } |
| | } |
| |
|
| | private class VS2012LightDockPaneSplitterControlFactory : DockPanelExtender.IDockPaneSplitterControlFactory |
| | { |
| | public DockPane.SplitterControlBase CreateSplitterControl(DockPane pane) |
| | { |
| | return new VS2012LightSplitterControl(pane); |
| | } |
| | } |
| |
|
| | private class VS2012LightDockWindowSplitterControlFactory : DockPanelExtender.IDockWindowSplitterControlFactory |
| | { |
| | public SplitterBase CreateSplitterControl() |
| | { |
| | return new VS2012LightDockWindow.VS2012LightDockWindowSplitterControl(); |
| | } |
| | } |
| |
|
| | private class VS2012LightDockPaneStripFactory : DockPanelExtender.IDockPaneStripFactory |
| | { |
| | public DockPaneStripBase CreateDockPaneStrip(DockPane pane) |
| | { |
| | return new VS2012LightDockPaneStrip(pane); |
| | } |
| | } |
| |
|
| | private class VS2012LightAutoHideStripFactory : DockPanelExtender.IAutoHideStripFactory |
| | { |
| | public AutoHideStripBase CreateAutoHideStrip(DockPanel panel) |
| | { |
| | return new VS2012LightAutoHideStrip(panel); |
| | } |
| | } |
| |
|
| | private class VS2012LightDockPaneCaptionFactory : DockPanelExtender.IDockPaneCaptionFactory |
| | { |
| | public DockPaneCaptionBase CreateDockPaneCaption(DockPane pane) |
| | { |
| | return new VS2012LightDockPaneCaption(pane); |
| | } |
| | } |
| |
|
| | private class VS2012LightDockWindowFactory : DockPanelExtender.IDockWindowFactory |
| | { |
| | public DockWindow CreateDockWindow(DockPanel dockPanel, DockState dockState) |
| | { |
| | return new VS2012LightDockWindow(dockPanel, dockState); |
| | } |
| | } |
| |
|
| | public static DockPanelSkin CreateVisualStudio2012Light() |
| | { |
| | var dot = Color.FromArgb(80, 170, 220); |
| | var skin = new DockPanelSkin(); |
| |
|
| | if (Type.GetType("Mono.Runtime") == null) |
| | { |
| | skin.AutoHideStripSkin.DockStripGradient.StartColor = SystemColors.ActiveCaption; |
| | skin.AutoHideStripSkin.DockStripGradient.EndColor = SystemColors.ActiveCaption; |
| | skin.AutoHideStripSkin.TabGradient.StartColor = SystemColors.ActiveCaption; |
| | skin.AutoHideStripSkin.TabGradient.EndColor = SystemColors.ActiveCaption; |
| | skin.AutoHideStripSkin.TabGradient.TextColor = SystemColors.ActiveCaptionText; |
| | skin.AutoHideStripSkin.DockStripBackground.StartColor = SystemColors.ActiveCaption; |
| | skin.AutoHideStripSkin.DockStripBackground.EndColor = SystemColors.ActiveCaption; |
| |
|
| | } |
| | else { |
| | skin.AutoHideStripSkin.DockStripGradient.StartColor = SystemColors.InactiveCaption; |
| | skin.AutoHideStripSkin.DockStripGradient.EndColor = SystemColors.InactiveCaption; |
| | skin.AutoHideStripSkin.TabGradient.StartColor = SystemColors.InactiveCaption; |
| | skin.AutoHideStripSkin.TabGradient.EndColor = SystemColors.InactiveCaption; |
| | skin.AutoHideStripSkin.TabGradient.TextColor = SystemColors.InactiveCaptionText; |
| | skin.AutoHideStripSkin.DockStripBackground.StartColor = SystemColors.InactiveCaption; |
| | skin.AutoHideStripSkin.DockStripBackground.EndColor = SystemColors.InactiveCaption; |
| | } |
| |
|
| | skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.StartColor = SystemColors.Control; |
| | skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.EndColor = SystemColors.Control; |
| | skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.StartColor = SystemColors.ActiveCaption; |
| | skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.EndColor = SystemColors.ActiveCaption; |
| | skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.StartColor = SystemColors.InactiveCaption; |
| | skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.EndColor = SystemColors.InactiveCaption; |
| | skin.DockPaneStripSkin.DocumentGradient.ActiveTabGradient.TextColor = SystemColors.ActiveCaptionText; |
| | skin.DockPaneStripSkin.DocumentGradient.InactiveTabGradient.TextColor = SystemColors.InactiveCaptionText; |
| |
|
| |
|
| | skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.StartColor = SystemColors.Control; |
| | skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.EndColor = SystemColors.Control; |
| |
|
| | if (Type.GetType("Mono.Runtime") == null) |
| | { |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor = SystemColors.ControlLightLight; |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor = SystemColors.ControlLightLight; |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor = SystemColors.ActiveCaptionText; |
| | } |
| | else |
| | { |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor = SystemColors.ActiveCaption; |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor = SystemColors.ActiveCaption; |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor = SystemColors.ActiveCaptionText; |
| | } |
| |
|
| | if (Type.GetType("Mono.Runtime") == null) |
| | { |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.StartColor = SystemColors.Control; |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.EndColor = SystemColors.Control; |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.TextColor = SystemColors.InactiveCaptionText; |
| | } |
| | else |
| | { |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.StartColor = SystemColors.InactiveCaption; |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.EndColor = SystemColors.InactiveCaption; |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.TextColor = SystemColors.InactiveCaptionText; |
| | } |
| |
|
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient.StartColor = SystemColors.ActiveCaption; |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient.EndColor = SystemColors.ActiveCaptionText; |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient.LinearGradientMode = LinearGradientMode.Vertical; |
| |
|
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient.StartColor = SystemColors.InactiveCaption; |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient.EndColor = SystemColors.InactiveCaptionText; |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient.LinearGradientMode = LinearGradientMode.Vertical; |
| | |
| | if (Type.GetType("Mono.Runtime") == null) |
| | { |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient.TextColor = SystemColors.ActiveCaptionText; |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient.TextColor = SystemColors.InactiveCaptionText; |
| | } |
| | else |
| | { |
| | skin.DockPaneStripSkin.ToolWindowGradient.ActiveCaptionGradient.TextColor = SystemColors.ActiveCaption; |
| | skin.DockPaneStripSkin.ToolWindowGradient.InactiveCaptionGradient.TextColor = SystemColors.InactiveCaption; |
| | } |
| |
|
| | if (Type.GetType("Mono.Runtime") != null) |
| | { |
| | skin.DockPaneStripSkin.TextFont = SystemFonts.DefaultFont; |
| | } |
| |
|
| | return skin; |
| | } |
| | } |
| | } |