From 3cb43e5d3ee9b5c36e2b9d3cbda2bbc561b60d33 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sun, 22 May 2022 20:00:06 -0600 Subject: [PATCH] Improve display --- .../ProcessQueue/VirtualFlowControl.Designer.cs | 13 ++++++++++++- .../ProcessQueue/VirtualFlowControl.cs | 14 +++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.Designer.cs b/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.Designer.cs index 77f793fc..dfcedef8 100644 --- a/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.Designer.cs +++ b/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.Designer.cs @@ -29,6 +29,7 @@ private void InitializeComponent() { this.panel1 = new System.Windows.Forms.Panel(); + this.vScrollBar1 = new System.Windows.Forms.VScrollBar(); this.SuspendLayout(); // // panel1 @@ -39,12 +40,21 @@ this.panel1.BackColor = System.Drawing.SystemColors.ControlDark; this.panel1.Location = new System.Drawing.Point(0, 0); 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; // + // 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 // this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.Controls.Add(this.vScrollBar1); this.Controls.Add(this.panel1); this.Name = "VirtualFlowControl"; this.Size = new System.Drawing.Size(377, 505); @@ -55,5 +65,6 @@ #endregion private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.VScrollBar vScrollBar1; } } diff --git a/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.cs b/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.cs index d031d191..296e34bf 100644 --- a/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.cs +++ b/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.cs @@ -75,7 +75,6 @@ namespace LibationWinForms.ProcessQueue /// private readonly int TopMargin; - private readonly VScrollBar vScrollBar1; private readonly List BookControls = new(); #endregion @@ -101,16 +100,6 @@ namespace LibationWinForms.ProcessQueue { 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 += (_, _) => { AdjustScrollBar(); @@ -135,6 +124,7 @@ namespace LibationWinForms.ProcessQueue panel1.Controls.Add(control); } + vScrollBar1.Scroll += (_, s) => SetScrollPosition(s.NewValue); vScrollBar1.SmallChange = SmallScrollChange; panel1.Height += NUM_BLANK_SPACES_AT_BOTTOM * VirtualControlHeight; } @@ -227,6 +217,8 @@ namespace LibationWinForms.ProcessQueue /// private void SetScrollPosition(int value) { + if (!vScrollBar1.Enabled) return; + int newPos = (int)Math.Round((double)value / SmallScrollChange) * SmallScrollChange; if (vScrollBar1.Value != newPos) {