DrawEllipse() public méthode

public DrawEllipse ( Pen pen, Rectangle rect ) : void
pen Pen
rect Rectangle
Résultat void
Exemple #1
0
        /// <summary>
        /// Draw method.
        /// </summary>
        /// <param name="g">Graphics context.</param>
        public override void Draw(Graphics g)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            g.FillEllipse(LcogBrushes.Planet, this.X, this.Y, 2, 2);

            if (this.Faction == null)
            {
            }
            else if (this.Faction == Client.Instance.Player.Faction)
            {
                g.DrawEllipse(LcogPens.OwnPlanet, this.X - 2, this.Y - 2, 6, 6);
            }
            else if (this.Faction != Client.Instance.Player.Faction && this.Faction.Relations == "neutral")
            {
                g.DrawEllipse(LcogPens.NeutralPlanet, this.X - 2, this.Y - 2, 6, 6);
            }
            else
            {
                g.DrawEllipse(LcogPens.HostilePlanet, this.X - 2, this.Y - 2, 6, 6);
            }

            if (this == Client.Instance.Selected)
            {
                g.DrawEllipse(LcogPens.Selected, this.X - 2, this.Y - 2, 6, 6);
            }
        }
Exemple #2
0
 private void DrawLineBetweenJoints(Graphics g, Skeleton skel, SkeletonJoint.JointType j1, SkeletonJoint.JointType j2)
 {
     try
     {
         if (skel.State == Skeleton.SkeletonState.TRACKED)
         {
             SkeletonJoint joint1 = skel.getJoint(j1);
             SkeletonJoint joint2 = skel.getJoint(j2);
             if (joint1.Position.Z > 0 && joint2.Position.Z > 0)
             {
                 Point j1PosEllipse = new Point();
                 Point j2PosEllipse = new Point();
                 NiTEWrapper.PointF j1PosLine = uTracker.ConvertJointCoordinatesToDepth(joint1.Position);
                 NiTEWrapper.PointF j2PosLine = uTracker.ConvertJointCoordinatesToDepth(joint2.Position);
                 j1PosEllipse.X = (int)j1PosLine.X - 5;
                 j1PosEllipse.Y = (int)j1PosLine.Y - 5;
                 j2PosEllipse.X = (int)j2PosLine.X - 5;
                 j2PosEllipse.Y = (int)j2PosLine.Y - 5;
                 j1PosLine.X -= 2;
                 j1PosLine.Y -= 2;
                 j2PosLine.X -= 2;
                 j2PosLine.Y -= 2;
                 g.DrawLine(new Pen(Brushes.White, 3), j1PosLine.X, j1PosLine.Y, j2PosLine.X, j2PosLine.Y);
                 g.DrawEllipse(new Pen(Brushes.White, 5), new Rectangle(j1PosEllipse, new System.Drawing.Size(5, 5)));
                 g.DrawEllipse(new Pen(Brushes.White, 5), new Rectangle(j2PosEllipse, new System.Drawing.Size(5, 5)));
             }
         }
     }
     catch (Exception) { }
 }
Exemple #3
0
        public override void Draw(Graphics g, Pen p, Brush b)
        {
            if (g == null)
            {
                throw new ShapeException("Graphics is null");
            }
            else if (g == null && p == null)
            {
                throw new ShapeException("Pen && Brush is null");
            }

            //Нарисовать элипс необходимого типа

            if (this.IsFill)
            {
                if (b == null) { throw new ShapeException("Brash is null"); }
                g.FillEllipse(b, new Rectangle(BeginPoint.X, BeginPoint.Y, EndPoint.X - BeginPoint.X, EndPoint.Y - BeginPoint.Y));
                if (p != null)
                {
                    g.DrawEllipse(p, new Rectangle(BeginPoint.X, BeginPoint.Y, EndPoint.X - BeginPoint.X, EndPoint.Y - BeginPoint.Y));
                }
            }
            else
            {
                if (p == null) { throw new ShapeException("Pen is null"); }
                g.DrawEllipse(p, new Rectangle(BeginPoint.X, BeginPoint.Y, EndPoint.X - BeginPoint.X, EndPoint.Y - BeginPoint.Y));
            }
        }
        internal override void Render(Graphics graphics, SizeF minimumSize, PointF location)
        {
            var size = Measure(graphics);
            size.Width = Math.Max(minimumSize.Width, size.Width);
            size.Height = Math.Max(minimumSize.Height, size.Height);

            Brush incomingSignalColor = Brushes.LightSteelBlue;
            Brush ownSignalColor = Brushes.LightSteelBlue;

            if (m_signal.IsIncomingRised())
            {
                incomingSignalColor = Brushes.LimeGreen;
            }

            if (m_signal.IsDropped())
            {
                ownSignalColor = Brushes.Tomato;
            }
            if (m_signal.IsRised())
            {
                ownSignalColor = Brushes.LimeGreen;
            }

            graphics.FillEllipse(incomingSignalColor, location.X + SIGNAL_OFFSET, location.Y + SIGNAL_OFFSET, SIGNAL_SIZE, SIGNAL_SIZE);
            graphics.DrawEllipse(Pens.DimGray, location.X + SIGNAL_OFFSET, location.Y + SIGNAL_OFFSET, SIGNAL_SIZE, SIGNAL_SIZE);

            graphics.FillEllipse(ownSignalColor, location.X + 2 * SIGNAL_OFFSET + SIGNAL_SIZE, location.Y + SIGNAL_OFFSET, SIGNAL_SIZE, SIGNAL_SIZE);
            graphics.DrawEllipse(Pens.DimGray, location.X + 2 * SIGNAL_OFFSET + SIGNAL_SIZE, location.Y + SIGNAL_OFFSET, SIGNAL_SIZE, SIGNAL_SIZE);

            graphics.DrawString(this.Text, SystemFonts.MenuFont, Brushes.Black, new RectangleF(location, size), GraphConstants.RightTextStringFormat);
        }
Exemple #5
0
        void insertLights(Graphics g)
        {
            return;

            uint mapSize = 64 * 17;
            float realSize = 64 * Utils.Metrics.Tilesize;
            float step = realSize / mapSize;
            Pen innerPen = new Pen(Color.Orange, 4);
            Pen outerPen = new Pen(Color.Red, 4);

            foreach (var dbl in DBC.DBCStores.Light.Records)
            {
                if (dbl.MapID == Game.GameManager.WorldManager.MapID)
                {
                    float x = dbl.x / 36;
                    float y = dbl.z / 36;
                    x /= step;
                    y /= step;
                    float iRadius = dbl.falloff / 36;
                    iRadius /= step;
                    float oRadius = dbl.falloffEnd / 36;
                    oRadius /= step;

                    g.DrawEllipse(innerPen, x - iRadius, y - iRadius, 2 * iRadius, 2 * iRadius);
                    g.DrawEllipse(outerPen, x - oRadius, y - oRadius, 2 * oRadius, 2 * oRadius);
                }
            }
        }
        public override void drawnShap(Graphics pe)
        {
            Brush CurrentBrush = initBrush();
            if (this.State.Shift1 == true)
            {
                calcShift();

                findSecondPointWhenShift();

                pe.DrawEllipse(new Pen(State.CurrentColor, State.LineWidth), State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Width1);
                if (State.IsBrushFill == true)
                {
                    pe.FillEllipse(CurrentBrush, State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Width1);
                }
            }
            else
            {
                calcHeightWidth();
                pe.DrawEllipse(new Pen(State.CurrentColor, State.LineWidth), State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Height1);

                if (State.IsBrushFill == true)
                {
                    pe.FillEllipse(CurrentBrush, State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Height1);
                }
            }


        }
Exemple #7
0
        public void backward(Graphics g, string textBoxrstartx1, string textBoxrstarty1, string textBoxrtravel, string textBoxrangle, string textBoxrendx, string textBoxrendy)
        {
            IncializePic(g);

            //Draw Robot Angle
            x1 = double.Parse(textBoxrstartx1);
            y1 = double.Parse(textBoxrstarty1);
            x2 = (double)((Convert.ToDouble(textBoxrtravel)) * Math.Cos((Math.PI / 180) * (Convert.ToDouble(textBoxrangle))));
            y2 = (double)((Convert.ToDouble(textBoxrtravel)) * Math.Sin((Math.PI / 180) * (Convert.ToDouble(textBoxrangle))));
            x3 = (double)(length * Math.Cos((Math.PI / 180) * (Convert.ToDouble(textBoxrangle))));
            y3 = (double)(length * Math.Sin((Math.PI / 180) * (Convert.ToDouble(textBoxrangle))));

            //Old Position
            g.DrawLine(p3, (float)x1, (float)y1, (float)(x1 + x3), (float)(y1 + y3));
            //Old Direction
            g.DrawEllipse(p3, (float)x1 - 5, (float)y1 - 5, 10, 10);

            //Draw Direction
            g.DrawLine(p1, (float)(x1 - x2), (float)(y1 - y2), (float)(x1 - x2 + x3), (float)(y1 - y2 + y3));
            //Draw Robot Position /Start Point Incremented
            g.DrawEllipse(p1, (float)(x1 - x2) - 5, (float)(y1 - y2) - 5, 10, 10);

            //Draw End Point
            g.DrawEllipse(p2, (float)double.Parse(textBoxrendx) - 5, (float)double.Parse(textBoxrendy) - 5, 10, 10);
        }
Exemple #8
0
 public void Draw(Graphics aGraphics)
 {
     float s = Size * 0.27f;
     aGraphics.DrawRectangle(Pens.Purple, Center.X - s, Center.Y - s, s * 2, s * 2);
     aGraphics.DrawEllipse(Pens.Purple, Center.X - 10, Center.Y - 10, 20, 20);
     aGraphics.DrawEllipse(Pens.Purple, Center.X - (Size * 0.5f), Center.Y - (Size * 0.5f), Size, Size);
 }
        }//end constructor

        //call the paint method
        public override void paint (Graphics graphics)
        {
            try
            {
                //save the old value of the circle position
                previousLeftPosition = leftPosition;
                previousTopPosition = topPosition;

                //put this thread to sleep
                Thread.Sleep(speed);

                //lock thread to prevent thread from running back on itself
                lock (typeof(Thread))
                {
                    leftPosition = leftPosition + base.directionX;
                    topPosition = topPosition + base.directionY;
                    base.CheckCoordinates();

                    //grouped the drawing functions together like this to slightly reduce flickering
                    graphics.DrawEllipse(new System.Drawing.Pen(Color.White), previousLeftPosition, previousTopPosition, width, height);
                    graphics.DrawEllipse(new System.Drawing.Pen(shapeColor), leftPosition, topPosition, width, height);
                }
            }
            catch
            {
                //force the thread to end, but only after removing the shape from the screen
                graphics.Clear(Color.White);
                Thread.CurrentThread.Abort();
            }
        }//end paint
