public string SavePoint(ImageCtl drawArea) { string s = ""; for (int i = 0; i < drawArea.GraphicsList.Count; i++)//查找点 { DrawObject o = drawArea.GraphicsList[i]; if (o.GetType().FullName == "BaseControls.ImageBox.DrawTools.DrawPoint") { s = ((DrawPoint)o).Point.X.ToString() + ";" + ((DrawPoint)o).Point.Y.ToString() + ";" + o.ID.ToString(); } } return(s); }
protected void AddNewObject(DrawArea drawArea, DrawObject o) { drawArea.GraphicsList.UnselectAll(); o.Selected = true; drawArea.GraphicsList.Add(o); string oName = o.GetType().Name; if (oName == "Switch" || oName == "SwitchPort") { drawArea.mapType = "NetDataSet"; } drawArea.Capture = true; drawArea.Refresh(); drawArea.SetDirty(); }
/// <summary> /// 进行序列化; /// </summary> /// <param name="drawObject"></param> /// <returns></returns> public XElement Serialize(DrawObject drawObject) { if (drawObject == null) { throw new ArgumentNullException(nameof(drawObject)); } //因为绘制对象可能存在继承关系,所以需判断最终类型是否匹配; if (drawObject.GetType() != typeof(TDrawObject)) { return(null); } var tDrawObject = drawObject as TDrawObject; var xElem = new XElement(_xElemName_DrawObject); OnSerialize(tDrawObject, xElem); return(xElem); }
protected void AddNewObject(DrawObject o) { graphicsList.UnselectAll(); o.Selected = true; int listCount = -1; int maxValue = 0; int left = 0, top = 0, tagid = -1, intflag = -1; string id = ""; string name = o.GetType().Name; switch (name) { case "BOM": listCount = graphicsList.BomVerify.Count; if (listCount > 0) { var max = Int32.Parse(graphicsList.BomVerify.Max()); maxValue = Int32.Parse(listCount > 0 ? graphicsList.BomVerify.Max() : "0", System.Globalization.NumberStyles.HexNumber); //十六进制转十进制 if (maxValue == 255) //限制只能添加两位十六进制位数 { graphicsList.BomVerify.Remove("ff"); graphicsList.BomVerify.Remove("FF"); maxValue = Int32.Parse(graphicsList.BomVerify.Max(), System.Globalization.NumberStyles.HexNumber); //取第二大值 } BOM bom = (BOM)o.Clone(maxValue + 1); left = bom.RectangleLs.X; top = bom.RectangleLs.Y; id = bom.LogicIDTail; tagid = bom.TagIDBase; intflag = bom.Flag; if (tagid != 0) { //同步标志位 bom.TagIDBase = intflag; Text bomprop = new Text(); bomprop.TextFont = new Font("宋体", 9, FontStyle.Regular); bomprop.Texttest = ""; // id; bomprop.setTextDisplay(left, top - 25); bomprop.ObjectID = intflag; bomprop.TextType = "BOM_Logical_ID"; this.graphicsList.Add(bom); this.graphicsList.Add(bomprop); } else { this.graphicsList.Add((BOM)o.Clone()); } } else { this.graphicsList.Add((BOM)o.Clone()); } break; case "AGMChannel": listCount = graphicsList.AGMVerify.Count; if (listCount > 0) { AGMChannel agmChannel = (AGMChannel)o.Clone(maxValue + 1); left = agmChannel.RectangleLs.X; top = agmChannel.RectangleLs.Y; id = agmChannel.LogicIDTail; intflag = agmChannel.Flag; tagid = agmChannel.TagIDBase; if (tagid != 0) { //同步标志位 agmChannel.TagIDBase = intflag; Text agmChannelprop = new Text(); agmChannelprop.TextFont = new Font("宋体", 9, FontStyle.Regular); agmChannelprop.setTextDisplay(left, top - 25); agmChannelprop.ObjectID = intflag; agmChannelprop.TextType = "AGM_Logical_ID"; this.graphicsList.Add(agmChannel); this.graphicsList.Add(agmChannelprop); } else { this.graphicsList.Add((AGMChannel)o.Clone()); } } else { this.graphicsList.Add((AGMChannel)o.Clone()); } break; case "AGMChannelDual": listCount = graphicsList.AGMVerify.Count; if (listCount > 0) { AGMChannelDual agmChannelDual = (AGMChannelDual)o.Clone(maxValue + 1); left = agmChannelDual.RectangleLs.X; top = agmChannelDual.RectangleLs.Y; id = agmChannelDual.LogicIDTail; intflag = agmChannelDual.Flag; tagid = agmChannelDual.TagIDBase; if (tagid != 0) { //同步标志位 agmChannelDual.TagIDBase = intflag; Text agmChannelDualprop = new Text(); agmChannelDualprop.TextFont = new Font("宋体", 9, FontStyle.Regular); agmChannelDualprop.setTextDisplay(left, top - 25); agmChannelDualprop.ObjectID = intflag; agmChannelDualprop.TextType = "AGMDual_Logical_ID"; this.graphicsList.Add(agmChannelDual); this.graphicsList.Add(agmChannelDualprop); } else { this.graphicsList.Add((AGMChannelDual)o.Clone()); } } else { this.graphicsList.Add((AGMChannelDual)o.Clone()); } break; case "AGMWallSingle": listCount = graphicsList.AGMWallSingleVerify.Count; if (listCount > 0) { AGMWallSingle agmWallSingle = (AGMWallSingle)o.Clone(maxValue + 1); left = agmWallSingle.RectangleLs.X; top = agmWallSingle.RectangleLs.Y; id = agmWallSingle.LogicIDTail; intflag = agmWallSingle.Flag; tagid = agmWallSingle.TagIDBase; if (tagid != 0) { //同步标志位 agmWallSingle.TagIDBase = intflag; Text agmChannelDualprop = new Text(); agmChannelDualprop.TextFont = new Font("宋体", 9, FontStyle.Regular); agmChannelDualprop.setTextDisplay(left, top - 25); agmChannelDualprop.ObjectID = intflag; agmChannelDualprop.TextType = "AGMWallSingle_Logical_ID"; this.graphicsList.Add(agmWallSingle); this.graphicsList.Add(agmChannelDualprop); } else { this.graphicsList.Add((AGMWallSingle)o.Clone()); } } else { this.graphicsList.Add((AGMWallSingle)o.Clone()); } break; case "AGMWallDual": listCount = graphicsList.AGMWallDualVerify.Count; if (listCount > 0) { AGMWallDual agmWallDual = (AGMWallDual)o.Clone(maxValue + 1); left = agmWallDual.RectangleLs.X; top = agmWallDual.RectangleLs.Y; id = agmWallDual.LogicIDTail; intflag = agmWallDual.Flag; tagid = agmWallDual.TagIDBase; if (tagid != 0) { //同步标志位 agmWallDual.TagIDBase = intflag; Text agmChannelDualprop = new Text(); agmChannelDualprop.TextFont = new Font("宋体", 9, FontStyle.Regular); agmChannelDualprop.setTextDisplay(left, top - 25); agmChannelDualprop.ObjectID = intflag; agmChannelDualprop.TextType = "AGMWallDual_Logical_ID"; this.graphicsList.Add(agmWallDual); this.graphicsList.Add(agmChannelDualprop); if (HasInclude(graphicsList.AGMVerify, id)) { MessageBox.Show("设备ID重复,同一车站同一设备类型不能有重复的设备ID!"); } } else { this.graphicsList.Add((AGMWallDual)o.Clone()); } } else { this.graphicsList.Add((AGMWallDual)o.Clone()); } break; case "AGMWallDummy": listCount = graphicsList.AGMWallDummyVerify.Count; if (listCount > 0) { AGMWallDummy agmWallDummy = (AGMWallDummy)o.Clone(maxValue + 1); left = agmWallDummy.RectangleLs.X; top = agmWallDummy.RectangleLs.Y; id = agmWallDummy.LogicIDTail; intflag = agmWallDummy.Flag; tagid = agmWallDummy.TagIDBase; if (tagid != 0) { //同步标志位 agmWallDummy.TagIDBase = intflag; Text agmChannelDualprop = new Text(); agmChannelDualprop.TextFont = new Font("宋体", 9, FontStyle.Regular); agmChannelDualprop.setTextDisplay(left, top - 25); agmChannelDualprop.ObjectID = intflag; agmChannelDualprop.TextType = "AGMWallDummy_Logical_ID"; this.graphicsList.Add(agmWallDummy); this.graphicsList.Add(agmChannelDualprop); } else { this.graphicsList.Add((AGMWallDummy)o.Clone()); } } else { this.graphicsList.Add((AGMWallDummy)o.Clone()); } break; case "TCM": listCount = graphicsList.TCMVerify.Count; if (listCount > 0) { TCM tcm = (TCM)o.Clone(maxValue + 1); left = tcm.RectangleLs.X; top = tcm.RectangleLs.Y; id = tcm.LogicIDTail; intflag = tcm.Flag; tagid = tcm.TagIDBase; if (tagid != 0) { //同步标志位 tcm.TagIDBase = intflag; Text tcmprop = new Text(); tcmprop.TextFont = new Font("宋体", 9, FontStyle.Regular); tcmprop.setTextDisplay(left, top - 25); tcmprop.ObjectID = intflag; tcmprop.TextType = "TCM_Logical_ID"; this.graphicsList.Add(tcm); this.graphicsList.Add(tcmprop); } else { this.graphicsList.Add((TCM)o.Clone()); } } else { this.graphicsList.Add((TCM)o.Clone()); } break; case "TVM": listCount = graphicsList.TVMVerify.Count; if (listCount > 0) { TVM tvm = (TVM)o.Clone(maxValue + 1); left = tvm.RectangleLs.X; top = tvm.RectangleLs.Y; id = tvm.LogicIDTail; intflag = tvm.Flag; tagid = tvm.TagIDBase; if (tagid != 0) { //同步标志位 tvm.TagIDBase = intflag; Text tvmprop = new Text(); tvmprop.TextFont = new Font("宋体", 9, FontStyle.Regular); tvmprop.setTextDisplay(left, top - 25); tvmprop.ObjectID = intflag; tvmprop.TextType = "TVM_Logical_ID"; this.graphicsList.Add(tvm); this.graphicsList.Add(tvmprop); } else { this.graphicsList.Add((TVM)o.Clone()); } } else { this.graphicsList.Add((TVM)o.Clone()); } break; case "SC": listCount = graphicsList.SCVerify.Count; if (listCount > 0) { SC sc = (SC)o.Clone(maxValue + 1); left = sc.RectangleLs.X; top = sc.RectangleLs.Y; id = sc.LogicIDTail; intflag = sc.Flag; tagid = sc.TagIDBase; if (tagid != 0) { //同步标志位 sc.TagIDBase = intflag; Text scprop = new Text(); scprop.TextFont = new Font("宋体", 9, FontStyle.Regular); scprop.setTextDisplay(left, top - 25); scprop.ObjectID = intflag; scprop.TextType = "SC_Logical_ID"; this.graphicsList.Add(sc); this.graphicsList.Add(scprop); } else { this.graphicsList.Add((SC)o.Clone()); } } else { this.graphicsList.Add((SC)o.Clone()); } break; default: this.graphicsList.Add(o.Clone()); break; } }
private void SelectionUcProperiesForm(DrawObject drawObject) { //清除 plProperties.Controls.Clear(); if (htUcCache == null) htUcCache = new Hashtable(); //缓存 if (!htUcCache.ContainsKey(drawObject.drawingType)) htUcCache.Add(drawObject.drawingType, GetNewUcProperies(drawObject.GetType())); //设置参数 (htUcCache[drawObject.drawingType] as ucProperiesBase).SetGraphicsProperties(drawObject.NowProperties); //填充窗体 (htUcCache[drawObject.drawingType] as ucProperiesBase).FillProperties(); //设置属性窗体 SetUcProperiesForm(htUcCache[drawObject.drawingType] as ucProperiesBase); }
public string SaveImageToXml2(ImageCtl drawArea, string imageName) { string xml = ""; xmlDoc.Load(XmlPath); xmlE = null; XmlElement root = xmlDoc.DocumentElement; XmlNode node = xmlDoc.SelectSingleNode("PatientBackImage/Image[@Name='" + imageName + "'] "); if (node == null)//新图片记录 { xmlE = xmlDoc.CreateElement("Image"); XmlAttribute xmlA = xmlDoc.CreateAttribute("Name"); XmlText xt = xmlDoc.CreateTextNode(imageName); xmlE.Attributes.Append(xmlA); xmlA.AppendChild(xt); } else//已处理过 { for (int i = 0; i < ((XmlElement)node).ChildNodes.Count; i++) { XmlElement xx = (XmlElement)(node.ChildNodes[i]); if (xx.Name != "Process") { node.RemoveChild(xx); } } xmlE = (XmlElement)node; } DrawObject o = null; TextBox xtb = new TextBox(); for (int k = 0; k < drawArea.Controls.Count; k++)//查找textbox { if ((drawArea.Controls[k].GetType().FullName == "BaseControls.ImageBox.DrawTools.XTextBox" || drawArea.Controls[k].GetType().FullName == "SIS.ImgProcess.ToolText") && drawArea.Controls[k].Name != "") { xtb = (TextBox)drawArea.Controls[k]; XmlElement nodeNext = (XmlElement)xmlDoc.SelectSingleNode("PatientBackImage/Image[@Name='" + imageName + "']/TextBox[@ID='" + xtb.Name + "']"); if (nodeNext != null) { nodeNext.SetAttribute("X", xtb.Location.X.ToString()); nodeNext.SetAttribute("Y", xtb.Location.Y.ToString()); nodeNext.SetAttribute("Width", xtb.Size.Width.ToString()); nodeNext.SetAttribute("Height", xtb.Size.Height.ToString()); nodeNext.SetAttribute("Content", xtb.Text); } else { XmlElement xmlText = xmlDoc.CreateElement("TextBox"); XmlAttribute xmlATextID = xmlDoc.CreateAttribute("ID"); XmlText xtTextID = xmlDoc.CreateTextNode(xtb.Name); XmlAttribute xmlATextX = xmlDoc.CreateAttribute("X"); XmlText xtTextX = xmlDoc.CreateTextNode(xtb.Location.X.ToString()); XmlAttribute xmlATextY = xmlDoc.CreateAttribute("Y"); XmlText xtTextY = xmlDoc.CreateTextNode(xtb.Location.Y.ToString()); XmlAttribute xmlATextWidth = xmlDoc.CreateAttribute("Width"); XmlText xtTextWidth = xmlDoc.CreateTextNode(xtb.Size.Width.ToString()); XmlAttribute xmlATextHeight = xmlDoc.CreateAttribute("Height"); XmlText xtTextHeight = xmlDoc.CreateTextNode(xtb.Size.Height.ToString()); XmlAttribute xmlATextContent = xmlDoc.CreateAttribute("Content"); XmlText xtTextContent = xmlDoc.CreateTextNode(xtb.Text); xmlText.Attributes.Append(xmlATextID); xmlATextID.AppendChild(xtTextID); xmlText.Attributes.Append(xmlATextX); xmlATextX.AppendChild(xtTextX); xmlText.Attributes.Append(xmlATextY); xmlATextY.AppendChild(xtTextY); xmlText.Attributes.Append(xmlATextWidth); xmlATextWidth.AppendChild(xtTextWidth); xmlText.Attributes.Append(xmlATextHeight); xmlATextHeight.AppendChild(xtTextHeight); xmlText.Attributes.Append(xmlATextContent); xmlATextContent.AppendChild(xtTextContent); xmlE.AppendChild(xmlText); } } } for (int i = 0; i < drawArea.GraphicsList.Count; i++)//查找连接线、椭圆、矩形、箭头 { o = drawArea.GraphicsList[i]; switch (o.GetType().FullName) { case "BaseControls.ImageBox.DrawTools.DrawLine": XmlElement nodeNext = (XmlElement)xmlDoc.SelectSingleNode("PatientBackImage/Image[@Name='" + imageName + "']/DrawLine[@ID='" + o.ID.ToString() + "']"); if (nodeNext != null) { nodeNext.SetAttribute("StartPointX", ((DrawLine)o).startPoint.X.ToString()); nodeNext.SetAttribute("StartPointY", ((DrawLine)o).startPoint.Y.ToString()); nodeNext.SetAttribute("EndPointX", ((DrawLine)o).endPoint.X.ToString()); nodeNext.SetAttribute("EndPointY", ((DrawLine)o).endPoint.Y.ToString()); } else { XmlElement xmlEDrawLine = xmlDoc.CreateElement("DrawLine"); XmlAttribute xmlADrawLineID = xmlDoc.CreateAttribute("ID"); XmlText xtDrawLineIDt = xmlDoc.CreateTextNode(o.ID.ToString()); XmlAttribute xmlADrawLineSartX = xmlDoc.CreateAttribute("StartPointX"); XmlText xtDrawLineStartXT = xmlDoc.CreateTextNode(((DrawLine)o).startPoint.X.ToString()); XmlAttribute xmlADrawLineSartY = xmlDoc.CreateAttribute("StartPointY"); XmlText xtDrawLineStartYT = xmlDoc.CreateTextNode(((DrawLine)o).startPoint.Y.ToString()); XmlAttribute xmlADrawLineEndX = xmlDoc.CreateAttribute("EndPointX"); XmlText xtDrawLineEndXT = xmlDoc.CreateTextNode(((DrawLine)o).endPoint.X.ToString()); XmlAttribute xmlADrawLineEndY = xmlDoc.CreateAttribute("EndPointY"); XmlText xtDrawLineEndYT = xmlDoc.CreateTextNode(((DrawLine)o).endPoint.Y.ToString()); xmlEDrawLine.Attributes.Append(xmlADrawLineID); xmlADrawLineID.AppendChild(xtDrawLineIDt); xmlEDrawLine.Attributes.Append(xmlADrawLineSartX); xmlADrawLineSartX.AppendChild(xtDrawLineStartXT); xmlEDrawLine.Attributes.Append(xmlADrawLineSartY); xmlADrawLineSartY.AppendChild(xtDrawLineStartYT); xmlEDrawLine.Attributes.Append(xmlADrawLineEndX); xmlADrawLineEndX.AppendChild(xtDrawLineEndXT); xmlEDrawLine.Attributes.Append(xmlADrawLineEndY); xmlADrawLineEndY.AppendChild(xtDrawLineEndYT); xmlE.AppendChild(xmlEDrawLine); } break; case "BaseControls.ImageBox.DrawTools.DrawRectangle": XmlElement nodeNext2 = (XmlElement)xmlDoc.SelectSingleNode("PatientBackImage/Image[@Name='" + imageName + "']/DrawRectangle[@ID='" + o.ID.ToString() + "']"); if (nodeNext2 != null) { nodeNext2.SetAttribute("X", ((DrawRectangle)o).rectangle.X.ToString()); nodeNext2.SetAttribute("Y", ((DrawRectangle)o).rectangle.Y.ToString()); nodeNext2.SetAttribute("Width", ((DrawRectangle)o).rectangle.Width.ToString()); nodeNext2.SetAttribute("Height", ((DrawRectangle)o).rectangle.Height.ToString()); } else { XmlElement xmlEDrawRectangle = xmlDoc.CreateElement("DrawRectangle"); XmlAttribute xmlADrawRectangleID = xmlDoc.CreateAttribute("ID"); XmlText xtDrawRectangleIDt = xmlDoc.CreateTextNode(o.ID.ToString()); XmlAttribute xmlADrawRectangleX = xmlDoc.CreateAttribute("X"); XmlText xtDrawRectangleXT = xmlDoc.CreateTextNode(((DrawRectangle)o).rectangle.X.ToString()); XmlAttribute xmlADrawRectangleY = xmlDoc.CreateAttribute("Y"); XmlText xtDrawRectangleYT = xmlDoc.CreateTextNode(((DrawRectangle)o).rectangle.Y.ToString()); XmlAttribute xmlADrawRectangleWidth = xmlDoc.CreateAttribute("Width"); XmlText xtDrawRectangleWidth = xmlDoc.CreateTextNode(((DrawRectangle)o).rectangle.Width.ToString()); XmlAttribute xmlADrawRectangleHeight = xmlDoc.CreateAttribute("Height"); XmlText xtDrawRectangleHeight = xmlDoc.CreateTextNode(((DrawRectangle)o).rectangle.Height.ToString()); xmlEDrawRectangle.Attributes.Append(xmlADrawRectangleID); xmlADrawRectangleID.AppendChild(xtDrawRectangleIDt); xmlEDrawRectangle.Attributes.Append(xmlADrawRectangleX); xmlADrawRectangleX.AppendChild(xtDrawRectangleXT); xmlEDrawRectangle.Attributes.Append(xmlADrawRectangleY); xmlADrawRectangleY.AppendChild(xtDrawRectangleYT); xmlEDrawRectangle.Attributes.Append(xmlADrawRectangleWidth); xmlADrawRectangleWidth.AppendChild(xtDrawRectangleWidth); xmlEDrawRectangle.Attributes.Append(xmlADrawRectangleHeight); xmlADrawRectangleHeight.AppendChild(xtDrawRectangleHeight); xmlE.AppendChild(xmlEDrawRectangle); } break; case "BaseControls.ImageBox.DrawTools.DrawEllipse": XmlElement nodeNext3 = (XmlElement)xmlDoc.SelectSingleNode("PatientBackImage/Image[@Name='" + imageName + "']/DrawEllipse[@ID='" + o.ID.ToString() + "']"); if (nodeNext3 != null) { nodeNext3.SetAttribute("X", ((DrawEllipse)o).rectangle.X.ToString()); nodeNext3.SetAttribute("Y", ((DrawEllipse)o).rectangle.Y.ToString()); nodeNext3.SetAttribute("Width", ((DrawEllipse)o).rectangle.Width.ToString()); nodeNext3.SetAttribute("Height", ((DrawEllipse)o).rectangle.Height.ToString()); } else { XmlElement xmlEDrawEllipse = xmlDoc.CreateElement("DrawEllipse"); XmlAttribute xmlADrawEllipseID = xmlDoc.CreateAttribute("ID"); XmlText xtDrawEllipseIDt = xmlDoc.CreateTextNode(o.ID.ToString()); XmlAttribute xmlADrawEllipseeX = xmlDoc.CreateAttribute("X"); XmlText xtDrawEllipseXT = xmlDoc.CreateTextNode(((DrawEllipse)o).rectangle.X.ToString()); XmlAttribute xmlADrawEllipseY = xmlDoc.CreateAttribute("Y"); XmlText xtDrawEllipseYT = xmlDoc.CreateTextNode(((DrawEllipse)o).rectangle.Y.ToString()); XmlAttribute xmlADrawEllipseWidth = xmlDoc.CreateAttribute("Width"); XmlText xtDrawEllipseWidth = xmlDoc.CreateTextNode(((DrawEllipse)o).rectangle.Width.ToString()); XmlAttribute xmlADrawEllipseHeight = xmlDoc.CreateAttribute("Height"); XmlText xtDrawEllipseHeight = xmlDoc.CreateTextNode(((DrawEllipse)o).rectangle.Height.ToString()); xmlEDrawEllipse.Attributes.Append(xmlADrawEllipseID); xmlADrawEllipseID.AppendChild(xtDrawEllipseIDt); xmlEDrawEllipse.Attributes.Append(xmlADrawEllipseeX); xmlADrawEllipseeX.AppendChild(xtDrawEllipseXT); xmlEDrawEllipse.Attributes.Append(xmlADrawEllipseY); xmlADrawEllipseY.AppendChild(xtDrawEllipseYT); xmlEDrawEllipse.Attributes.Append(xmlADrawEllipseWidth); xmlADrawEllipseWidth.AppendChild(xtDrawEllipseWidth); xmlEDrawEllipse.Attributes.Append(xmlADrawEllipseHeight); xmlADrawEllipseHeight.AppendChild(xtDrawEllipseHeight); xmlE.AppendChild(xmlEDrawEllipse); } break; case "BaseControls.ImageBox.DrawTools.DrawPoint": XmlElement nodeNext4 = (XmlElement)xmlDoc.SelectSingleNode("PatientBackImage/Image[@Name='" + imageName + "']/DrawPoint[@ID='" + o.ID.ToString() + "']"); if (nodeNext4 != null) { nodeNext4.SetAttribute("X", ((DrawPoint)o).Point.X.ToString()); nodeNext4.SetAttribute("Y", ((DrawPoint)o).Point.Y.ToString()); } else { XmlElement xmlEDrawPoint = xmlDoc.CreateElement("DrawPoint"); XmlAttribute xmlADrawPointID = xmlDoc.CreateAttribute("ID"); XmlText xtDrawPointIDt = xmlDoc.CreateTextNode(o.ID.ToString()); XmlAttribute xmlADrawPointX = xmlDoc.CreateAttribute("X"); XmlText xtDrawPointXT = xmlDoc.CreateTextNode(((DrawPoint)o).Point.X.ToString()); XmlAttribute xmlADrawPointY = xmlDoc.CreateAttribute("Y"); XmlText xtDrawPointYT = xmlDoc.CreateTextNode(((DrawPoint)o).Point.Y.ToString()); xmlEDrawPoint.Attributes.Append(xmlADrawPointID); xmlADrawPointID.AppendChild(xtDrawPointIDt); xmlEDrawPoint.Attributes.Append(xmlADrawPointX); xmlADrawPointX.AppendChild(xtDrawPointXT); xmlEDrawPoint.Attributes.Append(xmlADrawPointY); xmlADrawPointY.AppendChild(xtDrawPointYT); xmlE.AppendChild(xmlEDrawPoint); } break; case "BaseControls.ImageBox.DrawTools.DrawPolygon": XmlElement nodeNext5 = (XmlElement)xmlDoc.SelectSingleNode("PatientBackImage/Image[@Name='" + imageName + "']/DrawPolygon[@ID='" + o.ID.ToString() + "']"); if (nodeNext5 != null) { nodeNext5.SetAttribute("StartPointX", ((DrawPolygon)o).startPoint.X.ToString()); nodeNext5.SetAttribute("StartPointY", ((DrawPolygon)o).startPoint.Y.ToString()); nodeNext5.SetAttribute("EndPointX", ((DrawPolygon)o).endPoint.X.ToString()); nodeNext5.SetAttribute("EndPointX", ((DrawPolygon)o).endPoint.Y.ToString()); Point p = new Point(); string pointStr = "$"; for (int j = 0; j < ((DrawPolygon)o).pointArray.Count; j++) { p = ((DrawPolygon)o).pointArray[j]; pointStr = pointStr + p.X + "," + p.Y + "$"; } nodeNext5.SetAttribute("pointStr", pointStr); } else { XmlElement xmlEDrawPolygon = xmlDoc.CreateElement("DrawPolygon"); XmlAttribute xmlADrawPolygonID = xmlDoc.CreateAttribute("ID"); XmlText xtDrawPolygonIDt = xmlDoc.CreateTextNode(o.ID.ToString()); XmlAttribute xmlADrawPolygonSartX = xmlDoc.CreateAttribute("StartPointX"); XmlText xtDrawPolygonStartXT = xmlDoc.CreateTextNode(((DrawPolygon)o).startPoint.X.ToString()); XmlAttribute xmlADrawPolygonSartY = xmlDoc.CreateAttribute("StartPointY"); XmlText xtDrawPolygonStartYT = xmlDoc.CreateTextNode(((DrawPolygon)o).startPoint.Y.ToString()); XmlAttribute xmlADrawPolygonEndX = xmlDoc.CreateAttribute("EndPointX"); XmlText xtDrawPolygonEndXT = xmlDoc.CreateTextNode(((DrawPolygon)o).endPoint.X.ToString()); XmlAttribute xmlADrawPolygonEndY = xmlDoc.CreateAttribute("EndPointY"); XmlText xtDrawPolygonEndYT = xmlDoc.CreateTextNode(((DrawPolygon)o).endPoint.Y.ToString()); XmlAttribute xmlADrawPloygonPoint = xmlDoc.CreateAttribute("pointStr"); Point p = new Point(); string pointStr = "$"; for (int j = 0; j < ((DrawPolygon)o).pointArray.Count; j++) { p = ((DrawPolygon)o).pointArray[j]; pointStr = pointStr + p.X + "," + p.Y + "$"; } XmlText xtDrawPloygonPoint = xmlDoc.CreateTextNode(pointStr); xmlEDrawPolygon.Attributes.Append(xmlADrawPolygonID); xmlADrawPolygonID.AppendChild(xtDrawPolygonIDt); xmlEDrawPolygon.Attributes.Append(xmlADrawPolygonSartX); xmlADrawPolygonSartX.AppendChild(xtDrawPolygonStartXT); xmlEDrawPolygon.Attributes.Append(xmlADrawPolygonSartY); xmlADrawPolygonSartY.AppendChild(xtDrawPolygonStartYT); xmlEDrawPolygon.Attributes.Append(xmlADrawPolygonEndX); xmlADrawPolygonEndX.AppendChild(xtDrawPolygonEndXT); xmlEDrawPolygon.Attributes.Append(xmlADrawPolygonEndY); xmlADrawPolygonEndY.AppendChild(xtDrawPolygonEndYT); xmlEDrawPolygon.Attributes.Append(xmlADrawPloygonPoint); xmlADrawPloygonPoint.AppendChild(xtDrawPloygonPoint); xmlE.AppendChild(xmlEDrawPolygon); } break; } } XmlNode xn = xmlDoc.SelectSingleNode("PatientBackImage"); xn.AppendChild(xmlE); xmlDoc.Save(XmlPath); return(xmlE.InnerXml); }