Exemplo n.º 1
0
        private void InscribePolygon(PaintGraphics graphics, PaintRectangleF rectangle, int numSides)
        {
            float       Radius = (float)((double)Math.Min(rectangle.Width, rectangle.Height) / 2.0);
            ShapePointF Center = new ShapePointF(
                (float)(rectangle.Location.X + rectangle.Width / 2.0),
                (float)(rectangle.Location.Y + rectangle.Height / 2.0));
            PaintRectangleF rectangleF = new PaintRectangleF(Center, new ShaipSizeF(1, 1));

            rectangleF.Inflate(Radius, Radius);

            float Sides         = (float)numSides;
            float ExteriorAngle = (float)360 / Sides;
            float InteriorAngle = (Sides - (float)2) / Sides * (float)180;
            float SideLength    = (float)2 * Radius * (float)Math.Sin(Math.PI / (double)Sides);

            for (int i = 1; i <= Sides; i++)
            {
                graphics.ResetTransform();
                graphics.TranslateTransform(Center.X, Center.Y);
                graphics.RotateTransform((i - 1) * ExteriorAngle);
                graphics.TranslateTransform(0, -Radius);
                graphics.RotateTransform(180 - InteriorAngle / 2);
                graphics.MySmoothingMode = EPaintSmoothingMode.AntiAlias;
                PaintPen pen = new PaintPen(Color, Thickness);
                pen.StartCap = EPaintLineCap.Round;
                pen.EndCap   = EPaintLineCap.Round;
                graphics.DrawLine(
                    pen,
                    new ShapePointF(0, 0).ToPointF(),
                    new ShapePointF(0, -SideLength).ToPointF());
            }
        }
Exemplo n.º 2
0
        private void MainPictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            if (!_isStartMove && !_isSelectMode && !_isMoveMode && e.Button == MouseButtons.Left)
            {
                if (_bl.isBoolCount())
                {
                    IShape currentShape = _bl.Last();
                    currentShape.MouseUp(new ShapePoint(e.Location));
                    Repaint();
                }
            }
            else if (_isStartMove && e.Button == MouseButtons.Left)
            {
                IShape currentShape = _bl.Last();
                _bl.Move(e.X - _lastPonit.X, e.Y - _lastPonit.Y, currentShape);
                currentShape.Draw(PaintGraphics.FromImage(_currentBitmap));
                if (currentShape.Name == EShapeType.Dot)
                {
                    currentShape.EShapeStatus = EShapeStatus.DONE;
                    Repaint();
                }

                _isStartMove = false;
                _isSelected  = false;
            }
        }
Exemplo n.º 3
0
        public override void Draw(PaintGraphics graphics)
        {
            (int x, int y, int width, int height) = CalculateHexagon();

            if (width == 0 || height == 0)
            {
                return;
            }
            if (Cornes == 0)
            {
                Cornes = _cornes;
            }
            width  += Thickness;
            height += Thickness;
            int             Radius    = (int)((double)Math.Min(width, height) / (double)2.0 * (double)0.8);
            ShapePointF     Center    = new ShapePointF((int)((double)width / (double)2.0), (int)((double)height / (double)2.0));
            PaintRectangleF rectangle = new PaintRectangleF(Center, new ShaipSizeF(1, 1));

            rectangle.Inflate(Radius, Radius);

            PaintImage    img         = new PaintBitmap(Size.Width, Size.Height);
            PaintGraphics tmpGraphics = PaintGraphics.FromImage(img);

            InscribePolygon(tmpGraphics, rectangle, _cornes);
            graphics.DrawImage(img, x, y);
        }
Exemplo n.º 4
0
 public override void Draw(PaintGraphics graphics)
 {
     graphics.DrawLine(
         new PaintPen(new PaintSolidBrush(Color), Thickness),
         Location.X,
         Location.Y,
         FinishLocation.X,
         FinishLocation.Y);
 }
Exemplo n.º 5
0
 public override void Draw(PaintGraphics graphics)
 {
     graphics.MySmoothingMode = EPaintSmoothingMode.AntiAlias;
     graphics.DrawEllipse(
         new PaintPen(new PaintSolidBrush(Color), Thickness),
         Location.X,
         Location.Y,
         FinishLocation.X - Location.X,
         FinishLocation.Y - Location.Y);
 }
Exemplo n.º 6
0
 public override void Draw(PaintGraphics graphics)
 {
     (int x, int y, int width, int height) = CalculateRect();
     graphics.DrawRectangle(
         new PaintPen(Color, Thickness),
         x,
         y,
         width,
         height);
 }
Exemplo n.º 7
0
        public override void Draw(PaintGraphics graphics)
        {
            List <ShapePoint> Triangle = new List <ShapePoint>();

            Triangle.Add(new ShapePoint(FinishLocation.X, FinishLocation.Y));
            Triangle.Add(new ShapePoint(Location.X, FinishLocation.Y));
            Triangle.Add(new ShapePoint((Location.X + FinishLocation.X) / 2, Location.Y));

            graphics.DrawPolygon(new PaintPen(new PaintSolidBrush(Color), Thickness), Triangle.ToArray());
        }
Exemplo n.º 8
0
        public override void Draw(PaintGraphics graphics)
        {
            (int x, int y, int width, int height) = CalculateRoundRect();

            graphics.MySmoothingMode = EPaintSmoothingMode.AntiAlias;
            PaintPen pen = new PaintPen(Color, Thickness);

            pen.LineJoin = EPainLinejoin.Round;
            PaintRectangleF   rect = new PaintRectangleF(x, y, width, height);
            PaintGraphicsPath path = this.GetRoundRectangle(rect, radius);

            graphics.DrawPath(pen, path);
        }
Exemplo n.º 9
0
 public override void Draw(PaintGraphics graphics)
 {
     if (EShapeStatus == FigureDrawingClass.EShapeStatus.DONE)
     {
         graphics.MySmoothingMode = EPaintSmoothingMode.AntiAlias;
         graphics.FillEllipse(
             new PaintSolidBrush(Color),
             Location.X - Thickness / 2,
             Location.Y - Thickness / 2,
             Thickness,
             Thickness);
     }
 }
Exemplo n.º 10
0
 private void Repaint()
 {
     if (_bl.isBoolCount())
     {
         IShape currentShape = _bl.Last();
         _bufferedBitmap = _currentBitmap.Clone() as PaintBitmap;
         PaintGraphics _bufferedGraphics = PaintGraphics.FromImage(_bufferedBitmap);
         currentShape.Draw(_bufferedGraphics);
         if (currentShape.EShapeStatus == EShapeStatus.IN_PROGRESS)
         {
             pictureBoxMain.Image = _bufferedBitmap?.ToImage();
         }
         if (currentShape.EShapeStatus == EShapeStatus.DONE)
         {
             _currentBitmap       = _bufferedBitmap?.Clone() as PaintBitmap;
             pictureBoxMain.Image = _currentBitmap?.ToImage();
         }
     }
 }
Exemplo n.º 11
0
 public override void Draw(PaintGraphics graphics)
 {
     if (_points.Count > 1)
     {
         for (int i = 0; i < _points.Count - 1; i++)
         {
             graphics.DrawLine(new PaintPen(new PaintSolidBrush(Color), Thickness), _points[i], _points[i + 1]);
         }
         foreach (ShapePoint point in _points)
         {
             graphics.MySmoothingMode = EPaintSmoothingMode.AntiAlias;
             graphics.FillEllipse(new PaintSolidBrush(Color),
                                  point.X - Thickness / 2,
                                  point.Y - Thickness / 2,
                                  Thickness,
                                  Thickness);
         }
     }
 }