Exemple #10
0
        //default robot draw method
        public virtual void draw(Graphics g, CoordinateFrame frame)
        {
            Point upperleft = frame.to_display((float)(circle.p.x - radius),(float)(circle.p.y- radius));
            int size = (int)((radius*2)/frame.scale);
            Rectangle r = new Rectangle(upperleft.X,upperleft.Y,size,size);
            if (disabled)
                g.DrawEllipse(EngineUtilities.YellowPen, r);
            else if (collide_last)
                g.DrawEllipse(EngineUtilities.RedPen, r);
            else if (corrected)
                g.DrawEllipse(EngineUtilities.YellowPen, r);
            else
                g.DrawEllipse(EngineUtilities.BluePen, r);
            int sensCount=0;
            foreach(ISensor sensor in sensors)
            {
                sensor.draw(g,frame);
            }

            if(display_debug)
            foreach(ISensor sensor in sensors)
            {
                if(draw_sensors) {
                double val = sensor.get_value();
                if(val<0.0) val=0.0;
                if(val>1.0) val=1.0;
                Color col = Color.FromArgb((int)(val*255),0,0); //(int)(val*255),(int)(val*255));
                SolidBrush newpen = new SolidBrush(col);
                g.FillRectangle(newpen,sensCount*40,500+30*id,40,30);
                sensCount+=1;
                }
            }
        }
 private void DrawMagnetControl(Graphics g, double a)
 {
     g.DrawEllipse(Pens.Red, 200, 200, 100, 100);
     float x = (float)(100 * Math.Cos(a));
     float y = (float)(100 * Math.Sin(a));
     g.DrawEllipse(Pens.Black, x, y, 1, 1);
 }
        public override void draw(Graphics g, int width, int height)
        {
            setRectangle(width, height);

            if (m_Rectangle.X > width * 0.4 && m_Rectangle.X < width * 0.6)
                g.DrawEllipse(System.Drawing.Pens.Red, m_Rectangle);
            else
                g.DrawEllipse(m_Pen, m_Rectangle);
        }
Exemple #13
0
 public override void Draw(Graphics g, Rectangle clip)
 {
     var stoneWidth = clip.Width / 3;
     int stoneHeight = clip.Height / 3;
     if(Stones >= 1) g.DrawEllipse(_pen, new Rectangle(clip.X + 1, clip.Y + 1, stoneWidth, stoneHeight));
     if(Stones >= 2) g.DrawEllipse(_pen, new Rectangle(clip.Right - stoneWidth - 1, clip.Y + 1, stoneWidth, stoneHeight));
     if(Stones >= 3) g.DrawEllipse(_pen, new Rectangle(clip.X + 1, clip.Bottom - stoneHeight - 1, stoneWidth, stoneHeight));
     if(Stones >= 4) g.DrawEllipse(_pen, new Rectangle(clip.Right - stoneWidth - 1, clip.Bottom - stoneHeight - 1, stoneWidth, stoneHeight));
 }
 public static void CreatePersonFat(Graphics g, Pen p)
 {
     g.DrawEllipse(p, 50, 20, 30, 30); //head
     g.DrawEllipse(p, 45, 50, 40, 50); //body
     g.DrawLine(p, 50, 50, 30, 100); //left arm
     g.DrawLine(p, 80, 50, 100, 100); //right arm
     g.DrawLine(p, 60, 100, 45, 150); //left leg
     g.DrawLine(p, 70, 100, 85, 150); //right leg
 }
Exemple #15
0
        public void Draw(Graphics aGraphics)
        {
            aGraphics.DrawLine(Pens.Purple, Center.X + X.X + Y.X, Center.Y + X.Y + Y.Y, Center.X - X.X + Y.X, Center.Y - X.Y + Y.Y);
            aGraphics.DrawLine(Pens.Purple, Center.X + X.X + Y.X, Center.Y + X.Y + Y.Y, Center.X + X.X - Y.X, Center.Y + X.Y - Y.Y);
            aGraphics.DrawLine(Pens.Purple, Center.X - X.X - Y.X, Center.Y - X.Y - Y.Y, Center.X - X.X + Y.X, Center.Y - X.Y + Y.Y);
            aGraphics.DrawLine(Pens.Purple, Center.X - X.X - Y.X, Center.Y - X.Y - Y.Y, Center.X + X.X - Y.X, Center.Y + X.Y - Y.Y);

            aGraphics.DrawEllipse(Pens.Purple, Center.X - 10, Center.Y - 10, 20, 20);
            aGraphics.DrawEllipse(Pens.Purple, Center.X - 50, Center.Y - 50, 100, 100);
        }
 public override void Draw(Graphics g)
 {
     Pen pen = new Pen(Brushes.Black,3);
        UpdateBounds();
        g.FillEllipse(Brushes.Red, X,Y, 10, 10);
        g.DrawEllipse(pen, X - 3, Y - 3, 13, 13);
        g.FillPie(Brushes.White,X,Y, 10, 10, 0, 180);
        g.DrawEllipse(pen, X + 3, Y + 3, 2, 2);
     Y = Y - BallInterval;
 }
        public static void drawPolarGraph(Graphics g,Panel p)
        {
            Pen largePen = new Pen(Color.Black,2);
            Pen smallPen = new Pen(Color.Gray, 1);
            Font mainFont = SystemFonts.DefaultFont;
            SolidBrush blackBrush = new SolidBrush(Color.Black);

            int width = p.Width;
            int height = p.Height;

            Point center = new Point(width/2,height/2);

            int radius = 0;
            if (width <= height)
                radius = width / 2 - 30;
            else
                radius = height / 2 - 30;

            g.DrawEllipse(largePen, center.X - radius, center.Y-radius, radius * 2, radius * 2);
            g.DrawEllipse(largePen, center.X - 2, center.Y - 2, 4, 4);

            for (int i = 1; i <= 4; i++)
            {
                g.DrawEllipse(smallPen, center.X - i * radius/4, center.Y - i * radius/4, radius * i/2, radius * i/2);
            }

            for (int i = 0; i < 360; i += 360 / 12) // create radial pattern every 360/12 = 30 degrees
            {
                int x2 = Convert.ToInt32(center.X + radius * Math.Sin(Equations.toRad(i)));
                int y2 = Convert.ToInt32(center.Y + radius * Math.Cos(Equations.toRad(i-180)));
                Point endPoint = new Point(x2,y2);
                g.DrawLine(smallPen, center, endPoint); // draw lines

                PointF textLocation;
                int xOffset = 0; // this next section find the postion offset for the text. purely for cosmetic purposes
                if (i == 0 || i == 180)
                    xOffset = 0;
                else if (i > 0 && i < 180)
                    xOffset = 5;
                else
                    xOffset = -25;

                int yOffset = 0;
                if (i == 90 || i == 270)
                    yOffset = -10;
                else if (i > 90 && i < 270)
                    yOffset = 10;
                else
                    yOffset = -20;

                textLocation = new PointF(x2+xOffset,y2+yOffset +2);

                g.DrawString(Convert.ToString(i), mainFont, blackBrush, textLocation); //draw angle text
            }
        }
Exemple #18
0
        public void Draw(Graphics g)
        {
            float r = this.r / 4;

            float d = (float)Math.Sqrt(this.vx * this.vx + this.vy * this.vy);
            if (d != 0.0f) {
                float vx = this.vx / d;
                float vy = this.vy / d;
                float vx_ = vy;
                float vy_ = -vx;

                PointF[] points = new PointF[3];
                points[0] = new PointF(this.px + this.r * vx_, this.py + this.r * vy_);
                points[1] = new PointF(this.px + 3 * this.r / 2 * vx, this.py + 3 * this.r / 2 * vy);
                points[2] = new PointF(this.px - this.r * vx_, this.py - this.r * vy_);
                Brush brush = new SolidBrush(Color.FromArgb(150, Color.Blue));
                g.FillPolygon(brush, points);

                float x;
                float y;

                float rFoot = this.r - r / 2;
                float rHand = 2 * r;
                float koef = (float)Math.Sin(this.t / rFoot * (float)Math.PI);
                float dFoot = rFoot * koef;
                float dHand = rHand * koef;

                x = this.px + vx_ * (this.r - r) + dHand * vx;
                y = this.py + vy_ * (this.r - r) + dHand * vy;
                g.FillEllipse(this.brush, x - r, y - r, 2 * r, 2 * r);
                g.DrawEllipse(this.pen, x - r, y - r, 2 * r, 2 * r);

                x = this.px + vx_ * r - dFoot * vx;
                y = this.py + vy_ * r - dFoot * vy;
                g.FillEllipse(this.brush, x - r, y - r, 2 * r, 2 * r);
                g.DrawEllipse(this.pen, x - r, y - r, 2 * r, 2 * r);

                x = this.px - vx_ * (this.r - r) - dHand * vx;
                y = this.py - vy_ * (this.r - r) - dHand * vy;
                g.FillEllipse(this.brush, x - r, y - r, 2 * r, 2 * r);
                g.DrawEllipse(this.pen, x - r, y - r, 2 * r, 2 * r);

                x = this.px - vx_ * r + dFoot * vx;
                y = this.py - vy_ * r + dFoot * vy;
                g.FillEllipse(this.brush, x - r, y - r, 2 * r, 2 * r);
                g.DrawEllipse(this.pen, x - r, y - r, 2 * r, 2 * r);

                this.t += d;
            } else {
                this.t = 0.0f;
            }

            g.FillEllipse(this.brush, this.px - this.r, this.py - this.r, 2 * this.r, 2 * this.r);
            g.DrawEllipse(this.pen, this.px - this.r, this.py - this.r, 2 * this.r, 2 * this.r);
        }
Exemple #19
0
 public void draw(Graphics g, CoordinateFrame frame)
 {
     Point upperleft = frame.to_display((float)(circle.p.x - circle.radius), (float)(circle.p.y - circle.radius));
     int size = (int)((circle.radius * 2) / frame.scale);
     Rectangle r = new Rectangle(upperleft.X, upperleft.Y, size, size);
     if (caught)
         g.DrawEllipse(EngineUtilities.BluePen, r);
     else if (visible)
         g.DrawEllipse(EngineUtilities.RedPen, r);
     else
         g.DrawEllipse(EngineUtilities.GreendPen, r);
 }
Exemple #20
0
        public void Draw(Graphics grafico)
        {
            Pen p = new Pen(Color.Black);

            grafico.DrawEllipse(p,r1);
            grafico.FillEllipse(brs[0],r1);
            grafico.DrawEllipse(p,r2);
            grafico.FillEllipse(brs[1],r2);
            grafico.DrawEllipse(p,r3);
            grafico.FillEllipse(brs[2],r3);
            grafico.DrawEllipse(p,r4);
            grafico.FillEllipse(brs[3],r4);
        }
