Update Transition Text
This commit is contained in:
parent
bb9a9c1d09
commit
df1defc709
@ -191,6 +191,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
FormatInfo formatInfo = _MyItemInfo.ActiveFormat;
|
||||
_MyItem = _MyItemInfo.Get();
|
||||
// check for different text, i.e. text from this itm doesn't match
|
||||
// original text, a change occurred in database, but not from this user.
|
||||
@ -225,6 +226,10 @@ namespace Volian.Controls.Library
|
||||
if (ctReplacements.Count > 0)
|
||||
{
|
||||
EditText = FixCtReplacements(EditText, ctReplacements);
|
||||
// Replace Transition Text
|
||||
foreach (ContentTransition ct in ctReplacements.Values)
|
||||
using (TransitionInfo tran = TransitionInfo.Get(ct.TransitionID))
|
||||
_MyItem.MyContent.FixTransitionText(tran);
|
||||
_MyItem.Save();
|
||||
}
|
||||
if (roUsgReplacements.Count > 0)
|
||||
@ -695,7 +700,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (ti.TransitionID == transitionID)
|
||||
{
|
||||
string path = ti.ResolvePathTo(_MyFormat, _MyItemInfo, ItemInfo.Get(ti.ToID), ti.RangeID==0?null:ItemInfo.Get(ti.RangeID));
|
||||
string path = ti.ResolvePathTo(_MyFormat, _MyItemInfo, ti.TranType, ti.MyItemToID, ti.MyItemRangeID);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@ -746,7 +751,14 @@ namespace Volian.Controls.Library
|
||||
else if (text[endComment + 3] == '\\') retlen = 3;
|
||||
vte.TextAndLink = text.Substring(index, endComment - index + retlen);
|
||||
rettoken = endComment + retlen;
|
||||
if (vte.Type != E_TextElementType.ReferencedObject) vte.TextAndLink = vte.TextAndLink = vte.TextAndLink.Replace("(Resolved Transition Text)", tmptxt);
|
||||
if (vte.Type != E_TextElementType.ReferencedObject)
|
||||
{
|
||||
if (vte.TextAndLink.Contains("(Resolved Transition Text)"))
|
||||
vte.TextAndLink = vte.TextAndLink.Replace("(Resolved Transition Text)", tmptxt);
|
||||
else
|
||||
if (vte.Text != tmptxt)
|
||||
vte.Text = tmptxt;
|
||||
}
|
||||
DisplayTextElementList.Add(vte);
|
||||
return rettoken;
|
||||
}
|
||||
@ -825,9 +837,18 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
string pat = @"(?<=\W|^)" + rs.ReplaceWord + @"(?=\W|$)";
|
||||
// If there are Regex Control Characters '\[]()' prefix them with backslash
|
||||
string replaceWord = Regex.Replace(rs.ReplaceWord, @"\\[[\]()]", @"\$0");
|
||||
string pat = @"(?<=\W|^)" + replaceWord + @"(?=\W|$)";
|
||||
try
|
||||
{
|
||||
Text = Regex.Replace(Text, pat, rs.ReplaceWith);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("{0},'{1}',{2},'{3}'", _MyItemInfo.ActiveFormat.Name, replaceWord, ex.GetType().Name, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -852,8 +873,8 @@ namespace Volian.Controls.Library
|
||||
get { return _Type; }
|
||||
set { _Type = value; }
|
||||
}
|
||||
private string _Text;
|
||||
public string Text
|
||||
protected string _Text;
|
||||
virtual public string Text
|
||||
{
|
||||
get { return _Text; }
|
||||
set { _Text = value; }
|
||||
@ -873,6 +894,31 @@ namespace Volian.Controls.Library
|
||||
get { return _TextAndLink; }
|
||||
set { _TextAndLink = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Text - this should parse the text and return the results
|
||||
/// </summary>
|
||||
override public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_TextAndLink != null)
|
||||
{
|
||||
Match m = Regex.Match(_TextAndLink, @"<START\]\\v0 (.*?)\\v #Link:(.*?)\[END>");
|
||||
return m.Groups[1].ToString();
|
||||
}
|
||||
return _Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_TextAndLink != null)
|
||||
{
|
||||
Match m = Regex.Match(_TextAndLink, @"<START\]\\v0 (.*?)\\v #Link:(.*?)\[END>");
|
||||
System.Text.RegularExpressions.Group g = m.Groups[1];
|
||||
_TextAndLink = _TextAndLink.Substring(0, g.Index) + value + _TextAndLink.Substring(g.Index + g.Length);
|
||||
}
|
||||
_Text = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user