From dfbdd0dbdb7375cd86c5e27e2bd2c14106a69ca8 Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 5 Jun 2013 12:43:08 +0000 Subject: [PATCH] Improvements and bug fixes, including clear all & reset to fix 'caching' problem --- .../DisplayFoldoutMaint.Designer.cs | 79 +++++++++++++------ .../DisplayFoldoutMaint.cs | 75 ++++++++++++++++-- 2 files changed, 121 insertions(+), 33 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayFoldoutMaint.Designer.cs b/PROMS/Volian.Controls.Library/DisplayFoldoutMaint.Designer.cs index ee805164..1c354937 100644 --- a/PROMS/Volian.Controls.Library/DisplayFoldoutMaint.Designer.cs +++ b/PROMS/Volian.Controls.Library/DisplayFoldoutMaint.Designer.cs @@ -31,9 +31,11 @@ namespace Volian.Controls.Library this.groupFoldouts = new DevComponents.DotNetBar.Controls.GroupPanel(); this.listBoxFoldouts = new System.Windows.Forms.ListBox(); this.groupSteps = new DevComponents.DotNetBar.Controls.GroupPanel(); - this.lvSteps = new System.Windows.Forms.ListView(); - this.lblStepSelect = new DevComponents.DotNetBar.LabelX(); this.btnSave = new DevComponents.DotNetBar.ButtonX(); + this.lblStepSelect = new DevComponents.DotNetBar.LabelX(); + this.lvSteps = new System.Windows.Forms.ListView(); + this.btnClear = new DevComponents.DotNetBar.ButtonX(); + this.btnClearAll = new DevComponents.DotNetBar.ButtonX(); this.groupFoldouts.SuspendLayout(); this.groupSteps.SuspendLayout(); this.SuspendLayout(); @@ -93,12 +95,14 @@ namespace Volian.Controls.Library // this.groupSteps.CanvasColor = System.Drawing.SystemColors.Control; this.groupSteps.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; + this.groupSteps.Controls.Add(this.btnClearAll); + this.groupSteps.Controls.Add(this.btnClear); this.groupSteps.Controls.Add(this.btnSave); this.groupSteps.Controls.Add(this.lblStepSelect); this.groupSteps.Controls.Add(this.lvSteps); this.groupSteps.Location = new System.Drawing.Point(0, 142); this.groupSteps.Name = "groupSteps"; - this.groupSteps.Size = new System.Drawing.Size(337, 427); + this.groupSteps.Size = new System.Drawing.Size(337, 476); // // // @@ -130,17 +134,17 @@ namespace Volian.Controls.Library this.groupSteps.TabIndex = 1; this.groupSteps.Text = "Steps"; // - // lvSteps + // btnSave // - this.lvSteps.Dock = System.Windows.Forms.DockStyle.Bottom; - this.lvSteps.Location = new System.Drawing.Point(0, 80); - this.lvSteps.MultiSelect = false; - this.lvSteps.Name = "lvSteps"; - this.lvSteps.Size = new System.Drawing.Size(331, 324); - this.lvSteps.TabIndex = 0; - this.lvSteps.UseCompatibleStateImageBehavior = false; - this.lvSteps.View = System.Windows.Forms.View.List; - this.lvSteps.SelectedIndexChanged += new System.EventHandler(this.lvSteps_SelectedIndexChanged); + this.btnSave.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.btnSave.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.btnSave.Location = new System.Drawing.Point(3, 42); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(101, 23); + this.btnSave.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.btnSave.TabIndex = 2; + this.btnSave.Text = "Save Selection"; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // lblStepSelect // @@ -153,18 +157,41 @@ namespace Volian.Controls.Library this.lblStepSelect.Size = new System.Drawing.Size(296, 23); this.lblStepSelect.TabIndex = 1; // - // btnSave + // lvSteps // - this.btnSave.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; - this.btnSave.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnSave.FocusOnLeftMouseButtonDown = true; - this.btnSave.Location = new System.Drawing.Point(29, 42); - this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(101, 23); - this.btnSave.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; - this.btnSave.TabIndex = 2; - this.btnSave.Text = "Save Selection"; - this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + this.lvSteps.Dock = System.Windows.Forms.DockStyle.Bottom; + this.lvSteps.Location = new System.Drawing.Point(0, 140); + this.lvSteps.MultiSelect = false; + this.lvSteps.Name = "lvSteps"; + this.lvSteps.Size = new System.Drawing.Size(331, 313); + this.lvSteps.TabIndex = 0; + this.lvSteps.UseCompatibleStateImageBehavior = false; + this.lvSteps.View = System.Windows.Forms.View.List; + this.lvSteps.SelectedIndexChanged += new System.EventHandler(this.lvSteps_SelectedIndexChanged); + // + // btnClear + // + this.btnClear.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.btnClear.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.btnClear.Location = new System.Drawing.Point(3, 71); + this.btnClear.Name = "btnClear"; + this.btnClear.Size = new System.Drawing.Size(101, 23); + this.btnClear.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.btnClear.TabIndex = 3; + this.btnClear.Text = "Clear Selection"; + this.btnClear.Click += new System.EventHandler(this.btnClear_Click); + // + // btnClearAll + // + this.btnClearAll.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.btnClearAll.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.btnClearAll.Location = new System.Drawing.Point(119, 56); + this.btnClearAll.Name = "btnClearAll"; + this.btnClearAll.Size = new System.Drawing.Size(101, 23); + this.btnClearAll.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.btnClearAll.TabIndex = 4; + this.btnClearAll.Text = "Clear All"; + this.btnClearAll.Click += new System.EventHandler(this.btnClearAll_Click); // // DisplayFoldoutMaint // @@ -173,7 +200,7 @@ namespace Volian.Controls.Library this.Controls.Add(this.groupSteps); this.Controls.Add(this.groupFoldouts); this.Name = "DisplayFoldoutMaint"; - this.Size = new System.Drawing.Size(340, 588); + this.Size = new System.Drawing.Size(340, 632); this.groupFoldouts.ResumeLayout(false); this.groupSteps.ResumeLayout(false); this.ResumeLayout(false); @@ -188,5 +215,7 @@ namespace Volian.Controls.Library private System.Windows.Forms.ListView lvSteps; private DevComponents.DotNetBar.LabelX lblStepSelect; private DevComponents.DotNetBar.ButtonX btnSave; + private DevComponents.DotNetBar.ButtonX btnClear; + private DevComponents.DotNetBar.ButtonX btnClearAll; } } diff --git a/PROMS/Volian.Controls.Library/DisplayFoldoutMaint.cs b/PROMS/Volian.Controls.Library/DisplayFoldoutMaint.cs index 54254f09..2f031c33 100644 --- a/PROMS/Volian.Controls.Library/DisplayFoldoutMaint.cs +++ b/PROMS/Volian.Controls.Library/DisplayFoldoutMaint.cs @@ -40,6 +40,8 @@ namespace Volian.Controls.Library } private ItemInfo _firstStep; private ItemInfo _lastStep; + private bool _Initializing; + public DisplayFoldoutMaint() { InitializeComponent(); @@ -48,8 +50,7 @@ namespace Volian.Controls.Library private void FillInControls() { - - + _Initializing = true; // for this iteminfo, get the procedure and then the list of sections. For any section, starting with // Foldout, add it to list: if (MyItemInfo != null) @@ -67,7 +68,7 @@ namespace Volian.Controls.Library } // find default step section & use its steps to fill in tree. - + ItemInfo startitm = MainStepSection.Steps != null && MainStepSection.Steps.Count > 0 ? MainStepSection.Steps[0] : null; while (startitm != null) { @@ -75,22 +76,35 @@ namespace Volian.Controls.Library lvSteps.Items[lvSteps.Items.Count - 1].Tag = startitm; startitm = (startitm.NextItem != null && startitm.NextItems.Count > 0 ? startitm.NextItems[0] : null); } + ColorFoldoutSelection(); + _Initializing = false; + } + + } + private void ReLoadTree() + { + lvSteps.Clear(); + ItemInfo startitm = MainStepSection.Steps != null && MainStepSection.Steps.Count > 0 ? MainStepSection.Steps[0] : null; + while (startitm != null) + { + lvSteps.Items.Add(startitm.ToString()); + lvSteps.Items[lvSteps.Items.Count - 1].Tag = startitm; + startitm = (startitm.NextItem != null && startitm.NextItems.Count > 0 ? startitm.NextItems[0] : null); } - ColorFoldoutSelection(); } private void ColorFoldoutSelection() { if (MyItemInfo == null) return; if (listBoxFoldouts.Items[0].ToString() == "No Foldouts Exist") return; + if (!_Initializing)ReLoadTree(); // reload tree because the 'caching' was not updating changes. SectionInfo foldOutselected = listBoxFoldouts.Items[listBoxFoldouts.SelectedIndex] as SectionInfo; ItemInfo tmpStep = null; // keep track of previous step, so can set _lastStep; + _firstStep = null; + _lastStep = null; for (int i = 0; i