Reduced duplicated Audits
Added comments Added and used calculated IsDirty Property
This commit is contained in:
@@ -32,8 +32,160 @@ namespace Volian.Controls.Library
|
||||
get { return _SpellChecker; }
|
||||
set { _SpellChecker = value; }
|
||||
}
|
||||
|
||||
public static GridCopyInfo MyCopyInfo = new GridCopyInfo();
|
||||
//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;
|
||||
|
||||
public Color DefaultCellBackgroundcolor
|
||||
|
Reference in New Issue
Block a user