This commit is contained in:
parent
9f96d885fe
commit
7de364dbac
@ -20,21 +20,26 @@ namespace Volian.Controls.Library
|
||||
get { return _CurProcSet; }
|
||||
set { _CurProcSet = value; }
|
||||
}
|
||||
private bool _Modify = false;
|
||||
public bool Modify
|
||||
{
|
||||
get { return _Modify; }
|
||||
set { _Modify = value; }
|
||||
}
|
||||
private int _TranFmtIndx = -1;
|
||||
private ItemInfo _CurItem;
|
||||
public ItemInfo CurItem
|
||||
private ItemInfo _CurItemFrom;
|
||||
private TransitionInfo _CurTrans;
|
||||
public TransitionInfo CurTrans
|
||||
{
|
||||
get { return _CurItem; }
|
||||
get { return _CurTrans; }
|
||||
set
|
||||
{
|
||||
_CurItem = value;
|
||||
infotabTransitionFillIn();
|
||||
_CurTrans = value;
|
||||
if (_CurTrans == null)
|
||||
{
|
||||
if (MyRTB == null) return;
|
||||
_CurItemFrom = MyRTB.MyItem;
|
||||
ClearControls();
|
||||
DetermineCurProcSet();
|
||||
return;
|
||||
}
|
||||
_TranFmtIndx = _CurTrans.TranType;
|
||||
_CurItemFrom = ItemInfo.Get(_CurTrans.FromID);
|
||||
TransitionFillIn();
|
||||
}
|
||||
}
|
||||
private VETreeNode _RangeNode1;
|
||||
@ -50,75 +55,41 @@ namespace Volian.Controls.Library
|
||||
private int _CurrentProcIndex;
|
||||
#endregion
|
||||
#region Constructors
|
||||
public DisplayTransition(ItemInfo curitm, bool modify, DisplayRTB rtb)
|
||||
{
|
||||
_Modify = modify;
|
||||
_CurItem = curitm;
|
||||
_MyRTB = rtb;
|
||||
InitializeComponent();
|
||||
infotabTransitionFillIn();
|
||||
}
|
||||
public DisplayTransition()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public DisplayTransition(ItemInfo curitm, string curtran, bool modify, DisplayRTB rtb)
|
||||
{
|
||||
_Modify = modify;
|
||||
_CurItem = curitm;
|
||||
ParseModifyLink(curtran);
|
||||
_MyRTB = rtb;
|
||||
InitializeComponent();
|
||||
infotabTransitionFillIn();
|
||||
}
|
||||
private void ParseModifyLink(string linktext)
|
||||
{
|
||||
Match m = Regex.Match(linktext, ".*[#]Link:([A-Za-z]*):(.*)");
|
||||
_TranFmtIndx = Convert.ToInt32(m.Groups[2].Value.Split(" ".ToCharArray())[0]);
|
||||
int transitionID = Convert.ToInt32(m.Groups[2].Value.Split(" ".ToCharArray())[1]);
|
||||
Transition mytran = Transition.Get(transitionID);
|
||||
int itm1 = Convert.ToInt32(m.Groups[2].Value.Split(" ".ToCharArray())[2]);
|
||||
_tranitem1 = ItemInfo.Get(itm1);
|
||||
if (m.Groups[1].Value == "TransitionRange")
|
||||
{
|
||||
int itm2 = Convert.ToInt32(m.Groups[2].Value.Split(" ".ToCharArray())[3]);
|
||||
_tranitem2 = ItemInfo.Get(itm2);
|
||||
}
|
||||
// determine if current item & the transition point item are in the same set.
|
||||
// if different sets, different controls are displayed.
|
||||
DocVersion dv = CurItem.MyProcedure.ActiveParent as DocVersion;
|
||||
if (dv == null) return; // what to do if null?
|
||||
DocVersion dvto = _tranitem1.MyProcedure.ActiveParent as DocVersion;
|
||||
if (dvto == null) return; // what to do if null?
|
||||
if (dv.VersionID != dvto.VersionID) CurProcSet = false;
|
||||
else CurProcSet = true;
|
||||
cbCurProcSet.Checked = CurProcSet;
|
||||
}
|
||||
#endregion
|
||||
#region LoadControlData
|
||||
// infotabTransitionFillIn uses other methods to fill in all controls on the
|
||||
// TransitionFillIn uses other methods to fill in all controls on the
|
||||
// insert/modify transition tab.
|
||||
private bool _InitializingTrans;
|
||||
private void infotabTransitionFillIn()
|
||||
private void TransitionFillIn()
|
||||
{
|
||||
if (_CurItem == null) return;
|
||||
//if (_CurItem == null) return;
|
||||
btnTranInsert.Text = "Select Transition";
|
||||
_InitializingTrans = true;
|
||||
|
||||
if (_RangeNode1!= null) _RangeNode1.BackColor = tvTran.BackColor;
|
||||
// first see if transition is within same set, i.e. if modify then check
|
||||
// if current item is in same set as transition to item. If not modify,
|
||||
// initialize is always setting to within current set. This is important
|
||||
// because different controls are used for same (list view) versus different
|
||||
// set (tree view).
|
||||
// first see if transition is within same set, this determines what
|
||||
// controls & settings are used.
|
||||
DetermineCurProcSet();
|
||||
if (!CurProcSet)
|
||||
{
|
||||
return;
|
||||
}
|
||||
listBoxTranFmtFillIn();
|
||||
else
|
||||
CurrentProcSetFillIn();
|
||||
|
||||
_InitializingTrans = false;
|
||||
}
|
||||
|
||||
// if new, use CurItem to find the section level & procedure level,
|
||||
// if modify, use the first transition to, _tranitem1
|
||||
ItemInfo tmpitm = Modify?_tranitem1:CurItem;
|
||||
private void CurrentProcSetFillIn()
|
||||
{
|
||||
ListBoxTranFmtFillIn();
|
||||
|
||||
// if new, use _CurItemFrom to find the section level & procedure level,
|
||||
// if modify, use the first transition to, _CurTrans
|
||||
//ItemInfo tmpitm = _ToModify!=null?_tranitem1:_CurItem;
|
||||
ItemInfo tmpitm = _CurTrans==null?_CurItemFrom:_CurTrans.MyItemToID;
|
||||
ItemInfo selstpitm = tmpitm;
|
||||
while (tmpitm.MyContent.Type >= 20000)
|
||||
{
|
||||
@ -129,20 +100,35 @@ namespace Volian.Controls.Library
|
||||
ItemInfo prcitm = secitm.MyParent;
|
||||
_CurrentProcedure = prcitm;
|
||||
listBoxTranProcsFillIn(prcitm);
|
||||
|
||||
tvTranFillIn(selstpitm);
|
||||
_InitializingTrans = false;
|
||||
SetControlsEnabling();
|
||||
}
|
||||
private void listBoxTranFmtFillIn()
|
||||
private void DetermineCurProcSet()
|
||||
{
|
||||
TransTypeList ttl = _CurItem.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList;
|
||||
// If a current transition exists then check if current from item is in same set
|
||||
// as transition to item. If no current transition (new), initialize to current
|
||||
// set. Different controls are used for same set (list view) versus different
|
||||
// set (tree view).
|
||||
if (_CurTrans != null)
|
||||
{
|
||||
DocVersionInfo dv = _CurItemFrom.MyProcedure.ActiveParent as DocVersionInfo;
|
||||
if (dv == null) return; // what to do if null?
|
||||
DocVersionInfo dvto = _CurTrans.MyItemToID.MyProcedure.ActiveParent as DocVersionInfo;
|
||||
if (dv.VersionID != dvto.VersionID) CurProcSet = false;
|
||||
else CurProcSet = true;
|
||||
cbCurProcSet.Checked = CurProcSet;
|
||||
}
|
||||
else
|
||||
CurProcSet = cbCurProcSet.Checked;
|
||||
|
||||
}
|
||||
private void ListBoxTranFmtFillIn()
|
||||
{
|
||||
TransTypeList ttl = _CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList;
|
||||
listBoxTranFmt.Items.Clear();
|
||||
for (int i = 0; i < ttl.Count; i++)
|
||||
listBoxTranFmt.Items.Add(ttl[i].TransFormat);
|
||||
if (!_Modify)
|
||||
listBoxTranFmt.SelectedIndex = 0;
|
||||
else
|
||||
listBoxTranFmt.SelectedIndex = _TranFmtIndx;
|
||||
listBoxTranFmt.SelectedIndex = _TranFmtIndx;
|
||||
}
|
||||
private void tvTranFillIn(ItemInfo startitm)
|
||||
{
|
||||
@ -152,10 +138,13 @@ namespace Volian.Controls.Library
|
||||
|
||||
// For the tree view, use parent, unless already at HLS. If at HLS, use this level.
|
||||
ItemInfo selitm = startitm;
|
||||
if (!startitm.IsHigh)
|
||||
if (_CurTrans == null)
|
||||
{
|
||||
startitm = startitm.MyParent;
|
||||
selitm = startitm;
|
||||
if (!startitm.IsHigh)
|
||||
{
|
||||
startitm = startitm.MyParent;
|
||||
selitm = startitm;
|
||||
}
|
||||
}
|
||||
startitm = startitm.FirstSibling;
|
||||
while (startitm != null)
|
||||
@ -199,6 +188,64 @@ namespace Volian.Controls.Library
|
||||
prcitm = (prcitm.NextItemCount > 0 ? prcitm.NextItems[0] : null);
|
||||
}
|
||||
}
|
||||
private void SetControlsEnabling()
|
||||
{
|
||||
if (CurProcSet)
|
||||
{
|
||||
groupPanelTranFmt.Visible = true;
|
||||
groupPanelTransitionProcs.Visible = true;
|
||||
groupPanelTransitionSect.Visible = true;
|
||||
groupPanelTranstionSteps.Visible = true;
|
||||
groupPanelProcSets.Visible = false;
|
||||
tvProcSets.Visible = false;
|
||||
|
||||
// Determine, based on selection, i.e. select proc/section and disable associated list boxes if
|
||||
// enum representing the transition restricts the selection.
|
||||
if (_CurItemFrom == null) return;
|
||||
int indx = listBoxTranFmt.SelectedIndex;
|
||||
if (listBoxTranFmt.SelectedIndex < 0 || listBoxTranFmt.SelectedIndex > listBoxTranFmt.Items.Count) indx = 0;
|
||||
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[indx].TransUI;
|
||||
// do the procedure list box. (in 16-bit system it was types 0, 3, 5
|
||||
if ((etm & E_TransUI.ProcMenu) == E_TransUI.ProcMenu)
|
||||
listBoxTranProcs.Enabled = true;
|
||||
else
|
||||
{
|
||||
listBoxTranProcs.SelectedIndex = _CurrentProcIndex > 0 ? _CurrentProcIndex : 0;
|
||||
listBoxTranProcs.Enabled = false;
|
||||
}
|
||||
|
||||
// in 16-bit system it was types 0, 3, 4, 5
|
||||
if (((etm & E_TransUI.SectDefault) == E_TransUI.SectDefault) ||
|
||||
((etm & E_TransUI.SectMenuAny) == E_TransUI.SectMenuAny) ||
|
||||
((etm & E_TransUI.SectMenuStep) == E_TransUI.SectMenuStep))
|
||||
{
|
||||
// find default step section and make it the selected item - then disable from further selection.
|
||||
//listBoxTranSects.SelectedIndex = 1; // TEMP until default step section found.
|
||||
listBoxTranSects.Enabled = true;
|
||||
}
|
||||
else
|
||||
listBoxTranSects.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
groupPanelTranFmt.Visible = false;
|
||||
groupPanelTransitionProcs.Visible = false;
|
||||
groupPanelTransitionSect.Visible = false;
|
||||
groupPanelTranstionSteps.Visible = false;
|
||||
groupPanelProcSets.Visible = true;
|
||||
tvProcSets.Visible = true;
|
||||
tvProcSets.Dock = DockStyle.Top;
|
||||
return;
|
||||
}
|
||||
}
|
||||
private void ClearControls()
|
||||
{
|
||||
listBoxTranFmt.Items.Clear();
|
||||
listBoxTranProcs.Items.Clear();
|
||||
listBoxTranSects.Items.Clear();
|
||||
tvTran.Nodes.Clear();
|
||||
_TranFmtIndx = 0;
|
||||
}
|
||||
#endregion
|
||||
#region Events
|
||||
private void listBoxTranFmt_Click(object sender, EventArgs e)
|
||||
@ -215,29 +262,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
_TranFmtIndx = listBoxTranFmt.SelectedIndex;
|
||||
|
||||
// Determine, based on selection, i.e. select proc/section and disable associated list boxes if
|
||||
// enum representing the transition restricts the selection.
|
||||
E_TransUI etm = (E_TransUI)_CurItem.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
|
||||
// do the procedure list box. (in 16-bit system it was types 0, 3, 5
|
||||
if ((etm & E_TransUI.ProcMenu) == E_TransUI.ProcMenu)
|
||||
listBoxTranProcs.Enabled = true;
|
||||
else
|
||||
{
|
||||
listBoxTranProcs.SelectedIndex = _CurrentProcIndex > 0 ? _CurrentProcIndex : 0;
|
||||
listBoxTranProcs.Enabled = false;
|
||||
}
|
||||
|
||||
// in 16-bit system it was types 0, 3, 4, 5
|
||||
if (((etm & E_TransUI.SectDefault) == E_TransUI.SectDefault) ||
|
||||
((etm & E_TransUI.SectMenuAny) == E_TransUI.SectMenuAny) ||
|
||||
((etm & E_TransUI.SectMenuStep) == E_TransUI.SectMenuStep))
|
||||
{
|
||||
// find default step section and make it the selected item - then disable from further selection.
|
||||
//listBoxTranSects.SelectedIndex = 1; // TEMP until default step section found.
|
||||
listBoxTranSects.Enabled = true;
|
||||
}
|
||||
else
|
||||
listBoxTranSects.Enabled = false;
|
||||
SetControlsEnabling();
|
||||
|
||||
tvTran.Enabled = true;
|
||||
}
|
||||
@ -286,7 +311,7 @@ namespace Volian.Controls.Library
|
||||
string trantxt = "{Resolved Transition Text}";
|
||||
string linktxt = null;
|
||||
//int type = (int)(_CurItem.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].Type);
|
||||
E_TransUI etm = (E_TransUI)_CurItem.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
|
||||
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
|
||||
// do the procedure list box. (in 16-bit system it was types 0, 3, 5
|
||||
if (!((etm & E_TransUI.StepAllowNone) == E_TransUI.StepAllowNone)) // _tranitem1 is set from step tree node.
|
||||
{
|
||||
@ -356,7 +381,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
VETreeNode vtn = (VETreeNode)tvTran.SelectedNode;
|
||||
_tranitem1 = (ItemInfo)vtn.VEObject; // is this cast valid?
|
||||
E_TransUI etm = (E_TransUI)_CurItem.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
|
||||
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
|
||||
|
||||
// if this is a range, we'll denote the first 'to' item with color on the
|
||||
// tree view.
|
||||
@ -390,7 +415,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
VETreeNode vtn = (VETreeNode)tvTran.SelectedNode;
|
||||
_tranitem1 = (ItemInfo)vtn.VEObject; // is this cast valid?
|
||||
E_TransUI etm = (E_TransUI)_CurItem.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
|
||||
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
|
||||
// if this is a range, we'll denote the first 'to' item with color on the
|
||||
// tree view.
|
||||
if ((etm & E_TransUI.StepLast) == E_TransUI.StepLast)
|
||||
@ -414,7 +439,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
VETreeNode vtn = (VETreeNode)tvTran.SelectedNode;
|
||||
_tranitem1 = (ItemInfo)vtn.VEObject; // is this cast valid?
|
||||
E_TransUI etm = (E_TransUI)_CurItem.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
|
||||
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
|
||||
// if this is a range, we'll denote the first 'to' item with color on the
|
||||
// tree view.
|
||||
if ((etm & E_TransUI.StepLast) == E_TransUI.StepLast)
|
||||
@ -431,6 +456,32 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
|
||||
private void btnNewTrans_Click(object sender, EventArgs e)
|
||||
{
|
||||
_CurItemFrom = _MyRTB.MyItem;
|
||||
_CurTrans = null;
|
||||
_TranFmtIndx = 0;
|
||||
TransitionFillIn();
|
||||
}
|
||||
private void LoadProcSetTree()
|
||||
{
|
||||
VETreeNode tn = VETreeNode.GetFolder(1);
|
||||
tvProcSets.Nodes.Add(tn);
|
||||
tn.LoadChildren(true);
|
||||
tvProcSets.BeforeExpand += new TreeViewCancelEventHandler(tvProcSet_BeforeExpand);
|
||||
}
|
||||
private void tvProcSet_BeforeExpand(object sender, TreeViewCancelEventArgs e)
|
||||
{
|
||||
VETreeNode tn = ((VETreeNode)e.Node);
|
||||
tn.LoadChildren(true);
|
||||
}
|
||||
private void cbCurProcSet_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
CurProcSet = cbCurProcSet.Checked;
|
||||
if (!CurProcSet && tvProcSets.Nodes.Count == 0) LoadProcSetTree();
|
||||
SetControlsEnabling();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user