public static bool SetXmlNodeByParamName(string _paramname, string _paramvalue) { bool result; try { XmlCommomOp.CreaetDocument(); List <XmlNode> list = new List <XmlNode>(); list.Clear(); if (XmlCommomOp.doc == null || _paramname.Trim() == "") { result = false; } else { foreach (XmlNode node in XmlCommomOp.doc.ChildNodes) { XmlCommomOp.GetNodeOfInnerTextByParamname(node, _paramname, list); } foreach (XmlNode current in list) { current.InnerText = current.InnerText.Replace("{@" + _paramname + "}", _paramvalue); } result = true; } } catch (Exception ex) { throw ex; } return(result); }
public static XmlNode[] GetXmlNodeById(string _idvalue) { XmlNode[] result; try { XmlCommomOp.CreaetDocument(); List <XmlNode> list = new List <XmlNode>(); list.Clear(); if (XmlCommomOp.doc == null || _idvalue.Trim() == "") { result = list.ToArray(); } else { foreach (XmlNode node in XmlCommomOp.doc.ChildNodes) { XmlCommomOp.GetNodeByAttributesIgnoreCase(node, "Id", _idvalue, list); } result = list.ToArray(); } } catch (Exception ex) { throw ex; } return(result); }
public static bool Landspace() { bool result; try { XmlNode xmlNode = XmlCommomOp.GetXmlNodeByTagname("PageSize")[0]; if (xmlNode == null || xmlNode.Attributes["landspace"] == null || string.IsNullOrEmpty(xmlNode.Attributes["landspace"].Value)) { result = false; } else if (xmlNode.Attributes["landspace"].Value == "false") { result = false; } else { result = true; } } catch (Exception) { throw; } return(result); }
private static bool FormateParamtersValue(Dictionary <string, ParamObject> dicParamsList) { bool result; try { XmlNode[] xmlNodeByTagname = XmlCommomOp.GetXmlNodeByTagname("Parameters"); if (xmlNodeByTagname == null || xmlNodeByTagname.Length == 0) { result = false; } else { XmlNode xmlNode = xmlNodeByTagname[0]; foreach (XmlNode xmlNode2 in xmlNode.ChildNodes) { if (xmlNode2.Attributes["ParameterName"] != null && !string.IsNullOrEmpty(xmlNode2.Attributes["ParameterName"].Value)) { if (!XmlCommomOp.IsFillValue(xmlNode2, dicParamsList)) { XmlCommomOp.SetXmlNodeByParamName(xmlNode2.Attributes["ParameterName"].Value, xmlNode2.Attributes["DefaultValue"].Value); } } } result = false; } } catch (Exception ex) { throw ex; } return(result); }
public static DrawInfo XmlNodeToDrawInfo(XmlNode _node) { DrawInfo result; try { DrawInfo drawInfo = CommonMethods.DrawInfoStringToDrawInfo(new DrawInfoString { Left = XmlCommomOp.GetValueByAttribute(_node, "Left"), Top = XmlCommomOp.GetValueByAttribute(_node, "Top"), Width = XmlCommomOp.GetValueByAttribute(_node, "Width"), Height = XmlCommomOp.GetValueByAttribute(_node, "Height"), Align = XmlCommomOp.GetValueByAttribute(_node, "Align"), Valign = XmlCommomOp.GetValueByAttribute(_node, "Valign"), FontColor = XmlCommomOp.GetValueByAttribute(_node, "Font"), BgColor = XmlCommomOp.GetValueByAttribute(_node, "BgColor"), Border = XmlCommomOp.GetValueByAttribute(_node, "Border") }); result = drawInfo; } catch (Exception ex) { throw ex; } return(result); }
public static bool SetRowsAttributeByXmlNode(string _TagName) { bool result; try { if (_TagName == null) { throw new NullReferenceException(); } XmlNode[] xmlNodeByTagname = XmlCommomOp.GetXmlNodeByTagname(_TagName); if (xmlNodeByTagname == null || xmlNodeByTagname.Length <= 0) { result = false; } else { for (int i = 0; i < xmlNodeByTagname.Length; i++) { DrawDriverXmlOp.SetRowsAttributeByXmlNode(xmlNodeByTagname[i]); } result = true; } } catch (Exception ex) { throw ex; } return(result); }
public static XmlNode[] GetXmlNodeByTagname(string _tagname) { XmlNode[] result; try { XmlCommomOp.CreaetDocument(); try { List <XmlNode> list = new List <XmlNode>(); list.Clear(); if (XmlCommomOp.doc == null || _tagname.Trim() == "") { result = list.ToArray(); } else { foreach (XmlNode node in XmlCommomOp.doc.ChildNodes) { XmlCommomOp.GetNodeByTagNameIgnoreCase(node, _tagname, list); } result = list.ToArray(); } } catch (Exception ex) { throw ex; } } catch (Exception ex2) { throw ex2; } return(result); }
public static DrawInfo GetDrawInfoByXmlNode(XmlNode _node) { DrawInfo result; try { if (_node == null) { throw new NullReferenceException(); } string valueByAttribute = XmlCommomOp.GetValueByAttribute(_node, "Style"); if (valueByAttribute == null) { DrawDriverXmlOp.SetDrawInfoByXmlNode(_node); } DrawInfoString objString = new DrawInfoString(); string[] supportAttributeByXmlNode = DrawDriverXmlOp.GetSupportAttributeByXmlNode(_node); for (int i = 0; i < supportAttributeByXmlNode.Length; i++) { DrawDriverXmlOp.SetStyle(ref objString, supportAttributeByXmlNode[i], _node, valueByAttribute); } DrawInfo drawInfo = CommonMethods.DrawInfoStringToDrawInfo(objString); result = drawInfo; } catch (Exception ex) { throw ex; } return(result); }
public static string[] GetSupportAttributes() { string[] result; try { List <string> list = new List <string>(); XmlDocument xmlDocumentDTD = DrawDriverXmlOp.GetXmlDocumentDTD(); XmlCommomOp.xmlPath = DrawDriverXmlOp.strXmlDocumentDTDFilePath; XmlNode[] xmlNodeByTagname = XmlCommomOp.GetXmlNodeByTagname("SupportAttribute"); if (xmlNodeByTagname == null || xmlNodeByTagname.Length <= 0) { result = null; } else { foreach (XmlNode xmlNode in xmlNodeByTagname[0]) { list.Add(xmlNode.Name); } result = list.ToArray(); } } catch (Exception ex) { throw ex; } return(result); }
private static void GetNodeByTagNameIgnoreCase(XmlNode _node, string _tagname, List <XmlNode> _lst) { try { if (_node.HasChildNodes) { foreach (XmlNode node in _node.ChildNodes) { XmlCommomOp.GetNodeByTagNameIgnoreCase(node, _tagname, _lst); } if (_node.LocalName.ToLower() == _tagname.ToLower()) { _lst.Add(_node); } } else if (_node.LocalName.ToLower() == _tagname.ToLower()) { _lst.Add(_node); } } catch (Exception ex) { throw ex; } }
public static bool AddChildNode(XmlNode _curretnode, string _tag, string _innerText) { bool result; try { XmlCommomOp.CreaetDocument(); if (_curretnode != null && !string.IsNullOrEmpty(_tag) && !string.IsNullOrEmpty(_innerText)) { XmlElement xmlElement = XmlCommomOp.doc.CreateElement(_tag); xmlElement.InnerText = _innerText; _curretnode.AppendChild(xmlElement); result = true; } else { result = false; } } catch (Exception ex) { throw ex; } return(result); }
public static bool SetDrawInfoByXmlNode(XmlNode _node) { bool result; try { if (_node == null) { throw new NullReferenceException(); } XmlNode[] xmlNodeByTagname = XmlCommomOp.GetXmlNodeByTagname("Style"); if (xmlNodeByTagname == null || xmlNodeByTagname.Length <= 0) { result = false; } else { string innerText = xmlNodeByTagname[0].InnerText; string str = ""; XmlElement xmlElement = (XmlElement)_node; foreach (XmlAttribute xmlAttribute in xmlElement.Attributes) { if (xmlAttribute.Name.ToLower().Equals("Class".ToLower())) { str = xmlAttribute.Value; } } Regex regex = new Regex("." + str + "([^{}]*?){([^{}]*?)}"); MatchCollection matchCollection = regex.Matches(innerText); if (matchCollection.Count > 0) { string[] array = matchCollection[0].Value.Trim().Replace("\t", "").Replace("\r\n", "").Split(new char[] { '{' }); string attrValue = ""; if (array.Length >= 2) { attrValue = array[1].Replace("}", ""); } XmlCommomOp.SetXmlAttribute(_node, "Style", attrValue); result = true; } else { result = false; } } } catch (Exception ex) { throw ex; } return(result); }
public static string[] GetSupportChildTypeByXmlNode(XmlNode _node) { string[] result; try { if (_node == null) { throw new NullReferenceException(); } List <string> list = new List <string>(); XmlDocument xmlDocumentDTD = DrawDriverXmlOp.GetXmlDocumentDTD(); XmlCommomOp.xmlPath = DrawDriverXmlOp.strXmlDocumentDTDFilePath; XmlNode[] xmlNodeByTagname = XmlCommomOp.GetXmlNodeByTagname(_node.Name); if (xmlNodeByTagname == null || xmlNodeByTagname.Length <= 0) { result = null; } else { XmlNode[] array = xmlNodeByTagname; for (int i = 0; i < array.Length; i++) { XmlNode xmlNode = array[i]; XmlNode parentNode = xmlNode.ParentNode; if (parentNode != null) { if (parentNode.Name.ToLower().Trim().Equals("LabelContains".ToLower())) { XmlElement xmlElement = (XmlElement)xmlNode; foreach (XmlAttribute xmlAttribute in xmlElement.Attributes) { if (xmlAttribute.Name.ToLower().Equals("Contains".ToLower())) { string text = xmlAttribute.Value.ToLower(); result = text.Split(new char[] { ',' }); return(result); } } } } } result = null; } } catch (Exception ex) { throw ex; } return(result); }
public static FontColor XmlNodeToFontColor(XmlNode _node) { FontColor fontColor; try { DrawInfo drawInfo = CommonMethods.DrawInfoStringToDrawInfo(new DrawInfoString { FontColor = XmlCommomOp.GetValueByAttribute(_node, "Font") }); fontColor = drawInfo.FontColor; } catch (Exception ex) { throw ex; } return(fontColor); }
public static void BindingDate(DataSet datatables, Dictionary <string, ParamObject> dicParamsList) { try { if (datatables != null && datatables.Tables != null && datatables.Tables.Count > 0) { XmlCommomOp.FormateTableNodeValue(datatables); } if (dicParamsList != null && dicParamsList.Count > 0) { XmlCommomOp.FormateParamtersValue(dicParamsList); } } catch (Exception ex) { throw ex; } }
public static void GetAllChildNode(XmlNode _node, ref List <XmlNode> nodesList) { try { if (_node.HasChildNodes) { foreach (XmlNode node in _node.ChildNodes) { XmlCommomOp.GetAllChildNode(node, ref nodesList); } } else { nodesList.Add(_node); } } catch (Exception ex) { throw ex; } }
public static void DrawTable(XmlNode tableNode, Graphics g, int x, int y) { try { CommonDrawOp.DrawHead(tableNode, g, x, y); XmlCommomOp.SetXmlAttribute(tableNode, "left", string.Concat(x)); XmlCommomOp.SetXmlAttribute(tableNode, "top", string.Concat(y)); int num = y; XmlNode xmlNode = tableNode.SelectNodes("TableHead")[0]; XmlNodeList childNodes = xmlNode.ChildNodes; for (int i = 0; i < childNodes.Count; i++) { num += int.Parse(childNodes[i].Attributes["height"].Value); } CommonDrawOp.DrawTableBody(tableNode, g, x, num); } catch (Exception ex) { throw ex; } }
public static Dictionary <int, XmlNode> GetColumn(XmlNode xmlNode) { Dictionary <int, XmlNode> result; try { Dictionary <int, List <int> > tableModel = XmlCommomOp.GetTableModel(xmlNode); XmlNode xmlNode2 = xmlNode.SelectNodes("TableHead")[0]; XmlNodeList childNodes = xmlNode2.ChildNodes; int count = childNodes.Count; Dictionary <int, XmlNode> dictionary = new Dictionary <int, XmlNode>(); for (int i = 0; i < count; i++) { int num = 0; for (int j = 0; j < childNodes[i].ChildNodes.Count; j++) { int num2 = (childNodes[i].ChildNodes[j].Attributes["colspan"] == null) ? 1 : int.Parse(childNodes[i].ChildNodes[j].Attributes["colspan"].Value); if (childNodes[i].ChildNodes[j].Attributes["ColumnName"] != null) { dictionary.Add(tableModel[i + 1][num], childNodes[i].ChildNodes[j]); if (num < tableModel[i + 1].Count) { num += num2; } } else { num += num2; } } } result = dictionary; } catch (Exception ex) { throw ex; } return(result); }
private static void GetNodeByAttributesIgnoreCase(XmlNode _node, string _attributesname, string _attributesvalue, List <XmlNode> _lst) { try { if (_node.HasChildNodes) { foreach (XmlNode node in _node.ChildNodes) { XmlCommomOp.GetNodeByAttributesIgnoreCase(node, _attributesname, _attributesvalue, _lst); } if (_node.Attributes != null) { foreach (XmlAttribute xmlAttribute in _node.Attributes) { if (xmlAttribute.Name.ToLower() == _attributesname.ToLower() && xmlAttribute.Value == _attributesvalue) { _lst.Add(_node); break; } } } } else if (_node.Attributes != null) { foreach (XmlAttribute xmlAttribute in _node.Attributes) { if (xmlAttribute.Name.ToLower() == _attributesname.ToLower() && xmlAttribute.Value == _attributesvalue) { _lst.Add(_node); break; } } } } catch (Exception ex) { throw ex; } }
public static bool IsFillValue(XmlNode node, Dictionary <string, ParamObject> dicParamsList) { bool result; try { bool flag = false; foreach (KeyValuePair <string, ParamObject> current in dicParamsList) { if (current.Key.Trim().Equals(node.Attributes["ParameterName"].Value) && current.Value.Value.Trim() != "") { XmlCommomOp.SetXmlNodeByParamName(current.Key, current.Value.Value); flag = true; } } result = flag; } catch (Exception ex) { throw ex; } return(result); }
private static void GetNodeOfInnerTextByParamname(XmlNode _node, string _paramname, List <XmlNode> _lst) { try { if (_node.HasChildNodes) { foreach (XmlNode node in _node.ChildNodes) { XmlCommomOp.GetNodeOfInnerTextByParamname(node, _paramname, _lst); } } else if (_node.NodeType == XmlNodeType.Text) { if (_node.ParentNode.InnerText.Contains("{@" + _paramname + "}")) { _lst.Add(_node); } } } catch (Exception ex) { throw ex; } }
public static bool FormateTableNodeValue(DataSet datatables) { bool result; try { XmlNode[] xmlNodeByTagname = XmlCommomOp.GetXmlNodeByTagname("Table"); XmlNode[] array = xmlNodeByTagname; for (int i = 0; i < array.Length; i++) { XmlNode xmlNode = array[i]; if (xmlNode.Attributes["datasource"] != null && !string.IsNullOrEmpty(xmlNode.Attributes["datasource"].Value)) { XmlCommomOp.CreateTrAndTh(xmlNode, datatables.Tables[xmlNode.Attributes["datasource"].Value]); } } result = true; } catch (Exception ex) { throw ex; } return(result); }
private static void DrawTableBody(XmlNode xmlNode, Graphics g, int x, int y) { try { XmlNode xmlNode2 = xmlNode.SelectNodes("TableBody")[0]; Dictionary <int, XmlNode> column = XmlCommomOp.GetColumn(xmlNode); XmlNodeList childNodes = xmlNode2.ChildNodes; int count = childNodes.Count; StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; Rectangle rectangle = default(Rectangle); rectangle.Y = y; rectangle.Height = int.Parse(xmlNode2.FirstChild.Attributes["height"].Value); string str = (xmlNode2.Attributes["Font"] == null || xmlNode2.Attributes["Font"].Value == "") ? "" : xmlNode2.Attributes["Font"].Value; FontColor fontColor = CommonMethods.StringToFontColor(str); foreach (XmlNode xmlNode3 in childNodes) { rectangle.X = x; int num = 1; foreach (XmlNode xmlNode4 in xmlNode3.ChildNodes) { rectangle.Width = int.Parse(column[num].Attributes["width"].Value); string text = (column[num].Attributes["ContentAlign"] == null || column[num].Attributes["ContentAlign"].Value == "") ? "left" : column[num].Attributes["ContentAlign"].Value; string text2 = text.ToLower().Trim().ToString(); if (text2 == null) { goto IL_22E; } if (!(text2 == "left")) { if (!(text2 == "right")) { if (!(text2 == "center")) { goto IL_22E; } stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; } else { stringFormat.LineAlignment = StringAlignment.Center; stringFormat.Alignment = StringAlignment.Far; } } else { stringFormat.LineAlignment = StringAlignment.Center; stringFormat.Alignment = StringAlignment.Near; } IL_242: string innerText = xmlNode4.InnerText; g.DrawRectangle(Pens.Black, rectangle); g.DrawString(innerText, fontColor.Font, new SolidBrush(fontColor.Color), rectangle, stringFormat); rectangle.X += rectangle.Width; num++; continue; IL_22E: stringFormat.LineAlignment = StringAlignment.Center; stringFormat.Alignment = StringAlignment.Near; goto IL_242; } rectangle.Y += rectangle.Height; } } catch (Exception ex) { throw ex; } }
private static void DrawHead(XmlNode xmlNode, Graphics g, int x, int y) { try { Dictionary <int, List <int> > tableModel = XmlCommomOp.GetTableModel(xmlNode); Dictionary <int, XmlNode> column = XmlCommomOp.GetColumn(xmlNode); XmlNode xmlNode2 = xmlNode.SelectNodes("TableHead")[0]; XmlNodeList childNodes = xmlNode2.ChildNodes; int count = childNodes.Count; int num = 0; foreach (XmlNode xmlNode3 in childNodes[0]) { if (xmlNode3.Attributes["colspan"] != null) { num += int.Parse(xmlNode3.Attributes["colspan"].Value); } else { num++; } } Rectangle rectangle = default(Rectangle); rectangle.Y = y; rectangle.X = x; for (int i = 1; i <= childNodes.Count; i++) { int num2 = int.Parse(childNodes[i - 1].Attributes["height"].Value); rectangle.X = x; rectangle.Height = num2; for (int j = 0; j < num; j++) { int width = int.Parse(column[j + 1].Attributes["width"].Value); rectangle.Width = width; g.DrawRectangle(Pens.Black, rectangle); rectangle.Offset(rectangle.Width, 0); } rectangle.Y += num2; } rectangle = default(Rectangle); rectangle.Y = y; for (int i = 1; i <= count; i++) { int num3 = 0; int num4 = tableModel[i][num3]; int num5 = int.Parse(childNodes[i - 1].Attributes["height"].Value); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; foreach (XmlNode xmlNode4 in childNodes[i - 1].ChildNodes) { int num6 = (xmlNode4.Attributes["rowspan"] == null || xmlNode4.Attributes["rowspan"].Value == "") ? 1 : int.Parse(xmlNode4.Attributes["rowspan"].Value); int num7 = (xmlNode4.Attributes["colspan"] == null || xmlNode4.Attributes["colspan"].Value == "") ? 1 : int.Parse(xmlNode4.Attributes["colspan"].Value); int arg_34C_0 = (xmlNode4.Attributes["width"] == null || xmlNode4.Attributes["width"].Value == "") ? 1 : int.Parse(xmlNode4.Attributes["width"].Value); string str = (xmlNode4.Attributes["Font"] == null || xmlNode4.Attributes["Font"].Value == "") ? "" : xmlNode4.Attributes["Font"].Value; string text = (xmlNode4.Attributes["IsBlod"] == null || xmlNode4.Attributes["IsBlod"].Value == "") ? "false" : xmlNode4.Attributes["IsBlod"].Value; string text2 = (xmlNode4.Attributes["Align"] == null || xmlNode4.Attributes["Align"].Value == "") ? "Center" : xmlNode4.Attributes["Align"].Value; string text3 = text2.ToLower().Trim().ToString(); if (text3 == null) { goto IL_4C9; } if (!(text3 == "left")) { if (!(text3 == "right")) { if (!(text3 == "center")) { goto IL_4C9; } stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; } else { stringFormat.LineAlignment = StringAlignment.Center; stringFormat.Alignment = StringAlignment.Far; } } else { stringFormat.LineAlignment = StringAlignment.Center; stringFormat.Alignment = StringAlignment.Near; } IL_4DD: FontColor fontColor = CommonMethods.StringToFontColor(str); FontStyle style = fontColor.Font.Style; Font font; if (text.ToLower().Trim().Equals("true")) { font = new Font(fontColor.Font.Name, fontColor.Font.Size, fontColor.Font.Style | FontStyle.Bold); } else { font = new Font(fontColor.Font.Name, fontColor.Font.Size, fontColor.Font.Style); } string innerText = xmlNode4.InnerText; rectangle.X = x; rectangle.Height = 0; rectangle.Width = 0; for (int j = 1; j < num4; j++) { rectangle.X += int.Parse(column[j].Attributes["width"].Value); } for (int k = i; k < i + num6; k++) { rectangle.Height += int.Parse(childNodes[k - 1].Attributes["height"].Value); } for (int l = num4; l < num4 + num7; l++) { rectangle.Width += int.Parse(column[l].Attributes["width"].Value); } g.FillRectangle(Brushes.White, rectangle); g.DrawRectangle(Pens.Black, rectangle); g.DrawString(innerText, font, new SolidBrush(fontColor.Color), rectangle, stringFormat); num3 += num7; if (num3 < tableModel[i].Count) { num4 = tableModel[i][num3]; } continue; IL_4C9: stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; goto IL_4DD; } rectangle.Y += num5; } } catch (Exception ex) { throw ex; } }
public static bool SetRowsAttributeByXmlNode(XmlNode _node) { bool result; try { if (_node == null) { throw new NullReferenceException(); } string input = ""; XmlNode[] xmlNodeByTagname = XmlCommomOp.GetXmlNodeByTagname("Style"); if (xmlNodeByTagname != null && xmlNodeByTagname.Length > 0) { input = xmlNodeByTagname[0].InnerText; } string name = _node.Name; string str = ""; string text = ""; XmlElement xmlElement = (XmlElement)_node; foreach (XmlAttribute xmlAttribute in xmlElement.Attributes) { if (xmlAttribute.Name.ToLower().Equals("Class".ToLower())) { str = xmlAttribute.Value; } if (xmlAttribute.Name.ToLower().Equals("Style".ToLower())) { text = xmlAttribute.Value; } } XmlCommomOp.DeleteNodeAttribute(_node, "Class"); XmlCommomOp.DeleteNodeAttribute(_node, "Style"); if (text.Trim().Length > 0) { string[] array = text.Split(new char[] { ';' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[] { ':' }); if (array2.Length >= 2) { if (!DrawDriverXmlOp.YNHaveAttribute(_node, array2[0].Trim().ToLower())) { XmlCommomOp.SetXmlAttribute(_node, array2[0].Trim().ToLower(), array2[1].ToLower()); } } } } Regex regex = new Regex("([^{}\\s]*?)([^{}]*?){([^{}]*?)}"); MatchCollection matchCollection = regex.Matches(input); string[,] array3 = new string[matchCollection.Count, 2]; for (int i = 0; i < matchCollection.Count; i++) { string[] array4 = matchCollection[i].Value.Trim().Replace("\t", "").Replace("\r\n", "").Split(new char[] { '{' }); if (array4.Length >= 2) { array3[i, 0] = array4[0].Trim(); array3[i, 1] = array4[1].Replace("}", ""); } } string[] array5 = DrawDriverXmlOp.GetStyle(array3, "." + str).Split(new char[] { ';' }); for (int i = 0; i < array5.Length; i++) { string[] array2 = array5[i].Split(new char[] { ':' }); if (array2.Length >= 2) { if (!DrawDriverXmlOp.YNHaveAttribute(_node, array2[0].Trim().ToLower())) { XmlCommomOp.SetXmlAttribute(_node, array2[0].Trim().ToLower(), array2[1].ToLower()); } } } array5 = DrawDriverXmlOp.GetStyle(array3, name).Split(new char[] { ';' }); for (int i = 0; i < array5.Length; i++) { string[] array2 = array5[i].Split(new char[] { ':' }); if (array2.Length >= 2) { if (!DrawDriverXmlOp.YNHaveAttribute(_node, array2[0].Trim().ToLower())) { XmlCommomOp.SetXmlAttribute(_node, array2[0].Trim().ToLower(), array2[1].ToLower()); } } } result = false; } catch (Exception ex) { throw ex; } return(result); }
private static bool CreateTrAndTh(XmlNode curNode, DataTable dt) { bool result; try { Dictionary <int, XmlNode> dictionary = null; Font font = null; int num = 0; int num2 = 0; string innerText = (curNode.Attributes["defaultValue"] == null || curNode.Attributes["defaultValue"].Value == "") ? "" : curNode.Attributes["defaultValue"].Value; string text = (curNode.Attributes["FillRowIndex"] == null || curNode.Attributes["FillRowIndex"].Value == "") ? dt.Rows.Count.ToString() : curNode.Attributes["FillRowIndex"].Value; List <string> list = new List <string>(); if (text.Contains(",")) { list = text.Split(new char[] { ',' }).ToList <string>(); } else { for (int i = 0; i < int.Parse(text); i++) { list.Add(i.ToString()); } } bool flag = false; if (curNode != null && curNode.SelectSingleNode("TableBody") != null) { num2 = int.Parse(curNode.SelectSingleNode("TableBody").FirstChild.Attributes["height"].Value); string familyName = (curNode.SelectSingleNode("TableBody").Attributes["font-family"] == null || curNode.SelectSingleNode("TableBody").Attributes["font-family"].Value == "") ? "新宋体" : curNode.SelectSingleNode("TableBody").Attributes["font-family"].Value; string s = (curNode.SelectSingleNode("TableBody").Attributes["font-size"] == null || curNode.SelectSingleNode("TableBody").Attributes["font-size"].Value == "") ? "12" : curNode.SelectSingleNode("TableBody").Attributes["font-size"].Value; font = new Font(familyName, float.Parse(s), FontStyle.Regular, GraphicsUnit.Pixel); XmlNode xmlNode = curNode.SelectSingleNode("TableBody"); foreach (XmlNode oldChild in xmlNode.ChildNodes) { xmlNode.RemoveChild(oldChild); } dictionary = XmlCommomOp.GetColumn(curNode); } if (curNode != null && curNode.SelectSingleNode("TableHead") != null) { foreach (XmlNode xmlNode2 in curNode.SelectSingleNode("TableHead").ChildNodes) { num += int.Parse((xmlNode2.Attributes["height"] == null || xmlNode2.Attributes["height"].Value == "") ? "0" : xmlNode2.Attributes["height"].Value); } } if (curNode != null && dictionary.Count > 0 && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { num += num2; XmlElement xmlElement = XmlCommomOp.Doc.CreateElement("Tr"); xmlElement.SetAttribute("height", num2.ToString().Trim()); int num3 = 0; for (int j = 1; j <= dictionary.Count; j++) { XmlElement xmlElement2 = XmlCommomOp.Doc.CreateElement("Td"); string value = dictionary[j].Attributes["ColumnName"].Value; int width = int.Parse(dictionary[j].Attributes["width"].Value); int num4 = int.Parse((dictionary[j].Attributes["Wrap"] == null || dictionary[j].Attributes["Wrap"].Value == "") ? "0" : dictionary[j].Attributes["Wrap"].Value); string text2 = dt.Rows[i][value].ToString().Trim(); List <string> list2 = CommonMethods.WrapLongString(font, text2, width); if (num4 == 1 && list2.Count > 1) { if (num3 < list2.Count) { dt.Rows[i][value] = list2[0]; for (int k = 1; k < list2.Count - num3; k++) { DataRow dataRow = dt.NewRow(); dataRow[value] = list2[k]; dt.Rows.InsertAt(dataRow, i + k); } num3 = list2.Count; } else { for (int k = 0; k < list2.Count; k++) { dt.Rows[i + k][value] = list2[k]; } } } if (list.Contains(i.ToString())) { if (string.IsNullOrEmpty(dt.Rows[i][value].ToString())) { if (flag) { xmlElement2.InnerText = dt.Rows[i][value].ToString(); } else { xmlElement2.InnerText = innerText; } } else { xmlElement2.InnerText = dt.Rows[i][value].ToString(); flag = true; } } else { xmlElement2.InnerText = dt.Rows[i][value].ToString(); } xmlElement.AppendChild(xmlElement2); } curNode.SelectSingleNode("TableBody").AppendChild(xmlElement); flag = false; } XmlCommomOp.SetXmlAttribute(curNode, "height", num.ToString().Trim()); result = true; } else { XmlCommomOp.SetXmlAttribute(curNode, "height", num.ToString().Trim()); result = false; } } catch (Exception ex) { throw ex; } return(result); }
private static void SetStyle(ref DrawInfoString objString, string strName, XmlNode _node, string strStyle) { try { if (objString == null) { throw new NullReferenceException(); } if (strName == null) { throw new NullReferenceException(); } if (_node == null) { throw new NullReferenceException(); } if (strStyle == null) { throw new NullReferenceException(); } if (strName.Trim().ToLower().Equals("left")) { objString.Left = XmlCommomOp.GetValueByAttribute(_node, strName); if (objString.Left == null) { objString.Left = CommonMethods.GetStyleValue(strStyle, strName); } } else if (strName.Trim().ToLower().Equals("top")) { objString.Top = XmlCommomOp.GetValueByAttribute(_node, strName); if (objString.Top == null) { objString.Top = CommonMethods.GetStyleValue(strStyle, strName); } } else if (strName.Trim().ToLower().Equals("width")) { objString.Width = XmlCommomOp.GetValueByAttribute(_node, strName); if (objString.Width == null) { objString.Width = CommonMethods.GetStyleValue(strStyle, strName); } } else if (strName.Trim().ToLower().Equals("height")) { objString.Height = XmlCommomOp.GetValueByAttribute(_node, strName); if (objString.Height == null) { objString.Height = CommonMethods.GetStyleValue(strStyle, strName); } } else if (strName.Trim().ToLower().Equals("align")) { objString.Align = XmlCommomOp.GetValueByAttribute(_node, strName); if (objString.Align == null) { objString.Align = CommonMethods.GetStyleValue(strStyle, strName); } } else if (strName.Trim().ToLower().Equals("valign")) { objString.Valign = XmlCommomOp.GetValueByAttribute(_node, strName); if (objString.Valign == null) { objString.Valign = CommonMethods.GetStyleValue(strStyle, strName); } } else if (strName.Trim().ToLower().Equals("fontcolor")) { objString.FontColor = XmlCommomOp.GetValueByAttribute(_node, strName); if (objString.FontColor == null) { objString.FontColor = CommonMethods.GetStyleValue(strStyle, strName); } } else if (strName.Trim().ToLower().Equals("bgcolor")) { objString.BgColor = XmlCommomOp.GetValueByAttribute(_node, strName); if (objString.BgColor == null) { objString.BgColor = CommonMethods.GetStyleValue(strStyle, strName); } } else if (strName.Trim().ToLower().Equals("border")) { objString.Border = XmlCommomOp.GetValueByAttribute(_node, strName); if (objString.Border == null) { objString.Border = CommonMethods.GetStyleValue(strStyle, strName); } } } catch (Exception ex) { throw ex; } }
public static DrawType GetDrawTypeByXmlNode(XmlNode _node) { DrawType result; try { if (_node == null) { throw new NullReferenceException(); } List <string> list = new List <string>(); XmlDocument xmlDocumentDTD = DrawDriverXmlOp.GetXmlDocumentDTD(); XmlCommomOp.xmlPath = DrawDriverXmlOp.strXmlDocumentDTDFilePath; XmlNode[] xmlNodeByTagname = XmlCommomOp.GetXmlNodeByTagname(_node.Name); if (xmlNodeByTagname == null || xmlNodeByTagname.Length <= 0) { result = DrawType.None; } else { XmlNode[] array = xmlNodeByTagname; for (int i = 0; i < array.Length; i++) { XmlNode xmlNode = array[i]; XmlNode parentNode = xmlNode.ParentNode; if (parentNode != null) { if (parentNode.Name.ToLower().Trim().Equals("SupportLabels".ToLower())) { XmlElement xmlElement = (XmlElement)xmlNode; foreach (XmlAttribute xmlAttribute in xmlElement.Attributes) { if (xmlAttribute.Name.ToLower().Equals("DrawType".ToLower())) { string text = xmlAttribute.Value.ToLower(); if (text.Equals("string")) { result = DrawType.String; return(result); } if (text.Equals("line")) { result = DrawType.Line; return(result); } if (text.Equals("image")) { result = DrawType.Image; return(result); } if (text.Equals("fillrectangle")) { result = DrawType.FillRectangle; return(result); } if (text.Equals("rectangle")) { result = DrawType.Rectangle; return(result); } if (text.Equals("circle")) { result = DrawType.Circle; return(result); } result = DrawType.None; return(result); } } } } } result = DrawType.None; } } catch (Exception ex) { throw ex; } return(result); }