예제 #1
0
    public static void Main()
    {
        MainShape ms;

        ms = new MainShape();
        ms.draw();
        ms = new Rectangle();
        ms.draw();
        ms = new Circle();
        ms.draw();
    }
예제 #2
0
 /// <summary>
 /// Happens when the Window asks to repaint itself
 /// </summary>
 /// <param name="Renderer"></param>
 protected void OnWindowRepaint(IRenderer Renderer)
 {
     if (MainShape != null)
     {
         MainShape.Draw(Renderer);
         //Renderer.DrawOperations.DrawPie(
         //    MainShape.Bounds,
         //    72, 260,
         //    System.Drawing.Color.Bisque,
         //    System.Drawing.Color.AntiqueWhite);
     }
 }
예제 #3
0
 /// <summary>
 ///     Creates/modifies Shape.
 /// </summary>
 /// <param name="shapeType">Defines which shape to create.</param>
 /// <param name="start">Start coordinate of mouse drag.</param>
 /// <param name="end">End coordinate of mouse drag.</param>
 /// <param name="prevShape">previous shape to modify.</param>
 /// <returns></returns>
 public static MainShape MainShapeCreatorFactory(ShapeType shapeType, Coordinate start, Coordinate end,
                                                 MainShape prevShape)
 {
     if (shapeType == ShapeType.ELLIPSE)
     {
         return(s.ShapeMaker(start, end, prevShape));
     }
     if (shapeType == ShapeType.LINE)
     {
         return(s.ShapeMaker(start, end, prevShape));
     }
     if (shapeType == ShapeType.POLYLINE)
     {
         return(s.ShapeMaker(start, end, prevShape));
     }
     return(s.ShapeMaker(start, end, prevShape));
 }
예제 #4
0
        public void RecalcBounds()
        {
            if (MainShape != null && RootBlock != null)
            {
                if (RootBlock.MyRootControl.StretchToWindow)
                {
                    bool showScrollbars            = ShowScrollbars;
                    int  VerticalScrollbarWidth    = showScrollbars ? MainShape.VScroll.Bounds.Size.X : 0;
                    int  HorizontalScrollbarHeight = showScrollbars ? MainShape.HScroll.Bounds.Size.Y : 0;

                    RootBlock.MyRootControl.Bounds.Size.X = this.ClientSize.Width - VerticalScrollbarWidth;
                    RootBlock.MyRootControl.Bounds.Size.Y = this.ClientSize.Height - HorizontalScrollbarHeight;
                    RootBlock.MyRootControl.LayoutDock();
                }

                MainShape.Bounds.Size.Set(this.Bounds.Size);
                MainShape.LayoutCore();
            }
        }
예제 #5
0
        private void MyRootControl_ShouldScrollTo(Rect shape)
        {
            const int horizBorder  = 150;
            const int verticBorder = 50;

            Rect.RectangleRelativePosition RelativePosition = shape.RelativeToRectY(MainShape.Scrollable.ViewPort);
            int x              = shape.Location.X;
            int y              = shape.Location.Y;
            int totalHeight    = RootBlock.MyRootControl.Bounds.Size.Y;
            int viewportLeft   = MainShape.Scrollable.ViewPort.Location.X;
            int viewportRight  = MainShape.Scrollable.ViewPort.Right;
            int viewportHeight = MainShape.Scrollable.ViewPort.Size.Y;
            int viewportTop    = MainShape.Scrollable.ViewPort.Top;

            bool shouldScrollX = false;
            bool shouldScrollY = false;
            int  scrollToX     = 0;
            int  scrollToY     = 0;

            switch (RelativePosition)
            {
            case Rect.RectangleRelativePosition.FullyContaining:
            case Rect.RectangleRelativePosition.IntersectingBeginning:
            case Rect.RectangleRelativePosition.FullyBefore:
            case Rect.RectangleRelativePosition.IntersectingEnd:
            case Rect.RectangleRelativePosition.FullyAfter:
                shouldScrollY = true;
                scrollToY     = y - verticBorder;
                break;

            case Rect.RectangleRelativePosition.FullyInside:
            default:
                if (totalHeight > viewportHeight &&
                    viewportHeight > 300 &&
                    totalHeight - y < 300)
                {
                    shouldScrollY = true;
                    scrollToY     = totalHeight;
                }
                else if (y > viewportTop && y < viewportTop + verticBorder)
                {
                    shouldScrollY = true;
                    scrollToY     = y - verticBorder;
                }
                break;
            }

            if (x < viewportLeft + horizBorder)
            {
                shouldScrollX = true;
                scrollToX     = x - horizBorder;
            }

            if (x > viewportRight - horizBorder)
            {
                shouldScrollX = true;
                scrollToX     = x + horizBorder;
            }

            if (shouldScrollX && shouldScrollY)
            {
                MainShape.ScrollContentXY(scrollToX, scrollToY);
            }
            else if (shouldScrollX)
            {
                MainShape.ScrollContentX(scrollToX);
            }
            else if (shouldScrollY)
            {
                MainShape.ScrollContentY(scrollToY);
            }
        }
예제 #6
0
 static ShapeFactory()
 {
     s = new Ellipse();
 }