예제 #1
0
        public void EraseTrueFalse(PictureBox pictureBox, Rectangle rect)
        {
            using (Graphics flagGraphics = Graphics.FromImage(pictureBox.Image))
                flagGraphics.FillEllipse(Brushes.White, rect.X, rect.Y, rect.Width, rect.Height);



            pictureBox.Invalidate();
        }
예제 #2
0
        public void Drawing(PictureBox pictureBox, DashStyle dashStyle, Color penColor, Color solidBrushColor, Brush brush)
        {
            using (Graphics flagGraphics = Graphics.FromImage(pictureBox.Image))
            {
                flagGraphics.FillRectangle(Brushes.White, rect.X, rect.Y, rect.Width, rect.Height);

                flagGraphics.FillEllipse(brush, inCircle.rect.X, inCircle.rect.Y, inCircle.rect.Height, inCircle.rect.Width);


                //drawing rectangle
                using (Pen pen = new Pen(penColor, 2))
                {
                    pen.Alignment = PenAlignment.Inset;
                    pen.DashStyle = dashStyle;
                    flagGraphics.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
                }

                //rysowanie stringa w środku:

                using (StringFormat sf = new StringFormat())
                {
                    sf.Alignment     = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    using (Font drawFont = new Font("Arial", 7))
                        using (SolidBrush drawBrush = new SolidBrush(solidBrushColor))
                            flagGraphics.DrawString(text, drawFont, drawBrush, rect, sf);
                }

                inCircle.rect  = new Rectangle((int)rect.X + (int)(rect.Width / 2) - circleRadius, (int)rect.Y - circleRadius, 2 * circleRadius, 2 * circleRadius);
                outCircle.rect = new Rectangle((int)rect.X + (int)(rect.Width / 2) - circleRadius, (int)rect.Y + (int)rect.Height - circleRadius, 2 * circleRadius, 2 * circleRadius);
            }


            if (penColor == Color.Black)
            {
                if (inCircle.isVisible)
                {
                    this.DrawingCircle(pictureBox, penColor, Brushes.White, inCircle);
                }
                if (outCircle.isVisible)
                {
                    this.DrawingCircle(pictureBox, penColor, Brushes.Black, outCircle);
                }
            }
            else
            {
                this.DrawingCircle(pictureBox, penColor, Brushes.White, inCircle);
                this.DrawingCircle(pictureBox, penColor, Brushes.White, outCircle);
            }



            pictureBox.Invalidate();
        }
예제 #3
0
        protected void DrawingCircle(PictureBox pictureBox, Color penColor, Brush brush, Circle circle)
        {
            Rectangle rect = circle.rect;

            using (Graphics flagGraphics = Graphics.FromImage(pictureBox.Image))
            {
                flagGraphics.FillEllipse(brush, rect.X, rect.Y, rect.Height, rect.Width);


                //drawing rectangle
                using (Pen pen = new Pen(penColor, 2))
                {
                    pen.Alignment = PenAlignment.Inset;

                    flagGraphics.DrawEllipse(pen, rect.X, rect.Y, rect.Height, rect.Width);
                }
            }
            pictureBox.Invalidate();
        }
예제 #4
0
        public void DrawingTrueFalse(PictureBox pictureBox, Color solidBrushColor, Rectangle rect, string text)
        {
            using (Graphics flagGraphics = Graphics.FromImage(pictureBox.Image))
            {
                //rysowanie stringa w środku:
                using (StringFormat sf = new StringFormat())
                {
                    sf.Alignment     = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;

                    Rectangle textRect = new Rectangle((int)(rect.X), (int)(rect.Y), (int)rect.Width, (int)rect.Height);
                    using (Font drawFont = new Font("Arial", 7))
                        using (SolidBrush drawBrush = new SolidBrush(solidBrushColor))
                            flagGraphics.DrawString(text, drawFont, drawBrush, textRect, sf);
                }

                pictureBox.Invalidate();
            }
        }
