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.groupFoldouts = new DevComponents.DotNetBar.Controls.GroupPanel();
this.listBoxFoldouts = new System.Windows.Forms.ListBox(); this.listBoxFoldouts = new System.Windows.Forms.ListBox();
this.groupSteps = new DevComponents.DotNetBar.Controls.GroupPanel(); 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.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.groupFoldouts.SuspendLayout();
this.groupSteps.SuspendLayout(); this.groupSteps.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -93,12 +95,14 @@ namespace Volian.Controls.Library
// //
this.groupSteps.CanvasColor = System.Drawing.SystemColors.Control; this.groupSteps.CanvasColor = System.Drawing.SystemColors.Control;
this.groupSteps.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; 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.btnSave);
this.groupSteps.Controls.Add(this.lblStepSelect); this.groupSteps.Controls.Add(this.lblStepSelect);
this.groupSteps.Controls.Add(this.lvSteps); this.groupSteps.Controls.Add(this.lvSteps);
this.groupSteps.Location = new System.Drawing.Point(0, 142); this.groupSteps.Location = new System.Drawing.Point(0, 142);
this.groupSteps.Name = "groupSteps"; 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.TabIndex = 1;
this.groupSteps.Text = "Steps"; this.groupSteps.Text = "Steps";
// //
// lvSteps // btnSave
// //
this.lvSteps.Dock = System.Windows.Forms.DockStyle.Bottom; this.btnSave.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.lvSteps.Location = new System.Drawing.Point(0, 80); this.btnSave.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.lvSteps.MultiSelect = false; this.btnSave.Location = new System.Drawing.Point(3, 42);
this.lvSteps.Name = "lvSteps"; this.btnSave.Name = "btnSave";
this.lvSteps.Size = new System.Drawing.Size(331, 324); this.btnSave.Size = new System.Drawing.Size(101, 23);
this.lvSteps.TabIndex = 0; this.btnSave.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.lvSteps.UseCompatibleStateImageBehavior = false; this.btnSave.TabIndex = 2;
this.lvSteps.View = System.Windows.Forms.View.List; this.btnSave.Text = "Save Selection";
this.lvSteps.SelectedIndexChanged += new System.EventHandler(this.lvSteps_SelectedIndexChanged); this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
// //
// lblStepSelect // lblStepSelect
// //
@ -153,18 +157,41 @@ namespace Volian.Controls.Library
this.lblStepSelect.Size = new System.Drawing.Size(296, 23); this.lblStepSelect.Size = new System.Drawing.Size(296, 23);
this.lblStepSelect.TabIndex = 1; this.lblStepSelect.TabIndex = 1;
// //
// btnSave // lvSteps
// //
this.btnSave.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.lvSteps.Dock = System.Windows.Forms.DockStyle.Bottom;
this.btnSave.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; this.lvSteps.Location = new System.Drawing.Point(0, 140);
this.btnSave.FocusOnLeftMouseButtonDown = true; this.lvSteps.MultiSelect = false;
this.btnSave.Location = new System.Drawing.Point(29, 42); this.lvSteps.Name = "lvSteps";
this.btnSave.Name = "btnSave"; this.lvSteps.Size = new System.Drawing.Size(331, 313);
this.btnSave.Size = new System.Drawing.Size(101, 23); this.lvSteps.TabIndex = 0;
this.btnSave.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.lvSteps.UseCompatibleStateImageBehavior = false;
this.btnSave.TabIndex = 2; this.lvSteps.View = System.Windows.Forms.View.List;
this.btnSave.Text = "Save Selection"; this.lvSteps.SelectedIndexChanged += new System.EventHandler(this.lvSteps_SelectedIndexChanged);
this.btnSave.Click += new System.EventHandler(this.btnSave_Click); //
// 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 // DisplayFoldoutMaint
// //
@ -173,7 +200,7 @@ namespace Volian.Controls.Library
this.Controls.Add(this.groupSteps); this.Controls.Add(this.groupSteps);
this.Controls.Add(this.groupFoldouts); this.Controls.Add(this.groupFoldouts);
this.Name = "DisplayFoldoutMaint"; this.Name = "DisplayFoldoutMaint";
this.Size = new System.Drawing.Size(340, 588); this.Size = new System.Drawing.Size(340, 632);
this.groupFoldouts.ResumeLayout(false); this.groupFoldouts.ResumeLayout(false);
this.groupSteps.ResumeLayout(false); this.groupSteps.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
@ -188,5 +215,7 @@ namespace Volian.Controls.Library
private System.Windows.Forms.ListView lvSteps; private System.Windows.Forms.ListView lvSteps;
private DevComponents.DotNetBar.LabelX lblStepSelect; private DevComponents.DotNetBar.LabelX lblStepSelect;
private DevComponents.DotNetBar.ButtonX btnSave; 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 _firstStep;
private ItemInfo _lastStep; private ItemInfo _lastStep;
private bool _Initializing;
public DisplayFoldoutMaint() public DisplayFoldoutMaint()
{ {
InitializeComponent(); InitializeComponent();
@ -48,8 +50,7 @@ namespace Volian.Controls.Library
private void FillInControls() private void FillInControls()
{ {
_Initializing = true;
// for this iteminfo, get the procedure and then the list of sections. For any section, starting with // for this iteminfo, get the procedure and then the list of sections. For any section, starting with
// Foldout, add it to list: // Foldout, add it to list:
if (MyItemInfo != null) if (MyItemInfo != null)
@ -75,22 +76,35 @@ namespace Volian.Controls.Library
lvSteps.Items[lvSteps.Items.Count - 1].Tag = startitm; lvSteps.Items[lvSteps.Items.Count - 1].Tag = startitm;
startitm = (startitm.NextItem != null && startitm.NextItems.Count > 0 ? startitm.NextItems[0] : null); startitm = (startitm.NextItem != null && startitm.NextItems.Count > 0 ? startitm.NextItems[0] : null);
} }
}
ColorFoldoutSelection(); 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);
}
} }
private void ColorFoldoutSelection() private void ColorFoldoutSelection()
{ {
if (MyItemInfo == null) return; if (MyItemInfo == null) return;
if (listBoxFoldouts.Items[0].ToString() == "No Foldouts Exist") 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; SectionInfo foldOutselected = listBoxFoldouts.Items[listBoxFoldouts.SelectedIndex] as SectionInfo;
ItemInfo tmpStep = null; // keep track of previous step, so can set _lastStep; ItemInfo tmpStep = null; // keep track of previous step, so can set _lastStep;
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; _firstStep = null;
_lastStep = 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;
if (sc != null) if (sc != null)
{ {
if (sc.Step_FloatingFoldout == foldOutselected.ItemID) if (sc.Step_FloatingFoldout == foldOutselected.ItemID)
@ -137,7 +151,7 @@ namespace Volian.Controls.Library
private void btnSave_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
{ {
lblStepSelect.Text = "Select First Step"; 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. // the selected foldout.
bool sav = false; bool sav = false;
SectionInfo foldOutselected = listBoxFoldouts.Items[listBoxFoldouts.SelectedIndex] as SectionInfo; 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();
}
} }
} }