コード例 #1
0
        protected void LoadEdit2d(Edit2DHoleGroup edit, SingleHoleGroup sg)
        {
            edit.DrawPrimitives   = oDrawPrimitives;
            edit.PictureBoxHeight = (int)oCanvas.Height;
            edit.PictureBoxWidth  = (int)oCanvas.Width;

            string hg = sg.oHoleGroup.HoleGroupID;

            edit.AddHoleGroup(hg);
            edit.SelectHoleGroup(hg);

            foreach (LayoutHole lh in sg.oHoleGroup.HoleList)
            {
                int    hIndex  = lh.HoleTypeIndex;
                float  OffsetX = lh.OffsetX;
                float  OffsetY = lh.OffsetY;
                PointF wp      = oFWRInput.W2S(OffsetX, OffsetY);
                switch (lh.HoleType)
                {
                case "rect":
                    BoundaryRectangle br = sg.RectangleArray[hIndex];
                    edit.AddRectangle((int)wp.X, (int)wp.Y, (int)br.Width, (int)br.Height);
                    break;
                }
            }
        }
コード例 #2
0
        private void UpdateRectangle(int ScreenMouseX, int ScreenMouseY, int ScreenDeltaX, int ScreenDeltaY)
        {
            BoundaryRectangle oRect  = BoundaryRectangleList.GetFrom(CurrentlySelectedHole.HoleTypeIndex);
            PointF            pWorld = this.S2W(ScreenMouseX, ScreenMouseY);

            float newx = pWorld.X;
            float newy = pWorld.Y;

            // Update the world points to the nearest grid
            if (this.GridSize > 1)
            {
                newx = this.RoundToGrid((int)pWorld.X);
                newy = this.RoundToGrid((int)pWorld.Y);
            }

            switch (CurrentlySelectedHandleType)
            {
            case eHandleType.MoveHandle:

                CurrentlySelectedHole.OffsetX = newx;
                CurrentlySelectedHole.OffsetY = newy;
                break;

            case eHandleType.ResizeHandle:
                // Get the hole struct and change the size
                switch (CurrentlySelectedHole.HoleType)
                {
                case "rect":
                    oRect.Width  += ScreenDeltaX * CurrentZoom;
                    oRect.Height += ScreenDeltaY * CurrentZoom;
                    break;
                }
                break;
            }
        }
コード例 #3
0
        //----------------------------------------------------------------------------
        private bool TrySelectRectangle(LayoutHole oHole, int ScreenMouseX, int ScreenMouseY)
        {
            PointF MoveHandle   = new PointF(0, 0);
            PointF ResizeHandle = new PointF(0, 0);

            BoundaryRectangle oRect = BoundaryRectangleList.GetFrom(oHole.HoleTypeIndex);

            // The move handle  is the lower left
            MoveHandle = this.W2S(oHole.OffsetX, oHole.OffsetY);
            if (IsHitOnTarget(ScreenMouseX, ScreenMouseY, MoveHandle))
            {
                CurrentlySelectedHole       = oHole;
                MostRecentlySelectedHole    = oHole;
                CurrentlySelectedHandleType = eHandleType.MoveHandle;
                return(true);
            }

            // The resize handle is the lower right corner
            // the position of the handle is based on the zoom

            float HandleOffsetX = oRect.Width / this.CurrentZoom;
            float HandleOffsetY = oRect.Height / this.CurrentZoom;

            ResizeHandle = new PointF(MoveHandle.X + HandleOffsetX, MoveHandle.Y + HandleOffsetY);

            if (IsHitOnTarget(ScreenMouseX, ScreenMouseY, ResizeHandle))
            {
                CurrentlySelectedHole       = oHole;
                MostRecentlySelectedHole    = oHole;
                CurrentlySelectedHandleType = eHandleType.ResizeHandle;
                return(true);
            }

            return(false);
        }
