Reduced duplicated Audits
Added comments Added and used calculated IsDirty Property
This commit is contained in:
parent
6358acba7d
commit
729fa6e2dc
@ -17,6 +17,12 @@ namespace Volian.Controls.Library
|
||||
public partial class GridItem : EditItem
|
||||
{
|
||||
#region Fields
|
||||
private bool _IsSaving;
|
||||
public bool IsSaving
|
||||
{
|
||||
get { return _IsSaving; }
|
||||
set { _IsSaving = value; }
|
||||
}
|
||||
public VlnFlexGrid MyFlexGrid
|
||||
{
|
||||
get { return _MyFlexGrid; }
|
||||
@ -381,8 +387,10 @@ namespace Volian.Controls.Library
|
||||
//_MyToolTip.SetSuperTooltip(MyStepRTB, tpi);
|
||||
_MyToolTip.SetSuperTooltip(MyFlexGrid, tpi);
|
||||
}
|
||||
private bool DoNotRefresh = false;
|
||||
public override void RefreshContent()
|
||||
{
|
||||
if (DoNotRefresh) return;
|
||||
_ActiveMode = MyFlexGrid.ContainsFocus;
|
||||
using (Grid myGrid = MyItemInfo.MyContent.MyGrid.Get())
|
||||
{
|
||||
@ -432,6 +440,7 @@ namespace Volian.Controls.Library
|
||||
public override void SetFocus() { MyFlexGrid.Focus();}
|
||||
public override void SaveContents()
|
||||
{
|
||||
if (!MyFlexGrid.IsDirty && !IsSaving) return;
|
||||
List<int> RtfRoUsageList = new List<int>();
|
||||
List<int> RtfTransList = new List<int>();
|
||||
|
||||
@ -1144,17 +1153,22 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
public override void SaveCurrentAndContents()
|
||||
{
|
||||
IsSaving = true;
|
||||
if (MyFlexGrid.Row >= 0 && MyFlexGrid.Col >= 0 && MyStepRTB.EditMode) // Only if a Cell is Selected
|
||||
{
|
||||
int row = MyFlexGrid.Row;
|
||||
int col = MyFlexGrid.Col;
|
||||
SaveContents();
|
||||
//SaveContents();
|
||||
DoNotRefresh = true;
|
||||
MyStepRTB.Rtf = MyStepRTB.DoNewLinkInGridCell();
|
||||
DoNotRefresh = false;
|
||||
MyFlexGrid.Row = row;
|
||||
MyFlexGrid.Col = col;
|
||||
MyFlexGrid[MyFlexGrid.Row, MyFlexGrid.Col] = MyStepRTB.Rtf;
|
||||
}
|
||||
if (!MyFlexGrid.IsDirty) return;
|
||||
SaveContents();
|
||||
IsSaving = false;
|
||||
}
|
||||
#endregion
|
||||
#region Miscellaneous Support
|
||||
|
@ -2876,10 +2876,14 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
rousg = itm.MyContent.ContentRoUsages.Add(roparts[1], rodb);
|
||||
}
|
||||
//get temporary rousageid
|
||||
oldid = rousg.ROUsageID;
|
||||
Rtf = Rtf.Replace("<NewID>", string.Format("<CROUSGID={0}>", rousg.ROUsageID));
|
||||
//save temporary rousageid to get real rousageid
|
||||
itm.Save();
|
||||
//replace temprorary rousageid with real rousageid
|
||||
Rtf = Rtf.Replace(string.Format("<CROUSGID={0}>", oldid), rousg.ROUsageID.ToString());
|
||||
//save real rousageid
|
||||
itm.Save();
|
||||
MyItemInfo.MyContent.RefreshContentRoUsages();
|
||||
}
|
||||
|
@ -32,7 +32,159 @@ namespace Volian.Controls.Library
|
||||
get { return _SpellChecker; }
|
||||
set { _SpellChecker = value; }
|
||||
}
|
||||
|
||||
//public string GridStackTrace
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// string st = Volian.Base.Library.vlnStackTrace.GetStack();
|
||||
// st = StripFunnyCharacters(st);
|
||||
// return st;
|
||||
// Console.WriteLine(st);
|
||||
// return st.Replace(@"\","|");
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// ;
|
||||
// }
|
||||
//}
|
||||
//private string StripFunnyCharacters(string st)
|
||||
//{
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// foreach (char c in st)
|
||||
// {
|
||||
// if ((c < ' ' || c > 255) && !"\r\n\t".Contains(c.ToString()))
|
||||
// sb.Append(string.Format("x{0:X4}", (int)c));
|
||||
// else
|
||||
// sb.Append(c);
|
||||
// }
|
||||
// return sb.ToString();
|
||||
//}
|
||||
public bool IsDirty
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsGridChanged(this._MyItemInfo.MyContent.MyGrid.Data, this.GetXMLData());
|
||||
}
|
||||
}
|
||||
private bool IsGridChanged(string oldXml, string newXml)
|
||||
{
|
||||
if (this.TableCellEditor.Text.Contains("<NewID>"))
|
||||
return false;
|
||||
XmlDocument XdOld = new XmlDocument();
|
||||
XdOld.LoadXml(oldXml);
|
||||
XmlDocument XdNew = new XmlDocument();
|
||||
XdNew.LoadXml(newXml);
|
||||
//check volian borders 1st
|
||||
if (XdNew.SelectSingleNode("C1FlexGrid/Control/MyBorderDetailString").InnerText != XdOld.SelectSingleNode("C1FlexGrid/Control/MyBorderDetailString").InnerText)
|
||||
return true;
|
||||
//check row/col sizes 2nd
|
||||
if (GetRowColSizeString(XdNew) != GetRowColSizeString(XdOld))
|
||||
return true;
|
||||
//check for cell data changes 3rd
|
||||
if (GetCellDataString(XdNew) != GetCellDataString(XdOld))
|
||||
return true;
|
||||
//check for cell format changes 4th
|
||||
if (GetCellFormatString(XdNew) != GetCellFormatString(XdOld))
|
||||
return true;
|
||||
//check for merged cells 5th
|
||||
if (GetCellMergeString(XdNew) != GetCellMergeString(XdOld))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
private string GetRowColSizeString(XmlDocument xd)
|
||||
{
|
||||
string defCW = xd.SelectSingleNode("C1FlexGrid/ColumnInfo/DefaultSize").InnerText;
|
||||
string defRH = xd.SelectSingleNode("C1FlexGrid/RowInfo/DefaultSize").InnerText;
|
||||
int cols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText);
|
||||
int rows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText);
|
||||
List<string> rh = new List<string>();
|
||||
for (int i = 0; i < rows; i++)
|
||||
rh.Add(defRH);
|
||||
List<string> cw = new List<string>();
|
||||
for (int i = 0; i < cols; i++)
|
||||
cw.Add(defCW);
|
||||
XmlNodeList nlr = xd.SelectNodes("C1FlexGrid/Rows/Row");
|
||||
foreach (XmlNode nr in nlr)
|
||||
{
|
||||
int idx = int.Parse(nr.Attributes.GetNamedItem("index").InnerText);
|
||||
rh[idx] = nr.SelectSingleNode("Height").InnerText;
|
||||
}
|
||||
XmlNodeList nlc = xd.SelectNodes("C1FlexGrid/Columns/Column");
|
||||
foreach (XmlNode nc in nlc)
|
||||
{
|
||||
int idx = int.Parse(nc.Attributes.GetNamedItem("index").InnerText);
|
||||
cw[idx] = nc.SelectSingleNode("Width").InnerText;
|
||||
}
|
||||
string rhcw = "RowHeights: ";
|
||||
string sep = string.Empty;
|
||||
foreach (string s in rh)
|
||||
{
|
||||
rhcw += sep + s;
|
||||
sep = ",";
|
||||
}
|
||||
rhcw += " - ColWidths: ";
|
||||
sep = string.Empty;
|
||||
foreach (string s in cw)
|
||||
{
|
||||
rhcw += sep + s;
|
||||
sep = ",";
|
||||
}
|
||||
return rhcw;
|
||||
}
|
||||
private string GetCellDataString(XmlDocument xd)
|
||||
{
|
||||
int cols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText);
|
||||
int rows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText);
|
||||
List<string> datum = new List<string>();
|
||||
for (int i = 0; i < rows * cols; i++)
|
||||
datum.Add("|");
|
||||
XmlNodeList nl = xd.SelectNodes("C1FlexGrid/Cells/Cell/Data");
|
||||
string data = string.Empty;
|
||||
foreach (XmlNode xn in nl)
|
||||
{
|
||||
RichTextBox rtb = new RichTextBox();
|
||||
rtb.Rtf = xn.InnerText;
|
||||
XmlAttribute xa = xn.ParentNode.Attributes.GetNamedItem("index") as XmlAttribute;
|
||||
string[] rc = xa.InnerText.Split(',');
|
||||
int r = int.Parse(rc[0]);
|
||||
int c = int.Parse(rc[1]);
|
||||
int index = r * cols + c;
|
||||
datum[index] = "|" + (rtb.Text == "" ? "" : rtb.Text);
|
||||
}
|
||||
foreach (string s in datum)
|
||||
data += s;
|
||||
return data;
|
||||
}
|
||||
private string GetCellFormatString(XmlDocument xd)
|
||||
{
|
||||
int cols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText);
|
||||
int rows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText);
|
||||
List<string> datum = new List<string>();
|
||||
for (int i = 0; i < rows * cols; i++)
|
||||
datum.Add("|");
|
||||
XmlNodeList nl = xd.SelectNodes("C1FlexGrid/Cells/Cell/Data");
|
||||
string data = string.Empty;
|
||||
foreach (XmlNode xn in nl)
|
||||
{
|
||||
RichTextBox rtb = new RichTextBox();
|
||||
rtb.Rtf = xn.InnerText;
|
||||
XmlAttribute xa = xn.ParentNode.Attributes.GetNamedItem("index") as XmlAttribute;
|
||||
string[] rc = xa.InnerText.Split(',');
|
||||
int r = int.Parse(rc[0]);
|
||||
int c = int.Parse(rc[1]);
|
||||
int index = r * cols + c;
|
||||
datum[index] = "|" + (rtb.Text == "" ? "" : rtb.Rtf);
|
||||
}
|
||||
foreach (string s in datum)
|
||||
data += s;
|
||||
return data;
|
||||
}
|
||||
private string GetCellMergeString(XmlDocument xd)
|
||||
{
|
||||
if(xd.SelectSingleNode("C1FlexGrid/MergedRanges") == null)
|
||||
return string.Empty;
|
||||
return xd.SelectSingleNode("C1FlexGrid/MergedRanges").InnerXml;
|
||||
}
|
||||
public static GridCopyInfo MyCopyInfo = new GridCopyInfo();
|
||||
private Color _DefaultCellBackgroundcolor;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user