コード例 #1
0
        private bool ValidateData()
        {
            if (this.txtModelName_.Text.Trim() == "")
            {
                this.errorProvider.SetError(this.txtModelName_, Properties.Resources.ST_PROMPT_INVALID_INPUT);
                this.txtModelName_.Focus();
                return(false);
            }

            if (this.txtStringlabel_.Text.Trim() == "")
            {
                this.errorProvider.SetError(this.txtStringlabel_, Properties.Resources.ST_PROMPT_INVALID_INPUT);
                this.txtStringlabel_.Focus();
                return(false);
            }

            if (this.txtModelName_.ReadOnly == false)
            {
                string     strHalignFilFilePath = 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())
                    {
                        this.errorProvider.SetError(this.txtStringlabel_
                                                    , "Model Name and String Level already exists\nPlease specify unique Model Name and String Level");
                        this.txtStringlabel_.Focus();
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #2
0
 private void GetDetailsFromExistingData(CHIPInfo hipinfo, ref List <CHHipData> listHhip)
 {
     if (hipinfo.DataList.Count > 0)
     {
         this.txtModelName_.Text       = hipinfo.ModelName;
         this.txtStringlabel_.Text     = hipinfo.StringLabel;
         this.txtStartInterval_.Value  = hipinfo.DataList[0].dStartchn;
         this.txtDefaultRadious_.Value = hipinfo.DataList[0].dRadius;
         listHhip = CHalignHipUtil.GenerateHIPData(hipinfo);
     }
 }
コード例 #3
0
        private void btnSave__Click(object sender, EventArgs e)
        {
            string strHalignTmpFilePath = Path.Combine(this.m_app.AppDataPath, "halign.tmp");

            if (File.Exists(strHalignTmpFilePath) == true)
            {
                CHalignHipUtil.SaveHalign(this.m_app.AppDataPath);
                //throw new FileNotFoundException("File not found : " + strHalignTmpFilePath);
            }



            //File.Delete(strHalignTmpFilePath);

            this.Close();
        }
コード例 #4
0
        /// <summary>
        /// This function copied from CHalignDxCode::save_halign()
        /// </summary>
        /// <param name="strWorkingDirPath"></param>
        public static void SaveHalign(string strWorkingDirPath)
        {
            StreamReader          readerSrc      = new StreamReader(Path.Combine(strWorkingDirPath, "halign.tmp"));
            List <CHalignFilData> listTempHalign = new List <CHalignFilData>();

            while (readerSrc.EndOfStream == false)
            {
                string         strlineSrc  = readerSrc.ReadLine();
                CHalignFilData filDataTemp = CHalignFilData.Parse(strlineSrc);
                if (filDataTemp != null)
                {
                    listTempHalign.Add(filDataTemp);
                }
            }
            readerSrc.Close();

            //If any data present in temp file
            if (listTempHalign.Count > 0)
            {
                string       strHalignFilFilePath = Path.Combine(strWorkingDirPath, "HALIGN.FIL");
                CHIPInfo[]   infoarr     = CHalignHipUtil.ReadHaligns(strHalignFilFilePath);
                StreamWriter writerDesti = new StreamWriter(strHalignFilFilePath, false);
                foreach (CHIPInfo info in infoarr)
                {
                    foreach (CHalignFilData filData in info.DataList)
                    {
                        if (filData.sMod != listTempHalign[0].sMod || filData.sString != listTempHalign[0].sString)
                        {
                            writerDesti.WriteLine(filData.ToString());
                        }
                    }
                }

                //Now write the data from temp file
                foreach (CHalignFilData filData in listTempHalign)
                {
                    writerDesti.WriteLine(filData.ToString());
                }

                writerDesti.Close();
            }
        }
コード例 #5
0
        private void PopulateSelectionTree()
        {
            TreeNode nodeRoot = this.treeViewModels_.Nodes[0];

            nodeRoot.Tag = null;
            nodeRoot.Expand();
            string strHalignFilFilePath = System.IO.Path.Combine(this.app.AppDataPath, "HALIGN.FIL");

            CHIPInfo[] infoarr = CHalignHipUtil.ReadHaligns(strHalignFilFilePath);
            foreach (CHIPInfo info in infoarr)
            {
                if (openmode == OpenMode.HipMethod)
                {
                    if (info.IsHipData == true)
                    {
                        TreeNode nodemodel = this.FindModelNode(info.ModelName);
                        if (nodemodel == null)
                        {
                            nodemodel = nodeRoot.Nodes.Add(info.ModelName);
                        }

                        TreeNode nodeLabel = nodemodel.Nodes.Add(info.StringLabel);
                        nodeLabel.Tag = info;
                    }
                }
                else if (openmode == OpenMode.ElementMethod)
                {
                    if (info.IsHipData != true)
                    {
                        TreeNode nodemodel = this.FindModelNode(info.ModelName);
                        if (nodemodel == null)
                        {
                            nodemodel = nodeRoot.Nodes.Add(info.ModelName);
                        }

                        TreeNode nodeLabel = nodemodel.Nodes.Add(info.StringLabel);
                        nodeLabel.Tag = info;
                    }
                }
            }
        }
コード例 #6
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);
        }
コード例 #7
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;
        }
コード例 #8
0
 public static void SaveHalign(string strWorkingDirPath)
 {
     CHalignHipUtil.SaveHalign(strWorkingDirPath);
 }