예제 #1
0
        /// <summary>
        /// Adds a regular multi-edged polygon on board
        /// </summary>
        /// <param name="region">region of the polygon</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is pentagon filled</param>
        /// <param name="points">Points of the polygon</param>
        public void AddRegularPolygon(Region region, Color penColor, Color fillColor,
                                      float penWidth, bool isFilled, List <PointF> points)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            Polygon regularPolygon = new Polygon();

            regularPolygon.Region       = region;
            regularPolygon.PenColor     = penColor;
            regularPolygon.PenWidth     = penWidth;
            regularPolygon.FillColor    = fillColor;
            regularPolygon.FillEnabled  = isFilled;
            regularPolygon.Curved       = false;
            regularPolygon.Closed       = true;
            regularPolygon.FixedCorners = true;

            List <PointElement> pointElementList = new List <PointElement>();

            foreach (PointF point in points)
            {
                pointElementList.Add(new PointElement(point));
            }
            regularPolygon.points = pointElementList;
            this.shapes.Add(regularPolygon);
            StoreInBuffer(BufferOperation.Insert, regularPolygon);
            handlerCol           = new ShapeHandlerCollection(regularPolygon);
            this.selectedElement = regularPolygon;
            this.selectedElement.Select();
        }
예제 #2
0
 /// <summary>
 /// Disposes object
 /// </summary>
 public void Dispose()
 {
     this.shapes      = null;
     this.undoManager = null;
     this.handlerCol  = null;
     GC.SuppressFinalize(this);
 }
