示例#1
0
        public void GivenMinAndMaxesSetAndHeightAndLatisGreaterWhenGetDeltaThenDeltaIsReturned()
        {
            _drawingUtil = new DrawingUtil(1050, 1650, _graphics);

            var points = new List <Point>();

            points.Add(new Point {
                X = 5600, Y = 8900
            });
            points.Add(new Point {
                X = 3600, Y = 7200
            });
            points.Add(new Point {
                X = 9000, Y = 1000
            });
            points.Add(new Point {
                X = 7600, Y = 2200
            });
            points.Add(new Point {
                X = 3000, Y = 9000
            });
            _drawingUtil.SetMinMax(points);

            var delta = _drawingUtil.GetDelta();

            Assert.AreEqual(6, delta);
        }
示例#2
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            bool   flag;
            string str = e.Value as string;

            if ((flag = !SharedUtil.IsEmpty(str)) || (FilePathTypeEditor <T> .NoFileImage != null))
            {
                e.Graphics.DrawImage(flag ? DrawingUtil.GetFileImage(str, false) : FilePathTypeEditor <T> .NoFileImage, new Rectangle(1, 2, e.Bounds.Width - 2, e.Bounds.Height - 2));
            }
            base.PaintValue(e);
        }
示例#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
        public void OnPathFound(Vector3[] newPath, bool pathFound)
        {
            if (pathFound)
            {
                var go = GameObject.Find("DrawDust");
                DrawUtil = go.GetComponent <DrawingUtil>();

                Path = newPath;
                DrawUtil.SpawnDust(Path, Playerloc);

                base.Use();
            }
        }
 public override void DrawChildren(DrawContext drawContext)
 {
     if (this._enclosing.IsBoxChecked())
     {
         PdfCanvas canvas    = drawContext.GetCanvas();
         Rectangle rectangle = this.GetInnerAreaBBox();
         canvas.SaveState();
         canvas.SetFillColor(ColorConstants.BLACK);
         DrawingUtil.DrawPdfACheck(canvas, rectangle.GetWidth(), rectangle.GetHeight(), rectangle.GetLeft(), rectangle
                                   .GetBottom());
         canvas.RestoreState();
     }
 }
示例#6
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();
            }
        }
示例#7
0
            public override void DrawChildren(DrawContext drawContext)
            {
                PdfCanvas canvas    = drawContext.GetCanvas();
                Rectangle rectangle = this._enclosing.flatRenderer.GetOccupiedArea().GetBBox();
                float     radius    = (float)Math.Min(rectangle.GetWidth(), rectangle.GetHeight()) / 2;

                canvas.SaveState();
                canvas.SetFillColor(RadioRenderer.DEFAULT_COLOR);
                DrawingUtil.DrawCircle(canvas, rectangle.GetLeft() + radius, rectangle.GetBottom() + radius, radius);
                if (this._enclosing.IsBoxChecked())
                {
                    canvas.SetFillColor(RadioRenderer.DEFAULT_CHECKED_COLOR);
                    DrawingUtil.DrawCircle(canvas, rectangle.GetLeft() + radius, rectangle.GetBottom() + radius, radius / 2);
                }
                canvas.RestoreState();
            }
示例#8
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();
            }
        }
示例#9
0
        public static (LightMap FloorLight, LightMap CeilingLight) Trace(
            Size dimensions,
            Func <Position, bool> isPositionObscured,
            LightRange lightRange,
            IEnumerable <LightDefinition> lights)
        {
            var floorLight   = new LightMap(lightRange, dimensions).Blackout();
            var ceilingLight = new LightMap(lightRange, dimensions).Blackout();

            foreach (var light in lights)
            {
                // Check a big square around the light. This is very brute force but it doesn't appear to cause any
                // problems.
                for (int y = 0; y < light.LengthAffected; y++)
                {
                    for (int x = 0; x < light.LengthAffected; x++)
                    {
                        var delta = new PositionDelta(x, y) - light.Radius;

                        var location = light.Center + delta;

                        if (!dimensions.Contains(location))
                        {
                            continue;
                        }

                        // check for line of sight
                        var obscured =
                            DrawingUtil.BresenhamLine(
                                start: light.Center,
                                end: location)
                            .Any(isPositionObscured);

                        if (!obscured)
                        {
                            var(floorIncrement, ceilingIncrement) = light.GetBrightness(location);

                            floorLight.Lighten(location, floorIncrement);
                            ceilingLight.Lighten(location, ceilingIncrement);
                        }
                    }
                }
            }

            return(floorLight, ceilingLight);
        }