Exemple #21
0
 public override void Draw(Graphics Container, bool isSelected)
 {
     Rectangle rect = new Rectangle(new Point(position.X - 12, position.Y - 12), new Size(25, 25));
     if (isSelected)
     {
         Pen myPen = new Pen(Color.Red);
         Container.DrawEllipse(myPen, rect);
     }
     else
     {
         Pen myPen = new Pen(Color.Black);
         Container.DrawEllipse(myPen, rect);
     }
 }
Exemple #22
0
 public void DrawToGraphics(Graphics g, PointF center, bool isFringe = false, bool isSelected = false)
 {
     if(isFringe)
     {
         if(isSelected)
             g.DrawEllipse(new Pen(GlobalSettings.selectedPen.Color,1.5f), center.X - GlobalSettings.fringeCircleSize, center.Y - GlobalSettings.fringeCircleSize, GlobalSettings.fringeCircleSize * 2, GlobalSettings.fringeCircleSize * 2);
         else
             g.DrawEllipse(new Pen(GlobalSettings.fringeLabelsColor, 1.5f), center.X - GlobalSettings.fringeCircleSize, center.Y - GlobalSettings.fringeCircleSize, GlobalSettings.fringeCircleSize * 2, GlobalSettings.fringeCircleSize * 2);
     }
     else
     {
         g.DrawEllipse(pen, center.X - ratio, center.Y - ratio, ratio * 2, ratio * 2);
     }
 }
Exemple #23
0
        public static void DrawBone(Bone b, Graphics graph, PointF rootPos, bool selected = false)
        {
            if (b.IsRoot)
            {
                if (selected)
                {
                    graph.DrawEllipse(Pens.Orange, rootPos.X - 30, rootPos.Y - 30, 60, 60);
                }
                else
                {
                    graph.DrawEllipse(Pens.Black, rootPos.X - 30, rootPos.Y - 30, 60, 60);
                }
            }
            else
            {
                PointV p0 = new PointV(b.StartPoint);
                PointV p3 = new PointV(b.EndPoint);
                PointV p1 = p3 - p0;
                PointV p2 = p1.Rotate(-0.2745);
                p1 = p1.Rotate(0.2745);
                p2.Length = p2.Length * 0.2;
                p1.Length = p1.Length * 0.2;
                p2 = p2 + p0;
                p1 = p1 + p0;
                Pen pen0 = new Pen(Color.Black);
                Brush brush0 = new SolidBrush(Color.FromArgb(180, Color.DarkGray));
                Pen pen1 = new Pen(Color.Black);
                pen1.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                PointF[] pts = new PointF[] { p0.Add(rootPos).Point, p1.Add(rootPos).Point,
                        p3.Add(rootPos).Point, p2.Add(rootPos).Point };
                if (selected)
                {
                    brush0 = new SolidBrush(Color.FromArgb(180, Color.Orange));
                    pen1.Color = Color.Orange;
                    pen0.Color = Color.Orange;
                    graph.DrawPolygon(pen0, pts);
                    graph.FillPolygon(brush0, pts);
                    graph.DrawLine(pen1, PointV.Add(rootPos, b.StartPoint), PointV.Add(rootPos, b.Parent.EndPoint));

                }
                else
                {
                    graph.DrawPolygon(pen0, pts);
                    graph.FillPolygon(brush0, pts);
                    graph.DrawLine(pen1, PointV.Add(rootPos, b.StartPoint), PointV.Add(rootPos, b.Parent.EndPoint));
                }

            }
        }
Exemple #24
0
        public override void OnRender(Graphics g) {
            System.Drawing.Point p1 = new System.Drawing.Point(LocalPosition.X, LocalPosition.Y);
            //new Pen(Color.FromArgb(144, Color.MidnightBlue));
            Rectangle r = new Rectangle(p1.X,p1.Y,10,10);
            Rectangle r2 = new Rectangle(p1.X+5, p1.Y, 10, 10);
            //g.FillEllipse(Brushes.White, r);
            //g.FillEllipse(Brushes.White, r2);
            g.DrawEllipse(Pens.Blue, r);
            g.DrawEllipse(Pens.Blue, r2);
            if (ShowText && !string.IsNullOrEmpty(Text)) {
                Size sf=g.MeasureString(Text, mFont).ToSize();

                g.DrawString(Text, mFont, Brushes.Black, LocalPosition.X+7  - sf.Width / 2, LocalPosition.Y - 15);
            }
        }
Exemple #25
0
        /*BuildPlayer method - Builds the player for the game*/
        public Graphics BuildPlayer(Graphics graphics, int x, int y)
        {
            Pen penColor = new Pen(Color.Black, 2);                         // Creating a new instance of the Pen object to use for the player creation

            graphics.DrawEllipse(penColor, x, y, 50, 50);                   //Head
            graphics.DrawEllipse(penColor, x + 15, y + 10, 5, 5);           //Left Eye
            graphics.DrawEllipse(penColor, x + 30, y + 10, 5, 5);           //Right Eye
            graphics.DrawEllipse(penColor, x + 16, y + 30, 20, 6);          //Mouth
            graphics.DrawLine(penColor, x + 25, y + 50, x + 25, y + 90);    //Body
            graphics.DrawLine(penColor, x + 10, y + 70, x + 40, y + 70);    //Arms
            graphics.DrawLine(penColor, x + 25, y + 90, x + 10, y + 110);   //Left Leg
            graphics.DrawLine(penColor, x + 25, y + 90, x + 40, y + 110);   //Right Leg

            return graphics;
        }
Exemple #26
0
 public void Draw3LineChar(object sender, PaintEventArgs e, List<int> P,List<int> Q,List<int> R)
 {
     if (P.Count == 0) return;
     //绘图
     g = e.Graphics;
     //横纵坐标
     g.DrawLine(black_pen, new Point(x0, (y0 + y1) / 2), new Point(x1, (y0 + y1) / 2));
     g.DrawLine(black_pen, new Point(x0, y0), new Point(x0, y1));
     int half=(y1+y0)/2;
     for (int i = 1; i < half; i++)
     {
         g.DrawLine(black_pen, new Point(x0, (int)(half + unit_y * i)), new Point(x0 + 4, (int)(half + unit_y * i)));
         g.DrawString((-i * 260 * unit_y).ToString(), new Font("微软雅黑", 6), Brushes.Black, new Point(x0, (int)(half + unit_y * i)));
         g.DrawLine(black_pen, new Point(x0, (int)(half - unit_y * i)), new Point(x0 + 4, (int)(half - unit_y * i)));
         g.DrawString((i * 260 * unit_y).ToString(), new Font("微软雅黑", 6), Brushes.Black, new Point(x0, (int)(half - unit_y * i)));
     }
     //绘制第一个点(圈)
     point_rect = new Rectangle(x0 - 1, (y1 + y0) / 2 - P[0] - 1, 2, 2);
     g.DrawEllipse(r_pen, point_rect);
     //
     point_rect = new Rectangle(x0 - 1, (y1 + y0) / 2 - Q[0] - 1, 2, 2);
     g.DrawEllipse(g_pen, point_rect);
     //
     point_rect = new Rectangle(x0 - 1, (y1 + y0) / 2 - R[0] - 1, 2, 2);
     g.DrawEllipse(b_pen, point_rect);
     //绘制后面的点,并把相邻的点绘制好
     for (int i = 1; i < P.Count; i++)
     {
         point_rect = new Rectangle((int)(x0 + unit_x * i - 1), (y1 + y0) / 2 - P[i] - 1, 2, 2);
         g.DrawEllipse(r_pen, point_rect);
         g.DrawLine(b_pen, new Point((int)(x0 + unit_x * (i - 1)), (y1 + y0) / 2 - P[i - 1]), new Point((int)(x0 + unit_x * i), (y1 + y0) / 2 - P[i]));
         //
         point_rect = new Rectangle((int)(x0 + unit_x * i - 1), (y1 + y0) / 2 - Q[i] - 1, 2, 2);
         g.DrawEllipse(g_pen, point_rect);
         g.DrawLine(r_pen, new Point((int)(x0 + unit_x * (i - 1)), (y1 + y0) / 2 - Q[i - 1]), new Point((int)(x0 + unit_x * i), (y1 + y0) / 2 - Q[i]));
         //
         point_rect = new Rectangle((int)(x0 + unit_x * i - 1), (y1 + y0) / 2 - R[i] - 1, 2, 2);
         g.DrawEllipse(b_pen, point_rect);
         g.DrawLine(g_pen, new Point((int)(x0 + unit_x * (i - 1)), (y1 + y0) / 2 - R[i - 1]), new Point((int)(x0 + unit_x * i), (y1 + y0) / 2 - R[i]));
     }
     //删除第一个点
     if (P.Count > div_x)
     {
         P.RemoveAt(0);
         Q.RemoveAt(0);
         R.RemoveAt(0);
     }
 }
Exemple #27
0
        public static void DrawOverlay(Graphics g, int topNumCandidates, bool showPeakPixels)
        {
            if (s_CandidateScores != null)
            {
                s_TopCandidatesToTake = topNumCandidates;

                var hotPixelsList = s_Candidates.Take(topNumCandidates);
                if (m_ShowHotPixelPositions)
                {
                    foreach (ImagePixel pixel in hotPixelsList)
                    {
                        g.DrawEllipse(Pens.Yellow, pixel.X - 5, pixel.Y - 5, 10, 10);
                    }
                }

                if (showPeakPixels && topNumCandidates < s_Candidates.Count())
                {
                    for (int i = topNumCandidates; i < s_Candidates.Length; i++)
                    {
                        ImagePixel pixel= s_Candidates[i];
                        g.DrawLine(Pens.Pink, pixel.X - 5, pixel.Y, pixel.X + 5, pixel.Y);
                        g.DrawLine(Pens.Pink, pixel.X, pixel.Y - 5, pixel.X, pixel.Y + 5);
                        g.DrawString(s_CandidateScores[i].ToString("0.00"), s_Font, Brushes.Pink, pixel.X + 1, pixel.Y - 10);
                    }
                }
            }
        }