예제 #3
0
        /// <summary>
        /// Selects last shape containing point(x,y)
        /// </summary>
        /// <param name="x">X region on coordinate system</param>
        /// <param name="y">Y region on coordinate system</param>
        public void Click(int x, int y)
        {
            handlerCol      = null;
            selectedElement = null;

            foreach (ShapeElement element in this.shapes)
            {
                element.Selected = false;
                element.DeSelect();

                if (element.Contains(x, y))
                {
                    selectedElement = element;
                }
            }
            if (selectedElement != null)
            {
                selectedElement.Selected = true;
                selectedElement.Select();

                if (selectedElement is Polygon)
                {
                    handlerCol = new PolygonHandlerCollection(selectedElement);
                }
                else
                {
                    handlerCol = new ShapeHandlerCollection(selectedElement);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Adds line to shape collection
        /// </summary>
        /// <param name="region">region of the line</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        public void AddLine(Region region, Color penColor, Color fillColor, float penWidth)
        {
            this.DeSelect();
            Line line = new Line();

            line.Region    = region;
            line.PenColor  = penColor;
            line.PenWidth  = penWidth;
            line.FillColor = fillColor;

            this.shapes.Add(line);
            StoreInBuffer(BufferOperation.Insert, line);
            handlerCol           = new ShapeHandlerCollection(line);
            this.selectedElement = line;
            this.selectedElement.Select();
        }
예제 #5
0
        /// <summary>
        /// Adds new point element in polygon
        /// </summary>
        public void AddPoint()
        {
            PolygonHandlerCollection phCol = (this.handlerCol as PolygonHandlerCollection);

            if (phCol != null)
            {
                PointElement point = phCol.GetNewPoint();
                int          index = phCol.GetNewPointIndex();

                if (index > 0)
                {
                    (this.selectedElement as Polygon).points.Insert(index - 1, point);
                    this.handlerCol = new PolygonHandlerCollection(this.selectedElement);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Adds image box to shape collection .
        /// Loads image from file
        /// </summary>
        /// <param name="region">region of the imagebox</param>
        /// <param name="image">Image of the image box</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="penColor">Color of the pen</param>
        public void AddImageBox(Region region, Bitmap image, Color penColor, float penWidth)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            ImageBox imageBox = new ImageBox();

            imageBox.Region   = region;
            imageBox.PenColor = penColor;
            imageBox.PenWidth = penWidth;

            this.shapes.Add(imageBox);
            StoreInBuffer(BufferOperation.Insert, imageBox);
            imageBox.Image       = image;
            handlerCol           = new ShapeHandlerCollection(imageBox);
            this.selectedElement = imageBox;
            this.selectedElement.Select();
        }
예제 #7
0
        /// <summary>
        /// Adds a cube to shape collection
        /// </summary>
        /// <param name="region">region of the Cube</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is Cube filled</param>
        public void AddCube(Region region, Color penColor, Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            Cube cube = new Cube();

            cube.Region      = region;
            cube.PenColor    = penColor;
            cube.PenWidth    = penWidth;
            cube.FillColor   = fillColor;
            cube.FillEnabled = isFilled;

            this.shapes.Add(cube);
            StoreInBuffer(BufferOperation.Insert, cube);
            handlerCol           = new ShapeHandlerCollection(cube);
            this.selectedElement = cube;
            this.selectedElement.Select();
        }
예제 #8
0
        /// <summary>
        /// Adds hexagon to shape collection
        /// </summary>
        /// <param name="region">region of the hexagon on the board</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is hexagon filled</param>
        public void AddHexagon(Region region, Color penColor, Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            Hexagon hexagon = new Hexagon();

            hexagon.Region      = region;
            hexagon.PenColor    = penColor;
            hexagon.PenWidth    = penWidth;
            hexagon.FillColor   = fillColor;
            hexagon.FillEnabled = isFilled;

            this.shapes.Add(hexagon);
            StoreInBuffer(BufferOperation.Insert, hexagon);
            handlerCol           = new ShapeHandlerCollection(hexagon);
            this.selectedElement = hexagon;
            this.selectedElement.Select();
        }
예제 #9
0
        /// <summary>
        /// Adds star to shape collection
        /// </summary>
        /// <param name="region">region of the star on the board</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is star filled</param>
        public void AddStar(Region region, Color penColor, Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            Star star = new Star();

            star.Region      = region;
            star.PenColor    = penColor;
            star.PenWidth    = penWidth;
            star.FillColor   = fillColor;
            star.FillEnabled = isFilled;

            this.shapes.Add(star);
            StoreInBuffer(BufferOperation.Insert, star);
            handlerCol           = new ShapeHandlerCollection(star);
            this.selectedElement = star;
            this.selectedElement.Select();
        }
예제 #10
0
        /// <summary>
        /// Adds pie to shape collection
        /// </summary>
        /// <param name="region">region of the pie</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is pie filled</param>
        public void AddPie(Region region, Color penColor, Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            Pie pie = new Pie();

            pie.Region      = region;
            pie.PenColor    = penColor;
            pie.PenWidth    = penWidth;
            pie.FillColor   = fillColor;
            pie.FillEnabled = isFilled;

            this.shapes.Add(pie);
            StoreInBuffer(BufferOperation.Insert, pie);
            handlerCol           = new ShapeHandlerCollection(pie);
            this.selectedElement = pie;
            this.selectedElement.Select();
        }
예제 #11
0
        /// <summary>
        /// Removes selected elements
        /// </summary>
        public void RemoveSelected()
        {
            ShapeElement[] selectedShapes = (from ShapeElement element in this.shapes
                                             where element.Selected
                                             select element).ToArray();

            if (this.selectedElement != null)
            {
                this.selectedElement = null;
                this.handlerCol      = null;
            }

            foreach (ShapeElement shape in selectedShapes)
            {
                StoreInBuffer(BufferOperation.Delete, shape);
                shapes.Remove(shape);
            }
        }
예제 #12
0
        /// <summary>
        /// Adds rounded rectangle to shape collection
        /// </summary>
        /// <param name="region">region of the rectangle</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is rectangle filled</param>
        public void AddRoundedRectangle(Region region, Color penColor, Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            RoundedRect rectangle = new RoundedRect();

            rectangle.Region      = region;
            rectangle.PenColor    = penColor;
            rectangle.PenWidth    = penWidth;
            rectangle.FillColor   = fillColor;
            rectangle.FillEnabled = isFilled;

            this.shapes.Add(rectangle);
            StoreInBuffer(BufferOperation.Insert, rectangle);
            handlerCol           = new ShapeHandlerCollection(rectangle);
            this.selectedElement = rectangle;
            this.selectedElement.Select();
        }
예제 #13
0
        /// <summary>
        /// Adds ellipse to shape collection
        /// </summary>
        /// <param name="region">region of the ellipse</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is ellipse filled</param>
        public void AddEllipse(Region region, Color penColor, Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            Ellipse ellipse = new Ellipse();

            ellipse.Region      = region;//new Ellipse(region);
            ellipse.PenColor    = penColor;
            ellipse.PenWidth    = penWidth;
            ellipse.FillColor   = fillColor;
            ellipse.FillEnabled = isFilled;

            this.shapes.Add(ellipse);
            StoreInBuffer(BufferOperation.Insert, ellipse);
            handlerCol           = new ShapeHandlerCollection(ellipse);
            this.selectedElement = ellipse;
            this.selectedElement.Select();
        }
예제 #14
0
        /// <summary>
        /// Adds <see href="http://en.wikipedia.org/wiki/Cartesian_coordinate_system">
        /// Cartesian Plane</see> to shape collection
        /// </summary>
        /// <param name="region">region of the arc</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        public void AddCartesianPlane(Region region, Color penColor, Color fillColor, float penWidth)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();

            CartesianPlane corPlane = new CartesianPlane();

            corPlane.Region    = region;
            corPlane.PenColor  = penColor;
            corPlane.PenWidth  = penWidth;
            corPlane.FillColor = fillColor;

            this.shapes.Add(corPlane);
            StoreInBuffer(BufferOperation.Insert, corPlane);
            handlerCol           = new ShapeHandlerCollection(corPlane);
            this.selectedElement = corPlane;
            this.selectedElement.Select();
        }
예제 #15
0
        /// <summary>
        /// Adds arc to shape collection
        /// </summary>
        /// <param name="region">region of the arc</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is arc filled</param>
        public void AddArc(Region region, Color penColor, Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            Arc arc = new Arc();

            arc.Region      = region;
            arc.PenColor    = penColor;
            arc.PenWidth    = penWidth;
            arc.FillColor   = fillColor;
            arc.FillEnabled = isFilled;

            this.shapes.Add(arc);
            StoreInBuffer(BufferOperation.Insert, arc);
            handlerCol           = new ShapeHandlerCollection(arc);
            this.selectedElement = arc;
            this.selectedElement.Select();
        }
예제 #16
0
        /// <summary>
        /// Adds trapezoid shape in shape list
        /// </summary>
        /// <param name="region">region of the trapezoid on the board</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is trapezoid filled</param>
        public void AddTrapezoid(Region region, Color penColor, Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();

            Trapezoid trapezoid = new Trapezoid();

            trapezoid.Region      = region;
            trapezoid.PenColor    = penColor;
            trapezoid.PenWidth    = penWidth;
            trapezoid.FillColor   = fillColor;
            trapezoid.FillEnabled = isFilled;

            this.shapes.Add(trapezoid);
            StoreInBuffer(BufferOperation.Insert, trapezoid);
            handlerCol           = new ShapeHandlerCollection(trapezoid);
            this.selectedElement = trapezoid;
            this.selectedElement.Select();
        }
예제 #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="region">region of the  text box </param>
        /// <param name="richTb">RichTextbox to be added</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is  text box  filled</param>
        public void AddRichTextBox(Region region, RichTextBox richTb, Color penColor,
                                   Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            RichTextBoxShape rtbShape = new RichTextBoxShape();

            rtbShape.Region      = region;
            rtbShape.PenWidth    = penWidth;
            rtbShape.FillColor   = fillColor;
            rtbShape.PenColor    = penColor;
            rtbShape.FillEnabled = isFilled;
            rtbShape.RTF         = richTb.Rtf;
            this.shapes.Add(rtbShape);

            // StoreInBuffer(BufferOperation.Insert, rtbShape);
            handlerCol           = new ShapeHandlerCollection(rtbShape);
            this.selectedElement = rtbShape;
            //this.selectedElement.Select();
        }
예제 #18
0
        /// <summary>
        /// Adds triangle to shape collection
        /// </summary>
        /// <param name="region">region of the triangle on the board</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is triangle filled</param>
        /// <param name="triangleType">Type of triangle( right or Equilateral)</param>
        public void AddTriangle(Region region, Color penColor, Color fillColor, float penWidth,
                                bool isFilled, TriangleType triangleType)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            Triangle triangle = new Triangle();

            triangle.TriangleType = triangleType;
            triangle.Region       = region;
            triangle.PenColor     = penColor;
            triangle.PenWidth     = penWidth;
            triangle.FillColor    = fillColor;
            triangle.FillEnabled  = isFilled;

            this.shapes.Add(triangle);
            StoreInBuffer(BufferOperation.Insert, triangle);
            handlerCol           = new ShapeHandlerCollection(triangle);
            this.selectedElement = triangle;
            this.selectedElement.Select();
        }
예제 #19
0
        /// <summary>
        /// Adds colored point set to shape collection
        /// </summary>
        /// <param name="region">region of the colored point set</param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="filled">Is polygon filled</param>
        /// <param name="points">List of points of the polygon</param>
        /// <param name="isCurved">Is polygon curved</param>
        public void AddColoredPointSet(Region region, Color penColor, Color fillColor, float penWidth, bool filled,
                                       List <PointElement> points, bool isCurved)
        {
            this.DeSelect();
            ColoredPointSet colPointSet = new ColoredPointSet();

            colPointSet.Region      = region;
            colPointSet.points      = points;
            colPointSet.PenColor    = penColor;
            colPointSet.PenWidth    = penWidth;
            colPointSet.FillColor   = fillColor;
            colPointSet.FillEnabled = filled;
            colPointSet.Curved      = isCurved;

            this.shapes.Add(colPointSet);
            StoreInBuffer(BufferOperation.Insert, colPointSet);
            handlerCol           = new PolygonHandlerCollection(colPointSet);
            this.selectedElement = colPointSet;
            this.selectedElement.Select();
        }
예제 #20
0
        /// <summary>
        /// Adds simple text box to shape collection
        /// </summary>
        /// <param name="region">region of the  text box </param>
        /// <param name="penColor">Color of the pen</param>
        /// <param name="fillColor">Fill color</param>
        /// <param name="penWidth">Width of the pen</param>
        /// <param name="isFilled">Is  text box  filled</param>
        /// <param name="textBox">TextBox that contains data of textbox</param>
        public void AddSimpleTextBox(Region region, TextBox textBox, Color penColor,
                                     Color fillColor, float penWidth, bool isFilled)
        {
            region.FixSize(MinimumSize);
            this.DeSelect();
            SimpleTextBox stextbox = new SimpleTextBox();

            stextbox.Region      = region;
            stextbox.Text        = textBox.Text;
            stextbox.Font        = textBox.Font;
            stextbox.PenColor    = penColor;
            stextbox.PenWidth    = penWidth;
            stextbox.FillEnabled = isFilled;
            stextbox.FillColor   = fillColor;

            this.shapes.Add(stextbox);
            StoreInBuffer(BufferOperation.Insert, stextbox);
            handlerCol           = new ShapeHandlerCollection(stextbox);
            this.selectedElement = stextbox;
            this.selectedElement.Select();
        }
예제 #21
0
        /// <summary>
        /// Select all shapes in an input rectangle
        /// </summary>
        /// <param name="region">region of the rectangle</param>
        public void MultiSelect(Region region)
        {
            handlerCol      = null;
            selectedElement = null;

            foreach (ShapeElement element in this.shapes)
            {
                element.Selected = false; //Set not selected (if its in region region, it'll be selected)
                element.DeSelect();       // Deselect

                int x0 = Math.Min(element.PosStartX, element.PosEndX);
                int x1 = Math.Max(element.PosStartX, element.PosEndX);
                int y0 = Math.Min(element.PosStartY, element.PosEndY);
                int y1 = Math.Max(element.PosStartY, element.PosEndY);

                if (x0 <= region.X1 & x1 >= region.X0 &
                    y0 <= region.Y1 & y1 > region.Y0) //If in region
                {
                    selectedElement  = element;       //Set it as selected
                    element.Selected = true;
                    element.Select();
                    //    element.Select(richTxtBox);
                    element.Select(region);
                }

                if (selectedElement != null)
                {
                    if (selectedElement is Polygon)
                    {
                        handlerCol = new PolygonHandlerCollection(selectedElement);
                    }
                    else
                    {
                        handlerCol = new ShapeHandlerCollection(selectedElement);
                    }
                }
            }
        }
예제 #22
0
        /// <summary>
        /// Copies all selected elements
        /// </summary>
        /// <param name="dx">Moves selected element by dx</param>
        /// <param name="dy">Moves selected element by dy</param>
        public void CopyMultiSelected(int dx, int dy)
        {
            List <ShapeElement> tempList = new List <ShapeElement>();

            foreach (ShapeElement shape in this.shapes)
            {
                if (shape.Selected)
                {
                    ShapeElement temp = shape.Copy();
                    temp.Selected = false;
                    temp.Move(dx, dy);
                    tempList.Add(temp);

                    this.handlerCol = new BaseHandlerCollection(temp);
                    selectedElement = temp;
                    selectedElement.EndMoveRedim();
                }
            }
            foreach (ShapeElement temp in tempList)
            {
                this.shapes.Add(temp);
                StoreInBuffer(BufferOperation.Insert, temp);
            }
        }
예제 #23
0
 /// <summary>
 /// Deselects element
 /// </summary>
 public void DeSelect()
 {
     shapes.ForEach(shape => shape.Selected = false);
     this.selectedElement = null;
     this.handlerCol      = null;
 }