public System.Windows.Forms.Form CreateOffsetModelDialog(IHeadsApplication app) { Offset.FormOffset formoffset = null; //Only one polyline object is selected IHdEntity[] selections = app.ActiveDocument.GetUserSelection(Resources.ST_PROMPT_SELECT_POLYLINE); IHdPolyline3D polyline = null; if (selections.Length == 1) { IHdEntity entity = selections[0]; //DictionaryEntry de = selections[0]; if (entity.EntityName == "POLYLINE3D") { polyline = (IHdPolyline3D)entity; } } if (polyline != null) { formoffset = new Offset.FormOffset(app, polyline); } else { MessageBox.Show(Resources.ST_PROMPT_SELECT_POLYLINE, HeadsUtils.Constants.ProductName); } return(formoffset); }
public System.Windows.Forms.Form CreateBoundaryDialog(IHeadsApplication app, bool bMakeString) { MakeString.FormMakeString formmakestring = null; //Only one polyline object is selected IHdEntity[] selections = app.ActiveDocument.GetUserSelection(Resources.ST_PROMPT_SELECT_POLYLINE); IHdPolyline3D polyline = null; if (selections.Length == 1) { IHdEntity entity = selections[0]; //DictionaryEntry de = selections[0]; if (entity.EntityName == "POLYLINE3D") { polyline = (IHdPolyline3D)entity; } } if (polyline != null) { MakeString.FormMakeString.OpenMode mode = (bMakeString == true) ? MakeString.FormMakeString.OpenMode.MakeString : HeadsFunctions1.MakeString.FormMakeString.OpenMode.Boundary; formmakestring = new MakeString.FormMakeString(app, polyline, mode); } else { MessageBox.Show(Resources.ST_PROMPT_SELECT_POLYLINE, HeadsUtils.Constants.ProductName); } return(formmakestring); }
public System.Windows.Forms.Form CreateNewHalignHIPMethodDialog(IHeadsApplication app) { FormHipMethod formhipmethod = null; IHdEntity[] selections = app.ActiveDocument.GetUserSelection(Resources.ST_PROMPT_SELECT_POLYLINE); IHdPolyline3D polyline = null; if (selections.Length == 1) { IHdEntity entity = selections[0]; //DictionaryEntry de = selections[0]; if (entity.EntityName == "POLYLINE3D") { polyline = (IHdPolyline3D)entity; } } if (polyline != null) { formhipmethod = new FormHipMethod(app, polyline); } else { MessageBox.Show(Resources.ST_PROMPT_SELECT_POLYLINE, HeadsUtils.Constants.ProductName); } return(formhipmethod); }
private static void SetLayerToEntity(bool bEngFunc, IHdEntity hdEntity, IHeadsDocument doc, string strLayerName) { if (bEngFunc) { hdEntity.SetLayer(doc.GetActiveLayer()); } else { if (strLayerName.Trim() != string.Empty) { IHdLayer hdlayer = doc.AddLayer(strLayerName); hdEntity.SetLayer(hdlayer); } } }
void ApplyValign() { if (this.ValidateData()) { this.app.ActiveDocument.ConfigParam.XMetric = 1; this.app.ActiveDocument.ConfigParam.YMetric = 10; CCfgtype cfg = new CCfgtype(); this.app.ActiveDocument.ConfigParam.CopyTo(cfg); IHdEntity entity = this.app.ActiveDocument.GetObjectById(this.LastAppliedPolyLineID); if (entity != null) { entity.Erase(); } //Erase the selected polyline on screen //this is because user may modify the X, Y //co-ordinates using this dialog entity = this.app.ActiveDocument.GetObjectById(this.MainPolyLineID); if (entity != null) { entity.Erase(); } List <VVIP> listParams = GetParamData(); List <CPoint3D> polypts = new List <CPoint3D>(); foreach (VVIP vdata in listParams) { polypts.Add(new CPoint3D(vdata.chainx * cfg.XMetric, vdata.chainy * cfg.YMetric, 0)); } this.MainPolyLineID = this.app.ActiveDocument.DrawPolyline3D(polypts).ObjectID; this.WriteDataFile(); ViewerUtils.DeleteFileIfExists(Path.Combine(this.app.AppDataPath, "VAL2.TMP")); CValignUtil util = new CValignUtil(); if (util.Funcmain(this.app.AppDataPath)) { DrawingUtil.DrawData(this.app, Path.Combine(this.app.AppDataPath, "VAL2.TMP"), "PVR", true); } this.app.ActiveDocument.RefreshDocument(); } }
public void AcceptLayout(IHeadsApplication app) { if (this.LastAppliedLayout != null && this.LastAppliedLayoutID != 0) { IHdEntity entity = app.ActiveDocument.GetObjectById(this.LastAppliedLayoutID); if (entity != null && entity.EntityName == "POLYLINE3D") { IHdPolyline3D polyline = (IHdPolyline3D)entity; CPoint3D[] cords = polyline.Coordinates; CPoint3D pt1 = null; CPoint3D pt2 = null; if (cords.Length > 7) { pt1 = cords[0]; pt2 = cords[1]; this.LastAppliedLayout.angle = ViewerUtils.GetAngle(pt1, pt2, false); pt1 = cords[5]; this.LastAppliedLayout.startX = pt1.X; this.LastAppliedLayout.startY = pt1.Y; StreamWriter sw = new StreamWriter(Path.Combine(app.AppDataPath, "Layout.fil"), true); string strTemp = string.Format("{0:f3} {1:f3} {2:f3} {3:f3} {4:f3} {5:f3} {6:f3} {7:f3} {8:f3} {9:f3} " , this.LastAppliedLayout.startX , this.LastAppliedLayout.startY , this.LastAppliedLayout.angle , this.LastAppliedLayout.sheetWidth , this.LastAppliedLayout.sheetLength , this.LastAppliedLayout.layOutScale , this.LastAppliedLayout.bottomM , this.LastAppliedLayout.rightM , this.LastAppliedLayout.topM , this.LastAppliedLayout.leftM); sw.WriteLine(strTemp); sw.Close(); } } //this.LastAppliedLayout = null; this.LastAppliedLayoutID = 0; } }
void Cancel() { int loop = nTotED; while (loop > 0) { loop--; IHdEntity entity = this.m_app.ActiveDocument.GetObjectById(carED[loop].npLineID); if (entity != null) { entity.Erase(); } } // delete halign.tmp ViewerUtils.DeleteFileIfExists(Path.Combine(this.m_app.AppDataPath, "halign.tmp")); if (System.IO.File.Exists(Path.Combine(this.m_app.AppDataPath, "~halign.fil"))) { // delete truncated halign.fil ViewerUtils.DeleteFileIfExists(Path.Combine(this.m_app.AppDataPath, "halign.fil")); ViewerUtils.RenameFile(Path.Combine(this.m_app.AppDataPath, "~halign.fil"), "halign.fil"); } }
private void ApplyHIP() { this.m_app.ActiveDocument.ConfigParam.XMetric = 1; this.m_app.ActiveDocument.ConfigParam.YMetric = 1; //Delete existing hip line IHdEntity entity = this.m_app.ActiveDocument.GetObjectById(this.m_iLastAppliedPolyLine); if (entity != null) { entity.Erase(); } //Erase the selected polyline on screen //this is because user may modify the X, Y //co-ordinates using this dialog entity = this.m_app.ActiveDocument.GetObjectById(this.m_iMainPolyLine); if (entity != null) { List <CHHipData> listLinedata = new List <CHHipData>(); GetPolylineDetails((IHdPolyline3D)entity, ref listLinedata); int temCount = this.dtParams.Rows.Count; for (int iCnt = 0; iCnt < temCount; iCnt++) { CHHipData hdata = listLinedata[iCnt]; this.dtParams.Rows[iCnt][FormHipMethod.ColNameXValue] = hdata.xvalue; this.dtParams.Rows[iCnt][FormHipMethod.ColNameYValue] = hdata.yvalue; } UpdateDeltaValue(); entity.Erase(); } //Redraw the polyline List <CPoint3D> listPt = new List <CPoint3D>(); for (int iCnt = 0; iCnt < this.dtParams.Rows.Count; iCnt++) { CHHipData data = this.GetRow(iCnt); listPt.Add(new CPoint3D(data.xvalue, data.yvalue, 0)); } this.m_iMainPolyLine = this.m_app.ActiveDocument.DrawPolyline3D(listPt).ObjectID; //Refresh the document this.m_app.ActiveDocument.RefreshDocument(); List <CHHipData> listHips = new List <CHHipData>(); for (int iCnt = 0; iCnt < this.dtParams.Rows.Count; iCnt++) { listHips.Add(this.GetRow(iCnt)); } CHalFile filedata = new CHalFile(); filedata.Code = 1; filedata.AcceptCode = 0; filedata.ModelName = this.txtModelName_.Text.Trim(); filedata.StringLevel = this.txtStringlabel_.Text.Trim(); filedata.StartChainage = this.txtStartInterval_.Value; filedata.ChainageInterval = this.txtChainageInterval_.Value; filedata.ListHip = listHips; string strHipFilePath = Path.Combine(m_app.AppDataPath, "HAL1.tmp"); CHalignHipUtil util = new CHalignHipUtil(); if (util.WriteHIPFile(strHipFilePath, filedata)) { //Delete HAL2.TEMP string strHAL2TmpPath = Path.Combine(m_app.AppDataPath, "HAL2.tmp"); ViewerUtils.DeleteFileIfExists(strHAL2TmpPath); //try { if (util.FuncMain(this.m_app.AppDataPath) == true) { this.m_iLastAppliedPolyLine = DrawingUtil.DrawData(this.m_app, strHAL2TmpPath, "PVR", true); this.m_app.ActiveDocument.RefreshDocument(); //this.m_app.ZoomExtents(); } } //catch (Exception ex) //{ // MessageBox.Show(this, ex.ToString(), "ERROR!" // , MessageBoxButtons.OK // , MessageBoxIcon.Error); // System.Diagnostics.Trace.Write(ex.ToString()); //} } else { MessageBox.Show(this , "Failed to generate HIP file" , Resources.ST_ERROR_MSGBOX_CAPTION , MessageBoxButtons.OK , MessageBoxIcon.Error); } this.ShowDetails(checkBoxShowDetails_.Checked); }
public void ApplyLayout(IHeadsApplication app) { if (this.LastAppliedLayoutID != 0) { if (MessageBox.Show("Last applied layout not accepted.\nDo you want to cancel the last applied layout?" , "Layout", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } //this.LastAppliedLayout = null; if (this.LastAppliedLayoutID != 0) { IHdEntity entity = app.ActiveDocument.GetObjectById(this.LastAppliedLayoutID); if (entity != null) { entity.Erase(); app.ActiveDocument.RefreshDocument(); } this.LastAppliedLayoutID = 0; } Layout.FormLayout formlayout = new Layout.FormLayout(); if (this.LastAppliedLayout != null) { formlayout.SelectedLayout = this.LastAppliedLayout; } if (formlayout.ShowDialog() == DialogResult.OK) { CPoint3D ptBottomLeft = app.ActiveDocument.GetUserPoint("Select the bottom-left edge to place the sheet"); if (ptBottomLeft != null) { this.LastAppliedLayout = formlayout.SelectedLayout; CCfgtype cfg = app.ActiveDocument.ConfigParam; double ActualHeight; double ActualWidth; double x2, y2, x11, y11, x22, y22; double x = ptBottomLeft.X; double y = ptBottomLeft.Y; double Xpos = x * cfg.XMetric; double Ypos = y * cfg.YMetric; ActualHeight = this.LastAppliedLayout.sheetLength * (this.LastAppliedLayout.layOutScale / 1000.00); ActualWidth = this.LastAppliedLayout.sheetWidth * (this.LastAppliedLayout.layOutScale / 1000.00); x2 = Xpos + ActualWidth; y2 = Ypos + ActualHeight; x11 = Xpos + this.LastAppliedLayout.leftM * (this.LastAppliedLayout.layOutScale / 1000.00); y11 = Ypos + this.LastAppliedLayout.bottomM * (this.LastAppliedLayout.layOutScale / 1000.00); x22 = x2 - this.LastAppliedLayout.rightM * (this.LastAppliedLayout.layOutScale / 1000.00); y22 = y2 - this.LastAppliedLayout.topM * (this.LastAppliedLayout.layOutScale / 1000.00); this.LastAppliedLayoutID = AddPolyLineLayout(app, Xpos, Ypos, x2, y2, x11, y11, x22, y22); app.ActiveDocument.RefreshDocument(); } } }
void ApplyData() { if (this.txtModelName_.Text.Trim() == "" || this.txtStringlabel_.Text.Trim() == "") { MessageBox.Show("Input Model Name and String Level" , Resources.ST_ERROR_MSGBOX_CAPTION , System.Windows.Forms.MessageBoxButtons.OK , System.Windows.Forms.MessageBoxIcon.Information); return; } else { if (this.txtModelName_.ReadOnly == false) { string strHalignFilFilePath = System.IO.Path.Combine(this.m_app.AppDataPath, "HALIGN.FIL"); CHIPInfo[] infoarr = CHalignHipUtil.ReadHaligns(strHalignFilFilePath); foreach (CHIPInfo info in infoarr) { if (info.ModelName.Trim().ToLower() == this.txtModelName_.Text.Trim().ToLower() && info.StringLabel.Trim().ToLower() == this.txtStringlabel_.Text.Trim().ToLower()) { MessageBox.Show("Model Name and String Level already exists\nPlease specify unique Model Name and String Level" , Resources.ST_ERROR_MSGBOX_CAPTION , System.Windows.Forms.MessageBoxButtons.OK , System.Windows.Forms.MessageBoxIcon.Information); return; } } } } this.Cursor = System.Windows.Forms.Cursors.WaitCursor; this.btnSaveFinish_.Enabled = false; ViewerUtils.DeleteFileIfExists(System.IO.Path.Combine(this.m_app.AppDataPath, "halign.tmp")); int loop = nTotED; while (loop > 0) { loop--; //Delete existing hip line IHdEntity entity = this.m_app.ActiveDocument.GetObjectById(carED[loop].npLineID); if (entity != null) { entity.Erase(); } } CHalignElementUtil code = new CHalignElementUtil(); for (loop = 0; loop < ElementNo - 1; loop++) { ViewerUtils.DeleteFileIfExists(System.IO.Path.Combine(this.m_app.AppDataPath, "HAL2.TMP")); code.Funcmain(this.m_app.AppDataPath, 2, 1, this.txtModelName_.Text, this.txtStringlabel_.Text , (short)carED[loop].nElementNo, (short)carED[loop].nType, carED[loop].dStartChain , carED[loop].dChainInterval, carED[loop].dXvalue, carED[loop].dYvalue , carED[loop].dBearings, carED[loop].dLength, carED[loop].dRadius); this.m_iLastAppliedPolyLine = DrawingUtil.DrawData(this.m_app, System.IO.Path.Combine(this.m_app.AppDataPath, "HAL2.TMP"), "ELE", true); carED[loop].npLineID = this.m_iLastAppliedPolyLine; } //end for ViewerUtils.DeleteFileIfExists(Path.Combine(this.m_app.AppDataPath, "HAL2.TMP")); //writes hal2.tmp, appends halign.tmp code.Funcmain(this.m_app.AppDataPath, 2, 1, this.txtModelName_.Text, this.txtStringlabel_.Text , (short)ElementNo, this.SelectedElementType, this.txtStartInterval_.Value , this.txtChainageInterval_.Value, this.txtXVal_.Value, this.txtYVal_.Value , this.txtWCBearings_.Value, this.txtLength_.Value, this.txtRadius_.Value); this.m_iLastAppliedPolyLine = DrawingUtil.DrawData(this.m_app, Path.Combine(this.m_app.AppDataPath, "HAL2.TMP"), "ELE", true); GetDlgED((ElementNo - 1), (int)this.SelectedElementType, this.m_iLastAppliedPolyLine); nTotED = ElementNo; // AcceptCode = 1; ElementNo = ElementNo + 1; this.StartEleNo = ElementNo; this.txtXVal_.Value = code.xe; this.txtYVal_.Value = code.ye; this.txtWCBearings_.Value = code.b2; this.txtStartInterval_.Value += this.txtLength_.Value; this.TotalEleDrawn = nTotED; lastED.dXvalue = code.xe; lastED.dYvalue = code.ye; lastED.dBearings = code.b2; lastED.dChainInterval = this.txtChainageInterval_.Value; lastED.dStartChain = this.txtStartInterval_.Value; lastED.nType = (int)this.SelectedElementType; lastED.dLength = this.txtLength_.Value; lastED.dRadius = this.txtRadius_.Value; lastED.nElementNo = ElementNo; this.m_app.ActiveDocument.RefreshDocument(); this.btnSaveFinish_.Enabled = true; this.Cursor = System.Windows.Forms.Cursors.Default; }