This commit is contained in:
Kathy Ruffing 2008-01-31 14:31:18 +00:00
parent 9f96d885fe
commit 7de364dbac

View File

@ -20,21 +20,26 @@ namespace Volian.Controls.Library
get { return _CurProcSet; } get { return _CurProcSet; }
set { _CurProcSet = value; } set { _CurProcSet = value; }
} }
private bool _Modify = false;
public bool Modify
{
get { return _Modify; }
set { _Modify = value; }
}
private int _TranFmtIndx = -1; private int _TranFmtIndx = -1;
private ItemInfo _CurItem; private ItemInfo _CurItemFrom;
public ItemInfo CurItem private TransitionInfo _CurTrans;
public TransitionInfo CurTrans
{ {
get { return _CurItem; } get { return _CurTrans; }
set set
{ {
_CurItem = value; _CurTrans = value;
infotabTransitionFillIn(); 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; private VETreeNode _RangeNode1;
@ -50,75 +55,41 @@ namespace Volian.Controls.Library
private int _CurrentProcIndex; private int _CurrentProcIndex;
#endregion #endregion
#region Constructors #region Constructors
public DisplayTransition(ItemInfo curitm, bool modify, DisplayRTB rtb)
{
_Modify = modify;
_CurItem = curitm;
_MyRTB = rtb;
InitializeComponent();
infotabTransitionFillIn();
}
public DisplayTransition() public DisplayTransition()
{ {
InitializeComponent(); 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 #endregion
#region LoadControlData #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. // insert/modify transition tab.
private bool _InitializingTrans; private bool _InitializingTrans;
private void infotabTransitionFillIn() private void TransitionFillIn()
{ {
if (_CurItem == null) return; //if (_CurItem == null) return;
btnTranInsert.Text = "Select Transition"; btnTranInsert.Text = "Select Transition";
_InitializingTrans = true; _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).
if (!CurProcSet)
{
return;
}
listBoxTranFmtFillIn();
// if new, use CurItem to find the section level & procedure level, if (_RangeNode1!= null) _RangeNode1.BackColor = tvTran.BackColor;
// if modify, use the first transition to, _tranitem1 // first see if transition is within same set, this determines what
ItemInfo tmpitm = Modify?_tranitem1:CurItem; // controls & settings are used.
DetermineCurProcSet();
if (!CurProcSet)
return;
else
CurrentProcSetFillIn();
_InitializingTrans = false;
}
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; ItemInfo selstpitm = tmpitm;
while (tmpitm.MyContent.Type >= 20000) while (tmpitm.MyContent.Type >= 20000)
{ {
@ -129,19 +100,34 @@ namespace Volian.Controls.Library
ItemInfo prcitm = secitm.MyParent; ItemInfo prcitm = secitm.MyParent;
_CurrentProcedure = prcitm; _CurrentProcedure = prcitm;
listBoxTranProcsFillIn(prcitm); listBoxTranProcsFillIn(prcitm);
tvTranFillIn(selstpitm); 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(); listBoxTranFmt.Items.Clear();
for (int i = 0; i < ttl.Count; i++) for (int i = 0; i < ttl.Count; i++)
listBoxTranFmt.Items.Add(ttl[i].TransFormat); listBoxTranFmt.Items.Add(ttl[i].TransFormat);
if (!_Modify)
listBoxTranFmt.SelectedIndex = 0;
else
listBoxTranFmt.SelectedIndex = _TranFmtIndx; listBoxTranFmt.SelectedIndex = _TranFmtIndx;
} }
private void tvTranFillIn(ItemInfo startitm) private void tvTranFillIn(ItemInfo startitm)
@ -152,11 +138,14 @@ namespace Volian.Controls.Library
// For the tree view, use parent, unless already at HLS. If at HLS, use this level. // For the tree view, use parent, unless already at HLS. If at HLS, use this level.
ItemInfo selitm = startitm; ItemInfo selitm = startitm;
if (_CurTrans == null)
{
if (!startitm.IsHigh) if (!startitm.IsHigh)
{ {
startitm = startitm.MyParent; startitm = startitm.MyParent;
selitm = startitm; selitm = startitm;
} }
}
startitm = startitm.FirstSibling; startitm = startitm.FirstSibling;
while (startitm != null) while (startitm != null)
{ {
@ -199,25 +188,23 @@ namespace Volian.Controls.Library
prcitm = (prcitm.NextItemCount > 0 ? prcitm.NextItems[0] : null); prcitm = (prcitm.NextItemCount > 0 ? prcitm.NextItems[0] : null);
} }
} }
#endregion private void SetControlsEnabling()
#region Events
private void listBoxTranFmt_Click(object sender, EventArgs e)
{ {
if (_InitializingTrans) return; if (CurProcSet)
if (listBoxTranFmt.SelectedIndex == _TranFmtIndx) return;
// if resetting format selection, null out the selected transitions.
_tranitem1 = null;
_tranitem2 = null;
if (_RangeNode1 != null)
{ {
_RangeNode1.BackColor = tvTran.BackColor; groupPanelTranFmt.Visible = true;
_RangeNode1 = null; groupPanelTransitionProcs.Visible = true;
} groupPanelTransitionSect.Visible = true;
_TranFmtIndx = listBoxTranFmt.SelectedIndex; groupPanelTranstionSteps.Visible = true;
groupPanelProcSets.Visible = false;
tvProcSets.Visible = false;
// Determine, based on selection, i.e. select proc/section and disable associated list boxes if // Determine, based on selection, i.e. select proc/section and disable associated list boxes if
// enum representing the transition restricts the selection. // enum representing the transition restricts the selection.
E_TransUI etm = (E_TransUI)_CurItem.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI; 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 // do the procedure list box. (in 16-bit system it was types 0, 3, 5
if ((etm & E_TransUI.ProcMenu) == E_TransUI.ProcMenu) if ((etm & E_TransUI.ProcMenu) == E_TransUI.ProcMenu)
listBoxTranProcs.Enabled = true; listBoxTranProcs.Enabled = true;
@ -238,6 +225,44 @@ namespace Volian.Controls.Library
} }
else else
listBoxTranSects.Enabled = false; 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)
{
if (_InitializingTrans) return;
if (listBoxTranFmt.SelectedIndex == _TranFmtIndx) return;
// if resetting format selection, null out the selected transitions.
_tranitem1 = null;
_tranitem2 = null;
if (_RangeNode1 != null)
{
_RangeNode1.BackColor = tvTran.BackColor;
_RangeNode1 = null;
}
_TranFmtIndx = listBoxTranFmt.SelectedIndex;
SetControlsEnabling();
tvTran.Enabled = true; tvTran.Enabled = true;
} }
@ -286,7 +311,7 @@ namespace Volian.Controls.Library
string trantxt = "{Resolved Transition Text}"; string trantxt = "{Resolved Transition Text}";
string linktxt = null; string linktxt = null;
//int type = (int)(_CurItem.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].Type); //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 // 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. 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; VETreeNode vtn = (VETreeNode)tvTran.SelectedNode;
_tranitem1 = (ItemInfo)vtn.VEObject; // is this cast valid? _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 // if this is a range, we'll denote the first 'to' item with color on the
// tree view. // tree view.
@ -390,7 +415,7 @@ namespace Volian.Controls.Library
{ {
VETreeNode vtn = (VETreeNode)tvTran.SelectedNode; VETreeNode vtn = (VETreeNode)tvTran.SelectedNode;
_tranitem1 = (ItemInfo)vtn.VEObject; // is this cast valid? _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 // if this is a range, we'll denote the first 'to' item with color on the
// tree view. // tree view.
if ((etm & E_TransUI.StepLast) == E_TransUI.StepLast) if ((etm & E_TransUI.StepLast) == E_TransUI.StepLast)
@ -414,7 +439,7 @@ namespace Volian.Controls.Library
{ {
VETreeNode vtn = (VETreeNode)tvTran.SelectedNode; VETreeNode vtn = (VETreeNode)tvTran.SelectedNode;
_tranitem1 = (ItemInfo)vtn.VEObject; // is this cast valid? _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 // if this is a range, we'll denote the first 'to' item with color on the
// tree view. // tree view.
if ((etm & E_TransUI.StepLast) == E_TransUI.StepLast) 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();
}
} }
} }