This commit is contained in:
Kathy Ruffing 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

View File

@ -1431,12 +1431,13 @@ namespace Volian.Controls.Library
IDataObject myDO = Clipboard.GetDataObject();
if (myDO.GetDataPresent(DataFormats.Rtf))
{
StepRTB stpRTB = new StepRTB();
stpRTB.SelectedRtf = myDO.GetData(DataFormats.Rtf).ToString();
RichTextBox rtb = new RichTextBox();
rtb.SelectedRtf = ItemInfo.StripLinks(myDO.GetData(DataFormats.Rtf).ToString());
if (cbxTextSearchAnnotation.Focused)
cbxTextSearchAnnotation.SelectedText = stpRTB.Text;
cbxTextSearchAnnotation.SelectedText = rtb.Text;
else if (cbxTextSearchText.Focused)
cbxTextSearchText.SelectedText = stpRTB.Text;// .SelectedText;//myDO.GetData(DataFormats.Text,true).ToString();
cbxTextSearchText.SelectedText = rtb.Text;// .SelectedText;//myDO.GetData(DataFormats.Text,true).ToString();
}
else if (myDO.GetDataPresent(DataFormats.Text))
if (cbxTextSearchAnnotation.Focused)

View File

@ -32,7 +32,7 @@ namespace Volian.Controls.Library
/// </summary>
private int _UniqueBarCount;
private ItemInfo _MyItemInfo = null;
private RTBItem _MyRTBItem = null;
private EditItem _MyEditItem = null;
private bool _RibbonExpanded=true;
public bool RibbonExpanded
{
@ -154,12 +154,12 @@ namespace Volian.Controls.Library
if (args != null)
{
_MyItemInfo = args.MyItemInfo;
_MyRTBItem = args.MyRTBItem;
_MyEditItem = args.MyEditItem;
}
else
{
_MyItemInfo = null;
_MyRTBItem = null;
_MyEditItem = null;
}
if (ItemSelectedChanged != null) ItemSelectedChanged(sender, args);
}
@ -213,8 +213,8 @@ namespace Volian.Controls.Library
void DisplayTabControl_Resize(object sender, EventArgs e)
{
// If the currently selected Item is in a Step, then adjust the scroll as necessary to keep it visible
if (_MyRTBItem != null)
_MyRTBItem.ItemShow();
if (_MyEditItem != null)
_MyEditItem.ItemShow();
}
private void SetupBar(Bar myBar)
{
@ -313,20 +313,20 @@ namespace Volian.Controls.Library
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{
DisplayTabItem pg = _MyDisplayTabItems[key];
if (pg.MyStepTabPanel.MyStepPanel._LookupRTBItems.ContainsKey(myItemInfo.ItemID))
if (pg.MyStepTabPanel.MyStepPanel._LookupEditItems.ContainsKey(myItemInfo.ItemID))
{
RTBItem stpitm = pg.MyStepTabPanel.MyStepPanel._LookupRTBItems[myItemInfo.ItemID];
EditItem edtitm = pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID];
switch (pasteType)
{
case ItemInfo.EAddpingPart.Before:
stpitm.PasteSiblingBefore(copyStartID);
edtitm.PasteSiblingBefore(copyStartID);
break;
case ItemInfo.EAddpingPart.After:
stpitm.PasteSiblingAfter(copyStartID);
edtitm.PasteSiblingAfter(copyStartID);
break;
case ItemInfo.EAddpingPart.Replace:
stpitm.PasteReplace(copyStartID);
stpitm.Dispose();
edtitm.PasteReplace(copyStartID);
edtitm.Dispose();
break;
default:
return false; ;
@ -354,10 +354,10 @@ namespace Volian.Controls.Library
CloseTabItem(pg);
return false;
}
if (pg.MyStepTabPanel.MyStepPanel._LookupRTBItems.ContainsKey(myItemInfo.ItemID))
if (pg.MyStepTabPanel.MyStepPanel._LookupEditItems.ContainsKey(myItemInfo.ItemID))
{
RTBItem stpitm = pg.MyStepTabPanel.MyStepPanel._LookupRTBItems[myItemInfo.ItemID];
stpitm.RemoveItem();
EditItem edtitm = pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID];
edtitm.RemoveItem();
return true;
}
}
@ -372,19 +372,19 @@ namespace Volian.Controls.Library
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{
DisplayTabItem pg = _MyDisplayTabItems[key];
if (pg.MyStepTabPanel.MyStepPanel._LookupRTBItems.ContainsKey(myItemInfo.ItemID))
if (pg.MyStepTabPanel.MyStepPanel._LookupEditItems.ContainsKey(myItemInfo.ItemID))
{
RTBItem stpitm = pg.MyStepTabPanel.MyStepPanel._LookupRTBItems[myItemInfo.ItemID];
EditItem edtitm = pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID];
switch (insertType)
{
case E_InsertType.Before:
stpitm.AddSiblingBefore(text,updateSelection);
edtitm.AddSiblingBefore(text,updateSelection);
break;
case E_InsertType.After:
stpitm.AddSiblingAfter(text,updateSelection);
edtitm.AddSiblingAfter(text,updateSelection);
break;
case E_InsertType.Child:
stpitm.AddChild(text, fromType, type);
edtitm.AddChild(text, fromType, type);
break;
default:
return false; ;