👾 修复 Splitter Lazy 不生效

* 修复splitter控件collapsepanel为none状态下,lazy为false属性不生效问题;修复lazy为false时,issp…
This commit is contained in:
淘气小浩
2025-03-25 06:36:25 +00:00
committed by Tom
parent 5a3482f3f5
commit 27d38dae6a
2 changed files with 38 additions and 32 deletions

View File

@@ -101,6 +101,7 @@ namespace Demo.Controls
// splitter1
//
splitter1.Dock = DockStyle.Fill;
splitter1.Lazy = false;
splitter1.Location = new Point(3, 3);
splitter1.Name = "splitter1";
//
@@ -112,8 +113,9 @@ namespace Demo.Controls
//
splitter1.Panel2.Controls.Add(label2);
splitter1.Size = new Size(610, 249);
splitter1.SplitterDistance = 290;
splitter1.SplitterWidth = 2;
splitter1.SplitterDistance = 218;
splitter1.SplitterSize = 50;
splitter1.SplitterWidth = 8;
splitter1.TabIndex = 1;
//
// label1
@@ -121,7 +123,7 @@ namespace Demo.Controls
label1.Dock = DockStyle.Fill;
label1.Location = new Point(0, 0);
label1.Name = "label1";
label1.Size = new Size(290, 249);
label1.Size = new Size(218, 249);
label1.TabIndex = 0;
label1.Text = "First";
label1.TextAlign = ContentAlignment.MiddleCenter;
@@ -131,7 +133,7 @@ namespace Demo.Controls
label2.Dock = DockStyle.Fill;
label2.Location = new Point(0, 0);
label2.Name = "label2";
label2.Size = new Size(318, 249);
label2.Size = new Size(384, 249);
label2.TabIndex = 0;
label2.Text = "Second";
label2.TextAlign = ContentAlignment.MiddleCenter;
@@ -153,7 +155,7 @@ namespace Demo.Controls
splitter2.Panel2.Controls.Add(label4);
splitter2.Panel2MinSize = 0;
splitter2.Size = new Size(610, 250);
splitter2.SplitterDistance = 290;
splitter2.SplitterDistance = 273;
splitter2.SplitterSize = 80;
splitter2.SplitterWidth = 10;
splitter2.TabIndex = 2;
@@ -163,7 +165,7 @@ namespace Demo.Controls
label3.Dock = DockStyle.Fill;
label3.Location = new Point(0, 0);
label3.Name = "label3";
label3.Size = new Size(290, 250);
label3.Size = new Size(273, 250);
label3.TabIndex = 0;
label3.Text = "First";
label3.TextAlign = ContentAlignment.MiddleCenter;
@@ -173,7 +175,7 @@ namespace Demo.Controls
label4.Dock = DockStyle.Fill;
label4.Location = new Point(0, 0);
label4.Name = "label4";
label4.Size = new Size(310, 250);
label4.Size = new Size(327, 250);
label4.TabIndex = 0;
label4.Text = "Second";
label4.TextAlign = ContentAlignment.MiddleCenter;

View File

@@ -406,13 +406,13 @@ namespace AntdUI
Point initialMousePoint;
protected override void OnMouseDown(MouseEventArgs e)
{
if (_collapsePanel == ADCollapsePanel.None)
{
base.OnMouseDown(e);
return;
}
//if (_collapsePanel == ADCollapsePanel.None)
//{
// base.OnMouseDown(e);
// return;
//}
Rectangle rect = SplitterRectangle, rect_arrow = ArrowRect(rect);
if (rect_arrow.Contains(e.Location)) _MouseState = true;//点位在箭头矩形内
if (_collapsePanel != ADCollapsePanel.None && rect_arrow.Contains(e.Location)) _MouseState = true;//点位在箭头矩形内
else if (!SplitPanelState) _MouseState = null;
else if (rect.Contains(e.Location))
{
@@ -425,7 +425,7 @@ namespace AntdUI
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
if (_collapsePanel == ADCollapsePanel.None) return;
//if (_collapsePanel == ADCollapsePanel.None) return;
SetCursor(CursorType.Default);
m_bIsArrowRegion = false;
Invalidate();
@@ -433,17 +433,17 @@ namespace AntdUI
protected override void OnMouseMove(MouseEventArgs e)
{
if (_collapsePanel == ADCollapsePanel.None)
{
base.OnMouseMove(e);
return;
}
//if (_collapsePanel == ADCollapsePanel.None)
//{
// base.OnMouseMove(e);
// return;
//}
//如果鼠标的左键没有按下,重置鼠标状态
if (e.Button != MouseButtons.Left) _MouseState = null;
//鼠标在Arrow矩形里并且不是在拖动
Rectangle rect = SplitterRectangle, rect_arrow = ArrowRect(rect);
if (rect_arrow.Contains(e.Location) && _MouseState != false)
if (_collapsePanel != ADCollapsePanel.None && rect_arrow.Contains(e.Location) && _MouseState != false)
{
SetCursor(CursorType.Hand);
m_bIsArrowRegion = true;
@@ -463,14 +463,18 @@ namespace AntdUI
return;
}
//正在拖动分隔栏
if (_MouseState == false && !IsSplitterFixed) SetCursor(Orientation == Orientation.Horizontal ? CursorType.HSplit : CursorType.VSplit);
else SetCursor(CursorType.Default);
if (Lazy) base.OnMouseMove(e);
else
if (_MouseState == false && !IsSplitterFixed)
{
SplitMove(e.X, e.Y);
initialMousePoint = e.Location;
SetCursor(Orientation == Orientation.Horizontal ? CursorType.HSplit : CursorType.VSplit);
if(!Lazy)
{
SplitMove(e.X, e.Y);
initialMousePoint = e.Location;
return;
}
}
else SetCursor(CursorType.Default);
base.OnMouseMove(e);
}
private void SplitMove(int x, int y)
@@ -511,14 +515,14 @@ namespace AntdUI
protected override void OnMouseUp(MouseEventArgs e)
{
if (_collapsePanel == ADCollapsePanel.None)
{
base.OnMouseUp(e);
return;
}
//if (_collapsePanel == ADCollapsePanel.None)
//{
// base.OnMouseUp(e);
// return;
//}
if (Lazy) base.OnMouseUp(e);
Invalidate();
if (_MouseState == true && e.Button == MouseButtons.Left && ArrowRect(SplitterRectangle).Contains(e.Location))
if (_collapsePanel != ADCollapsePanel.None && _MouseState == true && e.Button == MouseButtons.Left && ArrowRect(SplitterRectangle).Contains(e.Location))
{
SplitPanelState = !_splitPanelState;
SplitPanelStateChanged?.Invoke(this, new BoolEventArgs(SplitPanelState));