Exemple #28
0
    public override void Paint(System.Drawing.Graphics g, double x, double y, double scale)
    {
        double scaledRadius = this.Radius * scale;

        if ((x + scaledRadius < g.VisibleClipBounds.Left || x - scaledRadius > g.VisibleClipBounds.Right)
            &&
            (y + scaledRadius < g.VisibleClipBounds.Top || y - scaledRadius < g.VisibleClipBounds.Bottom))
        {
            return;
        }

        Vector orientation = this.Orientation.Copy();

        if (this.Radius == 0)
        {
            g.DrawLine(this.Pen, (float)x, (float)y, (float)(x + 1), (float)(y));
        }
        else
        {
            scaledRadius = Math.Max(Math.Ceiling(scaledRadius), 0.1);
            g.DrawEllipse(this.Pen,
                          (float)(x - scaledRadius),
                          (float)(y - scaledRadius),
                          (float)scaledRadius * 2,
                          (float)scaledRadius * 2);

            orientation *= scaledRadius;
            float x0 = (float)(x + (orientation * 0.9).X);
            float y0 = (float)(y + (orientation * 0.9).Y);
            float x1 = (float)(x + (orientation * 1.2).X);
            float y1 = (float)(y + (orientation * 1.2).Y);

            g.DrawLine(this.Pen, x0, y0, x1, y1);
        }
    }
Exemple #29
0
		/// <summary>
		/// This allows another container to draw an ellipse
		/// </summary>
		/// <param name="caller"></param>
		/// <param name="graphics"></param>
		/// <param name="renderMode"></param>
		public static void DrawEllipse(Rectangle rect, Graphics graphics, RenderMode renderMode, int lineThickness, Color lineColor, Color fillColor, bool shadow) {

			bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
			// draw shadow before anything else
			if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
				int basealpha = 100;
				int alpha = basealpha;
				int steps = 5;
				int currentStep = lineVisible ? 1 : 0;
				while (currentStep <= steps) {
					using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
						shadowPen.Width = lineVisible ? lineThickness : 1;
						Rectangle shadowRect = GuiRectangle.GetGuiRectangle(rect.Left + currentStep, rect.Top + currentStep, rect.Width, rect.Height);
						graphics.DrawEllipse(shadowPen, shadowRect);
						currentStep++;
						alpha = alpha - basealpha / steps;
					}
				}
			}
			//draw the original shape
			if (Colors.IsVisible(fillColor)) {
				using (Brush brush = new SolidBrush(fillColor)) {
					graphics.FillEllipse(brush, rect);
				}
			}
			if (lineVisible) {
				using (Pen pen = new Pen(lineColor, lineThickness)) {
					graphics.DrawEllipse(pen, rect);
				}
			}
		}
 private void DrawHouse(Graphics g, int mouseX, int mouseY)
 {
     Point topLeft = new Point(mouseX, mouseY);
     Point topRight = new Point(mouseX + size, mouseY);
     Point bottomLeft = new Point(mouseX, mouseY + size);
     Point bottomRight = new Point(mouseX + size, mouseY + size);
     Point top = new Point(mouseX + (size / 2), mouseY - (int)(size * 0.5));
     Point doorBottomLeft = new Point(bottomLeft.X + (int)(size * 0.2), bottomLeft.Y);
     Point doorBottomRight = new Point(bottomLeft.X + (int)(size * 0.5), bottomLeft.Y);
     Point doorTopLeft = new Point(doorBottomLeft.X, doorBottomLeft.Y - (int)(size * 0.6));
     Point doorTopRight = new Point(doorBottomRight.X, doorBottomRight.Y - (int)(size * 0.6));
     Point window1TopLeft = new Point(doorTopLeft.X, bottomLeft.Y - (int)(size * 0.9));
     Point window2TopLeft = new Point(bottomLeft.X + (int)(size * 0.6), window1TopLeft.Y);
     Point sunOrigin = new Point(topRight.X + (int)(size * 0.3), topRight.Y - (int)(size * 0.5));
     Size windowSize = new Size((int)(size * 0.3), (int)(size * 0.2));
     Size sunSize = new Size((int)(size * 0.4), (int)(size * 0.4));
     Rectangle window1 = new Rectangle(window1TopLeft, windowSize);
     Rectangle window2 = new Rectangle(window2TopLeft, windowSize);
     Rectangle sun = new Rectangle(sunOrigin, sunSize);
     Point[] square = new Point[] { topLeft, topRight, bottomRight, bottomLeft, topLeft, top, topRight };
     Point[] door = new Point[] { doorBottomLeft, doorTopLeft, doorTopRight, doorBottomRight };
     g.DrawLines(myPen, square);
     g.DrawLines(myPen, door);
     g.DrawRectangle(myPen, window1);
     g.DrawRectangle(myPen, window2);
     g.FillRectangle(myBrush, window1);
     g.FillRectangle(myBrush, window2);
     g.DrawEllipse(myPen, sun);
     g.FillEllipse(yellow, sun);
 }
        public static void RenderBorder(Graphics g, Rectangle rect, Color borderColor,
            ButtonBorderType borderType, int radius, RoundStyle roundType)
        {
            rect.Width--;
            rect.Height--;

            bool simpleRect = (borderType == ButtonBorderType.Rectangle && (roundType == RoundStyle.None || radius < 2));
            SmoothingMode newMode = simpleRect ? SmoothingMode.HighSpeed : SmoothingMode.AntiAlias;

            using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode))
            {
                using (Pen p = new Pen(borderColor))
                {
                    if (simpleRect)
                    {
                        g.DrawRectangle(p, rect);
                    }
                    else if (borderType == ButtonBorderType.Ellipse)
                    {
                        g.DrawEllipse(p, rect);
                    }
                    else
                    {
                        using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, radius, roundType, false))
                        {
                            g.DrawPath(p, path);
                        }
                    }
                }
            }
        }
Exemple #32
0
 private void DrawIt()
 {
     System.Drawing.Graphics graphics = this.CreateGraphics();
     if (Life == 9)
     {
         graphics.DrawLine(System.Drawing.Pens.Black, 85, 190, 210, 190);
     }
     else if (Life == 8)
     {
         graphics.DrawLine(System.Drawing.Pens.Black, 148, 190, 148, 50);
     }
     else if (Life == 7)
     {
         graphics.DrawLine(System.Drawing.Pens.Black, 148, 50, 198, 50);
     }
     else if (Life == 6)
     {
         graphics.DrawLine(System.Drawing.Pens.Black, 198, 50, 198, 70);
     }
     else if (Life == 5)
     {
         graphics.DrawEllipse(System.Drawing.Pens.Black, 188, 70, 20, 20);
     }
     else if (Life == 4)
     {
         graphics.DrawLine(System.Drawing.Pens.Black, 198, 90, 198, 130);
     }
     else if (Life == 3)
     {
         graphics.DrawLine(System.Drawing.Pens.Black, 198, 95, 183, 115);
     }
     else if (Life == 2)
     {
         graphics.DrawLine(System.Drawing.Pens.Black, 198, 95, 213, 115);
     }
     else if (Life == 1)
     {
         graphics.DrawLine(System.Drawing.Pens.Black, 198, 130, 183, 170);
     }
     else if (Life == 0)
     {
         graphics.DrawLine(System.Drawing.Pens.Black, 198, 130, 213, 170);
     }
 }
Exemple #33
0
        /// <summary>
        /// vẽ bàn cờ
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="IsDrawHelp"></param>
        /// <param name="step"></param>
        public void Draw(System.Drawing.Graphics graphics, bool IsDrawHelp, int step)
        {
            Pen pen = new Pen(Color.White, (float)0.5);

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    int   p = board[i, j];
                    Color c = Color.Green;

                    graphics.FillRectangle(new SolidBrush(c), i * WIDTH, j * WIDTH, WIDTH, WIDTH);

                    graphics.DrawRectangle(pen, i * WIDTH, j * WIDTH, WIDTH, WIDTH);

                    switch (p)
                    {
                    case BLACK:
                        graphics.FillEllipse(new SolidBrush(Color.Black), i * WIDTH + 3, j * WIDTH + 3, WIDTH - 6, WIDTH - 6);
                        break;

                    case WHITE:
                        graphics.FillEllipse(new SolidBrush(Color.White), i * WIDTH + 3, j * WIDTH + 3, WIDTH - 6, WIDTH - 6);
                        break;
                    }
                    ;
                }
            }
            if (IsDrawHelp)
            {
                DrawEnableSteps(step, graphics);
            }

            if (x_pre >= 0 && y_pre >= 0)
            {
                graphics.DrawEllipse(new Pen(Color.Red, 2), x_pre * WIDTH + 3, y_pre * WIDTH + 3, WIDTH - 6, WIDTH - 6);
                if (step == Board.WHITE)
                {
                    Temp.Push(new tuple(x_pre, y_pre));
                }
            }
            //x_pre = -1;
            //y_pre = -1;
        }
Exemple #34
0
        private void button1_Click(object sender, EventArgs e)
        {
            System.Drawing.Graphics g = Graph.CreateGraphics();
            for (double j = 0; j < 1; j += 0.0833)
            {
                double i  = j * 3.141590;
                Point  p1 = new Point((int)(Graph.Size.Width / 2 - 1000 * Math.Cos(i)), (int)(Graph.Size.Height / 2 - 1000 * Math.Sin(i)));
                Point  p2 = new Point((int)(Graph.Size.Width / 2 + 1000 * Math.Cos(i)), (int)(Graph.Size.Height / 2 + 1000 * Math.Sin(i)));
                Pen    p  = new Pen(Color.Black);
                if ((j == 0) || (Math.Abs(j - 0.5) < 0.02))
                {
                    p.Width = 3;
                }
                g.DrawLine(p, p1, p2);
            }
            for (int j = 1; j < 40; j++)
            {
                Pen p = new Pen(Color.Black);
                if (j % 4 == 0)
                {
                    p.Width = 2;
                }
                g.DrawEllipse(p, (int)(Graph.Size.Width / 2 - j * 25), (int)(Graph.Size.Height / 2) - j * 25, j * 50, j * 50);
            }
            double start = -30, stop = 30, step = 0.01;

            Point PS = new Point((int)((Graph.Size.Width / 2) + f(start) * Math.Cos(start)), (int)((Graph.Size.Height / 2) - f(start) * Math.Sin(start)));
            Point PT;

            for (double j = start + step; j < stop; j += step)
            {
                Pen p = new Pen(Color.Red);
                p.Width = 2;
                PT      = new Point((int)((Graph.Size.Width / 2) + f(j) * Math.Cos(j)), (int)((Graph.Size.Height / 2) - f(j) * Math.Sin(j)));
                if (Math.Abs(f(j) - f(j - step)) < 10000)
                {
                    g.DrawLine(p, PS, PT);
                }

                PS = PT;

                // System.Threading.Thread.Sleep(1);
            }
        }
