Пример #1
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();
            }
        }
Пример #2
0
        void read_input()
        {
            //IN_flag = 0;

            pathfile = Path.Combine(path, "chain1.tmp");

            if (File.Exists(pathfile) == false)
            {
                textstring = "File %s not found..." + pathfile;
                error_msg();
            }
            else
            {
                HeadsUtils.Chainage chain = new HeadsUtils.Chainage();

                fp1 = new BinaryReader(new FileStream(pathfile, FileMode.Open, FileAccess.Read), Encoding.Default);

                chain.ModelName        = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(30));
                chain.StringName       = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(20));
                chain.XMin             = fp1.ReadDouble();
                chain.YMin             = fp1.ReadDouble();
                chain.ChainageInterval = fp1.ReadDouble();
                chain.TextSize         = fp1.ReadDouble();
                chain.Rotation         = fp1.ReadDouble();

                model  = chain.ModelName;
                stglbl = chain.StringName;

                inc      = chain.ChainageInterval;
                textsize = chain.TextSize;
                rotn     = chain.Rotation;
                XMIN     = chain.XMin;
                YMIN     = chain.YMin;

                fp1.Close();
            }
        }