Skip to content

Commit

Permalink
Improve extensibility
Browse files Browse the repository at this point in the history
  • Loading branch information
yck1509 committed Jan 3, 2015
1 parent 8668fda commit 72645c5
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 157 deletions.
2 changes: 1 addition & 1 deletion WinFormsUI/Docking/DockPanel.SplitterDragHandler.cs
Expand Up @@ -157,7 +157,7 @@ private SplitterDragHandler GetSplitterDragHandler()
return m_splitterDragHandler;
}

internal void BeginDrag(ISplitterDragSource dragSource, Rectangle rectSplitter)
public void BeginDrag(ISplitterDragSource dragSource, Rectangle rectSplitter)
{
GetSplitterDragHandler().BeginDrag(dragSource, rectSplitter);
}
Expand Down
23 changes: 15 additions & 8 deletions WinFormsUI/Docking/DockPanel.cs
Expand Up @@ -799,20 +799,27 @@ public void SetPaneIndex(DockPane pane, int index)
Panes.AddAt(pane, index);
}

int suspendCount = 0;
public void SuspendLayout(bool allWindows)
{
FocusManager.SuspendFocusTracking();
SuspendLayout();
if (allWindows)
SuspendMdiClientLayout();
if (suspendCount++ == 0)
{
FocusManager.SuspendFocusTracking();
SuspendLayout();
if (allWindows)
SuspendMdiClientLayout();
}
}

public void ResumeLayout(bool performLayout, bool allWindows)
{
FocusManager.ResumeFocusTracking();
ResumeLayout(performLayout);
if (allWindows)
ResumeMdiClientLayout(performLayout);
if (--suspendCount == 0)
{
FocusManager.ResumeFocusTracking();
ResumeLayout(performLayout);
if (allWindows)
ResumeMdiClientLayout(performLayout);
}
}

internal Form ParentForm
Expand Down
2 changes: 1 addition & 1 deletion WinFormsUI/Docking/DockWindow.cs
Expand Up @@ -15,7 +15,7 @@ public partial class DockWindow : Panel, INestedPanesContainer, ISplitterDragSou
private SplitterBase m_splitter;
private NestedPaneCollection m_nestedPanes;

internal DockWindow(DockPanel dockPanel, DockState dockState)
protected internal DockWindow(DockPanel dockPanel, DockState dockState)
{
m_nestedPanes = new NestedPaneCollection(this);
m_dockPanel = dockPanel;
Expand Down
2 changes: 1 addition & 1 deletion WinFormsUI/Docking/Helpers/DockHelper.cs
Expand Up @@ -4,7 +4,7 @@

namespace WeifenLuo.WinFormsUI.Docking
{
internal static class DockHelper
public static class DockHelper
{
public static bool IsDockStateAutoHide(DockState dockState)
{
Expand Down
2 changes: 1 addition & 1 deletion WinFormsUI/Docking/Helpers/DrawHelper.cs
Expand Up @@ -6,7 +6,7 @@

namespace WeifenLuo.WinFormsUI.Docking
{
internal static class DrawHelper
public static class DrawHelper
{
public static Point RtlTransform(Control control, Point point)
{
Expand Down
75 changes: 63 additions & 12 deletions WinFormsUI/Docking/InertButtonBase.cs
Expand Up @@ -7,7 +7,7 @@

namespace WeifenLuo.WinFormsUI.Docking
{
internal abstract class InertButtonBase : Control
public abstract class InertButtonBase : Control
{
protected InertButtonBase()
{
Expand All @@ -34,11 +34,45 @@ private set
}
}

private bool m_isMouseDown = false;
protected bool IsMouseDown
{
get { return m_isMouseDown; }
private set
{
if (m_isMouseDown == value)
return;

m_isMouseDown = value;
Invalidate();
}
}

protected override Size DefaultSize
{
get { return Resources.DockPane_Close.Size; }
}

protected virtual Color HoverBackColor
{
get { return Color.Transparent; }
}

protected virtual Color HoverBorderColor
{
get { return ForeColor; }
}

protected virtual Color HoverForeColor
{
get { return ForeColor; }
}

protected virtual Color PressedBackColor
{
get { return Color.Transparent; }
}

protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
Expand All @@ -61,27 +95,44 @@ protected override void OnMouseLeave(EventArgs e)
IsMouseOver = false;
}

protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseLeave(e);
if (!IsMouseDown)
IsMouseDown = true;
}

protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseLeave(e);
if (IsMouseDown)
IsMouseDown = false;
}

protected override void OnPaint(PaintEventArgs e)
{
if (IsMouseOver && Enabled)
{
using (Pen pen = new Pen(ForeColor))
using (Pen pen = new Pen(this.HoverBorderColor))
using (Brush brush = new SolidBrush(IsMouseDown ? PressedBackColor : HoverBackColor))

This comment has been minimized.

Copy link
@lextm

lextm Sep 6, 2016

It shows how to show pressed image, which is quite useful for VS2012/2013 themes.

{
e.Graphics.DrawRectangle(pen, Rectangle.Inflate(ClientRectangle, -1, -1));
Rectangle rect = ClientRectangle;
rect.Width--;
rect.Height--;
e.Graphics.FillRectangle(brush, rect);
e.Graphics.DrawRectangle(pen, rect);
}
}

using (ImageAttributes imageAttributes = new ImageAttributes())
{
ColorMap[] colorMap = new ColorMap[2];
colorMap[0] = new ColorMap();
colorMap[0].OldColor = Color.FromArgb(0, 0, 0);
colorMap[0].NewColor = ForeColor;
colorMap[1] = new ColorMap();
colorMap[1].OldColor = Image.GetPixel(0, 0);
colorMap[1].NewColor = Color.Transparent;

imageAttributes.SetRemapTable(colorMap);
Color color = IsMouseOver ? HoverForeColor : ForeColor;
ColorMatrix matrix = new ColorMatrix();
matrix.Matrix40 = color.R / 255f;
matrix.Matrix41 = color.G / 255f;
matrix.Matrix42 = color.B / 255f;

imageAttributes.SetColorMatrix(matrix);

e.Graphics.DrawImage(
Image,
Expand Down
6 changes: 3 additions & 3 deletions WinFormsUI/Docking/Interfaces.cs
Expand Up @@ -20,12 +20,12 @@ public interface INestedPanesContainer
bool IsFloat { get; }
}

internal interface IDragSource
public interface IDragSource
{
Control DragControl { get; }
}

internal interface IDockDragSource : IDragSource
public interface IDockDragSource : IDragSource
{
Rectangle BeginDrag(Point ptMouse);
void EndDrag();
Expand All @@ -36,7 +36,7 @@ internal interface IDockDragSource : IDragSource
void DockTo(DockPanel panel, DockStyle dockStyle);
}

internal interface ISplitterDragSource : IDragSource
public interface ISplitterDragSource : IDragSource
{
void BeginDrag(Rectangle rectSplitter);
void EndDrag();
Expand Down
2 changes: 1 addition & 1 deletion WinFormsUI/Docking/NestedPaneCollection.cs
Expand Up @@ -69,7 +69,7 @@ private void CheckFloatWindowDispose()
/// Switches a pane with its first child in the pane hierarchy. (The actual hiding happens elsewhere.)
/// </summary>
/// <param name="pane">Pane to switch</param>
internal void SwitchPaneWithFirstChild(DockPane pane)
public void SwitchPaneWithFirstChild(DockPane pane)
{
if (!Contains(pane))
return;
Expand Down

1 comment on commit 72645c5

@lextm
Copy link

@lextm lextm commented on 72645c5 Sep 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked under dockpanelsuite#397

Please sign in to comment.