Exemple #35
0
 private void DisplayOverlay(double fzoom)
 {
     if (m_OverlayScene != null || m_EnableCross)
     {
         if (m_OverlayBmp == null)
         {
             m_OverlayBmp = new Bitmap(pbScreen.Width, pbScreen.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
         }
         System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(m_OverlayBmp);
         g.Clear(Color.Black);
         Pen axispen = new Pen(Color.LightCoral);
         g.DrawLine(axispen, 0, pbScreen.Height / 2, pbScreen.Width, pbScreen.Height / 2);
         g.DrawLine(axispen, pbScreen.Width / 2, 0, pbScreen.Width / 2, pbScreen.Height);
         if (m_OverlayScene != null)
         {
             BasicTypes.Vector2 S = new BasicTypes.Vector2();
             BasicTypes.Vector2 F = new BasicTypes.Vector2();
             foreach (GDI3D.Line ln in m_OverlayScene.Lines)
             {
                 S.X = ln.XS;
                 S.Y = ln.YS;
                 F.X = ln.XF;
                 F.Y = ln.YF;
                 var   vS = iMap.PlateMap.Transform(S);
                 var   vF = iMap.PlateMap.Transform(F);
                 float x1 = (float)((vS.X - m_StagePos.X) / m_ImagingConfiguration.Pixel2Micron.X * fzoom) + pbScreen.Width / 2;
                 float y1 = (float)((vS.Y - m_StagePos.Y) / m_ImagingConfiguration.Pixel2Micron.Y * fzoom) + pbScreen.Height / 2;
                 float x2 = (float)((vF.X - m_StagePos.X) / m_ImagingConfiguration.Pixel2Micron.X * fzoom) + pbScreen.Width / 2;
                 float y2 = (float)((vF.Y - m_StagePos.Y) / m_ImagingConfiguration.Pixel2Micron.Y * fzoom) + pbScreen.Height / 2;
                 g.DrawLine(new Pen(Color.FromArgb(255, ln.R, ln.G, ln.B)), x1, y1, x2, y2);
             }
             foreach (GDI3D.Point pn in m_OverlayScene.Points)
             {
                 S.X = pn.X;
                 S.Y = pn.Y;
                 var   vS = iMap.PlateMap.Transform(S);
                 float x  = (float)((vS.X - m_StagePos.X) / m_ImagingConfiguration.Pixel2Micron.X * fzoom) + pbScreen.Width / 2;
                 float y  = (float)((vS.Y - m_StagePos.Y) / m_ImagingConfiguration.Pixel2Micron.Y * fzoom) + pbScreen.Height / 2;
                 g.DrawEllipse(new Pen(Color.FromArgb(255, pn.R, pn.G, pn.B)), x - 2, y - 2, 5, 5);
             }
         }
         g.Dispose();
     }
 }
Exemple #36
0
            //
#if ALLOW_GDI
            internal override void Draw(SD.Graphics g)
            {
                var radius = new SD.SizeF(Radius, Radius);
                var rect   = new SD.RectangleF(PointF(Pos) - radius, radius + radius);

                if (FillColor != Color.Empty)
                {
                    using (var brush = new SD.SolidBrush(FillColor)) {
                        g.FillEllipse(brush, rect);
                    }
                }
                if (StrokeColor != Color.Empty)
                {
                    using (var pen = new SD.Pen(StrokeColor, (int)StrokeWidth)) {
                        g.DrawEllipse(pen, rect);
                    }
                }
                base.Draw(g);
            }
Exemple #37
0
        public void DrawVoronoi(Pen pointPen, Pen linePen)
        {
            try
            {
                int i = points.Count;
            }
            catch
            {
                return;
            }
            if (this.voronoiPoints == null)
            {
                return;
            }

            //if (pCheck.Checked)
            //{
            //    Draw(points, Pens.Black);
            //}

            System.Drawing.Graphics g = this.pictureBox1.CreateGraphics();

            g.DrawRectangle(Pens.Black, (float)(points.MinX - 50), (float)(points.MinY - 50), (float)(points.MaxX - points.MinX + 100), (float)(points.MaxY - points.MinY + 100));

            foreach (IRI.Ket.Geometry.VoronoiPoint item in voronoiPoints)
            {
                g.DrawEllipse(pointPen, new RectangleF((float)(item.X - 2), (float)(item.Y - 2), 4, 4));

                for (int i = 0; i < item.NeigboursCode.Count; i++)
                {
                    IRI.Ket.Geometry.VoronoiPoint p = voronoiPoints.GetPointByCode(item.NeigboursCode[i]);

                    if (item.TriangleCode == -1 || p.TriangleCode == -1)
                    {
                        g.DrawLine(Pens.Red, new PointF((float)item.X, (float)item.Y), new PointF((float)p.X, (float)p.Y));
                    }
                    else
                    {
                        g.DrawLine(linePen, new PointF((float)item.X, (float)item.Y), new PointF((float)p.X, (float)p.Y));
                    }
                }
            }
        }
        public override void Draw(System.Drawing.Graphics g)
        {
            base.Draw(g);
            PointF p1 = ToPointF(ControlPoints[0]);
            PointF p2 = ToPointF(ControlPoints[1]);

            float r1 = p2.X - p1.X;
            float r2 = p1.Y - p2.Y;

            Pen pen = LinePen.GetPen();

            foreach (float f in split)
            {
                g.DrawEllipse(pen, p1.X - r1 * f, p2.Y - r2 * f, r1 * 2 * f, r2 * 2 * f);
            }

            g.DrawLine(pen, p1.X, p1.Y, p1.X, p2.Y);
            g.DrawLine(pen, p1.X, p2.Y, p2.X, p2.Y);
        }
Exemple #39
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            System.Drawing.Graphics grafika = this.CreateGraphics();


            SolidBrush mojBrush  = new SolidBrush(System.Drawing.Color.White);
            SolidBrush mojBrush2 = new SolidBrush(System.Drawing.Color.Black);
            Pen        mojPen    = new Pen(System.Drawing.Color.Blue, 5);

            mojPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
            Rectangle rt = new Rectangle(200, 50, 100, 100);
            Rectangle elipsaPravougaonik = new Rectangle(20, 20, 250, 200);

            grafika.DrawEllipse(mojPen, elipsaPravougaonik);
            grafika.DrawLine(mojPen, 20, 20, 200, 210);
            grafika.FillRectangle(mojBrush, 210, 60, 80, 60);
            grafika.DrawString("RPR klinika", new Font("Arial", 16), mojBrush2, 160, 80);
        }
        // Draws the automata or the communication graph in the GUI
        private void DrawAutomata()
        {
            System.Drawing.Pen      automataPen  = new System.Drawing.Pen(System.Drawing.Color.Red, 5);
            System.Drawing.Pen      linesPen     = new System.Drawing.Pen(System.Drawing.Color.Black, 5);
            System.Drawing.Graphics formGraphics = automataCanvas.CreateGraphics();
            Label[] robotLabels  = new Label[Program.numberOfRobots];
            float   circleRadius = 10;

            System.Drawing.PointF center = new System.Drawing.PointF((float)automataCanvas.Width / 2 - circleRadius, (float)automataCanvas.Height / 2 - circleRadius);

            automataPositions = new System.Drawing.PointF[Program.numberOfRobots];

            float angleBetween = 2 * (float)Math.PI / Program.numberOfRobots;

            float bigRadius = ((float)Math.Min(automataCanvas.Width, automataCanvas.Height) * (float)0.8 - circleRadius * 2) / 2;

            float width  = 2 * circleRadius;
            float height = 2 * circleRadius;


            for (int i = 0; i < Program.numberOfRobots; i++)
            {
                automataPositions[i] = new System.Drawing.PointF(center.X + (float)Math.Cos(angleBetween * i) * bigRadius + circleRadius, center.Y + (float)Math.Sin(angleBetween * i) * bigRadius + circleRadius);
                formGraphics.DrawEllipse(automataPen, automataPositions[i].X - circleRadius, automataPositions[i].Y - circleRadius, (float)width, (float)height);
            }

            foreach (Robot robot in Program.robotList)
            {
                if (robot.getDetected())
                {
                    foreach (Robot neighbor in robot.getNeighbors())
                    {
                        if (neighbor.getDetected())
                        {
                            formGraphics.DrawLine(linesPen, automataPositions[Program.robotList.IndexOf(robot)], automataPositions[Program.robotList.IndexOf(neighbor)]);
                        }
                    }
                }
            }
            linesPen.Dispose();
            automataPen.Dispose();
            formGraphics.Dispose();
        }
Exemple #41
0
        private static void AddPoint(drawing.Graphics graphics, SqlGeometry point, Func <Point, Point> transform, drawing.Pen pen, drawing.Brush brush, double pointSize, SimplePointSymbol pointSymbol)
        {
            var parsedPoint = transform(point.AsWpfPoint()).AsPoint();

            if (pointSymbol?.GeometryPointSymbol != null)
            {
                GeometryHelper.Transform(graphics, pointSymbol.GeometryPointSymbol, parsedPoint, pen, brush);
            }
            else if (pointSymbol?.ImagePointSymbolGdiPlus != null)
            {
                //96.09.21
                //graphics.DrawImage(pointSymbol.ImagePointSymbol, new drawing.RectangleF((float)parsedPoint.X - _symbolOffset, (float)parsedPoint.Y - _symbolOffset, _symbolSize, _symbolSize));
                graphics.DrawImage(pointSymbol.ImagePointSymbolGdiPlus, new drawing.RectangleF((float)(parsedPoint.X - pointSymbol.SymbolWidth / 2.0), (float)(parsedPoint.Y - pointSymbol.SymbolHeight), (float)pointSymbol.SymbolWidth, (float)pointSymbol.SymbolHeight));
            }
            else
            {
                graphics.DrawEllipse(pen, (float)(parsedPoint.X - pointSymbol.SymbolWidth / 2.0), (float)(parsedPoint.Y - pointSymbol.SymbolHeight / 2.0), (float)pointSymbol.SymbolWidth, (float)pointSymbol.SymbolHeight);
                graphics.FillEllipse(brush, (float)(parsedPoint.X - pointSymbol.SymbolWidth / 2.0), (float)(parsedPoint.Y - pointSymbol.SymbolHeight / 2.0), (float)pointSymbol.SymbolWidth, (float)pointSymbol.SymbolHeight);
            }
        }
