This commit is contained in:
166
PROMS/Volian.Controls.Library/DisplayFoldoutMaint.cs
Normal file
166
PROMS/Volian.Controls.Library/DisplayFoldoutMaint.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
public partial class DisplayFoldoutMaint : UserControl
|
||||
{
|
||||
private ItemInfo _MyItemInfo;
|
||||
public ItemInfo MyItemInfo
|
||||
{
|
||||
get { return _MyItemInfo; }
|
||||
set
|
||||
{
|
||||
_MyItemInfo = value;
|
||||
_MainStepSection = null;
|
||||
FillInControls();
|
||||
}
|
||||
}
|
||||
private SectionInfo _MainStepSection;
|
||||
public SectionInfo MainStepSection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MainStepSection == null)
|
||||
{
|
||||
foreach (SectionInfo si in MyItemInfo.MyProcedure.Sections)
|
||||
{
|
||||
SectionConfig sc = (SectionConfig)si.MyConfig;
|
||||
if (sc.Section_OriginalSteps == "Y") _MainStepSection = si;
|
||||
}
|
||||
}
|
||||
return _MainStepSection;
|
||||
}
|
||||
}
|
||||
private ItemInfo _firstStep;
|
||||
private ItemInfo _lastStep;
|
||||
public DisplayFoldoutMaint()
|
||||
{
|
||||
InitializeComponent();
|
||||
FillInControls();
|
||||
}
|
||||
|
||||
private void FillInControls()
|
||||
{
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
ProcedureInfo pi = MyItemInfo.MyProcedure;
|
||||
listBoxFoldouts.Items.Clear();
|
||||
lvSteps.Items.Clear();
|
||||
foreach (SectionInfo si in pi.Sections)
|
||||
if (si.DisplayText.ToUpper().StartsWith("FOLDOUT"))listBoxFoldouts.Items.Add(si);
|
||||
if (listBoxFoldouts.Items.Count > 0) listBoxFoldouts.SelectedIndex = 0;
|
||||
else
|
||||
{
|
||||
listBoxFoldouts.Items.Add("No Foldouts Exist");
|
||||
return;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
private void ColorFoldoutSelection()
|
||||
{
|
||||
if (MyItemInfo == null) return;
|
||||
if (listBoxFoldouts.Items[0].ToString() == "No Foldouts Exist") return;
|
||||
SectionInfo foldOutselected = listBoxFoldouts.Items[listBoxFoldouts.SelectedIndex] as SectionInfo;
|
||||
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;
|
||||
_lastStep = null;
|
||||
if (sc != null)
|
||||
{
|
||||
if (sc.Step_FloatingFoldout == foldOutselected.ItemID)
|
||||
{
|
||||
if (_firstStep == null) _firstStep = ii;
|
||||
tmpStep = ii;
|
||||
lvSteps.Items[i].BackColor = Color.Aquamarine;
|
||||
}
|
||||
else
|
||||
lvSteps.Items[i].BackColor = lvSteps.BackColor;
|
||||
}
|
||||
}
|
||||
_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"))
|
||||
{
|
||||
// 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";
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
lblStepSelect.Text = "Select First Step";
|
||||
// for all selected steps, set their cofig floating foldout item to
|
||||
// the selected foldout.
|
||||
bool sav = false;
|
||||
SectionInfo foldOutselected = listBoxFoldouts.Items[listBoxFoldouts.SelectedIndex] as SectionInfo;
|
||||
|
||||
foreach (ItemInfo ii in MainStepSection.Steps)
|
||||
{
|
||||
if (ii.ItemID == _firstStep.ItemID)
|
||||
sav = true;
|
||||
if (sav)
|
||||
{
|
||||
StepConfig sc = ii.MyConfig as StepConfig;
|
||||
sc.Step_FloatingFoldout = foldOutselected.ItemID;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user