コード例 #1
0
 //导出
 /// <summary>
 /// 将测点的绘制与定位数据保存到xml文档的某节点中。
 /// </summary>
 /// <param name="xmlParent"></param>
 /// <param name="Pointinfos"></param>
 /// <remarks></remarks>
 private void ExportToXmlFile(XmlElement xmlParent, MonitorPointsInformation Pointinfos)
 {
     try
     {
         XmlDocument Doc = xmlParent.OwnerDocument;
         MonitorPointsInformation with_1 = Pointinfos;
         //
         XmlElement Nd_ShapeName_MonitorPointTag   = default(XmlElement);
         XmlElement Nd_pt_CAD_BottomLeft_X         = default(XmlElement);
         XmlElement Nd_pt_CAD_BottomLeft_Y         = default(XmlElement);
         XmlElement Nd_pt_CAD_UpRight_X            = default(XmlElement);
         XmlElement Nd_pt_CAD_UpRight_Y            = default(XmlElement);
         XmlElement Nd_pt_Visio_BottomLeft_ShapeID = default(XmlElement);
         XmlElement Nd_pt_Visio_UpRight_ShapeID    = default(XmlElement);
         //
         Nd_ShapeName_MonitorPointTag = xmlParent.SelectSingleNode(Nd2_ShapeName_MonitorPointTag);
         bool blnHasChildNode = false;
         if (Nd_ShapeName_MonitorPointTag != null)
         {
             blnHasChildNode = true;
         }
         //后面认为:如果节点中没有子节点“ShapeName_MonitorPointTag”,则没有其他的子节点;
         //而如果有此节点, 则认为其他的子节点也都存在
         if (blnHasChildNode)
         {
             Nd_pt_CAD_BottomLeft_X         = xmlParent.SelectSingleNode(Nd2_pt_CAD_BottomLeft_X);
             Nd_pt_CAD_BottomLeft_Y         = xmlParent.SelectSingleNode(Nd2_pt_CAD_BottomLeft_Y);
             Nd_pt_CAD_UpRight_X            = xmlParent.SelectSingleNode(Nd2_pt_CAD_UpRight_X);
             Nd_pt_CAD_UpRight_Y            = xmlParent.SelectSingleNode(Nd2_pt_CAD_UpRight_Y);
             Nd_pt_Visio_BottomLeft_ShapeID = xmlParent.SelectSingleNode(Nd2_pt_Visio_BottomLeft_ShapeID);
             Nd_pt_Visio_UpRight_ShapeID    = xmlParent.SelectSingleNode(Nd2_pt_Visio_UpRight_ShapeID);
         }
         else
         {
             Nd_ShapeName_MonitorPointTag   = xmlParent.AppendChild(Doc.CreateElement(Nd2_ShapeName_MonitorPointTag));
             Nd_pt_CAD_BottomLeft_X         = xmlParent.AppendChild(Doc.CreateElement(Nd2_pt_CAD_BottomLeft_X));
             Nd_pt_CAD_BottomLeft_Y         = xmlParent.AppendChild(Doc.CreateElement(Nd2_pt_CAD_BottomLeft_Y));
             Nd_pt_CAD_UpRight_X            = xmlParent.AppendChild(Doc.CreateElement(Nd2_pt_CAD_UpRight_X));
             Nd_pt_CAD_UpRight_Y            = xmlParent.AppendChild(Doc.CreateElement(Nd2_pt_CAD_UpRight_Y));
             Nd_pt_Visio_BottomLeft_ShapeID = xmlParent.AppendChild(Doc.CreateElement(Nd2_pt_Visio_BottomLeft_ShapeID));
             Nd_pt_Visio_UpRight_ShapeID    = xmlParent.AppendChild(Doc.CreateElement(Nd2_pt_Visio_UpRight_ShapeID));
         }
         Nd_ShapeName_MonitorPointTag.InnerText   = with_1.ShapeName_MonitorPointTag;
         Nd_pt_CAD_BottomLeft_X.InnerText         = System.Convert.ToString(with_1.pt_CAD_BottomLeft.X);
         Nd_pt_CAD_BottomLeft_Y.InnerText         = System.Convert.ToString(with_1.pt_CAD_BottomLeft.Y);
         Nd_pt_CAD_UpRight_X.InnerText            = System.Convert.ToString(with_1.pt_CAD_UpRight.X);
         Nd_pt_CAD_UpRight_Y.InnerText            = System.Convert.ToString(with_1.pt_CAD_UpRight.Y);
         Nd_pt_Visio_BottomLeft_ShapeID.InnerText = System.Convert.ToString(with_1.pt_Visio_BottomLeft_ShapeID);
         Nd_pt_Visio_UpRight_ShapeID.InnerText    = System.Convert.ToString(with_1.pt_Visio_UpRight_ShapeID);
         //
     }
     catch (Exception ex)
     {
         MessageBox.Show("导出到文件出错。" + "\r\n" + ex.Message + "\r\n" + "报错位置:" +
                         ex.TargetSite.Name, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
        //导入
        /// <summary>
        /// 从项目文件中导入测点的数据
        /// </summary>
        /// <param name="Path_xmlDocFile"></param>
        /// <remarks></remarks>
        private void ImportFromXmlFile(string Path_xmlDocFile)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(Path_xmlDocFile);
            //
            XmlElement eleRoot   = (XmlElement)(xmlDoc.SelectSingleNode(System.Convert.ToString(My.Settings.Default.ProjectName)));
            XmlElement ElePtInfo = (XmlElement)(eleRoot.SelectSingleNode(Nd1_MonitorPoints));

            if (ElePtInfo != null)
            {
                this.MonitorPointinfos = ImportFromXmlElement(ElePtInfo);
            }
            else
            {
                MessageBox.Show("项目文件中没有监测点位布置信息的数据");
            }
            //
            PointsInfoToUI(this.MonitorPointinfos);
        }
コード例 #3
0
            /// <summary>
            /// 构造函数
            /// </summary>
            /// <param name="strFilePath">要打开的Visio文档的绝对路径</param>
            /// <param name="type">Visio平面图所属的绘图类型</param>
            /// <param name="PageName_PlanView">开挖平面图在Visio中的页面名称</param>
            /// <param name="ShapeID_AllRegions">所有分区的组合形状的ID值</param>
            /// <param name="InfoBoxID">记录开挖信息的文本框</param>
            /// <remarks></remarks>
            public ClsDrawing_PlanView(string strFilePath, DrawingType type, string PageName_PlanView, int ShapeID_AllRegions, int InfoBoxID, bool HasMonitorPointsInfo, MonitorPointsInformation MonitorPointsInfo)
            {
                //开挖平面图信息
                this.F_PageName_PlanView  = PageName_PlanView;
                this.F_ShapeID_AllRegions = ShapeID_AllRegions;
                this.F_InfoBoxID          = InfoBoxID;
                //监测点位信息
                this.P_HasMonitorPointsInfo = HasMonitorPointsInfo;
                this.P_MonitorPointsInfo    = MonitorPointsInfo;
                //
                this.P_ShapeID_FinishedDate = GlobalApplication.Application.DataBase.ShapeIDAndFinishedDate;

                this.F_BackgroundWorker.WorkerReportsProgress      = true;
                this.F_BackgroundWorker.WorkerSupportsCancellation = true;
                //开始绘图
                if (!this.F_BackgroundWorker.IsBusy)
                {
                    //在工作线程中执行绘图操作
                    this.F_BackgroundWorker.RunWorkerAsync(new[] { strFilePath, type });
                }
            }
コード例 #4
0
        /// <summary>
        /// 从xml的节点中导入其子节点中保存的数据
        /// </summary>
        /// <param name="EleParent"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        private MonitorPointsInformation ImportFromXmlElement(XmlElement EleParent)
        {
            MonitorPointsInformation PointsInfo = new MonitorPointsInformation();

            try
            {
                PointsInfo.ShapeName_MonitorPointTag   = EleParent.SelectSingleNode(Nd2_ShapeName_MonitorPointTag).InnerText;
                PointsInfo.pt_Visio_BottomLeft_ShapeID = (int)(EleParent.SelectSingleNode(Nd2_pt_Visio_BottomLeft_ShapeID).InnerText);
                PointsInfo.pt_Visio_UpRight_ShapeID    = (int)(EleParent.SelectSingleNode(Nd2_pt_Visio_UpRight_ShapeID).InnerText);
                PointsInfo.pt_CAD_BottomLeft           = new PointF(float.Parse(EleParent.SelectSingleNode(Nd2_pt_CAD_BottomLeft_X).InnerText), float.Parse(
                                                                        EleParent.SelectSingleNode(Nd2_pt_CAD_BottomLeft_Y).InnerText));
                PointsInfo.pt_CAD_UpRight = new PointF(System.Convert.ToSingle(EleParent.SelectSingleNode(Nd2_pt_CAD_UpRight_X).InnerText), System.Convert.ToSingle(
                                                           EleParent.SelectSingleNode(Nd2_pt_CAD_UpRight_Y).InnerText));
            }
            catch (Exception ex)
            {
                MessageBox.Show("从文件导入出错" + "\r\n" + ex.Message + "\r\n" + "报错位置:" +
                                ex.TargetSite.Name, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(PointsInfo);
        }
コード例 #5
0
        public void Btn_Export_Click(object sender, EventArgs e)
        {
            XmlDocument xmlDoc = new XmlDocument();

            if (this.ProjectFilePath == null)
            {
                //用打开文件对话框选择 .ame 项目文件
            }
            xmlDoc.Load(this.ProjectFilePath);
            XmlElement eleRoot   = (XmlElement)(xmlDoc.SelectSingleNode(System.Convert.ToString(My.Settings.Default.ProjectName)));
            XmlElement ElePtInfo = (XmlElement)(eleRoot.SelectSingleNode(Nd1_MonitorPoints));

            if (ElePtInfo == null)
            {
                ElePtInfo = eleRoot.AppendChild(xmlDoc.CreateElement(Nd1_MonitorPoints));
            }
            //
            this.MonitorPointinfos = UIToPointsInfo();
            ExportToXmlFile(ElePtInfo, this.MonitorPointinfos);
            //
            xmlDoc.Save(this.ProjectFilePath);
            MessageBox.Show("导出到项目文件成功!", "Congratulations", MessageBoxButtons.OK, MessageBoxIcon.None);
        }