Exemple #42
0
        /// <summary>
        /// 绘制方法
        /// </summary>
        /// <param name="g">画布</param>
        /// <param name="center">地图中心</param>
        /// <param name="zoom">地图缩放级别</param>
        /// <param name="screen_size">地图大小</param>
        public override void Draw(System.Drawing.Graphics g, LatLngPoint center, int zoom, System.Drawing.Size screen_size)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            Point theScreenCenter      = MapHelper.GetScreenLocationByLatLng(Center, center, zoom, screen_size);      //椭圆中心点的屏幕坐标
            Point theScreenRightBottom = MapHelper.GetScreenLocationByLatLng(RightBottom, center, zoom, screen_size); //椭圆矩形任意一角的屏幕坐标
            int   width  = Math.Abs(2 * (theScreenRightBottom.X - theScreenCenter.X));
            int   height = Math.Abs(2 * (theScreenRightBottom.Y - theScreenCenter.Y));

            if (new Rectangle(new Point(0, 0), screen_size).IntersectsWith(new Rectangle(theScreenCenter.X - width / 2, theScreenCenter.Y - height / 2, width, height)))  //需要绘制
            {
                using (SolidBrush sb = new SolidBrush(Color.FromArgb(30, Color.Blue)))
                {
                    g.FillEllipse(sb, new Rectangle(theScreenCenter.X - width / 2, theScreenCenter.Y - height / 2, width, height));
                }
                using (Pen pen = new Pen(Color.FromArgb(150, Color.Blue), 4))
                {
                    g.DrawEllipse(pen, new Rectangle(theScreenCenter.X - width / 2, theScreenCenter.Y - height / 2, width, height));
                }
            }
        }
Exemple #43
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="g"></param>
        public override void Render(System.Drawing.Graphics g)
        {
            SizeF textsize = g.MeasureString(this.Index, new Font("微软雅黑", 12));

            if (!this.Crossflag)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                //g.DrawRectangle(new Pen(Color.Red), this.Bound);
                g.DrawEllipse(new Pen(this.boundcolor), this.Bound);
                g.SmoothingMode = SmoothingMode.Default;
                if (this.Editflag)
                {
                    g.FillEllipse(new SolidBrush(Color.FromArgb(0, 153, 229)), this.Bound);
                    //g.DrawLine(new Pen(this.fontcolor), new Point(this.Location.X + 2, this.Location.Y + (int)textsize.Height), new Point(this.Location.X + 2 + (int)textsize.Width, this.Location.Y + (int)textsize.Height));
                }
                g.DrawString(this.Index, new Font("微软雅黑", 12), new SolidBrush(this.fontcolor), new Point(this.Location.X + 4, this.Location.Y + 1));
            }

            base.Render(g);
        }
            public void setval(System.Drawing.Graphics zona_des, System.Drawing.Pen creion, System.Drawing.SolidBrush radiera, System.Drawing.SolidBrush p_blu, int alfa_gr)
            {
                // alfa_gr unghiul in grade
                int xc   = x0 + w / 2;
                int yc   = y0 + w / 2;
                int raza = w / 2;
                int yl;

                zona_des.FillRectangle(radiera, x0, y0, w, 3 * w);

                double alfa_r = 2 * System.Math.PI * (alfa_gr) / 360;// unghiul in radiani
                int    x      = System.Convert.ToInt16(xc + raza * System.Math.Cos(alfa_r));
                int    y      = System.Convert.ToInt16(yc - raza * System.Math.Sin(alfa_r));

                yl = System.Convert.ToInt16(raza * System.Math.Sin(alfa_r));
                zona_des.DrawEllipse(creion, xc - raza, yc - raza, 2 * raza, 2 * raza);
                zona_des.DrawLine(creion, x, y, xc, y0 + 2 * w - yl);
                zona_des.DrawLine(creion, x, y, xc, yc);
                zona_des.FillRectangle(p_blu, x0, y0 + 2 * w - yl, w, raza);
                zona_des.DrawRectangle(creion, x0, y0 + w + raza, w, 2 * w - raza / 2);
            }
Exemple #45
0
        private void applyButton_Click(object sender, EventArgs e)
        {
            myGraphics = CreateGraphics();
            myGraphics.Clear(Color.White);
            myGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            double theta = 0.0;
            double pi    = 4.0 * Math.Atan(1.0);

            int ry = (int)(100 + 40 * Math.Sin(theta)), rx = (int)(100 + 40 * Math.Cos(theta));
            int diameter   = 80;
            int iterations = Convert.ToInt32(numberOfCirclesSizeUpDown.Value);

            for (int i = 0; i < iterations; i++)
            {
                myGraphics.DrawEllipse(myPen, rx, ry, diameter, diameter);
                theta += pi / 180 * (360.0 / iterations);
                rx     = (int)(100 + 40 * Math.Sin(theta));
                ry     = (int)(100 + 40 * Math.Cos(theta));
            }
        }
Exemple #46
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pX"></param>
        /// <param name="pY"></param>
        /// <param name="pRadius"></param>
        /// <param name="pColor"></param>
        public override void DrawCircle(float pX, float pY, float pRadius, float pWidth, bool pDashed, Maths.Color4 pColor)
        {
            SMX.Maths.Vector2 start     = GetScreenCoords(pX, pY);
            SMX.Maths.Vector2 radScreen = GetScreenCoords(pRadius, pRadius);


            Pen pen = new Pen(pColor.ToGDI(), pWidth);

            if (pDashed)
            {
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            }
            else
            {
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
            }

            float width = radScreen.X * 2;

            mGraphics.DrawEllipse(pen, start.X - width / 2, start.Y - width / 2, width, width);
        }
Exemple #47
0
            public void Render(System.Drawing.Graphics g, int width, int height)
            {
                if (Rendering)
                {
                    Console.WriteLine("overrunning renderer");
                    return;
                }
                Rendering = true;

                // fixup
                if (width == 0)
                {
                    width = 1;
                }
                if (height == 0)
                {
                    height = 1;
                }

                // fill graphics background every so often
                if (++Count > 5)
                {
                    Count = 0;
                    g.FillRectangle(Brushes.Black, 0, 0, width, height);
                }

                // random ellipses
                var rnd = new Random();

                for (var i = 0; i < 100; i++)
                {
                    var px = rnd.Next(0, width);
                    var py = rnd.Next(0, height);
                    g.DrawEllipse(new Pen(Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)), 1),
                                  px, py, px + rnd.Next(0, width - px), py + rnd.Next(0, height - py));
                }

                g.DrawString("hello from renderer 12345687901234568790", new Font("Arial", 8), Brushes.White, 10, 10);
                Rendering = false;
            }
Exemple #48
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            double osx, osy, sx, sy;
            double omx, omy, mmx, mmy;
            double ohx, ohy, hx, hy;
            double curSec, curMin, curHour;

            System.Drawing.Pen      myPen        = new System.Drawing.Pen(System.Drawing.Color.GhostWhite);
            System.Drawing.Brush    myBrush      = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            System.Drawing.Graphics formGraphics = pictureBox1.CreateGraphics();
            formGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            curSec  = (double)DateTime.Now.Second;
            curMin  = (double)DateTime.Now.Minute + (curSec / 60.0);
            curHour = (double)DateTime.Now.Hour + (curMin / 60.0);
            sx      = Math.Cos((uSec * curSec) - HalfPi) * 90 + (double)CenterX;
            sy      = Math.Sin((uSec * curSec) - HalfPi) * 90 + (double)CenterY;
            osx     = Math.Cos((uSec * curSec) + HalfPi) * 35 + (double)CenterX;
            osy     = Math.Sin((uSec * curSec) + HalfPi) * 35 + (double)CenterY;
            mmx     = Math.Cos((uSec * curMin) - HalfPi) * 80 + (double)CenterX;
            mmy     = Math.Sin((uSec * curMin) - HalfPi) * 80 + (double)CenterY;
            omx     = Math.Cos((uSec * curMin) + HalfPi) * 20 + (double)CenterX;
            omy     = Math.Sin((uSec * curMin) + HalfPi) * 20 + (double)CenterY;
            hx      = Math.Cos((uHour * curHour) - HalfPi) * 70 + (double)CenterX;
            hy      = Math.Sin((uHour * curHour) - HalfPi) * 70 + (double)CenterY;
            ohx     = Math.Cos((uHour * curHour) + HalfPi) * 20 + (double)CenterX;
            ohy     = Math.Sin((uHour * curHour) + HalfPi) * 20 + (double)CenterY;
            formGraphics.DrawImage(this.BackgroundImage, pictureBox1.Bounds);
            myPen.Color = System.Drawing.Color.White;
            myPen.Width = 3;
            formGraphics.DrawLine(myPen, (int)omx, (int)omy, (int)mmx, (int)mmy);
            formGraphics.DrawLine(myPen, (int)ohx, (int)ohy, (int)hx, (int)hy);
            myPen.Width = 2;
            myPen.Color = System.Drawing.Color.White;
            formGraphics.FillEllipse(myBrush, CenterX - 4, CenterY - 4, 8, 8);
            formGraphics.DrawEllipse(myPen, CenterX - 4, CenterY - 4, 8, 8);
            myPen.Color = System.Drawing.Color.LightSkyBlue;
            myPen.Width = 2;
            formGraphics.DrawLine(myPen, (int)CenterX, (int)CenterY, (int)sx, (int)sy);
            formGraphics.DrawLine(myPen, (int)osx, (int)osy, (int)CenterX, (int)CenterY);
        }
Exemple #49
0
        public void DrawPointer(System.Drawing.Graphics Graphics)
        {
            Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            GraphicsPath path = new GraphicsPath();
            int          a    = 0;

            if (this.LinearGauge.MinimumValue < 0)
            {
                a = (int)Math.Ceiling((((Math.Abs(this.LinearGauge.MinimumValue) + LinearGauge.Value) / (float)LinearGauge.MajorDifference) * m_minorTicksPixels));
            }
            else
            {
                a = (int)Math.Ceiling(((LinearGauge.Value / (float)LinearGauge.MajorDifference) * m_minorTicksPixels));
            }
            int y = (this.LinearGauge.Height / 2 + 5 + LinearGauge.MajorTicksHeight) - LinearGauge.MajorTicksHeight;

            a = 10 + (int)Math.Ceiling((majorTicksDistance * m_minorTicksPixels)) - a;
            int placement = 28;

            if (LinearGauge.PointerPlacement == Placement.Near)
            {
                placement = 19;
            }
            else if (LinearGauge.PointerPlacement == Placement.Far)
            {
                placement = 42;
            }
            else
            {
                placement = 28;
            }
            Rectangle rect  = new Rectangle(new Point(this.LinearGauge.Width / 2 + placement, a), new Size(32, 32));
            SizeF     sf    = Graphics.MeasureString(this.LinearGauge.Value.ToString(), this.LinearGauge.GaugelabelFont);
            PointF    point = new PointF(rect.X + rect.Width / 2 - sf.Width / 2, rect.Y + rect.Height / 2 - sf.Height / 2);

            Graphics.FillEllipse(new SolidBrush(LinearGauge.NeedleColor), rect);
            Graphics.DrawEllipse(new Pen(ColorTranslator.FromHtml("#00a0d1")), rect);
            Graphics.DrawLine(new Pen(ColorTranslator.FromHtml("#00a0d1")), rect.X, rect.Y + rect.Height / 2, rect.X - 18, rect.Y + rect.Height / 2);
            Graphics.DrawString(Math.Round(LinearGauge.Value, 2).ToString(), this.LinearGauge.GaugelabelFont, new SolidBrush(ColorTranslator.FromHtml("#024e60")), point);
        }
