예제 #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
        /// <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();
            }
        }
예제 #3
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;
                    }
                }
            }
        }
예제 #4
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;
        }