コード例 #4
0
        public void DuplicateCurrentHole()
        {
            if (MostRecentlySelectedHole == null)
            {
                return;
            }

            LayoutHole oHole = LayoutHole.CopyFrom(MostRecentlySelectedHole);

            // Add at an offset so it will be easy to see
            oHole.OffsetX += 10;
            oHole.OffsetY += 10;

            // Create a new version of the instance of the hole

            int ndx = MostRecentlySelectedHole.HoleTypeIndex;

            switch (MostRecentlySelectedHole.HoleType)
            {
            case "ell":
                oHole.HoleTypeIndex = BoundaryEllipseList.Count;
                BoundaryEllipse e = BoundaryEllipseList.GetFrom(ndx);
                BoundaryEllipseList.Add(BoundaryEllipse.CopyFrom(e));
                break;

            case "rect":
                oHole.HoleTypeIndex = BoundaryRectangleList.Count;
                BoundaryRectangle r = BoundaryRectangleList.GetFrom(ndx);
                BoundaryRectangleList.Add(BoundaryRectangle.CopyFrom(r));
                break;

            case "poly":
                oHole.HoleTypeIndex = BoundaryPolygonList.Count;
                BoundaryPolygon p = BoundaryPolygonList.GetFrom(ndx);
                BoundaryPolygonList.Add(BoundaryPolygon.CopyFrom(p));
                break;
            }

            // Add the new hole to the hole group
            AddHoleToHoleGroup(MostRecentlySelectedHoleGroup, oHole);

            // trigger a repaint
            DrawShapes();
        }
コード例 #5
0
        public void AddRectangle(int ScreenOffsetX, int ScreenOffsetY, int Width, int Height)
        {
            if (MostRecentlySelectedHoleGroup == null)
            {
                return;
            }

            PointF WorldOffset = this.S2W(ScreenOffsetX, ScreenOffsetY);

            LayoutHole oHole = new LayoutHole();

            oHole.HoleType = "rect";
            oHole.OffsetX  = WorldOffset.X;
            oHole.OffsetY  = WorldOffset.Y;

            /*
             * Save this as the current and most recently selected
             */
            CurrentlySelectedHole    = oHole;
            MostRecentlySelectedHole = oHole;

            /*
             * The index is the at the end of the current list. This means we will have to manage the index values
             * when they are deleted
             */
            oHole.HoleTypeIndex = BoundaryRectangleList.Count;

            AddHoleToHoleGroup(MostRecentlySelectedHoleGroup, oHole);

            /*
             * Now create and add the rectangle
             */
            BoundaryRectangle rect = new BoundaryRectangle();

            rect.Width  = Width;
            rect.Height = Height;

            BoundaryRectangleList.Add(rect);

            // trigger draw shapes
            DrawShapes();
        }
コード例 #6
0
        //-------------------------------------------------------
        private void DrawShapes_Rectangle(LayoutHole oHole, bool IsCurrentHole)
        {
            BoundaryRectangle oRect = BoundaryRectangleList.GetFrom(oHole.HoleTypeIndex);

            PointF Screen = this.W2S(oHole.OffsetX, oHole.OffsetY);

            string color = IsCurrentHole ? "#0000FF" : "#ff0000";

            // Draw the move handle
            this.DrawCircle(color, HandleSize, Screen.X, Screen.Y);

            // Adjust the width and height for zoom
            float SWidth  = oRect.Width / CurrentZoom;
            float SHeight = oRect.Height / CurrentZoom;

            // Draw the rectangle as a set of lines so we can control how its positioned. The offset is the lower left
            color = ShapeStrokeColor;

            // The offset is to the lower left
            PointF LowerLeft = Screen;

            PointF LowerRight = new PointF(LowerLeft.X + SWidth, LowerLeft.Y);

            this.DrawLine(color, 1, LowerLeft, LowerRight);

            PointF UpperRight = new PointF(LowerLeft.X + SWidth, LowerLeft.Y + SHeight);

            this.DrawLine(color, 1, LowerRight, UpperRight);

            PointF UpperLeft = new PointF(LowerLeft.X, LowerLeft.Y + SHeight);

            this.DrawLine(color, 1, UpperRight, UpperLeft);

            // Last line
            this.DrawLine(color, 1, UpperLeft, LowerLeft);

            // draw the resize handle
            this.DrawRectangle("#00FF00", HandleSize, HandleSize, Screen.X + SWidth, Screen.Y + SHeight - HandleSize);
        }