Exemple #50
0
        static private Image CreateDropDownButtonImage()
        {
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(System.Drawing.Point.Empty, new Size(24, 24));
            Bitmap bmp = new Bitmap(rect.Width, rect.Height);

            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            using (System.Drawing.Brush brush = new System.Drawing.SolidBrush(Color.Transparent))
            {
                g.FillRectangle(brush, rect);
            }

            using (Pen pen = new Pen(Color.White, 2f))
            {
                pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
                pen.EndCap   = System.Drawing.Drawing2D.LineCap.Round;

                rect.Inflate(-2, -2);
                g.DrawEllipse(pen, rect);

                rect.Y += 1;

                int dx = -5;
                int dy = -7;
                rect.Inflate(dx, dy);

                System.Drawing.Point p1, p2;

                p1 = new System.Drawing.Point(rect.X, rect.Y);
                p2 = new System.Drawing.Point(rect.X + (rect.Width / 2), rect.Bottom);
                g.DrawLine(pen, p1, p2);

                p1 = new System.Drawing.Point(rect.Right, rect.Y);
                p2 = new System.Drawing.Point(rect.X + (rect.Width / 2), rect.Bottom);
                g.DrawLine(pen, p1, p2);
            }

            return(bmp);
        }
Exemple #51
0
        public void CreateBullet(List <Point> p1List)
        {
            System.Drawing.Graphics formGraphics = this.CreateGraphics();
            try
            {
                using (var p = new Pen(Color.Red, 5))
                {
                    Brush whiteBrush = new SolidBrush(Color.Red);
                    //Brush blackBrush = new SolidBrush(black);
                    Point     shootPoint = p1List[p1List.Count - 1];
                    Rectangle rect       = new Rectangle(shootPoint.X, shootPoint.Y, 10, 10);

                    formGraphics.DrawEllipse(p, rect);

                    //formGraphics.DrawLine(p, p1List[p1List.Count - 1], p1List[p1List.Count]);
                    //Thread.Sleep(50);
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #52
0
        /// <summary>
        /// Метод рисования графического примитива
        /// </summary>
        /// <param name="g"></param>
        /// <returns></returns>
        public override void Draw(System.Drawing.Graphics g)
        {
            GraphicsContainer containerState = null;

            try
            {
                /*создать графический контейнер, в нем можно делать с графиксом что угодно*/
                containerState = g.BeginContainer();
                using (Matrix transform = g.Transform)
                {
                    /*
                     * чтобы нарисовать примитив в нужном масштабе и положении
                     * нужно умножить матрицу преобразования графикса на матрицу ей обратную
                     * т.е на единичной матрице графикса рисуем примитив
                     */
                    transform.Invert();
                    g.MultiplyTransform(transform);
                    if (g.VisibleClipBounds.IntersectsWith(_boundRect) == true)
                    {
                        /*
                         * если видимый прямоугольник графикса пересекается
                         * с ограничивающим прямоугольноком примитива
                         * рисуем его
                         */
                        g.DrawEllipse(_pen, _circleRect);
                        g.DrawRectangle(_pen, _boundRect);
                        g.DrawLine(_pen, _circlePoint, _centerPoint);
                    }
                }
            }
            finally
            {
                if (containerState != null)
                {
                    /*закрыть графический контейнер*/
                    g.EndContainer(containerState);
                }
            }
        }
Exemple #53
0
        /// <summary>
        /// Paints the control
        /// </summary>
        /// <param name="g"></param>
        protected override void OnPaint(System.Drawing.Graphics g)
        {
            base.OnPaint(g);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Pen myPen;

            for (int i = 0; i < ScreenPoints.Length; i++)
            {
                PointF[] p = ScreenPoints[i];
                myPen = new Pen(this.GetColor(i), 2);

                for (int j = 0; j < p.Length; j++)
                {
                    if (p[j].X >= 0 && p[j].X <= this.Width)
                    {
                        if (p[j].Y <= Height && p[j].Y >= 0)
                        {
                            g.DrawEllipse(myPen, p[j].X, p[j].Y, 2, 2);
                        }
                    }
                }
            }
        }
Exemple #54
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Graphics gr = e.Graphics;
            gr.TranslateTransform(origin.X, origin.Y);



            gr.DrawEllipse(new Pen(Color.Red), new RectangleF(0, 0, 1, 1));
            gr.DrawLine(new Pen(Color.Black), new Point(0, 100), new Point(0, -100));
            gr.DrawLine(new Pen(Color.Black), new Point(-100, 0), new Point(200, 0));
            //if (tr.ThreadState != ThreadState.Running)
            // tr.Start();
            //if(tr.ThreadState != ThreadState.Running)
            for (int i = 0; i <= 180; ++i)
            {
                curve[i]  = new Point(i, -(int)(Math.Sin(Math.PI / 180 * (i + offset)) * 90));
                curve2[i] = new Point(i, -(int)(Math.Cos(Math.PI / 180 * (i + offset)) * 90));
            }
            offset++;

            gr.DrawCurve(new Pen(Color.Blue), curve);
            gr.DrawCurve(new Pen(Color.Green), curve2);
        }
Exemple #55
0
        public void DrawEllipse(Pen pen, double x, double y, double width, double height, bool fill = false)
        {
            if (pen == null)
            {
                throw new ArgumentNullException("pen");
            }

            lock (bitmapLock) {
                TryExpand(x, y, width, height, pen.Width);
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) {
                    g.SmoothingMode = (Antialiasing) ? SmoothingMode.AntiAlias : SmoothingMode.None;
                    if (fill)
                    {
                        g.FillEllipse(pen.Brush, (float)x, (float)y, (float)width, (float)height);
                    }
                    else
                    {
                        g.DrawEllipse(pen, (float)x, (float)y, (float)width, (float)height);
                    }
                }
                Texturize();
            }
        }
Exemple #56
0
        public void Draw(
            System.Drawing.Graphics g,
            System.Drawing.Pen pen,
            System.Drawing.Brush brush)
        {
            if (g == null)
            {
                return;
            }
            if (pen == null && brush == null)
            {
                return;
            }
            if (brush != null)
            {
                g.FillEllipse(brush, myBounds);
            }

            if (pen != null)
            {
                g.DrawEllipse(pen, myBounds);
            }
        }
Exemple #57
0
        public void Draw(AdjacencyList <IRI.Ket.Geometry.Point, double> network,
                         System.Drawing.Graphics g, System.Drawing.Pen nodePen, System.Drawing.Pen edgePen)
        {
            for (int i = 0; i < network.NumberOfNodes; i++)
            {
                float currentX = (float)network[i].X;

                float currentY = (float)network[i].Y;

                g.DrawEllipse(nodePen, new System.Drawing.RectangleF(currentX - 1, currentY - 1, 2, 2));

                LinkedList <Connection <IRI.Ket.Geometry.Point, double> > temp = network.GetConnectionsByNodeIndex(i);

                foreach (Connection <IRI.Ket.Geometry.Point, double> item in temp)
                {
                    IRI.Ket.Geometry.Point neighbour = item.Node;

                    g.DrawLine(edgePen,
                               new System.Drawing.PointF(currentX, currentY),
                               new System.Drawing.PointF((float)neighbour.X, (float)neighbour.Y));
                }
            }
        }
Exemple #58
0
        private void Clock_Draw(System.Drawing.Graphics g)
        {
            r_clock = r + 15;
            g.DrawEllipse(System.Drawing.Pens.Black, x1 - r_clock, y1 - r_clock, 2 * r_clock, 2 * r_clock);
            g.FillEllipse(brush, x1 - r_c, y1 - r_c, 2 * r_c, 2 * r_c);

            for (int i = 1; i <= 60; i++)
            {
                int    x0, y0, x3, y3, x_dig, y_dig;
                double a0 = -Math.PI / 2 + (i * Math.PI / 30);
                x3 = x1 + (int)(r_clock * Math.Cos(a0));
                y3 = y1 + (int)(r_clock * Math.Sin(a0));
                if (i % 5 == 0)
                {
                    int i1 = Math.Cos(a0) > 0 ? 1 : (int)(Math.Cos(a0));
                    int i2 = Math.Sin(a0) > 0 ? 1 : (int)(Math.Sin(a0));
                    x0 = x1 + (int)((r_clock - 10) * Math.Cos(a0));
                    y0 = y1 + (int)((r_clock - 10) * Math.Sin(a0));

                    x_dig = x1 + (int)((r_clock - 10) * Math.Cos(a0)) - 12 * i1 + 12 * i2;
                    y_dig = y1 + (int)((r_clock - 10) * Math.Sin(a0)) - +8 * i1 - 4 * i2;
                    Point p_dig = new Point(x_dig, y_dig);

                    g.DrawLine(pen_hour, x0, y0, x3, y3);
                    g.DrawString("" + (i / 5), drawFont, drawBrush, p_dig);
                    //g.DrawString("" + x_dig, drawFont, drawBrush, 150, 150 + 4 * i);
                    // g.DrawString("" + y_dig, drawFont, drawBrush, 200, 150+4*i);
                    //g.DrawString("" + (int)(a0*100), drawFont, drawBrush, 250, 150 + 4 * i);
                }
                else
                {
                    x0 = x1 + (int)((r_clock - 5) * Math.Cos(a0));
                    y0 = y1 + (int)((r_clock - 5) * Math.Sin(a0));
                    g.DrawLine(pen_1min, x0, y0, x3, y3);
                }
            }
        }
Exemple #59
0
    void DrawShapes()
    {
        SetTitle("Shapes & Brushes");

        var g = new Graphics(this);

        g.FillEllipse(Brushes.Red, 50, 50, 100, 100);
        g.DrawEllipse(Pens.Black, 50, 50, 100, 100);

        g.TranslateTransform(150, 150);
        g.RotateTransform(45);
        g.FillRectangle(Brushes.Yellow, 0, 0, 100, 100);
        g.ResetTransform();

        var rect = new RectangleF(200, 100, 200, 200);
        var lg   = new LinearGradientBrush(rect, Color.Red, Color.Blue, LinearGradientMode.Horizontal);

        g.FillEllipse(lg, rect);

        rect = new RectangleF(500, 100, 200, 200);
        lg   = new LinearGradientBrush(rect, Color.Red, Color.Blue, LinearGradientMode.Horizontal);
        lg.InterpolationColors = ColorBlends.Rainbow;
        g.FillRectangle(lg, rect);
    }
Exemple #60
0
        public void DrawField(System.Drawing.Graphics Grph)
        {
            /*
             * if  (!needdraw)
             *      return;
             * else
             *      needdraw=false;
             */

            Pen GridPen = new Pen(Color.FromArgb(100, Color.Black), 1);

            //Red
            Brush RedBrush = new SolidBrush(Color.Red);
            LinearGradientBrush gRedBrush = new LinearGradientBrush(new Rectangle(0, 0, CellW, CellH), Color.Red, Color.DarkRed, LinearGradientMode.Vertical);

            //Blue
            Brush BlueBrush = new SolidBrush(Color.Blue);
            LinearGradientBrush gBlueBrush = new LinearGradientBrush(new Rectangle(0, 0, CellW, CellH), Color.DarkBlue, Color.Blue, LinearGradientMode.Vertical);

            //Other
            Brush BGBrush   = new SolidBrush(Color.White);
            Brush DeadBrush = new SolidBrush(Color.Gray);
            LinearGradientBrush BackBrush = new LinearGradientBrush(new Rectangle(0, 0, OwnerForm.Width, OwnerForm.Height), OwnerForm.BackColor, Color.Black, LinearGradientMode.Vertical);

            //BG bitmap
//			Bitmap BGpic = new Bitmap("art\\bg.bmp");
            Bitmap BGpic = new Bitmap(GetType(), "bg.bmp");

            //Clops bitmaps
            Bitmap RClop  = new Bitmap(GetType(), "rclop.bmp");
            Bitmap BClop  = new Bitmap(GetType(), "bclop.bmp");
            Bitmap RClopD = new Bitmap(GetType(), "rclop_dead.bmp");
            Bitmap BClopD = new Bitmap(GetType(), "bclop_dead.bmp");
            Bitmap RClopG = new Bitmap(GetType(), "rclop_gray.bmp");
            Bitmap BClopG = new Bitmap(GetType(), "bclop_gray.bmp");

            RClop.MakeTransparent(Color.White);
            BClop.MakeTransparent(Color.White);
            RClopD.MakeTransparent(Color.White);
            BClopD.MakeTransparent(Color.White);
            RClopG.MakeTransparent(Color.White);
            BClopG.MakeTransparent(Color.White);
            Bitmap RedClop   = new Bitmap(RClop, CellW + (int)(0.6 * CellW), CellH + (int)(0.6 * CellH));
            Bitmap BlueClop  = new Bitmap(BClop, CellW + (int)(0.6 * CellW), CellH + (int)(0.6 * CellH));
            Bitmap RedClopG  = new Bitmap(RClopG, CellW + (int)(0.6 * CellW), CellH + (int)(0.6 * CellH));
            Bitmap BlueClopG = new Bitmap(BClopG, CellW + (int)(0.6 * CellW), CellH + (int)(0.6 * CellH));
            Bitmap RedClopD  = new Bitmap(RClopD, CellW + (int)(0.2 * CellW), CellH + (int)(0.2 * CellH));
            Bitmap BlueClopD = new Bitmap(BClopD, CellW + (int)(0.2 * CellW), CellH + (int)(0.2 * CellH));

            Pen    RedPen  = new Pen(RedBrush, 1);
            Pen    BluePen = new Pen(BlueBrush, 1);
            Pen    pen     = RedPen;
            Brush  brush   = RedBrush;
            Bitmap bmp     = RedClop;

            //Clear
            //Graph.FillRectangle(new SolidBrush(Color.White),OffX,OffY,FieldW*CellW,FieldH*CellH);
            //Grph.FillRectangle(BackBrush,new Rectangle(0,0,OwnerForm.Width,OwnerForm.Height));
            Grph.DrawImage(BGpic, OffX, OffY, CellW * FieldW, CellH * FieldH);

            Rectangle rect = new Rectangle(0, 0, CellW, CellH);
            Rectangle rct  = new Rectangle(0, 0, CellW - 2, CellH - 2);
            Point     pnt  = new Point(0, 0);


            //Draw cells & clops
            for (int i = 0; i < FieldH; i++)
            {
                for (int j = 0; j < FieldW; j++)
                //if (OldField[j,i]!=ClopWar.field[j,i].state)
                {
                    rect.X = OffX + j * CellW;
                    rect.Y = OffY + i * CellH;
                    rct.X  = OffX + j * CellW + 1;
                    rct.Y  = OffY + i * CellH + 1;

                    switch (ClopWar.field[j, i].owner)
                    {
                    case cell.RED:
                        pen   = RedPen;
                        brush = gRedBrush;
                        if (ClopWar.field[j, i].state == cell.DEAD)
                        {
                            bmp = RedClopD;
                        }
                        else
                        {
                            bmp = RedClop;
                        }
                        break;

                    case cell.BLUE:
                        pen   = BluePen;
                        brush = gBlueBrush;
                        if (ClopWar.field[j, i].state == cell.DEAD)
                        {
                            bmp = BlueClopD;
                        }
                        else
                        {
                            bmp = BlueClop;
                        }
                        break;

                    case cell.EMPTY:
                        pen   = GridPen;
                        brush = BGBrush;
                        if (ClopWar.turn == cell.RED)
                        {
                            bmp = RedClopG;
                        }
                        else
                        {
                            bmp = BlueClopG;
                        }
                        break;
                    }

                    //Grph.FillRectangle(BGBrush,rect);
                    pnt.X = OffX + j * CellW - (int)(bmp.Width - CellW) / 2;
                    pnt.Y = OffY + i * CellH - (int)(bmp.Height - CellH) / 2;


                    switch (ClopWar.field[j, i].state)
                    {
                    case cell.CLOP:
                        //Grph.DrawEllipse(pen,rct);
                        Grph.DrawImageUnscaled(bmp, pnt);
                        break;

                    case cell.DEAD:
                        Grph.DrawImageUnscaled(bmp, pnt);
                        break;

                    case cell.BASE:
                        Grph.FillRectangle(brush, rect);
                        if (ClopWar.turn == ClopWar.field[j, i].owner)
                        {
                            Grph.DrawEllipse(GridPen, rct);
                        }
                        ;
                        break;
                    }

                    if (showavail)
                    {
                        if (ClopWar.field[j, i].avail)
                        {
                            //Grph.DrawImageUnscaled(bmp,pnt);
                            Grph.DrawLine(GridPen, OffX + j * CellW + CellW / 2, OffY + i * CellH + CellH / 2, OffX + j * CellW + CellW / 2 + 1, OffY + i * CellH + CellH / 2 + 1);
                        }
                    }

                    OldField[j, i] = ClopWar.field[j, i].state;
                }
            }

            //Draw grid
            for (int i = 0; i <= FieldW; i++)
            {
                Grph.DrawLine(GridPen, OffX + i * CellW, OffY, OffX + i * CellW, OffY + FieldH * CellH);
            }
            for (int i = 0; i <= FieldH; i++)
            {
                Grph.DrawLine(GridPen, OffX, OffY + i * CellH, OffX + FieldW * CellW, OffY + i * CellH);
            }

            //Draw cursor
            if (showcursor)
            {
                Grph.FillRectangle(new SolidBrush(Color.FromArgb(130, Color.Gray)), OffX + cx * CellW, OffY + cy * CellH, CellW, CellH);
            }

            //Draw status
            if (showtext)
            {
                string s;
                s = "Turn: ";
                if (ClopWar.gameStatus == ClopWar.GAME_RED)
                {
                    s += "RED";
                }
                if (ClopWar.gameStatus == ClopWar.GAME_BLUE)
                {
                    s += "BLUE";
                }
                s += " " + (char)10 + (char)13;
                //s+="Coords(x,y,val): "+cx.ToString()+", "+cy.ToString()+", ";
                //s+=ClopWar.field[cx,cy].cost.ToString()+(char)10+(char)13;
                s += "Clops left: " + ClopWar.clopLeft.ToString() + " of " + ClopWar.clopNum.ToString();
                //s+=" "+(char)10+(char)13+" "+(char)10+(char)13+InfoString;

                RectangleF trect = new RectangleF(OffX + FieldW * CellW + 10, OffY, 200, 200);
                Grph.DrawString("Game Status", new Font("Courier", 18, FontStyle.Bold), new LinearGradientBrush(new Point(0, 0), new Point(800, 800), Color.Red, Color.Blue), trect);
                trect.Y += 30;
                Grph.DrawString(s, new Font("Arial", 10), new SolidBrush(Color.White), trect);
                trect.X++; trect.Y++;
                Grph.DrawString(s, new Font("Arial", 10), new SolidBrush(Color.Black), trect);
            }

            if (dispclopleft)
            {
                //Clops left
                //Gray
                //bmp=RClopG;
                //if (ClopWar.turn==cell.BLUE) bmp=BClopG;
                for (int i = -ClopWar.clopNum; i < 0; i++)
                {
                    Grph.DrawImage(RClopG, OffX + FieldW * CellW + 10, OffY + FieldH * CellH + (i - 1) * (OwnerForm.Height / ClopWar.clopNum / 2), 50, 50);
                    Grph.DrawImage(BClopG, OffX + FieldW * CellW + 70, OffY + FieldH * CellH + (i - 1) * (OwnerForm.Height / ClopWar.clopNum / 2), 50, 50);
                }
                //Color
                bmp = RClop;
                int oo = 0;
                if (ClopWar.turn == cell.BLUE)
                {
                    bmp = BClop;
                    oo  = 60;
                }

                for (int i = -ClopWar.clopLeft; i < 0; i++)
                {
                    Grph.DrawImage(bmp, OffX + FieldW * CellW + 10 + oo, OffY + FieldH * CellH + (i - 1) * (OwnerForm.Height / ClopWar.clopNum / 2), 50, 50);
                    Grph.DrawImage(bmp, OffX + FieldW * CellW + 10 + oo, OffY + FieldH * CellH + (i - 1) * (OwnerForm.Height / ClopWar.clopNum / 2), 50, 50);
                }
            }


            //DISPOSE!!!
            GridPen.Dispose();
            RedBrush.Dispose();
            gRedBrush.Dispose();
            BlueBrush.Dispose();
            gBlueBrush.Dispose();
            BGBrush.Dispose();
            DeadBrush.Dispose();
            BackBrush.Dispose();
            RClop.Dispose();
            BClop.Dispose();
            RClopD.Dispose();
            BClopD.Dispose();
            RedClop.Dispose();
            BlueClop.Dispose();
            RedClopD.Dispose();
            BlueClopD.Dispose();
            RedPen.Dispose();
            BluePen.Dispose();
        }