예제 #5
0
        public void Drawing(PictureBox pictureBox, DashStyle dashStyle, Color penColor, Color solidBrushColor, Brush brush)
        {
            using (Graphics flagGraphics = Graphics.FromImage(pictureBox.Image))
            {
                using (GraphicsPath rhombusPath = new GraphicsPath())
                {
                    rhombusPath.AddPolygon(rhombusPoints);

                    Region region = new Region(rhombusPath);

                    RectangleF rect = region.GetBounds(flagGraphics);

                    flagGraphics.FillPath(brush, rhombusPath);
                    using (Pen pen = new Pen(penColor, 2))
                    {
                        pen.Alignment = PenAlignment.Inset;
                        pen.DashStyle = dashStyle;
                        flagGraphics.DrawPath(pen, rhombusPath);

                        //rysowanie stringa w środku:
                        using (StringFormat sf = new StringFormat())
                        {
                            sf.Alignment     = StringAlignment.Center;
                            sf.LineAlignment = StringAlignment.Center;

                            Rectangle textRect = new Rectangle((int)(rect.X + rect.Width / 4), (int)(rect.Y + rect.Height / 4), (int)rect.Width / 2, (int)rect.Height / 2);
                            using (Font drawFont = new Font("Arial", 7))
                                using (SolidBrush drawBrush = new SolidBrush(solidBrushColor))
                                    flagGraphics.DrawString(this.text, drawFont, drawBrush, textRect, sf);
                        }
                    }

                    inCircle.rect    = new Rectangle((int)rect.X + (int)(rect.Width / 2) - circleRadius, (int)rect.Y - circleRadius, 2 * circleRadius, 2 * circleRadius);
                    falseCircle.rect = new Rectangle((int)rect.X - circleRadius, (int)rect.Y + (int)(rect.Height / 2) - circleRadius, 2 * circleRadius, 2 * circleRadius);
                    trueCircle.rect  = new Rectangle((int)rect.X + (int)(rect.Width) - circleRadius, (int)rect.Y + (int)(rect.Height / 2) - circleRadius, 2 * circleRadius, 2 * circleRadius);
                }

                if (penColor == Color.Black)
                {
                    if (inCircle.isVisible)
                    {
                        this.DrawingCircle(pictureBox, penColor, Brushes.White, inCircle);
                    }

                    if (trueCircle.isVisible)
                    {
                        this.DrawingCircle(pictureBox, penColor, Brushes.Black, trueCircle);
                    }
                    this.DrawingTrueFalse(pictureBox, penColor, new Rectangle(trueCircle.rect.X, trueCircle.rect.Y - 3 * circleRadius, 2 * circleRadius, 2 * circleRadius), "T");


                    if (falseCircle.isVisible)
                    {
                        this.DrawingCircle(pictureBox, penColor, Brushes.Black, falseCircle);
                    }
                    this.DrawingTrueFalse(pictureBox, penColor, new Rectangle(falseCircle.rect.X, falseCircle.rect.Y - 3 * circleRadius, 2 * circleRadius, 2 * circleRadius), "F");
                }
                else
                {
                    this.DrawingCircle(pictureBox, penColor, Brushes.White, inCircle);

                    this.DrawingCircle(pictureBox, penColor, Brushes.White, trueCircle);
                    this.EraseTrueFalse(pictureBox, new Rectangle(trueCircle.rect.X, trueCircle.rect.Y - 3 * circleRadius - 2, 2 * circleRadius, 3 * circleRadius));

                    this.DrawingCircle(pictureBox, penColor, Brushes.White, falseCircle);
                    this.EraseTrueFalse(pictureBox, new Rectangle(falseCircle.rect.X, falseCircle.rect.Y - 3 * circleRadius - 2, 2 * circleRadius, 3 * circleRadius));
                }
                pictureBox.Invalidate();
            }
        }