Improve display

This commit is contained in:
Michael Bucari-Tovo 2022-05-22 20:00:06 -06:00
parent f86bdba3c3
commit 3cb43e5d3e
2 changed files with 15 additions and 12 deletions

View File

@ -29,6 +29,7 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
this.SuspendLayout(); this.SuspendLayout();
// //
// panel1 // panel1
@ -39,12 +40,21 @@
this.panel1.BackColor = System.Drawing.SystemColors.ControlDark; this.panel1.BackColor = System.Drawing.SystemColors.ControlDark;
this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(377, 505); this.panel1.Size = new System.Drawing.Size(357, 505);
this.panel1.TabIndex = 0; this.panel1.TabIndex = 0;
// //
// vScrollBar1
//
this.vScrollBar1.Dock = System.Windows.Forms.DockStyle.Right;
this.vScrollBar1.Location = new System.Drawing.Point(360, 0);
this.vScrollBar1.Name = "vScrollBar1";
this.vScrollBar1.Size = new System.Drawing.Size(17, 505);
this.vScrollBar1.TabIndex = 0;
//
// VirtualFlowControl // VirtualFlowControl
// //
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Controls.Add(this.vScrollBar1);
this.Controls.Add(this.panel1); this.Controls.Add(this.panel1);
this.Name = "VirtualFlowControl"; this.Name = "VirtualFlowControl";
this.Size = new System.Drawing.Size(377, 505); this.Size = new System.Drawing.Size(377, 505);
@ -55,5 +65,6 @@
#endregion #endregion
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.VScrollBar vScrollBar1;
} }
} }

View File

@ -75,7 +75,6 @@ namespace LibationWinForms.ProcessQueue
/// </summary> /// </summary>
private readonly int TopMargin; private readonly int TopMargin;
private readonly VScrollBar vScrollBar1;
private readonly List<ProcessBookControl> BookControls = new(); private readonly List<ProcessBookControl> BookControls = new();
#endregion #endregion
@ -101,16 +100,6 @@ namespace LibationWinForms.ProcessQueue
{ {
InitializeComponent(); InitializeComponent();
vScrollBar1 = new VScrollBar
{
Minimum = 0,
Value = 0,
Dock = DockStyle.Right
};
Controls.Add(vScrollBar1);
vScrollBar1.Scroll += (_, s) => SetScrollPosition(s.NewValue);
panel1.Width -= vScrollBar1.Width + panel1.Margin.Right;
panel1.Resize += (_, _) => panel1.Resize += (_, _) =>
{ {
AdjustScrollBar(); AdjustScrollBar();
@ -135,6 +124,7 @@ namespace LibationWinForms.ProcessQueue
panel1.Controls.Add(control); panel1.Controls.Add(control);
} }
vScrollBar1.Scroll += (_, s) => SetScrollPosition(s.NewValue);
vScrollBar1.SmallChange = SmallScrollChange; vScrollBar1.SmallChange = SmallScrollChange;
panel1.Height += NUM_BLANK_SPACES_AT_BOTTOM * VirtualControlHeight; panel1.Height += NUM_BLANK_SPACES_AT_BOTTOM * VirtualControlHeight;
} }
@ -227,6 +217,8 @@ namespace LibationWinForms.ProcessQueue
/// </summary> /// </summary>
private void SetScrollPosition(int value) private void SetScrollPosition(int value)
{ {
if (!vScrollBar1.Enabled) return;
int newPos = (int)Math.Round((double)value / SmallScrollChange) * SmallScrollChange; int newPos = (int)Math.Round((double)value / SmallScrollChange) * SmallScrollChange;
if (vScrollBar1.Value != newPos) if (vScrollBar1.Value != newPos)
{ {