This commit is contained in:
2011-02-08 11:27:37 +00:00
parent bbe29f2b0a
commit 3363e0f69a
3 changed files with 57 additions and 52 deletions

View File

@@ -72,14 +72,14 @@ namespace Volian.Controls.Library
if (!Visible) return;
if (_MyRTB != null)
{
_MyRTB.LinkChanged -= new StepRTBLinkEvent(_MyRTB_LinkChanged);
_MyRTB.SelectionChanged -= new EventHandler(_MyRTB_SelectionChanged);
_MyRTB.LinkChanged -= new StepRTBLinkEvent(MyRTB_LinkChanged);
_MyRTB.SelectionChanged -= new EventHandler(MyRTB_SelectionChanged);
}
if (value == null) return;
_MyRTB = value;
_MyRTB.LinkChanged += new StepRTBLinkEvent(_MyRTB_LinkChanged);
_MyRTB.SelectionChanged+=new EventHandler(_MyRTB_SelectionChanged);
if (_MyRTB.MyLinkText == null)
MyRTB.LinkChanged += new StepRTBLinkEvent(MyRTB_LinkChanged);
MyRTB.SelectionChanged+=new EventHandler(MyRTB_SelectionChanged);
if (MyRTB.MyLinkText == null)
{
CurROLink = null;
_SavCurROLink = null;
@@ -87,14 +87,14 @@ namespace Volian.Controls.Library
}
}
void _MyRTB_SelectionChanged(object sender, EventArgs e)
void MyRTB_SelectionChanged(object sender, EventArgs e)
{
lbFound.SelectionMode = SelectionMode.None;
lbFound.DataSource = null;
//Spin through ROs looking for the selected text
if (_MyRTB.SelectedText != "")
if (MyRTB.SelectedText != "")
{
string lookFor = _MyRTB.SelectedText;
string lookFor = MyRTB.SelectedText;
List<ROFSTLookup.roChild> children = _MyROFST.ROFSTLookup.GetRosByValue(lookFor);
if (children != null)
{
@@ -110,9 +110,9 @@ namespace Volian.Controls.Library
lbFound.Visible = false;
}
void _MyRTB_LinkChanged(object sender, StepPanelLinkEventArgs args)
void MyRTB_LinkChanged(object sender, StepPanelLinkEventArgs args)
{
if (_MyRTB.MyLinkText == null)
if (MyRTB.MyLinkText == null)
CurROLink = null;
else
{
@@ -292,7 +292,7 @@ namespace Volian.Controls.Library
}
//else if (chld[i].type == 2 && chld[i].value == null) // table
//{
// if ((_MyRTB.MyItemInfo.MyContent.Type % 10000) == (int)E_FromType.Table)
// if ((MyRTB.MyItemInfo.MyContent.Type % 10000) == (int)E_FromType.Table)
// {
// tmp = new TreeNode(chld[i].title);
// tmp.Tag = chld[i];
@@ -492,31 +492,35 @@ namespace Volian.Controls.Library
if (dti.MyDSOTabPanel != null)
dti.MyDSOTabPanel.InsertText(AccPageID);
}
else if (_MyRTB != null) // a Procedure Steps section tab is active
else if (MyRTB != null) // a Procedure Steps section tab is active
{
_MyRTB.inRoAdd = true;
MyRTB.inRoAdd = true;
if (CheckROSelection(roch)) // check for RO type is valid for this type of step/substep
{
//int ss = _MyRTB.SelectionStart;
//int ss = MyRTB.SelectionStart;
// the roid may be 12 or 16 chars long, with the last 4 set if there is unit specific
// menuing. Pad to 12 to store in the rousage table.
string padroid = (roch.roid.Length <= 12) ? roch.roid + "0000" : roch.roid;
string linktxt = string.Format(@"#Link:ReferencedObject:<NewID> {0} {1}", padroid, _MyROFST.MyRODb.RODbID);
// Resolve symbols and scientific notation in the RO return value
string valtxt = ConvertSymbolsAndStuff(selectedChld.value);
int ss = _MyRTB.SelectionStart; // Remember where the link is being added
_MyRTB.InsertRO(valtxt, linktxt); // Insert the LINK
_MyRTB.SaveText(); // Save the text with the LINK - This also moves the cursor to the end of the text
int ss = MyRTB.SelectionStart; // Remember where the link is being added
int sl = MyRTB.SelectionLength;
MyRTB.OnReturnToEditor(this, new EventArgs());
MyRTB.Select(ss, sl);
MyRTB.InsertRO(valtxt, linktxt); // Insert the LINK
MyRTB.OnDoSaveContents(this, new EventArgs()); // .SaveText(); // Save the text with the LINK - This also moves the cursor to the end of the text
// By selecting a starting position within a link, StepRTB (HandleSelectionChange) will select the link
_MyRTB.Select(ss + 7 + valtxt.Length , 0);// Select the link, Try 7 for "<Start]" plus the length of the value
//Console.WriteLine("'{0}'",_MyRTB.Text.Substring(_MyRTB.SelectionStart,_MyRTB.SelectionLength));
string linkText = _MyRTB.Text.Substring(_MyRTB.SelectionStart, _MyRTB.SelectionLength);
MyRTB.Select(ss + 7 + valtxt.Length , 0);// Select the link, Try 7 for "<Start]" plus the length of the value
//Console.WriteLine("'{0}'",MyRTB.Text.Substring(MyRTB.SelectionStart,MyRTB.SelectionLength));
string linkText = MyRTB.Text.Substring(MyRTB.SelectionStart, MyRTB.SelectionLength);
if (_MyLog.IsInfoEnabled && (linkText.Contains("NewID") || linkText.Contains("CROUSGID")))
_MyLog.InfoFormat("ItemID {0}, LinkText '{1}'", _MyRTB.MyItemInfo.ItemID, linkText);
_MyRTB.Select(_MyRTB.SelectionStart + _MyRTB.SelectionLength, 0);// Move cursor to end of LINK
_MyRTB.Focus();
_MyLog.InfoFormat("ItemID {0}, LinkText '{1}'", MyRTB.MyItemInfo.ItemID, linkText);
int sel = MyRTB.SelectionStart + MyRTB.SelectionLength;
MyRTB.Select(sel, 0);// Move cursor to end of LINK
MyRTB.Focus();
}
_MyRTB.inRoAdd = false;
MyRTB.inRoAdd = false;
btnGoToRO.Enabled = btnSaveRO.Enabled = btnCancelRO.Enabled = btnPreviewRO.Enabled = false;
_SavCurROLink = null;
CurROLink = null;
@@ -543,19 +547,19 @@ namespace Volian.Controls.Library
switch (selectedRO.type)
{
case 1: // regular text RO
if (_MyRTB.MyItemInfo.IsFigure)
if (MyRTB.MyItemInfo.IsFigure)
{
errormsg = (replacingRO) ? "a Figure with a non-figure." : "a text RO in a Figure type.";
goodToGo = false;
}
break;
case 2: // table RO
if (_MyRTB.MyItemInfo.IsFigure)
if (MyRTB.MyItemInfo.IsFigure)
{
errormsg = (replacingRO) ? "a Figure with a non-figure." : "a table into a Figure type.";
goodToGo = false;
}
else if (!_MyRTB.MyItemInfo.IsTable)
else if (!MyRTB.MyItemInfo.IsTable)
{
errormsg = (replacingRO) ? "a non-table RO with a Table RO." : "a table into a non-table type.";
//TODO: Prompt user to insert a new Table substep type and place this RO into it
@@ -563,7 +567,7 @@ namespace Volian.Controls.Library
}
break;
case 4: // X/Y Plot RO type
if (!_MyRTB.MyItemInfo.IsAccPages)
if (!MyRTB.MyItemInfo.IsAccPages)
{
errormsg = (replacingRO) ? "a non-X/Y Plot RO with an X/Y Plot RO." : "an X/Y Plot RO in an non-Accessory Page type.";
//TODO: Prompt user to insert a new substep type that handles x/y Plots and place this RO into it
@@ -571,7 +575,7 @@ namespace Volian.Controls.Library
}
break;
case 8: // figure (intergrated graphics)
if (!_MyRTB.MyItemInfo.IsFigure && !_MyRTB.MyItemInfo.IsAccPages)
if (!MyRTB.MyItemInfo.IsFigure && !MyRTB.MyItemInfo.IsAccPages)
{
errormsg = (replacingRO) ? "a graphics RO with a non-graphcis RO." : "a Graphics RO in an non-Figure or a non-Accessory Page type.";
//TODO: Prompt user to insert a new substep type that handles x/y Plots and place this RO into it