This commit is contained in:
Sunny 2024-11-03 23:24:23 +08:00
parent 45d2eed8b9
commit b68740f828
3 changed files with 84 additions and 52 deletions

View File

@ -477,29 +477,35 @@ namespace Sunny.UI
return; return;
} }
if (RowCount > DisplayedRowCount(false)) VBar.ThreadSafeCall(() =>
{ {
VBar.Maximum = RowCount - DisplayedRowCount(false); if (RowCount > DisplayedRowCount(false))
VBar.Value = FirstDisplayedScrollingRowIndex; {
VBar.Visible = ScrollBars == ScrollBars.Vertical || ScrollBars == ScrollBars.Both; VBar.Maximum = RowCount - DisplayedRowCount(false);
} VBar.Value = FirstDisplayedScrollingRowIndex;
else VBar.Visible = ScrollBars == ScrollBars.Vertical || ScrollBars == ScrollBars.Both;
{ }
VBar.Visible = false; else
} {
VBar.Visible = false;
}
});
if (HorizontalScrollBar.Visible) HBar.ThreadSafeCall(() =>
{ {
HBar.Maximum = HorizontalScrollBar.Maximum; if (HorizontalScrollBar.Visible)
HBar.Value = HorizontalScrollBar.Value; {
HBar.BoundsWidth = HorizontalScrollBar.LargeChange; HBar.Maximum = HorizontalScrollBar.Maximum;
HBar.LargeChange = HorizontalScrollBar.LargeChange;//.Maximum / VisibleColumnCount(); HBar.Value = HorizontalScrollBar.Value;
HBar.Visible = ScrollBars == ScrollBars.Horizontal || ScrollBars == ScrollBars.Both; HBar.BoundsWidth = HorizontalScrollBar.LargeChange;
} HBar.LargeChange = HorizontalScrollBar.LargeChange;//.Maximum / VisibleColumnCount();
else HBar.Visible = ScrollBars == ScrollBars.Horizontal || ScrollBars == ScrollBars.Both;
{ }
HBar.Visible = false; else
} {
HBar.Visible = false;
}
});
SetBarPosition(); SetBarPosition();
} }
@ -607,31 +613,43 @@ namespace Sunny.UI
if (BorderStyle == BorderStyle.FixedSingle) if (BorderStyle == BorderStyle.FixedSingle)
{ {
VBar.Left = Width - barWidth - 2; VBar.ThreadSafeCall(() =>
VBar.Top = 1; {
VBar.Width = barWidth + 1; VBar.Left = Width - barWidth - 2;
VBar.Height = Height - 2; VBar.Top = 1;
VBar.BringToFront(); VBar.Width = barWidth + 1;
VBar.Height = Height - 2;
VBar.BringToFront();
});
HBar.Left = 1; HBar.ThreadSafeCall(() =>
HBar.Height = barHeight + 1; {
HBar.Width = Width - (VBar.Visible ? VBar.Width : 0) - 2; HBar.Left = 1;
HBar.Top = Height - HBar.Height - 1; HBar.Height = barHeight + 1;
HBar.BringToFront(); HBar.Width = Width - (VBar.Visible ? VBar.Width : 0) - 2;
HBar.Top = Height - HBar.Height - 1;
HBar.BringToFront();
});
} }
else else
{ {
VBar.Left = Width - barWidth - 1; VBar.ThreadSafeCall(() =>
VBar.Top = 0; {
VBar.Width = barWidth + 1; VBar.Left = Width - barWidth - 1;
VBar.Height = Height; VBar.Top = 0;
VBar.BringToFront(); VBar.Width = barWidth + 1;
VBar.Height = Height;
VBar.BringToFront();
});
HBar.Left = 0; HBar.ThreadSafeCall(() =>
HBar.Height = barHeight + 1; {
HBar.Width = Width - (VBar.Visible ? VBar.Width : 0); HBar.Left = 0;
HBar.Top = Height - HBar.Height; HBar.Height = barHeight + 1;
HBar.BringToFront(); HBar.Width = Width - (VBar.Visible ? VBar.Width : 0);
HBar.Top = Height - HBar.Height;
HBar.BringToFront();
});
} }
} }

View File

@ -61,10 +61,17 @@ namespace Sunny.UI
{ {
waterMarkContainer = new PanelEx(); waterMarkContainer = new PanelEx();
waterMarkContainer.Paint += new PaintEventHandler(waterMarkContainer_Paint); waterMarkContainer.Paint += new PaintEventHandler(waterMarkContainer_Paint);
waterMarkContainer.Invalidate();
waterMarkContainer.Click += new EventHandler(waterMarkContainer_Click); waterMarkContainer.Click += new EventHandler(waterMarkContainer_Click);
waterMarkContainer.DoubleClick += WaterMarkContainer_DoubleClick; waterMarkContainer.DoubleClick += WaterMarkContainer_DoubleClick;
this.Controls.Add(waterMarkContainer); this.ThreadSafeCall(() =>
{
this.Controls.Add(waterMarkContainer);
});
waterMarkContainer.ThreadSafeCall(() =>
{
waterMarkContainer.Invalidate();
});
} }
} }
@ -93,7 +100,11 @@ namespace Sunny.UI
{ {
if (waterMarkContainer != null) if (waterMarkContainer != null)
{ {
Controls.Remove(waterMarkContainer); this.ThreadSafeCall(() =>
{
Controls.Remove(waterMarkContainer);
});
waterMarkContainer = null; waterMarkContainer = null;
} }
} }

View File

@ -685,7 +685,7 @@ namespace Sunny.UI
{ {
if (IsDisposed) return; if (IsDisposed) return;
TextChanged?.Invoke(this, e); TextChanged?.Invoke(this, e);
SetScrollInfo(); if (Multiline) SetScrollInfo();
} }
/// <summary> /// <summary>
@ -722,15 +722,18 @@ namespace Sunny.UI
} }
var si = ScrollBarInfo.GetInfo(edit.Handle); var si = ScrollBarInfo.GetInfo(edit.Handle);
if (si.ScrollMax > 0) bar.ThreadSafeCall(() =>
{ {
bar.Maximum = si.ScrollMax; if (si.ScrollMax > 0)
bar.Value = si.nPos; {
} bar.Maximum = si.ScrollMax;
else bar.Value = si.nPos;
{ }
bar.Maximum = si.ScrollMax; else
} {
bar.Maximum = si.ScrollMax;
}
});
} }
protected override void OnRadiusChanged(int value) protected override void OnRadiusChanged(int value)