Improvements and bug fixes, including clear all & reset to fix 'caching' problem
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user