示例#10
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();
            }
        }
示例#11
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();
                }
            }
        }
示例#12
0
        void ShowItemEntities(List <CLabtype> entities, string strModelName, string stgLabel)
        {
            int           NumPts   = 0;
            CPoint3D      ptStart  = new CPoint3D();
            CPoint3D      ptEnd    = new CPoint3D();
            CPoint3D      ptLast   = new CPoint3D();
            CTXTtype      txt      = new CTXTtype();
            CLinetype     uline    = new CLinetype();
            IHdPolyline3D polyline = null;
            string        str1     = "";

            IHdPoint aPoint = null;
            CPTStype pts    = new CPTStype();

            this.App.ActiveDocument.ConfigParam.XMetric = 1.0;
            this.App.ActiveDocument.ConfigParam.YMetric = 1.0;

            CCfgtype cfg = this.App.ActiveDocument.ConfigParam;

            eHEADS_COLOR entitycolor = (stgLabel.StartsWith("member")) ? FormLoadDeflection.MemberColor : FormLoadDeflection.LoadColor;

            double dTextHeight = (this.App.ActiveDocument.ActiveTextHeight > 0) ? this.App.ActiveDocument.ActiveTextHeight : 1.0;

            for (int iIndex = 0; iIndex < entities.Count; iIndex++)
            {
                CLabtype labtype = entities[iIndex];

                if (labtype.attr == CLabtype.Type.Point)
                {
                    pts = (CPTStype)labtype.Tag;

                    ptEnd = new CPoint3D(pts.mx * cfg.XMetric, pts.my * cfg.YMetric, pts.mz);
                    NumPts++;

                    ptStart = ptLast;
                    ptLast  = ptEnd;

                    uline.StartPoint = new CPoint3D(ptStart);
                    uline.EndPoint   = new CPoint3D(ptEnd);

                    str1 = stgLabel;

                    if (NumPts == 1)
                    {
                        aPoint = this.App.ActiveDocument.DrawPoint(ptEnd);

                        aPoint.color = entitycolor;
                    }
                    else if (NumPts == 2)
                    {
                        uline.Layer  = this.App.ActiveDocument.GetActiveLayer().Name;
                        uline.elatt  = 1;
                        uline.laatt  = 1;
                        uline.Label  = strModelName;
                        uline.Label += ":";
                        uline.Label += stgLabel;
                        uline.scatt  = 1;

                        polyline = DrawingUtil.DrawPolyline3DDx(this.App.ActiveDocument, true, uline);

                        polyline.color = entitycolor;

                        aPoint.Erase();
                    }
                    else if (NumPts > 2)
                    {
                        polyline.AppendVertex(ptEnd);
                    }
                }
                else if (labtype.attr == CLabtype.Type.Text)
                {
                    txt = (CTXTtype)labtype.Tag;

                    ptEnd = new CPoint3D(txt.tx * cfg.XMetric, txt.ty * cfg.YMetric, txt.tz);
                    str1  = txt.tg;
                    IHdText textobj = this.App.ActiveDocument.DrawText(ptEnd, str1, dTextHeight);
                    textobj.color = entitycolor;
                    aPoint        = this.App.ActiveDocument.DrawPoint(ptEnd);
                    aPoint.color  = entitycolor;
                }
                else if (labtype.attr == CLabtype.Type.EndCode)
                {
                    NumPts = 0;
                }
            }
            this.App.ActiveDocument.RefreshDocument(true);
        }
示例#13
0
 public void Setup()
 {
     _tabPage     = new TabPage();
     _graphics    = _tabPage.CreateGraphics();
     _drawingUtil = new DrawingUtil(1050, 1050, _graphics);
 }
