Update Transition Text

This commit is contained in:
Rich
2009-07-30 19:03:38 +00:00
parent bb9a9c1d09
commit df1defc709
2 changed files with 75 additions and 25 deletions

View File

@@ -707,7 +707,7 @@ namespace Volian.Controls.Library
}
private void btnTranSave_Click(object sender, EventArgs e)
{
string trantxt = "*Resolved Transition Text*";
string trantxt = "(Resolved Transition Text)";
string linktxt = null;
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
// if must have a step, test for this first.
@@ -719,8 +719,8 @@ namespace Volian.Controls.Library
return;
}
}
ItemInfo _tranitem1 = null;
ItemInfo _tranitem2 = null;
ItemInfo toItem = null;
ItemInfo rangeItem = null;
if ((etm & E_TransUI.StepLast) == E_TransUI.StepLast) //range
{
if (_RangeNode1==null)
@@ -728,7 +728,7 @@ namespace Volian.Controls.Library
MessageBox.Show("Must 'Select Step' for transition 'to'");
return;
}
_tranitem1 = (ItemInfo)_RangeNode1.VEObject;
toItem = (ItemInfo)_RangeNode1.VEObject;
// Get the second item in the range, based on current tree view selection.
if (_RangeNode2 == null && tvTran.SelectedNode == null)
{
@@ -736,52 +736,56 @@ namespace Volian.Controls.Library
return;
}
if (_RangeNode2 == null) _RangeNode2 = (VETreeNode)tvTran.SelectedNode;
_tranitem2 = (ItemInfo)_RangeNode2.VEObject;
rangeItem = (ItemInfo)_RangeNode2.VEObject;
// Check that the two items are of the below the section type.
if (_tranitem1.MyContent.Type < 20000 || _tranitem2.MyContent.Type < 20000)
if (toItem.MyContent.Type < 20000 || rangeItem.MyContent.Type < 20000)
{
MessageBox.Show("Must select two items at the step level or below, i.e. no sections, procedures, etc.");
return;
}
linktxt = string.Format("#Link:Transition:{0} <NewID> {1} {2}", listBoxTranFmt.SelectedIndex, _tranitem1.ItemID, _tranitem2.ItemID);
linktxt = string.Format("#Link:Transition:{0} <NewID> {1} {2}", listBoxTranFmt.SelectedIndex, toItem.ItemID, rangeItem.ItemID);
}
else if ((etm & E_TransUI.StepFirst) == E_TransUI.StepFirst)
{
VETreeNode vtn = (VETreeNode)tvTran.SelectedNode;
if (vtn != null)
{
_tranitem1 = (ItemInfo)vtn.VEObject; // is this cast valid?
linktxt = string.Format("#Link:Transition:{0} <NewID> {1}", listBoxTranFmt.SelectedIndex, _tranitem1.ItemID);
toItem = (ItemInfo)vtn.VEObject; // is this cast valid?
linktxt = string.Format("#Link:Transition:{0} <NewID> {1}", listBoxTranFmt.SelectedIndex, toItem.ItemID);
}
}
if (_tranitem1 == null && (etm & E_TransUI.SectMenuAny) == E_TransUI.SectMenuAny)
if (toItem == null && (etm & E_TransUI.SectMenuAny) == E_TransUI.SectMenuAny)
{
if (tvTran.Enabled == false || _tranitem1.IsAccPages)
_tranitem1 = (ItemInfo)cbTranSects.SelectedItem;
if (tvTran.Enabled == false || toItem.IsAccPages)
toItem = (ItemInfo)cbTranSects.SelectedItem;
else
{
VETreeNode vtn = (VETreeNode)tvTran.SelectedNode;
_tranitem1 = (ItemInfo)vtn.VEObject;
toItem = (ItemInfo)vtn.VEObject;
}
if (_tranitem1==null)
if (toItem==null)
{
MessageBox.Show("Must 'Select Section' or 'Select Step' for transition 'to'");
return;
}
linktxt = string.Format("#Link:Transition:{0} <NewID> {1}", listBoxTranFmt.SelectedIndex, _tranitem1.ItemID);
linktxt = string.Format("#Link:Transition:{0} <NewID> {1}", listBoxTranFmt.SelectedIndex, toItem.ItemID);
}
if (_tranitem1 == null && (((etm & E_TransUI.ProcCur) == E_TransUI.ProcCur) || ((etm & E_TransUI.ProcMenu) == E_TransUI.ProcMenu)))
if (toItem == null && (((etm & E_TransUI.ProcCur) == E_TransUI.ProcCur) || ((etm & E_TransUI.ProcMenu) == E_TransUI.ProcMenu)))
{
_tranitem1 = (ItemInfo)cbTranProcs.SelectedItem;
if (_tranitem1 == null)
toItem = (ItemInfo)cbTranProcs.SelectedItem;
if (toItem == null)
{
MessageBox.Show("Must select an item for transition 'to'");
return;
}
linktxt = string.Format("#Link:Transition:{0} <NewID> {1}", listBoxTranFmt.SelectedIndex, _tranitem1.ItemID);
linktxt = string.Format("#Link:Transition:{0} <NewID> {1}", listBoxTranFmt.SelectedIndex, toItem.ItemID);
}
// Can I build the text right now?
trantxt = TransitionText.GetResolvedText(_MyRTB.MyItemInfo, listBoxTranFmt.SelectedIndex,toItem,rangeItem ?? toItem);
_MyRTB.InsertTran(trantxt, linktxt);
_MyRTB.Select(_MyRTB.SelectionStart + trantxt.Length + linktxt.Length,0);
_MyRTB.Focus();
}
#endregion
#region VariousSupportMethods