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
{
/*
* TODO: (2/14/11)
* TODO: (2/16/11)
* 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
* that it 'tells' you which events you need.
* May Need yet:
* OnOpenContextMenu (grid and/or rtb)
* steprtb->OnCopystep ?
* OnCheckClipboard
* OnSetMenu?? - related to context menu
* 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
* 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
* 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
* 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
* 4) KBR Paste step crashes. Look at when doing insert.
*/
#region Fields
public VlnFlexGrid MyFlexGrid
@ -101,8 +95,30 @@ namespace Volian.Controls.Library
MyStepRTB.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlDown : E_ArrowKeys.Down);
e.Handled = true;
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)
{
MyStepPanel.CursorMovement(this,new Point(0,0), args.Key);
@ -123,15 +139,6 @@ namespace Volian.Controls.Library
{
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)
{
//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.Enter += new EventHandler(MyFlexGrid_Enter);
//this.MyFlexGrid.KeyDown += new KeyEventHandler(MyFlexGrid_KeyDown);
this.MyFlexGrid.CursorMovement += new VlnFlexGridCursorMovementEvent(MyFlexGrid_CursorMovement);
this.MyFlexGrid.OpenAnnotations += new VlnFlexGridEvent(MyFlexGrid_OpenAnnotations);
this.MyFlexGrid.KeyDown +=new KeyEventHandler(MyFlexGrid_KeyDown);
this.MyStepRTB.LinkGoTo += new StepRTBLinkEvent(MyStepRTB_LinkGoTo);
this.MyStepRTB.LinkModifyRO += new StepRTBLinkEvent(MyStepRTB_LinkModifyRO);
this.MyStepRTB.LinkModifyTran += new StepRTBLinkEvent(MyStepRTB_LinkModifyTran);
this.MyStepRTB.CursorKeyPress += new StepRTBCursorKeysEvent(MyStepRTB_CursorKeyPress);
this.MyStepRTB.SetMenu += new StepRTBMenuEvent(MyStepRTB_SetMenu);
this.MyStepRTB.AdjustTableWidth += new StepRTBTableWidthEvent(MyStepRTB_AdjustTableWidth);
this.MyStepRTB.IsNotCurrentSelection += new StepRTBBooleanEvent(MyStepRTB_IsNotCurrentSelection);
this.MyStepRTB.OpenAnnotations += new StepRTBEvent(MyStepRTB_OpenAnnotations);
@ -306,13 +312,12 @@ namespace Volian.Controls.Library
}
public override void RefreshContent()
{
// content, i.e. MyContent, of the grid has changed, refresh the grid
/*
* Need:
* 'RefreshDisplay': Something to display grid
* 'IdentifyMe': Something to highlight appropriately, i.e. copy step OR backgroun color (annotation or not)
* 'SetExpandAndExpander': Handles whether it is visible, i.e. if step is collapsed - this is not visible.
*/
using (Grid myGrid = MyItemInfo.MyContent.MyGrid.Get())
{
MyItemInfo.MyContent.MyGrid.ResetContent(myGrid);
}
RefreshDisplay(_ActiveMode);
IdentifyMe(false);
}
public override int TableWidth { get { return 0; } } // DONE
public override int ItemLeft
@ -355,7 +360,6 @@ namespace Volian.Controls.Library
public override void SetFocus() { MyFlexGrid.Focus();}
public override void SaveContents()
{
StringBuilder sb = new StringBuilder();
List<int> RtfRoUsageList = new List<int>();
List<int> RtfTransList = new List<int>();
@ -364,59 +368,45 @@ namespace Volian.Controls.Library
int w = MyFlexGrid.Cols.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);
if (cr.r1 == r && cr.c1 == c)
// 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--)
{
string rtf = MyFlexGrid.GetCellRTFString(r, c);
if (rtf.StartsWith(@"{\rtf"))
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];
if (m != null && m.Groups.Count > 6 && m.Groups[6].ToString() == "ReferencedObject")
{
Match m = matches[i];
if (m != null && m.Groups.Count > 6 && m.Groups[6].ToString() == "ReferencedObject")
Regex regRefObj = new Regex(@"\#Link\:ReferencedObject\:([0-9]*) ([0-9a-zA-Z]*) ([0-9]*)", RegexOptions.Singleline);
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);
Match myMatch = regRefObj.Match(m.Value);
if (myMatch.Success)
{
int usgid = int.Parse(myMatch.Groups[1].Value);
RtfRoUsageList.Add(usgid);
}
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);
Match myMatch = regRefObj.Match(m.Value);
if (myMatch.Success)
{
int tid = int.Parse(myMatch.Groups[2].Value);
RtfTransList.Add(tid);
}
int tid = int.Parse(myMatch.Groups[2].Value);
RtfTransList.Add(tid);
}
}
}
c = c + 1;
if (c == w)
{
c = 0;
r = r + 1;
}
}
c = c + 1;
if (c == w)
{
c = 0;
r = r + 1;
}
}
// 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.
bool success = FinishSave(sb.ToString());
bool success = FinishSave(MyFlexGrid.GetSearchableText());
if (success)
{
MyStepRTB.FindAllLinks();
@ -724,8 +714,10 @@ namespace Volian.Controls.Library
get { return _Empty; }
set { _Empty = value; }
}
private bool _ActiveMode = false;
public override void RefreshDisplay(bool activeMode)
{
_ActiveMode = activeMode;
XmlDocument xd = new XmlDocument();
xd.LoadXml(MyItemInfo.MyContent.MyGrid.Data.Replace("Courier New", "Times New Roman"));
//xd.LoadXml(MyItemInfo.MyContent.MyGrid.Data);