/// <summary> /// 窗口加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks>先提取坐标变换的斜率及截距;再从监测点编号与其对应的坐标创建树形列表</remarks> public void FrmTreeView_Load(object sender, EventArgs e) { //blnHasLoaded是为了解决showdialog在每次加载窗口时都触发一次load事件的问题。 if (!blnHasLoaded) { try { // ------------------ 提取坐标变换的斜率及截距 Microsoft.Office.Interop.Visio.Shape CP1 = default(Microsoft.Office.Interop.Visio.Shape); Microsoft.Office.Interop.Visio.Shape CP2 = default(Microsoft.Office.Interop.Visio.Shape); CP1 = this.F_PaintingPage.Page.Shapes.ItemFromID(F_MonitorPointsInfo.pt_Visio_BottomLeft_ShapeID); CP2 = this.F_PaintingPage.Page.Shapes.ItemFromID(F_MonitorPointsInfo.pt_Visio_UpRight_ShapeID); //visio中的坐标以inch为单位 double xp1 = 0; double yp1 = 0; double xp2 = 0; double yp2 = 0; //x,y,xp,yp都是以inch为单位的 double x = 0; double y = 0; x = System.Convert.ToDouble(CP1.Cells("LocPinX").Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visInches)); y = System.Convert.ToDouble(CP1.Cells("LocPinY").Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visInches)); CP1.XYToPage(x, y, ref xp1, ref yp1); x = System.Convert.ToDouble(CP2.Cells("LocPinX").Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visInches)); y = System.Convert.ToDouble(CP2.Cells("LocPinY").Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visInches)); CP2.XYToPage(x, y, ref xp2, ref yp2); ConversionParameter = GeneralMethods.Coordinate_Conversion(this.F_MonitorPointsInfo.pt_CAD_BottomLeft.X, this.F_MonitorPointsInfo.pt_CAD_BottomLeft.Y, this.F_MonitorPointsInfo.pt_CAD_UpRight.X, this.F_MonitorPointsInfo.pt_CAD_UpRight.Y, xp1, yp1, xp2, yp2); //从监测点编号与其对应的坐标创建树形列表 constructTreeView(F_wkshtPoints, TreeViewPoints); //标记:此窗口已经在主程序中加载过,后面就不用再加载了。因为不会对其进行close,只会将其隐藏 blnHasLoaded = true; } catch (Exception ex) { MessageBox.Show("不能正确地提取监测点位信息。" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Exit Sub //Me.Close() this.Dispose(); } } }