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;
}
if (RowCount > DisplayedRowCount(false))
VBar.ThreadSafeCall(() =>
{
VBar.Maximum = RowCount - DisplayedRowCount(false);
VBar.Value = FirstDisplayedScrollingRowIndex;
VBar.Visible = ScrollBars == ScrollBars.Vertical || ScrollBars == ScrollBars.Both;
}
else
{
VBar.Visible = false;
}
if (RowCount > DisplayedRowCount(false))
{
VBar.Maximum = RowCount - DisplayedRowCount(false);
VBar.Value = FirstDisplayedScrollingRowIndex;
VBar.Visible = ScrollBars == ScrollBars.Vertical || ScrollBars == ScrollBars.Both;
}
else
{
VBar.Visible = false;
}
});
if (HorizontalScrollBar.Visible)
HBar.ThreadSafeCall(() =>
{
HBar.Maximum = HorizontalScrollBar.Maximum;
HBar.Value = HorizontalScrollBar.Value;
HBar.BoundsWidth = HorizontalScrollBar.LargeChange;
HBar.LargeChange = HorizontalScrollBar.LargeChange;//.Maximum / VisibleColumnCount();
HBar.Visible = ScrollBars == ScrollBars.Horizontal || ScrollBars == ScrollBars.Both;
}
else
{
HBar.Visible = false;
}
if (HorizontalScrollBar.Visible)
{
HBar.Maximum = HorizontalScrollBar.Maximum;
HBar.Value = HorizontalScrollBar.Value;
HBar.BoundsWidth = HorizontalScrollBar.LargeChange;
HBar.LargeChange = HorizontalScrollBar.LargeChange;//.Maximum / VisibleColumnCount();
HBar.Visible = ScrollBars == ScrollBars.Horizontal || ScrollBars == ScrollBars.Both;
}
else
{
HBar.Visible = false;
}
});
SetBarPosition();
}
@ -607,31 +613,43 @@ namespace Sunny.UI
if (BorderStyle == BorderStyle.FixedSingle)
{
VBar.Left = Width - barWidth - 2;
VBar.Top = 1;
VBar.Width = barWidth + 1;
VBar.Height = Height - 2;
VBar.BringToFront();
VBar.ThreadSafeCall(() =>
{
VBar.Left = Width - barWidth - 2;
VBar.Top = 1;
VBar.Width = barWidth + 1;
VBar.Height = Height - 2;
VBar.BringToFront();
});
HBar.Left = 1;
HBar.Height = barHeight + 1;
HBar.Width = Width - (VBar.Visible ? VBar.Width : 0) - 2;
HBar.Top = Height - HBar.Height - 1;
HBar.BringToFront();
HBar.ThreadSafeCall(() =>
{
HBar.Left = 1;
HBar.Height = barHeight + 1;
HBar.Width = Width - (VBar.Visible ? VBar.Width : 0) - 2;
HBar.Top = Height - HBar.Height - 1;
HBar.BringToFront();
});
}
else
{
VBar.Left = Width - barWidth - 1;
VBar.Top = 0;
VBar.Width = barWidth + 1;
VBar.Height = Height;
VBar.BringToFront();
VBar.ThreadSafeCall(() =>
{
VBar.Left = Width - barWidth - 1;
VBar.Top = 0;
VBar.Width = barWidth + 1;
VBar.Height = Height;
VBar.BringToFront();
});
HBar.Left = 0;
HBar.Height = barHeight + 1;
HBar.Width = Width - (VBar.Visible ? VBar.Width : 0);
HBar.Top = Height - HBar.Height;
HBar.BringToFront();
HBar.ThreadSafeCall(() =>
{
HBar.Left = 0;
HBar.Height = barHeight + 1;
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.Paint += new PaintEventHandler(waterMarkContainer_Paint);
waterMarkContainer.Invalidate();
waterMarkContainer.Click += new EventHandler(waterMarkContainer_Click);
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)
{
Controls.Remove(waterMarkContainer);
this.ThreadSafeCall(() =>
{
Controls.Remove(waterMarkContainer);
});
waterMarkContainer = null;
}
}

View File

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