This commit is contained in:
@@ -15,8 +15,8 @@ namespace Volian.Controls.Library
|
||||
public ItemInfo MyItemInfo
|
||||
{
|
||||
get { return _MyItemInfo; }
|
||||
set
|
||||
{
|
||||
set
|
||||
{
|
||||
_MyItemInfo = value;
|
||||
_MainStepSection = null;
|
||||
FillInControls();
|
||||
@@ -57,9 +57,9 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
ProcedureInfo pi = MyItemInfo.MyProcedure;
|
||||
listBoxFoldouts.Items.Clear();
|
||||
lvSteps.Items.Clear();
|
||||
lstCBSteps.Items.Clear();
|
||||
foreach (SectionInfo si in pi.Sections)
|
||||
if (si.DisplayText.ToUpper().StartsWith("FOLDOUT"))listBoxFoldouts.Items.Add(si);
|
||||
if (si.DisplayText.ToUpper().StartsWith("FOLDOUT")) listBoxFoldouts.Items.Add(si);
|
||||
if (listBoxFoldouts.Items.Count > 0) listBoxFoldouts.SelectedIndex = 0;
|
||||
else
|
||||
{
|
||||
@@ -68,158 +68,83 @@ 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)
|
||||
{
|
||||
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();
|
||||
FillInSteps();
|
||||
_Initializing = false;
|
||||
}
|
||||
|
||||
}
|
||||
private void ReLoadTree()
|
||||
private void FillInSteps()
|
||||
{
|
||||
lvSteps.Clear();
|
||||
ItemInfo foldOutselected = listBoxFoldouts.SelectedItem as ItemInfo;
|
||||
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()
|
||||
{
|
||||
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;
|
||||
StepConfig sc = startitm.MyConfig as StepConfig;
|
||||
if (sc != null)
|
||||
{
|
||||
if (sc.Step_FloatingFoldout == foldOutselected.ItemID)
|
||||
{
|
||||
if (_firstStep == null) _firstStep = ii;
|
||||
tmpStep = ii;
|
||||
lvSteps.Items[i].BackColor = Color.Aquamarine;
|
||||
lstCBSteps.Items.Add(startitm, CheckState.Checked);
|
||||
}
|
||||
else
|
||||
lvSteps.Items[i].BackColor = lvSteps.BackColor;
|
||||
lstCBSteps.Items.Add(startitm, CheckState.Unchecked);
|
||||
}
|
||||
else
|
||||
lstCBSteps.Items.Add(startitm, CheckState.Unchecked);
|
||||
startitm = (startitm.NextItem != null && startitm.NextItems.Count > 0 ? startitm.NextItems[0] : null);
|
||||
}
|
||||
_lastStep = tmpStep;
|
||||
}
|
||||
|
||||
private void listBoxFoldouts_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
ColorFoldoutSelection();
|
||||
lblStepSelect.Text = "Select First Step";
|
||||
}
|
||||
private int _firstIndexForSelect = -1;
|
||||
private void lvSteps_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (lvSteps.SelectedIndices == null || lvSteps.SelectedIndices.Count == 0) return;
|
||||
if (lblStepSelect.Text.Contains("Select First Step"))
|
||||
ItemInfo foldOutselected = listBoxFoldouts.SelectedItem as ItemInfo;
|
||||
int itemInList = 0;
|
||||
for (int i = 0; i < lstCBSteps.Items.Count; i++)
|
||||
{
|
||||
// clear out background from list, and change label for instruct.,
|
||||
// also set _firstStep to this one.
|
||||
for (int i = 0; i < lvSteps.Items.Count; i++) lvSteps.Items[i].BackColor = lvSteps.BackColor;
|
||||
lblStepSelect.Text = "Select Last Step";
|
||||
_firstIndexForSelect = lvSteps.SelectedIndices[0];
|
||||
_firstStep = (ItemInfo)lvSteps.Items[_firstIndexForSelect].Tag;
|
||||
}
|
||||
else
|
||||
{
|
||||
int lastind = lvSteps.SelectedIndices[0];
|
||||
_lastStep = (ItemInfo)lvSteps.Items[lastind].Tag;
|
||||
for (int i = _firstIndexForSelect; i < lastind; i++)
|
||||
lvSteps.Items[i].BackColor = Color.Aquamarine;
|
||||
lblStepSelect.Text = "Save or ReSelect First Step";
|
||||
ItemInfo startitm = lstCBSteps.Items[i] as ItemInfo;
|
||||
StepConfig sc = startitm.MyConfig as StepConfig;
|
||||
if (sc != null)
|
||||
lstCBSteps.SetItemChecked(itemInList, sc.Step_FloatingFoldout == foldOutselected.ItemID);
|
||||
else
|
||||
lstCBSteps.SetItemChecked(itemInList, false);
|
||||
itemInList++;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
lblStepSelect.Text = "Select First Step";
|
||||
// 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;
|
||||
|
||||
foreach (ItemInfo ii in MainStepSection.Steps)
|
||||
SectionInfo foldOutselected = listBoxFoldouts.SelectedItem as SectionInfo;
|
||||
int itemInList = 0;
|
||||
for (int i = 0; i < lstCBSteps.Items.Count; i++)
|
||||
{
|
||||
if (ii.ItemID == _firstStep.ItemID)
|
||||
sav = true;
|
||||
if (sav)
|
||||
bool savit = false;
|
||||
ItemInfo startitm = lstCBSteps.Items[i] as ItemInfo;
|
||||
StepConfig sc = startitm.MyConfig as StepConfig;
|
||||
if (lstCBSteps.GetItemChecked(itemInList)) // associate with foldout (if not already)
|
||||
{
|
||||
StepConfig sc = ii.MyConfig as StepConfig;
|
||||
sc.Step_FloatingFoldout = foldOutselected.ItemID;
|
||||
using (Item itm = ii.Get())
|
||||
if (sc == null || sc != null && sc.Step_FloatingFoldout != foldOutselected.ItemID)
|
||||
{
|
||||
sc.Step_FloatingFoldout = foldOutselected.ItemID;
|
||||
savit = true;
|
||||
}
|
||||
}
|
||||
else // remove association if exists
|
||||
{
|
||||
if (sc != null && sc.Step_FloatingFoldout == foldOutselected.ItemID)
|
||||
{
|
||||
sc.Step_FloatingFoldout = 0;
|
||||
savit = true;
|
||||
}
|
||||
}
|
||||
itemInList++;
|
||||
if (savit)
|
||||
{
|
||||
using (Item itm = startitm.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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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