This commit is contained in:
Kathy Ruffing 2011-02-16 16:09:35 +00:00
parent 660bb8ae25
commit 7288901ea4

View File

@ -16,26 +16,20 @@ namespace Volian.Controls.Library
public partial class GridItem : EditItem public partial class GridItem : EditItem
{ {
/* /*
* TODO: (2/14/11) * TODO: (2/16/11)
* 1) KBR Need to include/handle StepRTB/EditItem Events: Add for grid items, the events that * 1) KBR Need to include/handle StepRTB/EditItem Events: Add for grid items, the events that
* are handled by StepRTB/EditItem. Should these be abstract events within EditItem so * are handled by StepRTB/EditItem. Should these be abstract events within EditItem so
* that it 'tells' you which events you need. * that it 'tells' you which events you need.
* May Need yet: * May Need yet:
* OnOpenContextMenu (grid and/or rtb) * OnOpenContextMenu (grid and/or rtb)
* steprtb->OnCopystep ? * OnSetMenu?? - related to context menu
* OnCheckClipboard
* 2) KBR ContextMenu for table. May want it to function in a similar way to spellcheck, with * 2) KBR ContextMenu for table. May want it to function in a similar way to spellcheck, with
* the contentmenu to support table options and a last item that supports existing * the contentmenu to support table options and a last item that supports existing
* contextmenu * contextmenu
* 3) KBR When data migration of tables, need to include the font if there is a symbol. Move * 3) When data migration of tables, need to include the font if there is a symbol. Move
* AddFontTable from StepRTB.cs to a place accessible, such as volian.base. And then * AddFontTable from StepRTB.cs to a place accessible, such as volian.base. And then
* in data migration, will need to know if a font is fixed. * in data migration, will need to know if a font is fixed.
* 4) KBR Searchable text needs to look like 'Text' field in Contents record, i.e. \v ... \v0. This * 4) KBR Paste step crashes. Look at when doing insert.
* is needed so that search results list looks ok, UpdateTransition (ItemExt)'s call to
* FixTransitionText (ContentExt) finds text to refresh.
* 5) KBR Fix the grid (xml stored in Data) when a step is inserted so that transition text is changed,
* or when an ROvalue is changed. In ItemInsertExt.cs, UpdateTransitionText &
* UpdatePastedStepTransitionText
*/ */
#region Fields #region Fields
public VlnFlexGrid MyFlexGrid public VlnFlexGrid MyFlexGrid
@ -101,8 +95,30 @@ namespace Volian.Controls.Library
MyStepRTB.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlDown : E_ArrowKeys.Down); MyStepRTB.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlDown : E_ArrowKeys.Down);
e.Handled = true; e.Handled = true;
break; break;
case Keys.F5:
if (e.Shift)
{
e.Handled = true;
if (!CheckClipboard()) return; // check if 'clipboard' contains a step.
SetMenu("StepPaste");
}
else if (!e.Control && !e.Alt)
{
e.Handled = true;
CopyStep();
}
break;
} }
} }
void SetMenu(string contentMenu)
{
if (contentMenu == null)
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ClearContextMenu();
else if (contentMenu == "OpenContextMenu")
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetContextMenu();
else
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetShortCutContextMenu(contentMenu);
}
void MyFlexGrid_CursorMovement(object sender, VlnFlexGridCursorMovementEventArgs args) void MyFlexGrid_CursorMovement(object sender, VlnFlexGridCursorMovementEventArgs args)
{ {
MyStepPanel.CursorMovement(this,new Point(0,0), args.Key); MyStepPanel.CursorMovement(this,new Point(0,0), args.Key);
@ -123,15 +139,6 @@ namespace Volian.Controls.Library
{ {
MyStepPanel.StepCursorKeys(this, args); MyStepPanel.StepCursorKeys(this, args);
} }
void MyStepRTB_SetMenu(object sender, StepRTBMenuEventArgs args)
{
if (args.MenuGroup == null)
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ClearContextMenu();
else if (args.MenuGroup == "OpenContextMenu")
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetContextMenu();
else
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetShortCutContextMenu(args.MenuGroup);
}
void MyStepRTB_AdjustTableWidth(object sender, StepRTBTableWidthEventArgs args) void MyStepRTB_AdjustTableWidth(object sender, StepRTBTableWidthEventArgs args)
{ {
//if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)) //if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure))
@ -254,14 +261,13 @@ namespace Volian.Controls.Library
{ {
this.MyFlexGrid.Resize += new EventHandler(MyFlexGrid_Resize); this.MyFlexGrid.Resize += new EventHandler(MyFlexGrid_Resize);
this.MyFlexGrid.Enter += new EventHandler(MyFlexGrid_Enter); this.MyFlexGrid.Enter += new EventHandler(MyFlexGrid_Enter);
//this.MyFlexGrid.KeyDown += new KeyEventHandler(MyFlexGrid_KeyDown);
this.MyFlexGrid.CursorMovement += new VlnFlexGridCursorMovementEvent(MyFlexGrid_CursorMovement); this.MyFlexGrid.CursorMovement += new VlnFlexGridCursorMovementEvent(MyFlexGrid_CursorMovement);
this.MyFlexGrid.OpenAnnotations += new VlnFlexGridEvent(MyFlexGrid_OpenAnnotations); this.MyFlexGrid.OpenAnnotations += new VlnFlexGridEvent(MyFlexGrid_OpenAnnotations);
this.MyFlexGrid.KeyDown +=new KeyEventHandler(MyFlexGrid_KeyDown);
this.MyStepRTB.LinkGoTo += new StepRTBLinkEvent(MyStepRTB_LinkGoTo); this.MyStepRTB.LinkGoTo += new StepRTBLinkEvent(MyStepRTB_LinkGoTo);
this.MyStepRTB.LinkModifyRO += new StepRTBLinkEvent(MyStepRTB_LinkModifyRO); this.MyStepRTB.LinkModifyRO += new StepRTBLinkEvent(MyStepRTB_LinkModifyRO);
this.MyStepRTB.LinkModifyTran += new StepRTBLinkEvent(MyStepRTB_LinkModifyTran); this.MyStepRTB.LinkModifyTran += new StepRTBLinkEvent(MyStepRTB_LinkModifyTran);
this.MyStepRTB.CursorKeyPress += new StepRTBCursorKeysEvent(MyStepRTB_CursorKeyPress); this.MyStepRTB.CursorKeyPress += new StepRTBCursorKeysEvent(MyStepRTB_CursorKeyPress);
this.MyStepRTB.SetMenu += new StepRTBMenuEvent(MyStepRTB_SetMenu);
this.MyStepRTB.AdjustTableWidth += new StepRTBTableWidthEvent(MyStepRTB_AdjustTableWidth); this.MyStepRTB.AdjustTableWidth += new StepRTBTableWidthEvent(MyStepRTB_AdjustTableWidth);
this.MyStepRTB.IsNotCurrentSelection += new StepRTBBooleanEvent(MyStepRTB_IsNotCurrentSelection); this.MyStepRTB.IsNotCurrentSelection += new StepRTBBooleanEvent(MyStepRTB_IsNotCurrentSelection);
this.MyStepRTB.OpenAnnotations += new StepRTBEvent(MyStepRTB_OpenAnnotations); this.MyStepRTB.OpenAnnotations += new StepRTBEvent(MyStepRTB_OpenAnnotations);
@ -306,13 +312,12 @@ namespace Volian.Controls.Library
} }
public override void RefreshContent() public override void RefreshContent()
{ {
// content, i.e. MyContent, of the grid has changed, refresh the grid using (Grid myGrid = MyItemInfo.MyContent.MyGrid.Get())
/* {
* Need: MyItemInfo.MyContent.MyGrid.ResetContent(myGrid);
* 'RefreshDisplay': Something to display grid }
* 'IdentifyMe': Something to highlight appropriately, i.e. copy step OR backgroun color (annotation or not) RefreshDisplay(_ActiveMode);
* 'SetExpandAndExpander': Handles whether it is visible, i.e. if step is collapsed - this is not visible. IdentifyMe(false);
*/
} }
public override int TableWidth { get { return 0; } } // DONE public override int TableWidth { get { return 0; } } // DONE
public override int ItemLeft public override int ItemLeft
@ -355,7 +360,6 @@ namespace Volian.Controls.Library
public override void SetFocus() { MyFlexGrid.Focus();} public override void SetFocus() { MyFlexGrid.Focus();}
public override void SaveContents() public override void SaveContents()
{ {
StringBuilder sb = new StringBuilder();
List<int> RtfRoUsageList = new List<int>(); List<int> RtfRoUsageList = new List<int>();
List<int> RtfTransList = new List<int>(); List<int> RtfTransList = new List<int>();
@ -364,59 +368,45 @@ namespace Volian.Controls.Library
int w = MyFlexGrid.Cols.Count; int w = MyFlexGrid.Cols.Count;
int h = MyFlexGrid.Rows.Count; int h = MyFlexGrid.Rows.Count;
using (StepRTB myRTB = new StepRTB()) while (r < h)
{ {
while (r < h) CellRange cr = MyFlexGrid.GetMergedRange(r, c);
if (cr.r1 == r && cr.c1 == c)
{ {
CellRange cr = MyFlexGrid.GetMergedRange(r, c); // see if there are any links and save these so that any deleted ROs or transitions in the
if (cr.r1 == r && cr.c1 == c) // steprtb can have associated usages/transitions records removed from the database.
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v \\]+)*\\v(\\[^v \\]+)* #Link:(ReferencedObject|Transition[^:]*?):.*?\[END>");
MatchCollection matches = Regex.Matches((string)MyFlexGrid[r, c], lookFor);
for (int i = matches.Count - 1; i >= 0; i--)
{ {
string rtf = MyFlexGrid.GetCellRTFString(r, c); Match m = matches[i];
if (rtf.StartsWith(@"{\rtf")) if (m != null && m.Groups.Count > 6 && m.Groups[6].ToString() == "ReferencedObject")
myRTB.Rtf = rtf;
else
myRTB.Text = rtf;// RHM 20110214 This should not happen
//string strp = DisplayText.StaticStripRtfCommands((string)MyFlexGrid[r, c]); // probably still need to remove link stuff
//strp = StepRTB.RemoveLinkComments(strp);
sb.Append(myRTB.Text.Replace(@"\r\n", " ")); // strp.Replace(@"\r\n", " "));
sb.Append(@"\r\n");
// TODO: if this is an ro table, the searchable string should 'look like' an ro link
// see if there are any links and save these so that any deleted ROs or transitions in the
// steprtb can have associated usages/transitions records removed from the database.
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v \\]+)*\\v(\\[^v \\]+)* #Link:(ReferencedObject|Transition[^:]*?):.*?\[END>");
MatchCollection matches = Regex.Matches((string)MyFlexGrid[r, c], lookFor);
for (int i = matches.Count - 1; i >= 0; i--)
{ {
Match m = matches[i]; Regex regRefObj = new Regex(@"\#Link\:ReferencedObject\:([0-9]*) ([0-9a-zA-Z]*) ([0-9]*)", RegexOptions.Singleline);
if (m != null && m.Groups.Count > 6 && m.Groups[6].ToString() == "ReferencedObject") Match myMatch = regRefObj.Match(m.Value);
if (myMatch.Success)
{ {
Regex regRefObj = new Regex(@"\#Link\:ReferencedObject\:([0-9]*) ([0-9a-zA-Z]*) ([0-9]*)", RegexOptions.Singleline); int usgid = int.Parse(myMatch.Groups[1].Value);
Match myMatch = regRefObj.Match(m.Value); RtfRoUsageList.Add(usgid);
if (myMatch.Success)
{
int usgid = int.Parse(myMatch.Groups[1].Value);
RtfRoUsageList.Add(usgid);
}
} }
if (m != null && m.Groups.Count > 6 && m.Groups[6].ToString().StartsWith("Transition")) }
if (m != null && m.Groups.Count > 6 && m.Groups[6].ToString().StartsWith("Transition"))
{
Regex regRefObj = new Regex(@"\#Link\:Transition[a-zA-Z]*\:([0-9]*) ([0-9]*) ([0-9]*)", RegexOptions.Singleline);
Match myMatch = regRefObj.Match(m.Value);
if (myMatch.Success)
{ {
Regex regRefObj = new Regex(@"\#Link\:Transition[a-zA-Z]*\:([0-9]*) ([0-9]*) ([0-9]*)", RegexOptions.Singleline); int tid = int.Parse(myMatch.Groups[2].Value);
Match myMatch = regRefObj.Match(m.Value); RtfTransList.Add(tid);
if (myMatch.Success)
{
int tid = int.Parse(myMatch.Groups[2].Value);
RtfTransList.Add(tid);
}
} }
} }
} }
c = c + 1; }
if (c == w) c = c + 1;
{ if (c == w)
c = 0; {
r = r + 1; c = 0;
} r = r + 1;
} }
} }
// compare ro usages & transitions from database and list from grid contents // compare ro usages & transitions from database and list from grid contents
@ -440,7 +430,7 @@ namespace Volian.Controls.Library
} }
// now save the resulting Xml text, and the searchable text. // now save the resulting Xml text, and the searchable text.
bool success = FinishSave(sb.ToString()); bool success = FinishSave(MyFlexGrid.GetSearchableText());
if (success) if (success)
{ {
MyStepRTB.FindAllLinks(); MyStepRTB.FindAllLinks();
@ -724,8 +714,10 @@ namespace Volian.Controls.Library
get { return _Empty; } get { return _Empty; }
set { _Empty = value; } set { _Empty = value; }
} }
private bool _ActiveMode = false;
public override void RefreshDisplay(bool activeMode) public override void RefreshDisplay(bool activeMode)
{ {
_ActiveMode = activeMode;
XmlDocument xd = new XmlDocument(); XmlDocument xd = new XmlDocument();
xd.LoadXml(MyItemInfo.MyContent.MyGrid.Data.Replace("Courier New", "Times New Roman")); xd.LoadXml(MyItemInfo.MyContent.MyGrid.Data.Replace("Courier New", "Times New Roman"));
//xd.LoadXml(MyItemInfo.MyContent.MyGrid.Data); //xd.LoadXml(MyItemInfo.MyContent.MyGrid.Data);