This commit is contained in:
parent
001c92567c
commit
1456d43132
@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using VEPROMS.CSLA.Library;
|
||||
@ -15,7 +16,7 @@ namespace Volian.Controls.Library
|
||||
public partial class GridItem : EditItem
|
||||
{
|
||||
/*
|
||||
* TODO: (2/2/11)
|
||||
* TODO: (2/14/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.
|
||||
@ -23,20 +24,21 @@ namespace Volian.Controls.Library
|
||||
* OnOpenContextMenu (grid and/or rtb)
|
||||
* steprtb->OnCopystep ?
|
||||
* OnCheckClipboard
|
||||
* 3) KBR FindReplace.cs - had to check for Null rtbItem, so will need
|
||||
* to support if GridItem. AND frmVEPROMS.cs line 1021, findreplace
|
||||
* currently are set to need an RTBItem. Will need to be more general.
|
||||
* 4) 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
|
||||
* contextmenu
|
||||
* 6) RHM Selection is NOT selection, i.e. if merged cells, selection isn't selecting the 'merged'
|
||||
* i.e. parent cell.
|
||||
* 7) RHM Selecting a range can end up with uneven rows or uneven columns. We need to handle,
|
||||
* some possible options are to not allow operations to occur if uneven selections;
|
||||
* make selection even; etc.
|
||||
* 8) KBR When data migration of tables, need to include the font if there is a symbol. Move
|
||||
* 3) KBR 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
|
||||
* 6) RHM Insert HLS - wrong font.
|
||||
* 7) RHM HideCaret & ShowCaret should restore original color.
|
||||
* 8) RHM HideCaret & ShowCaret should not turn on editor unless editor had been previously been active
|
||||
*/
|
||||
#region Fields
|
||||
public VlnFlexGrid MyFlexGrid
|
||||
@ -176,6 +178,8 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
void MyStepRTB_DoSaveContents(object sender, EventArgs args)
|
||||
{
|
||||
if (MyFlexGrid.Row >= 0 && MyFlexGrid.Col >= 0) // Only if a Cell is Selected
|
||||
MyFlexGrid[MyFlexGrid.Row, MyFlexGrid.Col] = MyStepRTB.Rtf = MyStepRTB.DoNewLinkInGridCell();
|
||||
SaveContents();
|
||||
}
|
||||
void MyStepRTB_VisibleChanged(object sender, EventArgs e)
|
||||
@ -350,8 +354,109 @@ namespace Volian.Controls.Library
|
||||
public override void SetFocus() { MyFlexGrid.Focus();}
|
||||
public override void SaveContents()
|
||||
{
|
||||
if(MyFlexGrid.Row >= 0 && MyFlexGrid.Col >= 0) // Only if a Cell is Selected
|
||||
MyFlexGrid[MyFlexGrid.Row, MyFlexGrid.Col] = MyStepRTB.Rtf;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<int> RtfRoUsageList = new List<int>();
|
||||
List<int> RtfTransList = new List<int>();
|
||||
|
||||
int r = 0;
|
||||
int c = 0;
|
||||
int w = MyFlexGrid.Cols.Count;
|
||||
int h = MyFlexGrid.Rows.Count;
|
||||
|
||||
using (StepRTB myRTB = new StepRTB())
|
||||
{
|
||||
while (r < h)
|
||||
{
|
||||
CellRange cr = MyFlexGrid.GetMergedRange(r, c);
|
||||
if (cr.r1 == r && cr.c1 == c)
|
||||
{
|
||||
myRTB.Rtf = MyFlexGrid.GetCellRTFString(r, c);
|
||||
|
||||
//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")
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
int tid = int.Parse(myMatch.Groups[2].Value);
|
||||
RtfTransList.Add(tid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
c = c + 1;
|
||||
if (c == w)
|
||||
{
|
||||
c = 0;
|
||||
r = r + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// compare ro usages & transitions from database and list from grid contents
|
||||
// if in both lists, don't do anything
|
||||
// if only in database list, delete usage.
|
||||
// never will have condition where it is not in database list, but is in steprtb text list (this
|
||||
// case is handled when ro is inserted.
|
||||
if (MyItemInfo.MyContent.ContentRoUsages != null)
|
||||
{
|
||||
List<int> delRoUsgs = new List<int>();
|
||||
foreach (RoUsageInfo ru in MyItemInfo.MyContent.ContentRoUsages)
|
||||
if (!RtfRoUsageList.Contains(ru.ROUsageID)) delRoUsgs.Add(ru.ROUsageID);
|
||||
foreach (int dRU in delRoUsgs) RoUsage.Delete(dRU);
|
||||
}
|
||||
if (MyItemInfo.MyContent.ContentTransitions != null)
|
||||
{
|
||||
List<int> delTrans = new List<int>();
|
||||
foreach (TransitionInfo ti in MyItemInfo.MyContent.ContentTransitions)
|
||||
if (!RtfTransList.Contains(ti.TransitionID)) delTrans.Add(ti.TransitionID);
|
||||
foreach (int dt in delTrans) Transition.Delete(dt);
|
||||
}
|
||||
|
||||
// now save the resulting Xml text, and the searchable text.
|
||||
bool success = FinishSave(sb.ToString());
|
||||
if (success)
|
||||
{
|
||||
MyStepRTB.FindAllLinks();
|
||||
MyStepRTB.OrigRTF = MyStepRTB.Rtf;
|
||||
MyStepRTB.ClearUndo();
|
||||
}
|
||||
}
|
||||
|
||||
private bool FinishSave(string searchableText)
|
||||
{
|
||||
string xml = MyFlexGrid.GetXMLData();
|
||||
using (Item itm = MyItemInfo.Get())
|
||||
{
|
||||
itm.MyContent.MyGrid.Data = xml;
|
||||
itm.MyContent.Text = searchableText;
|
||||
// what about the 'config' for ro tables.
|
||||
itm.Save();
|
||||
MyItemInfo.MyContent.MyGrid.ResetContent(itm.MyContent.MyGrid);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public override bool CanExpand { get { return false; } set { ;} }
|
||||
public override void HandleResize() { ;} // DONE
|
||||
@ -361,6 +466,7 @@ namespace Volian.Controls.Library
|
||||
// Was getting an Error that _MyStepRTB was Disposed RHM 20101217
|
||||
if (!MyFlexGrid.Disposing)
|
||||
{
|
||||
Focus();
|
||||
MyFlexGrid.Focus();
|
||||
MyFlexGrid.Select(0, 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user