コード例 #1
0
        void SaveAndFinish()
        {
            CHalignElementUtil.SaveHalign(this.m_app.AppDataPath);

            // delete halign.tmp
            ViewerUtils.DeleteFileIfExists(System.IO.Path.Combine(this.m_app.AppDataPath, "halign.tmp"));
            ViewerUtils.RenameFile(System.IO.Path.Combine(this.m_app.AppDataPath, "~halign.fil"), "~*halign.fil");
        }
コード例 #2
0
        private void btnFinish__Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;

            CValignUtil.SaveValign(this.app.AppDataPath);

            ViewerUtils.DeleteFileIfExists(Path.Combine(this.app.AppDataPath, "VALIGN.TMP"));
            this.Close();
        }
コード例 #3
0
        private void btnOk__Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                CBox boundbox = this.hdapp.ActiveDocument.BoundingBox;
                if (boundbox != null)
                {
                    //Delete the existing
                    //ViewerUtils.DeleteEntitiesByLabel(this.hdapp.ActiveDocument, HeadsUtils.Constants.LABEL_DETAILS, false);

                    HeadsUtils.Detail Det = new Detail();
                    double            z   = 0.0;
                    Det.XMin       = boundbox.TopLeft.X;
                    Det.YMin       = boundbox.TopLeft.Y;
                    z              = boundbox.TopLeft.Z;
                    Det.ModelName  = this.SelectedModelName;
                    Det.StringName = this.SelectedStringLabel;
                    Det.TextSize   = this.tbTextSize_.Value;
                    Det.Rotation   = 0;
                    //For Halign Details1 to Details2
                    //For Valign Details2 to Details1
                    //string strFileName = (this.IsValign == false) ? "DETAILS1.TMP" : "DETAILS2.TMP";
                    string       PathName = Path.Combine(this.hdapp.AppDataPath, "DETAILS1.TMP");
                    BinaryWriter bw       = new BinaryWriter(new FileStream(PathName, FileMode.Create), Encoding.Default);
                    Det.ToStream(bw);
                    bw.Close();

                    string strDetailsOutFile = Path.Combine(this.hdapp.AppDataPath, "DETAILS2.TMP");
                    ViewerUtils.DeleteFileIfExists(strDetailsOutFile);

                    if (this.IsValign == false)
                    {
                        CDetailsHalignUtil util = new CDetailsHalignUtil();
                        util.Funcmain(this.hdapp.AppDataPath);
                    }
                    else
                    {
                        CDetailsValignUtil util = new CDetailsValignUtil();
                        util.Funcmain(this.hdapp.AppDataPath, this.hdapp.ActiveDocument.ConfigParam);
                    }

                    if (File.Exists(strDetailsOutFile))
                    {
                        DrawingUtil.DrawDrg(this.hdapp, strDetailsOutFile, HeadsUtils.Constants.LABEL_DETAILS, true);
                        this.hdapp.ActiveDocument.RefreshDocument();
                    }
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
コード例 #4
0
        private void btnOk__Click(object sender, EventArgs e)
        {
            if (this.ValidateData())
            {
                //string PathName;
                Grid Grd = new Grid();
                //CCfgtype cfg;

                CBox box = this.headsApp.ActiveDocument.BoundingBox;
                if (box != null)
                {
                    //Delete Existing
                    ViewerUtils.DeleteEntitiesByLabel(this.headsApp.ActiveDocument, HeadsUtils.Constants.LABEL_GRID, false);

                    double[] xy = new double[] { box.BottomRight.X, box.BottomRight.Y, box.TopLeft.X, box.TopLeft.Y };

                    Grd.ModelName  = "$$$$$$$$";
                    Grd.StringName = "****";
                    Grd.MinX       = xy[0];
                    Grd.MinY       = xy[1];
                    Grd.MaxX       = xy[2];
                    Grd.MaxY       = xy[3];

                    Grd.XInterval = this.tbXInterval_.Value;
                    Grd.YInterval = this.tbYInterval_.Value;
                    Grd.Rotation  = 0;
                    Grd.TextSize  = this.tbTextSize_.Value;

                    string FileName = Path.Combine(this.headsApp.AppDataPath, "GRID1.TMP");

                    BinaryWriter bw = new BinaryWriter(new FileStream(FileName, FileMode.Create), Encoding.Default);
                    Grd.ToStream(bw);
                    bw.Close();

                    FileName = Path.Combine(this.headsApp.AppDataPath, "GRID2.TMP");

                    ViewerUtils.DeleteFileIfExists(FileName);

                    CCoordinatesUtil util = new CCoordinatesUtil();
                    util.Funcmain(this.headsApp.AppDataPath);

                    DrawingUtil.DrawChainage(this.headsApp, FileName, HeadsUtils.Constants.LABEL_GRID, true);

                    this.headsApp.ActiveDocument.RefreshDocument();
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
        private void btnOk__Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                CBox boundbox = this.hdapp.ActiveDocument.BoundingBox;
                if (boundbox != null)
                {
                    //Delete the existing
                    //ViewerUtils.DeleteEntitiesByLabel(this.hdapp.ActiveDocument, HeadsUtils.Constants.LABEL_CHAINAGE, false);

                    //CCfgtype cfg = this.hdapp.ConfigParam;
                    HeadsUtils.Chainage Chng = new HeadsUtils.Chainage();
                    double z = 0.0;
                    Chng.XMin             = boundbox.TopLeft.X;
                    Chng.YMin             = boundbox.TopLeft.Y;
                    z                     = boundbox.TopLeft.Z;
                    Chng.ModelName        = this.SelectedModelName;
                    Chng.StringName       = this.SelectedStringLabel;
                    Chng.TextSize         = this.tbTextSize_.Value;
                    Chng.ChainageInterval = this.tbChainageInterval_.Value;
                    Chng.Rotation         = 0;

                    BinaryWriter bw = new BinaryWriter(new FileStream(Path.Combine(this.hdapp.AppDataPath, "CHAIN1.TMP"), FileMode.Create), Encoding.Default);
                    bw.Write(ViewerUtils.ConvertStringToByteArray(Chng.ModelName, 30));
                    bw.Write(ViewerUtils.ConvertStringToByteArray(Chng.StringName, 20));
                    bw.Write(Chng.XMin);
                    bw.Write(Chng.YMin);
                    bw.Write(Chng.ChainageInterval);
                    bw.Write(Chng.TextSize);
                    bw.Write(Chng.Rotation);
                    bw.Close();

                    ViewerUtils.DeleteFileIfExists(Path.Combine(this.hdapp.AppDataPath, "CHAIN2.TMP"));

                    CChainageUtil util = new CChainageUtil();
                    util.Funcmain(this.hdapp.AppDataPath);

                    DrawingUtil.DrawChainage(this.hdapp, Path.Combine(this.hdapp.AppDataPath, "CHAIN2.TMP"), "CHAIN", true);

                    this.hdapp.ActiveDocument.RefreshDocument();
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
コード例 #7
0
        private void btnApply__Click(object sender, EventArgs e)
        {
            WriteDataToFileOFF();

            if (File.Exists(Path.Combine(this.app.AppDataPath, "OFF1.TMP")) == true)
            {
                ViewerUtils.DeleteFileIfExists(Path.Combine(this.app.AppDataPath, "OFF2.TMP"));

                COffsetUtil util = new COffsetUtil();
                util.Funcmain(this.app.AppDataPath);

                if (File.Exists(Path.Combine(this.app.AppDataPath, "OFF2.TMP")))
                {
                    DrawingUtil.DrawData(this.app, Path.Combine(this.app.AppDataPath, "OFF2.TMP"), "PVR", true);
                    this.app.ActiveDocument.RefreshDocument();
                }
            }
        }
コード例 #8
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");
            }
        }
コード例 #9
0
        private void FormHipMethod_FormClosed(object sender, FormClosedEventArgs e)
        {
            string strHalignTmpFilePath = Path.Combine(this.m_app.AppDataPath, "halign.tmp");

            ViewerUtils.DeleteFileIfExists(strHalignTmpFilePath);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        void FillFromExistingData(CHIPInfo info)
        {
            if (info.IsHipData == false)
            {
                ViewerUtils.DeleteFileIfExists(System.IO.Path.Combine(this.m_app.AppDataPath, "halign.tmp"));

                int nidxED = 0;

                this.txtModelName_.Text   = info.ModelName;
                this.txtStringlabel_.Text = info.StringLabel;
                for (int iCnt = 0; iCnt < info.DataList.Count; iCnt++)
                {
                    CHalignFilData fildata = info.DataList[iCnt];
                    if (carED[nidxED] == null)
                    {
                        carED[nidxED] = new CElementData();
                    }
                    carED[nidxED].dBearings      = fildata.dB1;
                    carED[nidxED].dChainInterval = 10;
                    carED[nidxED].dLength        = fildata.dEllength;
                    if (fildata.iTurn == 1)
                    {
                        fildata.dRadius = -1 * fildata.dRadius;
                    }
                    carED[nidxED].dRadius     = fildata.dRadius;
                    carED[nidxED].dStartChain = fildata.dStartchn;
                    carED[nidxED].dXvalue     = fildata.dStartx;
                    carED[nidxED].dYvalue     = fildata.dStarty;
                    carED[nidxED].nElementNo  = nidxED + 1;
                    carED[nidxED].nType       = fildata.iEltype;

                    CHalignElementUtil code = new CHalignElementUtil();

                    code.Funcmain(this.m_app.AppDataPath, 2, 1, info.ModelName, info.StringLabel
                                  , (short)(nidxED + 1), fildata.iEltype, fildata.dStartchn
                                  , 10.0, fildata.dStartx, fildata.dStarty, fildata.dB1
                                  , fildata.dEllength, fildata.dRadius);

                    carED[nidxED].npLineID = DrawingUtil.DrawData(this.m_app, System.IO.Path.Combine(this.m_app.AppDataPath, "HAL2.TMP"), "ELE", true);

                    nidxED++;

                    this.SelectedElementType        = fildata.iEltype;
                    this.txtChainageInterval_.Value = 10.0;
                    this.txtLength_.Value           = fildata.dEllength;
                    this.txtModelName_.Text         = fildata.sMod;
                    this.txtRadius_.Value           = fildata.dRadius;
                    this.txtStartInterval_.Value    = fildata.dEndchn;
                    this.txtStringlabel_.Text       = fildata.sString;
                    this.txtWCBearings_.Value       = fildata.dB2;
                    this.txtXVal_.Value             = fildata.dEndx;
                    this.txtYVal_.Value             = fildata.dEndy;
                    this.StartEleNo = nidxED + 1;
                    ElementNo       = nidxED + 1;
                    nTotED          = ElementNo - 1;
                    TotalEleDrawn   = nidxED;

                    lastED.dStartChain    = this.txtStartInterval_.Value;
                    lastED.dChainInterval = this.txtChainageInterval_.Value;
                    lastED.dXvalue        = this.txtXVal_.Value;
                    lastED.dYvalue        = this.txtYVal_.Value;
                    lastED.nType          = this.SelectedElementType;
                    lastED.dBearings      = this.txtWCBearings_.Value;
                    lastED.dLength        = this.txtLength_.Value;
                    lastED.dRadius        = this.txtRadius_.Value;
                    lastED.nElementNo     = this.StartEleNo;
                }
                this.m_app.ActiveDocument.RefreshDocument();
                this.m_app.ZoomExtents();
                //ViewerUtils.DeleteFileIfExists(this.m_app.AppDataPath + @"\~halign.fil");
            }
        }
コード例 #12
0
        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;
        }