示例#14
0
        private void ExecDrawString(BinaryReader br)
        {
            bool bIsModel = false;
            bool bIsLabel = false;

            CPoint3D ptStart      = new CPoint3D();
            CPoint3D ptEnd        = new CPoint3D();
            CPoint3D ptLast       = new CPoint3D();
            CPoint3D ptFirst3dFac = new CPoint3D();
            string   strSeleModel = GetSelectedModelName();

            CTXTtype        txt          = new CTXTtype();
            CLinetype       uline        = new CLinetype();
            string          strModelName = "";
            int             NumPts       = 0;
            string          str1         = "";
            string          stgLabel     = "";
            IHdPoint        aPoint       = null;
            IHdPolyline3D   polyline     = null;
            CPTStype        pts          = new CPTStype();
            List <CPoint3D> pFArray      = new List <CPoint3D>();

            this.m_app.ActiveDocument.ConfigParam.XMetric = 1.0;
            this.m_app.ActiveDocument.ConfigParam.YMetric = 1.0;

            CCfgtype cfg = this.m_app.ActiveDocument.ConfigParam;

            int iSelectedLineType = this.GetSelectedLineType();

            double dTextHeight = (this.m_app.ActiveDocument.ActiveTextHeight > 0) ? this.m_app.ActiveDocument.ActiveTextHeight : 1.0;


            string strFilePath = m_strpathfilfile;
            //if (File.Exists(strFilePath))
            {
                //BinaryReader br = new BinaryReader(new FileStream(strFilePath, FileMode.Open, FileAccess.Read), Encoding.Default);

                //set the progress bar max value
                SetProgressBarMaxValue(100);

                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    CLabtype labtype = CLabtype.FromStream(br);

                    if (labtype.attr == CLabtype.Type.Model) // Model Name
                    {
                        NumPts       = 0;
                        strModelName = ((CModType)labtype.Tag).Name;
                        bIsModel     = (strModelName == strSeleModel) ? true : false;
                    }
                    else if (labtype.attr == CLabtype.Type.String)// String Label
                    {
                        stgLabel = ((CStgType)labtype.Tag).label;
                        if (bIsModel)
                        {
                            bIsLabel = this.lbStringLebels_.CheckedItems.Contains(stgLabel);
                        }
                    }
                    else if (labtype.attr == CLabtype.Type.Point)
                    {
                        pts = (CPTStype)labtype.Tag;

                        ptEnd = new CPoint3D(pts.mx * cfg.XMetric, pts.my * cfg.YMetric, pts.mz);
                        NumPts++;

                        ptStart = ptLast;
                        ptLast  = ptEnd;

                        if (bIsModel && bIsLabel)
                        {
                            uline.StartPoint = new CPoint3D(ptStart);
                            uline.EndPoint   = new CPoint3D(ptEnd);

                            str1 = stgLabel;
                            if (str1.ToUpper().StartsWith("P") == true)
                            {
                                if (str1.ToUpper().StartsWith("P0") == true)
                                {
                                    txt.Point = ptEnd;
                                    //double[] res = ptEnd.GetCordArr();

                                    txt.tr = 0.0;

                                    str1 = ptEnd.Z.ToString("0.000");
                                    this.m_app.ActiveDocument.DrawText(new CPoint3D(ptEnd.X, ptEnd.Y, dTextHeight), str1, dTextHeight);

                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X - 0.5, ptEnd.Y, ptEnd.Z), new CPoint3D(ptEnd.X + 0.5, ptEnd.Y, ptEnd.Z));
                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X, ptEnd.Y - 0.5, ptEnd.Z), new CPoint3D(ptEnd.X, ptEnd.Y + 0.5, ptEnd.Z));
                                }
                                else
                                {
                                    txt.Point = ptEnd;
                                    txt.tr    = 0.0;
                                    double[] res = ptEnd.GetCordArr();

                                    this.m_app.ActiveDocument.DrawText(new CPoint3D(ptEnd.X, ptEnd.Y, dTextHeight), str1, dTextHeight);

                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X - 0.5, ptEnd.Y, ptEnd.Z), new CPoint3D(ptEnd.X + 0.5, ptEnd.Y, ptEnd.Z));
                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X, ptEnd.Y - 0.5, ptEnd.Z), new CPoint3D(ptEnd.X, ptEnd.Y + 0.5, ptEnd.Z));
                                }
                            }
                            else
                            {
                                if (NumPts == 1)
                                {
                                    aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                                    if (iSelectedLineType == 4)
                                    {
                                        aPoint.Erase();
                                        ptFirst3dFac = new CPoint3D(ptEnd);
                                        pFArray.Add(ptEnd);
                                    }
                                }
                                else if (NumPts == 2)
                                {
                                    uline.Layer  = this.m_app.ActiveDocument.GetActiveLayer().Name;
                                    uline.elatt  = 1;
                                    uline.laatt  = 1;
                                    uline.Label  = strModelName;
                                    uline.Label += ":";
                                    uline.Label += stgLabel;
                                    uline.scatt  = 1;

                                    if (iSelectedLineType == 1)
                                    {
                                        polyline = DrawingUtil.DrawPolyline3DDx(this.m_app.ActiveDocument, true, uline);
                                    }
                                    else if (iSelectedLineType == 2)
                                    {
                                        polyline = DrawingUtil.DrawPolyline3DDx(this.m_app.ActiveDocument, true, uline);
                                    }
                                    else if (iSelectedLineType == 3)
                                    {
                                        aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                                    }
                                    else if (iSelectedLineType == 4)
                                    {
                                        pFArray.Add(ptEnd);
                                    }

                                    aPoint.Erase();
                                }
                                else if (NumPts > 2)
                                {
                                    if (iSelectedLineType == 1)
                                    {
                                        polyline.AppendVertex(ptEnd);
                                    }
                                    else if (iSelectedLineType == 2)
                                    {
                                        polyline = DrawingUtil.DrawPolyline3DDx(this.m_app.ActiveDocument, true, uline);
                                    }
                                    else if (iSelectedLineType == 3)
                                    {
                                        aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                                    }
                                    else if (iSelectedLineType == 4)
                                    {
                                        pFArray.Add(ptEnd);
                                    }
                                }
                            }
                        }
                    }
                    else if (labtype.attr == CLabtype.Type.Text)
                    {
                        txt = (CTXTtype)labtype.Tag;

                        ptEnd = new CPoint3D(txt.tx * cfg.XMetric, txt.ty * cfg.YMetric, txt.tz);
                        if (bIsLabel && bIsModel)
                        {
                            str1 = txt.tg;
                            //Display an Elevation
                            //TO DO:
                            this.m_app.ActiveDocument.DrawText(ptEnd, str1, dTextHeight);
                            aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                        }
                    }
                    else if (labtype.attr == CLabtype.Type.EndCode)
                    {
                        if ((iSelectedLineType == 4) && (bIsLabel && bIsModel))
                        {
                            if ((System.Math.Abs(ptEnd.X - ptFirst3dFac.X) > 0.00001) || (System.Math.Abs(ptEnd.Y - ptFirst3dFac.Y) > 0.00001))
                            {
                                if (NumPts < 4)
                                {
                                    pFArray.Add(ptFirst3dFac);   //close the face
                                }
                            }

                            if (pFArray.Count > 3)
                            {
                                IHd3DFace face3d = this.m_app.ActiveDocument.Draw3DFace(pFArray[0], pFArray[1], pFArray[2], pFArray[3]);
                                face3d.Update();
                            }
                            pFArray.Clear();
                        }
                        NumPts = 0;
                    }
                    int iCurProgressInPercent = (int)(((double)br.BaseStream.Position / (double)br.BaseStream.Length) * 100.00);

                    SetProgressBarValue(iCurProgressInPercent);
                    Thread.Sleep(0);
                }
                //br.Close();
            }
        }
示例#15
0
 internal System.Drawing.Image GetDisabledImage(System.Drawing.Color backColor, bool large)
 {
     return(DrawingUtil.GetDisabledImage(backColor, large ? this.Image : this.SmallImage));
 }
示例#16
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);
        }
示例#17
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;
        }
示例#18
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");
            }
        }