diff --git a/.nuget/DockPanelSuite.nuspec b/.nuget/DockPanelSuite.nuspec index 05c0022..ea2a8a3 100644 --- a/.nuget/DockPanelSuite.nuspec +++ b/.nuget/DockPanelSuite.nuspec @@ -1,7 +1,7 @@ - 3.0.0-alpha8 + 2.9.0.0 Weifen Luo and other contributors Weifen Luo and other contributors http://www.opensource.org/licenses/mit-license.php diff --git a/DockSample/AboutDialog.Designer.cs b/DockSample/AboutDialog.Designer.cs index f4f4a83..37623d5 100644 --- a/DockSample/AboutDialog.Designer.cs +++ b/DockSample/AboutDialog.Designer.cs @@ -21,12 +21,12 @@ namespace DockSample } #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { this.buttonOK = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); @@ -105,8 +105,8 @@ namespace DockSample this.ResumeLayout(false); this.PerformLayout(); - } - #endregion + } + #endregion private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; diff --git a/DockSample/DockSample.csproj b/DockSample/DockSample.csproj index e2f2490..b78490d 100644 --- a/DockSample/DockSample.csproj +++ b/DockSample/DockSample.csproj @@ -185,6 +185,11 @@ + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + Designer diff --git a/DockSample/DummyDoc.Designer.cs b/DockSample/DummyDoc.Designer.cs index 4c55edf..d4155de 100644 --- a/DockSample/DummyDoc.Designer.cs +++ b/DockSample/DummyDoc.Designer.cs @@ -21,12 +21,12 @@ namespace DockSample } #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DummyDoc)); this.mainMenu = new System.Windows.Forms.MenuStrip(); @@ -130,18 +130,18 @@ namespace DockSample this.ResumeLayout(false); this.PerformLayout(); - } - #endregion + } + #endregion private System.Windows.Forms.MenuStrip mainMenu; - private System.Windows.Forms.ToolStripMenuItem menuItem1; - private System.Windows.Forms.ToolStripMenuItem menuItem2; - private System.Windows.Forms.ContextMenuStrip contextMenuTabPage; - private System.Windows.Forms.ToolStripMenuItem menuItem3; - private System.Windows.Forms.ToolStripMenuItem menuItem4; - private System.Windows.Forms.ToolStripMenuItem menuItem5; - private System.Windows.Forms.ToolStripMenuItem menuItemCheckTest; - private System.Windows.Forms.ToolTip toolTip; + private System.Windows.Forms.ToolStripMenuItem menuItem1; + private System.Windows.Forms.ToolStripMenuItem menuItem2; + private System.Windows.Forms.ContextMenuStrip contextMenuTabPage; + private System.Windows.Forms.ToolStripMenuItem menuItem3; + private System.Windows.Forms.ToolStripMenuItem menuItem4; + private System.Windows.Forms.ToolStripMenuItem menuItem5; + private System.Windows.Forms.ToolStripMenuItem menuItemCheckTest; + private System.Windows.Forms.ToolTip toolTip; private System.Windows.Forms.RichTextBox richTextBox1; } } \ No newline at end of file diff --git a/DockSample/DummyOutputWindow.Designer.cs b/DockSample/DummyOutputWindow.Designer.cs index a543d0d..e767bb1 100644 --- a/DockSample/DummyOutputWindow.Designer.cs +++ b/DockSample/DummyOutputWindow.Designer.cs @@ -21,12 +21,12 @@ namespace DockSample } #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DummyOutputWindow)); this.comboBox = new System.Windows.Forms.ComboBox(); this.textBox1 = new System.Windows.Forms.TextBox(); @@ -74,10 +74,10 @@ namespace DockSample this.ResumeLayout(false); this.PerformLayout(); - } - #endregion + } + #endregion - private System.Windows.Forms.ComboBox comboBox; - private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.ComboBox comboBox; + private System.Windows.Forms.TextBox textBox1; } } \ No newline at end of file diff --git a/DockSample/DummyPropertyWindow.Designer.cs b/DockSample/DummyPropertyWindow.Designer.cs index 86231d1..2f47587 100644 --- a/DockSample/DummyPropertyWindow.Designer.cs +++ b/DockSample/DummyPropertyWindow.Designer.cs @@ -21,12 +21,12 @@ namespace DockSample } #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DummyPropertyWindow)); this.propertyGrid = new System.Windows.Forms.PropertyGrid(); @@ -84,12 +84,12 @@ namespace DockSample this.Text = "Properties"; this.ResumeLayout(false); - } - #endregion + } + #endregion - private System.Windows.Forms.PropertyGrid propertyGrid; - private System.Windows.Forms.ComboBox comboBox; - private System.Windows.Forms.MainMenu mainMenu1; - private System.Windows.Forms.MenuItem menuItem1; + private System.Windows.Forms.PropertyGrid propertyGrid; + private System.Windows.Forms.ComboBox comboBox; + private System.Windows.Forms.MainMenu mainMenu1; + private System.Windows.Forms.MenuItem menuItem1; } } \ No newline at end of file diff --git a/DockSample/DummySolutionExplorer.Designer.cs b/DockSample/DummySolutionExplorer.Designer.cs index 66abaa2..8a7c3dc 100644 --- a/DockSample/DummySolutionExplorer.Designer.cs +++ b/DockSample/DummySolutionExplorer.Designer.cs @@ -21,12 +21,12 @@ namespace DockSample } #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { this.components = new System.ComponentModel.Container(); System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Solution \'WinFormsUI\' (2 projects)"); System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("System", 6, 6); @@ -453,8 +453,8 @@ namespace DockSample this.Text = "Solution Explorer - WinFormsUI"; this.ResumeLayout(false); - } - #endregion + } + #endregion private System.Windows.Forms.TreeView treeView1; private System.Windows.Forms.ImageList imageList1; diff --git a/DockSample/DummyTaskList.Designer.cs b/DockSample/DummyTaskList.Designer.cs index 89ad51b..dacceea 100644 --- a/DockSample/DummyTaskList.Designer.cs +++ b/DockSample/DummyTaskList.Designer.cs @@ -21,12 +21,12 @@ namespace DockSample } #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DummyTaskList)); this.listView1 = new System.Windows.Forms.ListView(); this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); @@ -98,14 +98,14 @@ namespace DockSample this.Text = "Task List"; this.ResumeLayout(false); - } - #endregion + } + #endregion - private System.Windows.Forms.ListView listView1; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.ColumnHeader columnHeader3; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ListView listView1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; } } \ No newline at end of file diff --git a/DockSample/DummyToolbox.Designer.cs b/DockSample/DummyToolbox.Designer.cs index 1b17649..2d07cdd 100644 --- a/DockSample/DummyToolbox.Designer.cs +++ b/DockSample/DummyToolbox.Designer.cs @@ -21,12 +21,12 @@ namespace DockSample } #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DummyToolbox)); this.label2 = new System.Windows.Forms.Label(); @@ -86,8 +86,8 @@ namespace DockSample this.Text = "Toolbox"; this.ResumeLayout(false); - } - #endregion + } + #endregion private System.Windows.Forms.Label label2; private System.Windows.Forms.ImageList imageList; diff --git a/DockSample/MainForm.Designer.cs b/DockSample/MainForm.Designer.cs index 0edde8d..83ee6e1 100644 --- a/DockSample/MainForm.Designer.cs +++ b/DockSample/MainForm.Designer.cs @@ -21,12 +21,12 @@ namespace DockSample } #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); WeifenLuo.WinFormsUI.Docking.DockPanelSkin dockPanelSkin1 = new WeifenLuo.WinFormsUI.Docking.DockPanelSkin(); @@ -646,8 +646,8 @@ namespace DockSample this.ResumeLayout(false); this.PerformLayout(); - } - #endregion + } + #endregion private WeifenLuo.WinFormsUI.Docking.DockPanel dockPanel; private System.Windows.Forms.ImageList imageList; diff --git a/DockSample/MainForm.cs b/DockSample/MainForm.cs index 5e16bef..1597fae 100644 --- a/DockSample/MainForm.cs +++ b/DockSample/MainForm.cs @@ -91,13 +91,9 @@ namespace DockSample } else { - for (int index = dockPanel.Contents.Count - 1; index >= 0; index--) + foreach (IDockContent document in dockPanel.DocumentsToArray()) { - if (dockPanel.Contents[index] is IDockContent) - { - IDockContent content = (IDockContent)dockPanel.Contents[index]; - content.DockHandler.Close(); - } + document.DockHandler.Close(); } } } @@ -366,12 +362,15 @@ namespace DockSample { if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi) { - menuItemClose.Enabled = menuItemCloseAll.Enabled = (ActiveMdiChild != null); + menuItemClose.Enabled = + menuItemCloseAll.Enabled = + menuItemCloseAllButThisOne.Enabled = (ActiveMdiChild != null); } else { menuItemClose.Enabled = (dockPanel.ActiveDocument != null); - menuItemCloseAll.Enabled = (dockPanel.DocumentsCount > 0); + menuItemCloseAll.Enabled = + menuItemCloseAllButThisOne.Enabled = (dockPanel.DocumentsCount > 0); } } diff --git a/DockSample/Resources/DockPanel.xml b/DockSample/Resources/DockPanel.xml index a40333b..a3293eb 100644 Binary files a/DockSample/Resources/DockPanel.xml and b/DockSample/Resources/DockPanel.xml differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..69949c2 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +dockpanelsuite +============== + +DockPanel Suite - The Visual Studio inspired docking library for .NET WinForms + +For all the details, check out [http://dockpanelsuite.com](http://dockpanelsuite.com). diff --git a/WinFormsUI.Docking.vs2010.sln b/WinFormsUI.Docking.vs2010.sln deleted file mode 100644 index 5cdb838..0000000 --- a/WinFormsUI.Docking.vs2010.sln +++ /dev/null @@ -1,28 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "WinFormsUI\WinFormsUI.csproj", "{C75532C4-765B-418E-B09B-46D36B2ABDB1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DockSample", "DockSample\DockSample.csproj", "{40793A27-478B-4357-B4C3-FC8943131F3D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.Build.0 = Release|Any CPU - {40793A27-478B-4357-B4C3-FC8943131F3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {40793A27-478B-4357-B4C3-FC8943131F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {40793A27-478B-4357-B4C3-FC8943131F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {40793A27-478B-4357-B4C3-FC8943131F3D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = DockSample\DockSample.csproj - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/WinFormsUI.Docking.vs2012.sln b/WinFormsUI.Docking.vs2012.sln deleted file mode 100644 index dc66d9d..0000000 --- a/WinFormsUI.Docking.vs2012.sln +++ /dev/null @@ -1,25 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "WinFormsUI\WinFormsUI.csproj", "{C75532C4-765B-418E-B09B-46D36B2ABDB1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DockSample", "DockSample\DockSample.csproj", "{40793A27-478B-4357-B4C3-FC8943131F3D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.Build.0 = Release|Any CPU - {40793A27-478B-4357-B4C3-FC8943131F3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {40793A27-478B-4357-B4C3-FC8943131F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {40793A27-478B-4357-B4C3-FC8943131F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {40793A27-478B-4357-B4C3-FC8943131F3D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/WinFormsUI/Docking/DockContentHandler.cs b/WinFormsUI/Docking/DockContentHandler.cs index 0c88cbc..f1cac77 100644 --- a/WinFormsUI/Docking/DockContentHandler.cs +++ b/WinFormsUI/Docking/DockContentHandler.cs @@ -119,9 +119,8 @@ namespace WeifenLuo.WinFormsUI.Docking return; m_closeButton = value; - if (Pane != null) - if (Pane.ActiveContent.DockHandler == this) - Pane.RefreshChanges(); + if (IsActiveContentHandler) + Pane.RefreshChanges(); } } @@ -132,7 +131,20 @@ namespace WeifenLuo.WinFormsUI.Docking public bool CloseButtonVisible { get { return m_closeButtonVisible; } - set { m_closeButtonVisible = value; } + set + { + if (m_closeButtonVisible == value) + return; + + m_closeButtonVisible = value; + if (IsActiveContentHandler) + Pane.RefreshChanges(); + } + } + + private bool IsActiveContentHandler + { + get { return Pane != null && Pane.ActiveContent != null && Pane.ActiveContent.DockHandler == this; } } private DockState DefaultDockState @@ -825,6 +837,8 @@ namespace WeifenLuo.WinFormsUI.Docking if (DockState == DockState.Unknown) Show(dockPanel, DefaultShowState); + else if (DockPanel != dockPanel) + Show(dockPanel, DockState == DockState.Hidden ? m_visibleState : DockState); else Activate(); } @@ -841,15 +855,21 @@ namespace WeifenLuo.WinFormsUI.Docking DockPanel = dockPanel; - if (dockState == DockState.Float && FloatPane == null) + if (dockState == DockState.Float) + { + if (FloatPane == null) Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, true); + } else if (PanelPane == null) { DockPane paneExisting = null; foreach (DockPane pane in DockPanel.Panes) if (pane.DockState == dockState) { + if (paneExisting == null || pane.IsActivated) paneExisting = pane; + + if (pane.IsActivated) break; } diff --git a/WinFormsUI/Docking/DockPane.cs b/WinFormsUI/Docking/DockPane.cs index 374487e..68e0faa 100644 --- a/WinFormsUI/Docking/DockPane.cs +++ b/WinFormsUI/Docking/DockPane.cs @@ -1315,5 +1315,33 @@ namespace WeifenLuo.WinFormsUI.Docking } #endregion + + #region cachedLayoutArgs leak workaround + + /// + /// There's a bug in the WinForms layout engine + /// that can result in a deferred layout to not + /// properly clear out the cached layout args after + /// the layout operation is performed. + /// Specifically, this bug is hit when the bounds of + /// the Pane change, initiating a layout on the parent + /// (DockWindow) which is where the bug hits. + /// To work around it, when a pane loses the DockWindow + /// as its parent, that parent DockWindow needs to + /// perform a layout to flush the cached args, if they exist. + /// + private DockWindow _lastParentWindow; + protected override void OnParentChanged(EventArgs e) + { + base.OnParentChanged(e); + var newParent = Parent as DockWindow; + if (newParent != _lastParentWindow) + { + if (_lastParentWindow != null) + _lastParentWindow.PerformLayout(); + _lastParentWindow = newParent; + } + } + #endregion } } diff --git a/WinFormsUI/Docking/DockPanel.Appearance.cs b/WinFormsUI/Docking/DockPanel.Appearance.cs index 5bbdd70..cd72b02 100644 --- a/WinFormsUI/Docking/DockPanel.Appearance.cs +++ b/WinFormsUI/Docking/DockPanel.Appearance.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace WeifenLuo.WinFormsUI.Docking { diff --git a/WinFormsUI/Docking/DockPanel.AutoHideWindow.cs b/WinFormsUI/Docking/DockPanel.AutoHideWindow.cs index 955a55a..45a4c32 100644 --- a/WinFormsUI/Docking/DockPanel.AutoHideWindow.cs +++ b/WinFormsUI/Docking/DockPanel.AutoHideWindow.cs @@ -102,12 +102,12 @@ namespace WeifenLuo.WinFormsUI.Docking protected override void StartDrag() { - AutoHideWindow.DockPanel.BeginDrag(AutoHideWindow, AutoHideWindow.RectangleToScreen(Bounds)); + AutoHideWindow.DockPanel.BeginDrag(AutoHideWindow, AutoHideWindow.RectangleToScreen(Bounds)); } } #region consts - private const int ANIMATE_TIME = 100; // in mini-seconds + private const int ANIMATE_TIME = 100; // in mini-seconds #endregion private Timer m_timerMouseTrack; diff --git a/WinFormsUI/Docking/DockPanel.FocusManager.cs b/WinFormsUI/Docking/DockPanel.FocusManager.cs index 739fe09..62c5e1f 100644 --- a/WinFormsUI/Docking/DockPanel.FocusManager.cs +++ b/WinFormsUI/Docking/DockPanel.FocusManager.cs @@ -304,7 +304,7 @@ namespace WeifenLuo.WinFormsUI.Docking return false; } - private int m_countSuspendFocusTracking = 0; + private uint m_countSuspendFocusTracking = 0; public void SuspendFocusTracking() { m_countSuspendFocusTracking++; @@ -314,10 +314,10 @@ namespace WeifenLuo.WinFormsUI.Docking public void ResumeFocusTracking() { - if (m_countSuspendFocusTracking > 0) - m_countSuspendFocusTracking--; - if (m_countSuspendFocusTracking == 0) + return; + + if (--m_countSuspendFocusTracking == 0) { if (ContentActivating != null) { diff --git a/WinFormsUI/Docking/DockPanel.Persistor.cs b/WinFormsUI/Docking/DockPanel.Persistor.cs index 2754b7d..3019029 100644 --- a/WinFormsUI/Docking/DockPanel.Persistor.cs +++ b/WinFormsUI/Docking/DockPanel.Persistor.cs @@ -232,9 +232,7 @@ namespace WeifenLuo.WinFormsUI.Docking public static void SaveAsXml(DockPanel dockPanel, Stream stream, Encoding encoding, bool upstream) { - using (var xmlOut = new XmlTextWriter(stream, encoding)) - { - xmlOut.Formatting = Formatting.Indented; + XmlWriter xmlOut = XmlWriter.Create(stream, new XmlWriterSettings() { Encoding = encoding, Indent = true }); if (!upstream) xmlOut.WriteStartDocument(); diff --git a/WinFormsUI/Docking/DummyControl.cs b/WinFormsUI/Docking/DummyControl.cs index 99832c0..6c04ecd 100644 --- a/WinFormsUI/Docking/DummyControl.cs +++ b/WinFormsUI/Docking/DummyControl.cs @@ -3,11 +3,11 @@ using System.Windows.Forms; namespace WeifenLuo.WinFormsUI.Docking { - internal class DummyControl : Control - { - public DummyControl() - { - SetStyle(ControlStyles.Selectable, false); - } - } + internal class DummyControl : Control + { + public DummyControl() + { + SetStyle(ControlStyles.Selectable, false); + } + } } diff --git a/WinFormsUI/Docking/InertButton.cs b/WinFormsUI/Docking/InertButton.cs index 81a7f29..187881b 100644 --- a/WinFormsUI/Docking/InertButton.cs +++ b/WinFormsUI/Docking/InertButton.cs @@ -6,614 +6,614 @@ using System.ComponentModel; namespace WeifenLuo.WinFormsUI.Docking { - internal class InertButton : Button - { - private enum RepeatClickStatus - { - Disabled, - Started, - Repeating, - Stopped - } - - private class RepeatClickEventArgs : EventArgs - { - private static RepeatClickEventArgs _empty; - - static RepeatClickEventArgs() - { - _empty = new RepeatClickEventArgs(); - } - - public new static RepeatClickEventArgs Empty - { - get { return _empty; } - } - } - - private IContainer components = new Container(); - private int m_borderWidth = 1; - private bool m_mouseOver = false; - private bool m_mouseCapture = false; - private bool m_isPopup = false; - private Image m_imageEnabled = null; - private Image m_imageDisabled = null; - private int m_imageIndexEnabled = -1; - private int m_imageIndexDisabled = -1; - private bool m_monochrom = true; - private ToolTip m_toolTip = null; - private string m_toolTipText = ""; - private Color m_borderColor = Color.Empty; - - public InertButton() - { - InternalConstruct(null, null); - } - - public InertButton(Image imageEnabled) - { - InternalConstruct(imageEnabled, null); - } - - public InertButton(Image imageEnabled, Image imageDisabled) - { - InternalConstruct(imageEnabled, imageDisabled); - } - - private void InternalConstruct(Image imageEnabled, Image imageDisabled) - { - // Remember parameters - ImageEnabled = imageEnabled; - ImageDisabled = imageDisabled; - - // Prevent drawing flicker by blitting from memory in WM_PAINT - SetStyle(ControlStyles.ResizeRedraw, true); - SetStyle(ControlStyles.UserPaint, true); - SetStyle(ControlStyles.AllPaintingInWmPaint, true); - - // Prevent base class from trying to generate double click events and - // so testing clicks against the double click time and rectangle. Getting - // rid of this allows the user to press then release button very quickly. - //SetStyle(ControlStyles.StandardDoubleClick, false); - - // Should not be allowed to select this control - SetStyle(ControlStyles.Selectable, false); - - m_timer = new Timer(); - m_timer.Enabled = false; - m_timer.Tick += new EventHandler(Timer_Tick); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - if (components != null) - components.Dispose(); - } - base.Dispose(disposing); - } - - public Color BorderColor - { - get { return m_borderColor; } - set - { - if (m_borderColor != value) - { - m_borderColor = value; - Invalidate(); - } - } - } - - private bool ShouldSerializeBorderColor() - { - return (m_borderColor != Color.Empty); - } - - public int BorderWidth - { - get { return m_borderWidth; } - - set - { - if (value < 1) - value = 1; - if (m_borderWidth != value) - { - m_borderWidth = value; - Invalidate(); - } - } - } - - public Image ImageEnabled - { - get - { - if (m_imageEnabled != null) - return m_imageEnabled; - - try - { - if (ImageList == null || ImageIndexEnabled == -1) - return null; - else - return ImageList.Images[m_imageIndexEnabled]; - } - catch - { - return null; - } - } - - set - { - if (m_imageEnabled != value) - { - m_imageEnabled = value; - Invalidate(); - } - } - } - - private bool ShouldSerializeImageEnabled() - { - return (m_imageEnabled != null); - } - - public Image ImageDisabled - { - get - { - if (m_imageDisabled != null) - return m_imageDisabled; - - try - { - if (ImageList == null || ImageIndexDisabled == -1) - return null; - else - return ImageList.Images[m_imageIndexDisabled]; - } - catch - { - return null; - } - } - - set - { - if (m_imageDisabled != value) - { - m_imageDisabled = value; - Invalidate(); - } - } - } - - public int ImageIndexEnabled - { - get { return m_imageIndexEnabled; } - set - { - if (m_imageIndexEnabled != value) - { - m_imageIndexEnabled = value; - Invalidate(); - } - } - } - - public int ImageIndexDisabled - { - get { return m_imageIndexDisabled; } - set - { - if (m_imageIndexDisabled != value) - { - m_imageIndexDisabled = value; - Invalidate(); - } - } - } - - public bool IsPopup - { - get { return m_isPopup; } - - set - { - if (m_isPopup != value) - { - m_isPopup = value; - Invalidate(); - } - } - } - - public bool Monochrome - { - get { return m_monochrom; } - set - { - if (value != m_monochrom) - { - m_monochrom = value; - Invalidate(); - } - } - } - - public bool RepeatClick - { - get { return (ClickStatus != RepeatClickStatus.Disabled); } - set { ClickStatus = RepeatClickStatus.Stopped; } - } - - private RepeatClickStatus m_clickStatus = RepeatClickStatus.Disabled; - private RepeatClickStatus ClickStatus - { - get { return m_clickStatus; } - set - { - if (m_clickStatus == value) - return; - - m_clickStatus = value; - if (ClickStatus == RepeatClickStatus.Started) - { - Timer.Interval = RepeatClickDelay; - Timer.Enabled = true; - } - else if (ClickStatus == RepeatClickStatus.Repeating) - Timer.Interval = RepeatClickInterval; - else - Timer.Enabled = false; - } - } - - private int m_repeatClickDelay = 500; - public int RepeatClickDelay - { - get { return m_repeatClickDelay; } - set { m_repeatClickDelay = value; } - } - - private int m_repeatClickInterval = 100; - public int RepeatClickInterval - { - get { return m_repeatClickInterval; } - set { m_repeatClickInterval = value; } - } - - private Timer m_timer; - private Timer Timer - { - get { return m_timer; } - } - - public string ToolTipText - { - get { return m_toolTipText; } - set - { - if (m_toolTipText != value) - { - if (m_toolTip == null) - m_toolTip = new ToolTip(this.components); - m_toolTipText = value; - m_toolTip.SetToolTip(this, value); - } - } - } - - private void Timer_Tick(object sender, EventArgs e) - { - if (m_mouseCapture && m_mouseOver) - OnClick(RepeatClickEventArgs.Empty); - if (ClickStatus == RepeatClickStatus.Started) - ClickStatus = RepeatClickStatus.Repeating; - } - - /// - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); - - if (e.Button != MouseButtons.Left) - return; - - if (m_mouseCapture == false || m_mouseOver == false) - { - m_mouseCapture = true; - m_mouseOver = true; - - //Redraw to show button state - Invalidate(); - } - - if (RepeatClick) - { - OnClick(RepeatClickEventArgs.Empty); - ClickStatus = RepeatClickStatus.Started; - } - } - - /// - protected override void OnClick(EventArgs e) - { - if (RepeatClick && !(e is RepeatClickEventArgs)) - return; - - base.OnClick (e); - } - - /// - protected override void OnMouseUp(MouseEventArgs e) - { - base.OnMouseUp(e); - - if (e.Button != MouseButtons.Left) - return; - - if (m_mouseOver == true || m_mouseCapture == true) - { - m_mouseOver = false; - m_mouseCapture = false; - - // Redraw to show button state - Invalidate(); - } - - if (RepeatClick) - ClickStatus = RepeatClickStatus.Stopped; - } - - /// - protected override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - - // Is mouse point inside our client rectangle - bool over = this.ClientRectangle.Contains(new Point(e.X, e.Y)); - - // If entering the button area or leaving the button area... - if (over != m_mouseOver) - { - // Update state - m_mouseOver = over; - - // Redraw to show button state - Invalidate(); - } - } - - /// - protected override void OnMouseEnter(EventArgs e) - { - // Update state to reflect mouse over the button area - if (!m_mouseOver) - { - m_mouseOver = true; - - // Redraw to show button state - Invalidate(); - } - - base.OnMouseEnter(e); - } - - /// - protected override void OnMouseLeave(EventArgs e) - { - // Update state to reflect mouse not over the button area - if (m_mouseOver) - { - m_mouseOver = false; - - // Redraw to show button state - Invalidate(); - } - - base.OnMouseLeave(e); - } - - /// - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - DrawBackground(e.Graphics); - DrawImage(e.Graphics); - DrawText(e.Graphics); - DrawBorder(e.Graphics); - } - - private void DrawBackground(Graphics g) - { - using (SolidBrush brush = new SolidBrush(BackColor)) - { - g.FillRectangle(brush, ClientRectangle); - } - } - - private void DrawImage(Graphics g) - { - Image image = this.Enabled ? ImageEnabled : ((ImageDisabled != null) ? ImageDisabled : ImageEnabled); - ImageAttributes imageAttr = null; - - if (null == image) - return; - - if (m_monochrom) - { - imageAttr = new ImageAttributes(); - - // transform the monochrom image - // white -> BackColor - // black -> ForeColor - ColorMap[] colorMap = new ColorMap[2]; - colorMap[0] = new ColorMap(); - colorMap[0].OldColor = Color.White; - colorMap[0].NewColor = this.BackColor; - colorMap[1] = new ColorMap(); - colorMap[1].OldColor = Color.Black; - colorMap[1].NewColor = this.ForeColor; - imageAttr.SetRemapTable(colorMap); - } - - Rectangle rect = new Rectangle(0, 0, image.Width, image.Height); - - if ((!Enabled) && (null == ImageDisabled)) - { - using (Bitmap bitmapMono = new Bitmap(image, ClientRectangle.Size)) - { - if (imageAttr != null) - { - using (Graphics gMono = Graphics.FromImage(bitmapMono)) - { - gMono.DrawImage(image, new Point[3] { new Point(0, 0), new Point(image.Width - 1, 0), new Point(0, image.Height - 1) }, rect, GraphicsUnit.Pixel, imageAttr); - } - } - ControlPaint.DrawImageDisabled(g, bitmapMono, 0, 0, this.BackColor); - } - } - else - { - // Three points provided are upper-left, upper-right and - // lower-left of the destination parallelogram. - Point[] pts = new Point[3]; - pts[0].X = (Enabled && m_mouseOver && m_mouseCapture) ? 1 : 0; - pts[0].Y = (Enabled && m_mouseOver && m_mouseCapture) ? 1 : 0; - pts[1].X = pts[0].X + ClientRectangle.Width; - pts[1].Y = pts[0].Y; - pts[2].X = pts[0].X; - pts[2].Y = pts[1].Y + ClientRectangle.Height; - - if (imageAttr == null) - g.DrawImage(image, pts, rect, GraphicsUnit.Pixel); - else - g.DrawImage(image, pts, rect, GraphicsUnit.Pixel, imageAttr); - } - } - - private void DrawText(Graphics g) - { - if (Text == string.Empty) - return; - - Rectangle rect = ClientRectangle; - - rect.X += BorderWidth; - rect.Y += BorderWidth; - rect.Width -= 2 * BorderWidth; - rect.Height -= 2 * BorderWidth; - - StringFormat stringFormat = new StringFormat(); - - if (TextAlign == ContentAlignment.TopLeft) - { - stringFormat.Alignment = StringAlignment.Near; - stringFormat.LineAlignment = StringAlignment.Near; - } - else if (TextAlign == ContentAlignment.TopCenter) - { - stringFormat.Alignment = StringAlignment.Center; - stringFormat.LineAlignment = StringAlignment.Near; - } - else if (TextAlign == ContentAlignment.TopRight) - { - stringFormat.Alignment = StringAlignment.Far; - stringFormat.LineAlignment = StringAlignment.Near; - } - else if (TextAlign == ContentAlignment.MiddleLeft) - { - stringFormat.Alignment = StringAlignment.Near; - stringFormat.LineAlignment = StringAlignment.Center; - } - else if (TextAlign == ContentAlignment.MiddleCenter) - { - stringFormat.Alignment = StringAlignment.Center; - stringFormat.LineAlignment = StringAlignment.Center; - } - else if (TextAlign == ContentAlignment.MiddleRight) - { - stringFormat.Alignment = StringAlignment.Far; - stringFormat.LineAlignment = StringAlignment.Center; - } - else if (TextAlign == ContentAlignment.BottomLeft) - { - stringFormat.Alignment = StringAlignment.Near; - stringFormat.LineAlignment = StringAlignment.Far; - } - else if (TextAlign == ContentAlignment.BottomCenter) - { - stringFormat.Alignment = StringAlignment.Center; - stringFormat.LineAlignment = StringAlignment.Far; - } - else if (TextAlign == ContentAlignment.BottomRight) - { - stringFormat.Alignment = StringAlignment.Far; - stringFormat.LineAlignment = StringAlignment.Far; - } - - using (Brush brush = new SolidBrush(ForeColor)) - { - g.DrawString(Text, Font, brush, rect, stringFormat); - } - } - - private void DrawBorder(Graphics g) - { - ButtonBorderStyle bs; - - // Decide on the type of border to draw around image - if (!this.Enabled) - bs = IsPopup ? ButtonBorderStyle.Outset : ButtonBorderStyle.Solid; - else if (m_mouseOver && m_mouseCapture) - bs = ButtonBorderStyle.Inset; - else if (IsPopup || m_mouseOver) - bs = ButtonBorderStyle.Outset; - else - bs = ButtonBorderStyle.Solid; - - Color colorLeftTop; - Color colorRightBottom; - if (bs == ButtonBorderStyle.Solid) - { - colorLeftTop = this.BackColor; - colorRightBottom = this.BackColor; - } - else if (bs == ButtonBorderStyle.Outset) - { - colorLeftTop = m_borderColor.IsEmpty ? this.BackColor : m_borderColor; - colorRightBottom = this.BackColor; - } - else - { - colorLeftTop = this.BackColor; - colorRightBottom = m_borderColor.IsEmpty ? this.BackColor : m_borderColor; - } - ControlPaint.DrawBorder(g, this.ClientRectangle, - colorLeftTop, m_borderWidth, bs, - colorLeftTop, m_borderWidth, bs, - colorRightBottom, m_borderWidth, bs, - colorRightBottom, m_borderWidth, bs); - } - - /// - protected override void OnEnabledChanged(EventArgs e) - { - base.OnEnabledChanged(e); - if (Enabled == false) - { - m_mouseOver = false; - m_mouseCapture = false; - if (RepeatClick && ClickStatus != RepeatClickStatus.Stopped) - ClickStatus = RepeatClickStatus.Stopped; - } - Invalidate(); - } - } + internal class InertButton : Button + { + private enum RepeatClickStatus + { + Disabled, + Started, + Repeating, + Stopped + } + + private class RepeatClickEventArgs : EventArgs + { + private static RepeatClickEventArgs _empty; + + static RepeatClickEventArgs() + { + _empty = new RepeatClickEventArgs(); + } + + public new static RepeatClickEventArgs Empty + { + get { return _empty; } + } + } + + private IContainer components = new Container(); + private int m_borderWidth = 1; + private bool m_mouseOver = false; + private bool m_mouseCapture = false; + private bool m_isPopup = false; + private Image m_imageEnabled = null; + private Image m_imageDisabled = null; + private int m_imageIndexEnabled = -1; + private int m_imageIndexDisabled = -1; + private bool m_monochrom = true; + private ToolTip m_toolTip = null; + private string m_toolTipText = ""; + private Color m_borderColor = Color.Empty; + + public InertButton() + { + InternalConstruct(null, null); + } + + public InertButton(Image imageEnabled) + { + InternalConstruct(imageEnabled, null); + } + + public InertButton(Image imageEnabled, Image imageDisabled) + { + InternalConstruct(imageEnabled, imageDisabled); + } + + private void InternalConstruct(Image imageEnabled, Image imageDisabled) + { + // Remember parameters + ImageEnabled = imageEnabled; + ImageDisabled = imageDisabled; + + // Prevent drawing flicker by blitting from memory in WM_PAINT + SetStyle(ControlStyles.ResizeRedraw, true); + SetStyle(ControlStyles.UserPaint, true); + SetStyle(ControlStyles.AllPaintingInWmPaint, true); + + // Prevent base class from trying to generate double click events and + // so testing clicks against the double click time and rectangle. Getting + // rid of this allows the user to press then release button very quickly. + //SetStyle(ControlStyles.StandardDoubleClick, false); + + // Should not be allowed to select this control + SetStyle(ControlStyles.Selectable, false); + + m_timer = new Timer(); + m_timer.Enabled = false; + m_timer.Tick += new EventHandler(Timer_Tick); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + components.Dispose(); + } + base.Dispose(disposing); + } + + public Color BorderColor + { + get { return m_borderColor; } + set + { + if (m_borderColor != value) + { + m_borderColor = value; + Invalidate(); + } + } + } + + private bool ShouldSerializeBorderColor() + { + return (m_borderColor != Color.Empty); + } + + public int BorderWidth + { + get { return m_borderWidth; } + + set + { + if (value < 1) + value = 1; + if (m_borderWidth != value) + { + m_borderWidth = value; + Invalidate(); + } + } + } + + public Image ImageEnabled + { + get + { + if (m_imageEnabled != null) + return m_imageEnabled; + + try + { + if (ImageList == null || ImageIndexEnabled == -1) + return null; + else + return ImageList.Images[m_imageIndexEnabled]; + } + catch + { + return null; + } + } + + set + { + if (m_imageEnabled != value) + { + m_imageEnabled = value; + Invalidate(); + } + } + } + + private bool ShouldSerializeImageEnabled() + { + return (m_imageEnabled != null); + } + + public Image ImageDisabled + { + get + { + if (m_imageDisabled != null) + return m_imageDisabled; + + try + { + if (ImageList == null || ImageIndexDisabled == -1) + return null; + else + return ImageList.Images[m_imageIndexDisabled]; + } + catch + { + return null; + } + } + + set + { + if (m_imageDisabled != value) + { + m_imageDisabled = value; + Invalidate(); + } + } + } + + public int ImageIndexEnabled + { + get { return m_imageIndexEnabled; } + set + { + if (m_imageIndexEnabled != value) + { + m_imageIndexEnabled = value; + Invalidate(); + } + } + } + + public int ImageIndexDisabled + { + get { return m_imageIndexDisabled; } + set + { + if (m_imageIndexDisabled != value) + { + m_imageIndexDisabled = value; + Invalidate(); + } + } + } + + public bool IsPopup + { + get { return m_isPopup; } + + set + { + if (m_isPopup != value) + { + m_isPopup = value; + Invalidate(); + } + } + } + + public bool Monochrome + { + get { return m_monochrom; } + set + { + if (value != m_monochrom) + { + m_monochrom = value; + Invalidate(); + } + } + } + + public bool RepeatClick + { + get { return (ClickStatus != RepeatClickStatus.Disabled); } + set { ClickStatus = RepeatClickStatus.Stopped; } + } + + private RepeatClickStatus m_clickStatus = RepeatClickStatus.Disabled; + private RepeatClickStatus ClickStatus + { + get { return m_clickStatus; } + set + { + if (m_clickStatus == value) + return; + + m_clickStatus = value; + if (ClickStatus == RepeatClickStatus.Started) + { + Timer.Interval = RepeatClickDelay; + Timer.Enabled = true; + } + else if (ClickStatus == RepeatClickStatus.Repeating) + Timer.Interval = RepeatClickInterval; + else + Timer.Enabled = false; + } + } + + private int m_repeatClickDelay = 500; + public int RepeatClickDelay + { + get { return m_repeatClickDelay; } + set { m_repeatClickDelay = value; } + } + + private int m_repeatClickInterval = 100; + public int RepeatClickInterval + { + get { return m_repeatClickInterval; } + set { m_repeatClickInterval = value; } + } + + private Timer m_timer; + private Timer Timer + { + get { return m_timer; } + } + + public string ToolTipText + { + get { return m_toolTipText; } + set + { + if (m_toolTipText != value) + { + if (m_toolTip == null) + m_toolTip = new ToolTip(this.components); + m_toolTipText = value; + m_toolTip.SetToolTip(this, value); + } + } + } + + private void Timer_Tick(object sender, EventArgs e) + { + if (m_mouseCapture && m_mouseOver) + OnClick(RepeatClickEventArgs.Empty); + if (ClickStatus == RepeatClickStatus.Started) + ClickStatus = RepeatClickStatus.Repeating; + } + + /// + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + + if (e.Button != MouseButtons.Left) + return; + + if (m_mouseCapture == false || m_mouseOver == false) + { + m_mouseCapture = true; + m_mouseOver = true; + + //Redraw to show button state + Invalidate(); + } + + if (RepeatClick) + { + OnClick(RepeatClickEventArgs.Empty); + ClickStatus = RepeatClickStatus.Started; + } + } + + /// + protected override void OnClick(EventArgs e) + { + if (RepeatClick && !(e is RepeatClickEventArgs)) + return; + + base.OnClick (e); + } + + /// + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + + if (e.Button != MouseButtons.Left) + return; + + if (m_mouseOver == true || m_mouseCapture == true) + { + m_mouseOver = false; + m_mouseCapture = false; + + // Redraw to show button state + Invalidate(); + } + + if (RepeatClick) + ClickStatus = RepeatClickStatus.Stopped; + } + + /// + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + // Is mouse point inside our client rectangle + bool over = this.ClientRectangle.Contains(new Point(e.X, e.Y)); + + // If entering the button area or leaving the button area... + if (over != m_mouseOver) + { + // Update state + m_mouseOver = over; + + // Redraw to show button state + Invalidate(); + } + } + + /// + protected override void OnMouseEnter(EventArgs e) + { + // Update state to reflect mouse over the button area + if (!m_mouseOver) + { + m_mouseOver = true; + + // Redraw to show button state + Invalidate(); + } + + base.OnMouseEnter(e); + } + + /// + protected override void OnMouseLeave(EventArgs e) + { + // Update state to reflect mouse not over the button area + if (m_mouseOver) + { + m_mouseOver = false; + + // Redraw to show button state + Invalidate(); + } + + base.OnMouseLeave(e); + } + + /// + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + DrawBackground(e.Graphics); + DrawImage(e.Graphics); + DrawText(e.Graphics); + DrawBorder(e.Graphics); + } + + private void DrawBackground(Graphics g) + { + using (SolidBrush brush = new SolidBrush(BackColor)) + { + g.FillRectangle(brush, ClientRectangle); + } + } + + private void DrawImage(Graphics g) + { + Image image = this.Enabled ? ImageEnabled : ((ImageDisabled != null) ? ImageDisabled : ImageEnabled); + ImageAttributes imageAttr = null; + + if (null == image) + return; + + if (m_monochrom) + { + imageAttr = new ImageAttributes(); + + // transform the monochrom image + // white -> BackColor + // black -> ForeColor + ColorMap[] colorMap = new ColorMap[2]; + colorMap[0] = new ColorMap(); + colorMap[0].OldColor = Color.White; + colorMap[0].NewColor = this.BackColor; + colorMap[1] = new ColorMap(); + colorMap[1].OldColor = Color.Black; + colorMap[1].NewColor = this.ForeColor; + imageAttr.SetRemapTable(colorMap); + } + + Rectangle rect = new Rectangle(0, 0, image.Width, image.Height); + + if ((!Enabled) && (null == ImageDisabled)) + { + using (Bitmap bitmapMono = new Bitmap(image, ClientRectangle.Size)) + { + if (imageAttr != null) + { + using (Graphics gMono = Graphics.FromImage(bitmapMono)) + { + gMono.DrawImage(image, new Point[3] { new Point(0, 0), new Point(image.Width - 1, 0), new Point(0, image.Height - 1) }, rect, GraphicsUnit.Pixel, imageAttr); + } + } + ControlPaint.DrawImageDisabled(g, bitmapMono, 0, 0, this.BackColor); + } + } + else + { + // Three points provided are upper-left, upper-right and + // lower-left of the destination parallelogram. + Point[] pts = new Point[3]; + pts[0].X = (Enabled && m_mouseOver && m_mouseCapture) ? 1 : 0; + pts[0].Y = (Enabled && m_mouseOver && m_mouseCapture) ? 1 : 0; + pts[1].X = pts[0].X + ClientRectangle.Width; + pts[1].Y = pts[0].Y; + pts[2].X = pts[0].X; + pts[2].Y = pts[1].Y + ClientRectangle.Height; + + if (imageAttr == null) + g.DrawImage(image, pts, rect, GraphicsUnit.Pixel); + else + g.DrawImage(image, pts, rect, GraphicsUnit.Pixel, imageAttr); + } + } + + private void DrawText(Graphics g) + { + if (Text == string.Empty) + return; + + Rectangle rect = ClientRectangle; + + rect.X += BorderWidth; + rect.Y += BorderWidth; + rect.Width -= 2 * BorderWidth; + rect.Height -= 2 * BorderWidth; + + StringFormat stringFormat = new StringFormat(); + + if (TextAlign == ContentAlignment.TopLeft) + { + stringFormat.Alignment = StringAlignment.Near; + stringFormat.LineAlignment = StringAlignment.Near; + } + else if (TextAlign == ContentAlignment.TopCenter) + { + stringFormat.Alignment = StringAlignment.Center; + stringFormat.LineAlignment = StringAlignment.Near; + } + else if (TextAlign == ContentAlignment.TopRight) + { + stringFormat.Alignment = StringAlignment.Far; + stringFormat.LineAlignment = StringAlignment.Near; + } + else if (TextAlign == ContentAlignment.MiddleLeft) + { + stringFormat.Alignment = StringAlignment.Near; + stringFormat.LineAlignment = StringAlignment.Center; + } + else if (TextAlign == ContentAlignment.MiddleCenter) + { + stringFormat.Alignment = StringAlignment.Center; + stringFormat.LineAlignment = StringAlignment.Center; + } + else if (TextAlign == ContentAlignment.MiddleRight) + { + stringFormat.Alignment = StringAlignment.Far; + stringFormat.LineAlignment = StringAlignment.Center; + } + else if (TextAlign == ContentAlignment.BottomLeft) + { + stringFormat.Alignment = StringAlignment.Near; + stringFormat.LineAlignment = StringAlignment.Far; + } + else if (TextAlign == ContentAlignment.BottomCenter) + { + stringFormat.Alignment = StringAlignment.Center; + stringFormat.LineAlignment = StringAlignment.Far; + } + else if (TextAlign == ContentAlignment.BottomRight) + { + stringFormat.Alignment = StringAlignment.Far; + stringFormat.LineAlignment = StringAlignment.Far; + } + + using (Brush brush = new SolidBrush(ForeColor)) + { + g.DrawString(Text, Font, brush, rect, stringFormat); + } + } + + private void DrawBorder(Graphics g) + { + ButtonBorderStyle bs; + + // Decide on the type of border to draw around image + if (!this.Enabled) + bs = IsPopup ? ButtonBorderStyle.Outset : ButtonBorderStyle.Solid; + else if (m_mouseOver && m_mouseCapture) + bs = ButtonBorderStyle.Inset; + else if (IsPopup || m_mouseOver) + bs = ButtonBorderStyle.Outset; + else + bs = ButtonBorderStyle.Solid; + + Color colorLeftTop; + Color colorRightBottom; + if (bs == ButtonBorderStyle.Solid) + { + colorLeftTop = this.BackColor; + colorRightBottom = this.BackColor; + } + else if (bs == ButtonBorderStyle.Outset) + { + colorLeftTop = m_borderColor.IsEmpty ? this.BackColor : m_borderColor; + colorRightBottom = this.BackColor; + } + else + { + colorLeftTop = this.BackColor; + colorRightBottom = m_borderColor.IsEmpty ? this.BackColor : m_borderColor; + } + ControlPaint.DrawBorder(g, this.ClientRectangle, + colorLeftTop, m_borderWidth, bs, + colorLeftTop, m_borderWidth, bs, + colorRightBottom, m_borderWidth, bs, + colorRightBottom, m_borderWidth, bs); + } + + /// + protected override void OnEnabledChanged(EventArgs e) + { + base.OnEnabledChanged(e); + if (Enabled == false) + { + m_mouseOver = false; + m_mouseCapture = false; + if (RepeatClick && ClickStatus != RepeatClickStatus.Stopped) + ClickStatus = RepeatClickStatus.Stopped; + } + Invalidate(); + } + } } \ No newline at end of file diff --git a/WinFormsUI/Docking/Localization.cs b/WinFormsUI/Docking/Localization.cs index c6f71af..bfe73db 100644 --- a/WinFormsUI/Docking/Localization.cs +++ b/WinFormsUI/Docking/Localization.cs @@ -3,44 +3,44 @@ using System.ComponentModel; namespace WeifenLuo.WinFormsUI.Docking { - [AttributeUsage(AttributeTargets.All)] - internal sealed class LocalizedDescriptionAttribute : DescriptionAttribute - { - private bool m_initialized = false; + [AttributeUsage(AttributeTargets.All)] + internal sealed class LocalizedDescriptionAttribute : DescriptionAttribute + { + private bool m_initialized = false; - public LocalizedDescriptionAttribute(string key) : base(key) - { - } + public LocalizedDescriptionAttribute(string key) : base(key) + { + } - public override string Description - { - get - { - if (!m_initialized) - { - string key = base.Description; - DescriptionValue = ResourceHelper.GetString(key); - if (DescriptionValue == null) - DescriptionValue = String.Empty; + public override string Description + { + get + { + if (!m_initialized) + { + string key = base.Description; + DescriptionValue = ResourceHelper.GetString(key); + if (DescriptionValue == null) + DescriptionValue = String.Empty; - m_initialized = true; - } + m_initialized = true; + } - return DescriptionValue; - } - } - } + return DescriptionValue; + } + } + } - [AttributeUsage(AttributeTargets.All)] - internal sealed class LocalizedCategoryAttribute : CategoryAttribute - { - public LocalizedCategoryAttribute(string key) : base(key) - { - } + [AttributeUsage(AttributeTargets.All)] + internal sealed class LocalizedCategoryAttribute : CategoryAttribute + { + public LocalizedCategoryAttribute(string key) : base(key) + { + } - protected override string GetLocalizedString(string key) - { - return ResourceHelper.GetString(key); - } - } + protected override string GetLocalizedString(string key) + { + return ResourceHelper.GetString(key); + } + } } diff --git a/WinFormsUI/Docking/NestedDockingStatus.cs b/WinFormsUI/Docking/NestedDockingStatus.cs index 8d0de44..717e194 100644 --- a/WinFormsUI/Docking/NestedDockingStatus.cs +++ b/WinFormsUI/Docking/NestedDockingStatus.cs @@ -3,106 +3,106 @@ using System.Drawing; namespace WeifenLuo.WinFormsUI.Docking { - public sealed class NestedDockingStatus - { - internal NestedDockingStatus(DockPane pane) - { - m_dockPane = pane; - } + public sealed class NestedDockingStatus + { + internal NestedDockingStatus(DockPane pane) + { + m_dockPane = pane; + } - private DockPane m_dockPane = null; - public DockPane DockPane - { - get { return m_dockPane; } - } - - private NestedPaneCollection m_nestedPanes = null; - public NestedPaneCollection NestedPanes - { - get { return m_nestedPanes; } - } - - private DockPane m_previousPane = null; - public DockPane PreviousPane - { - get { return m_previousPane; } - } + private DockPane m_dockPane = null; + public DockPane DockPane + { + get { return m_dockPane; } + } + + private NestedPaneCollection m_nestedPanes = null; + public NestedPaneCollection NestedPanes + { + get { return m_nestedPanes; } + } + + private DockPane m_previousPane = null; + public DockPane PreviousPane + { + get { return m_previousPane; } + } - private DockAlignment m_alignment = DockAlignment.Left; - public DockAlignment Alignment - { - get { return m_alignment; } - } + private DockAlignment m_alignment = DockAlignment.Left; + public DockAlignment Alignment + { + get { return m_alignment; } + } - private double m_proportion = 0.5; - public double Proportion - { - get { return m_proportion; } - } + private double m_proportion = 0.5; + public double Proportion + { + get { return m_proportion; } + } - private bool m_isDisplaying = false; - public bool IsDisplaying - { - get { return m_isDisplaying; } - } + private bool m_isDisplaying = false; + public bool IsDisplaying + { + get { return m_isDisplaying; } + } - private DockPane m_displayingPreviousPane = null; - public DockPane DisplayingPreviousPane - { - get { return m_displayingPreviousPane; } - } + private DockPane m_displayingPreviousPane = null; + public DockPane DisplayingPreviousPane + { + get { return m_displayingPreviousPane; } + } - private DockAlignment m_displayingAlignment = DockAlignment.Left; - public DockAlignment DisplayingAlignment - { - get { return m_displayingAlignment; } - } + private DockAlignment m_displayingAlignment = DockAlignment.Left; + public DockAlignment DisplayingAlignment + { + get { return m_displayingAlignment; } + } - private double m_displayingProportion = 0.5; - public double DisplayingProportion - { - get { return m_displayingProportion; } - } + private double m_displayingProportion = 0.5; + public double DisplayingProportion + { + get { return m_displayingProportion; } + } - private Rectangle m_logicalBounds = Rectangle.Empty; - public Rectangle LogicalBounds - { - get { return m_logicalBounds; } - } + private Rectangle m_logicalBounds = Rectangle.Empty; + public Rectangle LogicalBounds + { + get { return m_logicalBounds; } + } - private Rectangle m_paneBounds = Rectangle.Empty; - public Rectangle PaneBounds - { - get { return m_paneBounds; } - } + private Rectangle m_paneBounds = Rectangle.Empty; + public Rectangle PaneBounds + { + get { return m_paneBounds; } + } - private Rectangle m_splitterBounds = Rectangle.Empty; - public Rectangle SplitterBounds - { - get { return m_splitterBounds; } - } + private Rectangle m_splitterBounds = Rectangle.Empty; + public Rectangle SplitterBounds + { + get { return m_splitterBounds; } + } - internal void SetStatus(NestedPaneCollection nestedPanes, DockPane previousPane, DockAlignment alignment, double proportion) - { - m_nestedPanes = nestedPanes; - m_previousPane = previousPane; - m_alignment = alignment; - m_proportion = proportion; - } + internal void SetStatus(NestedPaneCollection nestedPanes, DockPane previousPane, DockAlignment alignment, double proportion) + { + m_nestedPanes = nestedPanes; + m_previousPane = previousPane; + m_alignment = alignment; + m_proportion = proportion; + } - internal void SetDisplayingStatus(bool isDisplaying, DockPane displayingPreviousPane, DockAlignment displayingAlignment, double displayingProportion) - { - m_isDisplaying = isDisplaying; - m_displayingPreviousPane = displayingPreviousPane; - m_displayingAlignment = displayingAlignment; - m_displayingProportion = displayingProportion; - } + internal void SetDisplayingStatus(bool isDisplaying, DockPane displayingPreviousPane, DockAlignment displayingAlignment, double displayingProportion) + { + m_isDisplaying = isDisplaying; + m_displayingPreviousPane = displayingPreviousPane; + m_displayingAlignment = displayingAlignment; + m_displayingProportion = displayingProportion; + } - internal void SetDisplayingBounds(Rectangle logicalBounds, Rectangle paneBounds, Rectangle splitterBounds) - { - m_logicalBounds = logicalBounds; - m_paneBounds = paneBounds; - m_splitterBounds = splitterBounds; - } - } + internal void SetDisplayingBounds(Rectangle logicalBounds, Rectangle paneBounds, Rectangle splitterBounds) + { + m_logicalBounds = logicalBounds; + m_paneBounds = paneBounds; + m_splitterBounds = splitterBounds; + } + } } diff --git a/WinFormsUI/Properties/AssemblyInfo.cs b/WinFormsUI/Properties/AssemblyInfo.cs index 31a467f..9af398e 100644 --- a/WinFormsUI/Properties/AssemblyInfo.cs +++ b/WinFormsUI/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Diagnostics.CodeAnalysis; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Weifen Luo")] [assembly: AssemblyProduct("DockPanel Suite")] -[assembly: AssemblyCopyright("Copyright © 2007-2013 Weifen Luo and other contributors 2007-2012")] +[assembly: AssemblyCopyright("Copyright © Weifen Luo and other contributors 2007-2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: CLSCompliant(true)] @@ -18,8 +18,8 @@ using System.Diagnostics.CodeAnalysis; [assembly: Guid("9d690ef9-ce19-4c69-874c-e24d8eb36aff")] -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] +[assembly: AssemblyVersion("2.9.0.0")] +[assembly: AssemblyFileVersion("2.9.0.0")] [module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "namespace", Target = "WeifenLuo.WinFormsUI.Docking", MessageId = "Weifen")] [module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "namespace", Target = "WeifenLuo.WinFormsUI.Docking", MessageId = "Luo")] diff --git a/all.bat b/all.bat index 9f2315b..4a80382 100644 --- a/all.bat +++ b/all.bat @@ -2,4 +2,4 @@ CALL clean.bat CALL release.bat CALL clean.bat CALL release.net40.bat -CALL nuget.bat \ No newline at end of file +CALL nuget.bat diff --git a/clean.bat b/clean.bat index 7e19d3b..5c84417 100644 --- a/clean.bat +++ b/clean.bat @@ -1,4 +1,4 @@ set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319 -call %MSBuildDir%\msbuild WinFormsUI.Docking.vs2010.sln /t:clean -call %MSBuildDir%\msbuild WinFormsUI.Docking.vs2010.sln /t:clean /p:Configuration=Release +call %MSBuildDir%\msbuild WinFormsUI.Docking.sln /t:clean +call %MSBuildDir%\msbuild WinFormsUI.Docking.sln /t:clean /p:Configuration=Release @IF %ERRORLEVEL% NEQ 0 PAUSE \ No newline at end of file diff --git a/debug.bat b/debug.bat index d8ccad5..70694bc 100644 --- a/debug.bat +++ b/debug.bat @@ -1,3 +1,3 @@ set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319 -call %MSBuildDir%\msbuild WinFormsUI.Docking.vs2010.sln /t:build /p:Configuration="Debug" +call %MSBuildDir%\msbuild WinFormsUI.Docking.sln /t:build /p:Configuration="Debug" @IF %ERRORLEVEL% NEQ 0 PAUSE \ No newline at end of file diff --git a/release.bat b/release.bat index d655dee..abb6230 100644 --- a/release.bat +++ b/release.bat @@ -1,3 +1,3 @@ set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319 -call %MSBuildDir%\msbuild WinFormsUI.Docking.vs2010.sln /t:build /p:Configuration=Release /p:TargetFrameworkVersion=v2.0 /p:OutputPath=..\bin\net20\ +call %MSBuildDir%\msbuild WinFormsUI.Docking.sln /t:build /p:Configuration=Release /p:TargetFrameworkVersion=v2.0 /p:OutputPath=..\bin\net20\ @IF %ERRORLEVEL% NEQ 0 PAUSE \ No newline at end of file diff --git a/release.net40.bat b/release.net40.bat index 5f59bc4..994daf6 100644 --- a/release.net40.bat +++ b/release.net40.bat @@ -1,3 +1,3 @@ set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319 -call %MSBuildDir%\msbuild WinFormsUI.Docking.vs2010.sln /t:build /p:Configuration=Release /p:TargetFrameworkVersion=v4.0 /p:OutputPath=..\bin\net40\ +call %MSBuildDir%\msbuild WinFormsUI.Docking.sln /t:build /p:Configuration=Release /p:TargetFrameworkVersion=v4.0 /p:OutputPath=..\bin\net40\ @IF %ERRORLEVEL% NEQ 0 PAUSE \ No newline at end of file