Improvements and bug fixes, including clear all & reset to fix 'caching' problem

This commit is contained in:
Kathy Ruffing 2013-06-05 12:43:08 +00:00
parent 2b7749dc88
commit dfbdd0dbdb
2 changed files with 121 additions and 33 deletions

View File

@ -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;
}
}

View File

@ -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<lvSteps.Items.Count;i++)
{
ItemInfo ii = lvSteps.Items[i].Tag as ItemInfo;
StepConfig sc = ii.MyConfig as StepConfig;
_firstStep = null;
_lastStep = null;
if (sc != null)
{
if (sc.Step_FloatingFoldout == foldOutselected.ItemID)
@ -137,7 +151,7 @@ namespace Volian.Controls.Library
private void btnSave_Click(object sender, EventArgs e)
{
lblStepSelect.Text = "Select First Step";
// for all selected steps, set their cofig floating foldout item to
// for all selected steps, set their config floating foldout item to
// the selected foldout.
bool sav = false;
SectionInfo foldOutselected = listBoxFoldouts.Items[listBoxFoldouts.SelectedIndex] as SectionInfo;
@ -162,5 +176,50 @@ namespace Volian.Controls.Library
}
}
private void btnClear_Click(object sender, EventArgs e)
{
lblStepSelect.Text = "Select First Step";
// for all selected steps, clear their config floating foldout item
bool sav = false;
SectionInfo foldOutselected = listBoxFoldouts.Items[listBoxFoldouts.SelectedIndex] as SectionInfo;
if (_firstStep == null || _lastStep == null) return;
foreach (ItemInfo ii in MainStepSection.Steps)
{
if (ii.ItemID == _firstStep.ItemID)
sav = true;
if (sav)
{
StepConfig sc = ii.MyConfig as StepConfig;
sc.Step_FloatingFoldout = 0;
using (Item itm = ii.Get())
{
itm.MyContent.Config = sc.ToString();
itm.MyContent.DTS = DateTime.Now;
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
itm.Save();
}
if (ii.ItemID == _lastStep.ItemID) sav = false;
}
}
ColorFoldoutSelection();
}
private void btnClearAll_Click(object sender, EventArgs e)
{
foreach (ItemInfo ii in MainStepSection.Steps)
{
StepConfig sc = ii.MyConfig as StepConfig;
sc.Step_FloatingFoldout = 0;
using (Item itm = ii.Get())
{
itm.MyContent.Config = sc.ToString();
itm.MyContent.DTS = DateTime.Now;
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
itm.Save();
}
}
ColorFoldoutSelection();
}
}
}