DrawRectangle() public method

public DrawRectangle ( Pen pen, Rectangle rect ) : void
pen Pen
rect Rectangle
return void
        public override void Draw(System.Drawing.RectangleF dirtyRect)
        {
            var g = new Graphics();

            // NSView does not have a background color so we just use Clear to white here
            g.Clear(Color.White);

            //RectangleF ClientRectangle = this.Bounds;
            RectangleF ClientRectangle = dirtyRect;

            // Calculate the location and size of the drawing area
            // within which we want to draw the graphics:
            Rectangle rect = new Rectangle((int)ClientRectangle.X, (int)ClientRectangle.Y,
                                           (int)ClientRectangle.Width, (int)ClientRectangle.Height);
            drawingRectangle = new Rectangle(rect.Location, rect.Size);
            drawingRectangle.Inflate(-offset, -offset);
            //Draw ClientRectangle and drawingRectangle using Pen:
            g.DrawRectangle(Pens.Red, rect);
            g.DrawRectangle(Pens.Black, drawingRectangle);
            // Draw a line from point (3,2) to Point (6, 7)
            // using the Pen with a width of 3 pixels:
            Pen aPen = new Pen(Color.Green, 3);
            g.DrawLine(aPen, Point2D(new PointF(3, 2)),
                       Point2D(new PointF(6, 7)));

            g.PageUnit = GraphicsUnit.Inch;
            ClientRectangle = new RectangleF(0.5f,0.5f, 1.5f, 1.5f);
            aPen.Width = 1 / g.DpiX;
            g.DrawRectangle(aPen, ClientRectangle);

            aPen.Dispose();

            g.Dispose();
        }
Example #2
2
        /// <summary>
        /// Draws the Card at its location
        /// </summary>
        /// <param name="g">The Graphics object to draw on</param>
        public override void Draw(Graphics g)
        {
            Color colour = this.GetColor();

            g.FillRectangle(new SolidBrush(colour), _rekt);     // Fill

            if (Selected)
            {
                g.DrawRectangle(new Pen(Brushes.Black, 2), _rekt);  // Draw outline
            }
            else
            {

                g.DrawRectangle(new Pen(Brushes.White, 4), _rekt);  // White 4pt
                g.DrawRectangle(new Pen(Brushes.Black, 1), _rekt);  // Black border 1pt
            }

            // The number
            int fontHeight = _rekt.Height / 4;
            Font arial = new Font("Arial", fontHeight, FontStyle.Bold);

            // Fancy Centering
            StringFormat stringFormat = new StringFormat();
            stringFormat.Alignment = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;

            g.DrawString(this.Value.ToString(), arial, Brushes.Black, _rekt, stringFormat); // Black text (the number)
        }
Example #3
1
        public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, Rectangle gripRect, bool enableShadows, bool useroundedCorners)
        {
            if (appointment == null)
                throw new ArgumentNullException("appointment");

            if (g == null)
                throw new ArgumentNullException("g");

            if (rect.Width != 0 && rect.Height != 0)
                using (StringFormat format = new StringFormat())
                {
                    format.Alignment = StringAlignment.Near;
                    format.LineAlignment = StringAlignment.Near;

                    if ((appointment.Locked) && isSelected)
                    {
                        // Draw back
                        using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }
                    else
                    {
                        // Draw back
                        using (SolidBrush m_Brush = new SolidBrush(appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }

                    if (isSelected)
                    {
                        using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
                            g.DrawRectangle(m_Pen, rect);

                        Rectangle m_BorderRectangle = rect;

                        m_BorderRectangle.Inflate(2, 2);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);

                        m_BorderRectangle.Inflate(-4, -4);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);
                    }
                    else
                    {
                        // Draw gripper
                        gripRect.Width += 1;

                        using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor))
                            g.FillRectangle(m_Brush, gripRect);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, rect);
                    }

                    rect.X += gripRect.Width;
                    g.DrawString(appointment.Subject, this.BaseFont, SystemBrushes.WindowText, rect, format);
                }
        }
        }//end constructor

        //call the paint method
        public override void paint (Graphics graphics)
        {
            try
            {
                //save the old value of the rectangle 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.DrawRectangle(new System.Drawing.Pen(Color.White), previousLeftPosition, previousTopPosition, width, height);
                    graphics.DrawRectangle(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
		public override void Draw(Graphics graphics)
		{
			if (graphics == null) return;
			
			#region Panel
			graphics.FillRectangle(shadowBrush, 1, 14, 10.5f, 1.5f);
			graphics.FillRectangle(shadowBrush, 10, 6, 1.5f, 9);
			
			graphics.FillRectangle(panelBrush, 0, 5, 10, 9);
			graphics.DrawRectangle(panelPen, 0, 5, 10, 9);
			
			graphics.FillRectangle(linesBrush, 1.5f, 9, 2, 1);
			graphics.FillRectangle(linesBrush, 5, 9, 3, 1);

			graphics.FillRectangle(linesBrush, 1.5f, 11, 2, 1);
			graphics.FillRectangle(linesBrush, 5, 11, 3, 1);
			#endregion
			
			#region Hand
			//TODO - improve the hand, choose better colors
			graphics.FillPolygon(handBrush, handPoints);
			graphics.DrawPolygon(handPen, handPoints);
			graphics.DrawLine(handPen, 6, 6, 8, 4);
			graphics.DrawLine(handPen, 7, 7, 9.5f, 4.5f);
			graphics.DrawLine(handPen, 8, 8, 11, 5);
			graphics.FillRectangle(sleeveBrush, 13, 2, 2, 4);
			graphics.DrawRectangle(sleevePen, 13, 2, 2, 4);
			#endregion
		}
        protected void DrawBackground( Graphics g, DrawState state )
        {
            Rectangle rc = ClientRectangle;

              // Draw background
              if( state == DrawState.Normal || state == DrawState.Disable )
              {
            g.FillRectangle( SystemBrushes.Control, rc );

            Pen p = ( state == DrawState.Disable ) ? SystemPens.ControlDark : SystemPens.ControlDarkDark;

            // Draw border rectangle
            g.DrawRectangle( p, rc.Left, rc.Top, rc.Width-1, rc.Height-1);

              }
              else if( state == DrawState.Hot || state == DrawState.Pressed  )
              {
            // Erase whaterver that was there before
            if ( state == DrawState.Hot )
              g.FillRectangle( ColorUtil.VSNetSelectionBrush, rc );
            else
              g.FillRectangle( ColorUtil.VSNetPressedBrush, rc );

            // Draw border rectangle
            g.DrawRectangle( SystemPens.Highlight, rc.Left, rc.Top, rc.Width-1, rc.Height-1 );
              }
        }
 public void Draw(Graphics g, bool FirstTime)
 {
     //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     // Limpia
     // Dibuja las líneas
     if (useRect) ModifiedRectangles.Clear();
     foreach (Link l in allDyingLinks.Values)
     {
         if (useRect) ModifiedRectangles.Add(l.boundRectangle);
         DrawLink(g, l, Pens.Red);
     }
     foreach (Link l in allBornLinks.Values)
     {
         if (useRect) ModifiedRectangles.Add(l.boundRectangle);
         DrawLink(g, l, Pens.Green);
     }
     foreach (Link l in allStableLinks.Values)
         if (useRect == false || FirstTime || IsInModifiedRectangles(l.boundRectangle))
         {
             DrawLink(g, l, Pens.Black);
             if (useRect) ModifiedRectangles.Add(l.boundRectangle);
         }
     // Dibuja encima los puntos
     foreach(PointF p in this.PointList.Locations)
     {
         //g.FillEllipse(Brushes.Blue, p.X-r/2, p.Y-r/2, r,r);
         //g.FillEllipse(Brushes.White, p.X-r2/2, p.Y-r2/2, r2,r2);
         if (useRect == false || FirstTime || IsInModifiedRectangles(new RectangleF(p.X-1, p.Y-1, 3,3)))
         {
             g.DrawRectangle(Pens.Blue, TranslateX(p.X) * zoom -1, TranslateY(p.Y) * zoom-1, 2,2);
             g.DrawRectangle(Pens.White, TranslateX(p.X) * zoom, TranslateY(p.Y) * zoom, 0,0);
         }
     }
 }
Example #8
0
		public override void Draw(Graphics graphics, RenderMode rm) {
			int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
			Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
			bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
			bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
			if (lineVisible) {
				graphics.SmoothingMode = SmoothingMode.HighSpeed;
				graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
				graphics.CompositingQuality = CompositingQuality.HighQuality;
				graphics.PixelOffsetMode = PixelOffsetMode.None;
				//draw shadow first
				if (shadow) {
					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), lineThickness)) {
							Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + currentStep, Top + currentStep, Width, Height);
							graphics.DrawRectangle(shadowPen, shadowRect);
							currentStep++;
							alpha = alpha - (basealpha / steps);
						}
					}
				}
				Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
				if (lineThickness > 0) {
					using (Pen pen = new Pen(lineColor, lineThickness)) {
						graphics.DrawRectangle(pen, rect);
					}
				}
			}
		}
        public override void drawnShap(Graphics pe)
        {

            Brush CurrentBrush = initBrush();
            if (this.State.Shift1 == true)
            {
                calcShift();

                //Tính toán lại điểm kết thúc
                findSecondPointWhenShift();

                pe.DrawRectangle(new Pen(State.CurrentColor, State.LineWidth), State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Width1);

                if (State.IsBrushFill)
                {
                    pe.FillRectangle(CurrentBrush, State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Width1);
                }

            }
            else
            {
                calcHeightWidth();
                pe.DrawRectangle(new Pen(State.CurrentColor, State.LineWidth), State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Height1);
                if (State.IsBrushFill)
                {
                    pe.FillRectangle(CurrentBrush, State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Height1);
                }

            }

        }
		public void Draw(Graphics g, Size mapSize)
		{
			bool drawSquares = false;
			var galaxyMap = GalaxyMap.Instance;
			var galaxy = galaxyMap.Galaxy;
			var faction = galaxy.GetFaction(Planet);
			var color = faction != null ? faction.Color : Color.White;
			using (var brush = new SolidBrush(color)) {
				var x1 = (int)(Position.X*mapSize.Width - PlanetSize/2);
				var y1 = (int)(Position.Y*mapSize.Height - PlanetSize/2);

             
                g.FillEllipse(Brushes.Black, x1 - OutlineSize, y1 - OutlineSize, PlanetSize + OutlineSize * 2, PlanetSize + OutlineSize * 2);
				g.FillEllipse(brush, x1, y1, PlanetSize, PlanetSize);

                

				if (drawSquares) {
					g.SmoothingMode = SmoothingMode.None;
					g.InterpolationMode = InterpolationMode.NearestNeighbor;

					Faction attackFaction;
					var found = galaxyMap.AttackablePlanetIDs.TryGetValue(Planet.ID, out attackFaction);
					if (found) {
						g.DrawRectangle(new Pen(attackFaction.Color, 3), x1, y1, PlanetSize, PlanetSize);
					}

					if (galaxyMap.ClaimablePlanetIDs.Contains(Planet.ID)) {
						g.DrawRectangle(new Pen(Color.Purple, 3), x1, y1, PlanetSize, PlanetSize);
					}
					g.SmoothingMode = SmoothingMode.AntiAlias;
					g.InterpolationMode = InterpolationMode.HighQualityBicubic;
				}
			}
		}
Example #11
0
		public override void Draw(Graphics g, float zoom, PointF offset, PointF zoomPosition)
		{
			var rect = Helpers.NormalizedRect(currentRectangle.Location,
			                                  new PointF(currentRectangle.Right, currentRectangle.Bottom));

			int x0 = (int) (rect.Left*zoom + offset.X);
			int y0 = (int) (rect.Top*zoom + offset.Y);
			int x1 = (int) (rect.Width*zoom);
			int y1 = (int) (rect.Height*zoom);

			if (x1 == 0 || y1 == 0)
				return;


			using (var pen = new Pen(borderColor))
			{
				if (ImageViewPort.CastShadow)
				{
					using (var pen2 = new Pen(Color.FromArgb(64, 0, 0, 0)))
					{
						pen2.Width = borderSize;
						g.DrawRectangle(pen2, x0 + (int) (3*zoom), y0 + (int) (3*zoom), x1, y1);
					}
				}

				pen.Width = borderSize;
				g.DrawRectangle(pen, x0, y0, x1, y1);
			}
		}
        public void GraphicsIsVisibleRectangleF(Graphics g)
        {
            Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6);
            SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0));

            // Create the first rectangle and draw it to the screen in blue.
            g.DrawRectangle(myPen, regionRect1);
            g.FillRectangle (myBrush, regionRect1);

            // Create the second rectangle and draw it to the screen in red.
            myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
            myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);

            g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
            g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));

            // Create a region using the first rectangle.
            Region myRegion = new Region(regionRect1);

            // Determine if myRect is contained in the region.
            bool contained = myRegion.IsVisible(regionRect2);

            // Display the result.
            Font myFont = new Font("Arial", 8);
            SolidBrush txtBrush = new SolidBrush(Color.Black);
            g.DrawString("contained = " + contained.ToString(),
                myFont,
                txtBrush,
                new PointF(regionRectF2.Right + 10, regionRectF2.Top));

            regionRect1.Y += 120;
            regionRectF2.Y += 120;
            regionRectF2.X += 41;

            myPen.Color = Color.FromArgb (196, 0xC3, 0xC9, 0xCF);
            myBrush.Color = Color.FromArgb(127, 0xDD, 0xDD, 0xF0);

            // Create the first rectangle and draw it to the screen in blue.
            g.DrawRectangle(myPen, regionRect1);
            g.FillRectangle (myBrush, regionRect1);

            // Create the second rectangle and draw it to the screen in red.
            myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
            myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);

            g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
            g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));

            // Create a region using the first rectangle.
            myRegion = new Region(regionRect1);

            // Determine if myRect is contained in the region.
            contained = myRegion.IsVisible(regionRectF2);

            // Display the result.
            g.DrawString("contained = " + contained.ToString(),
                myFont,
                txtBrush,
                new PointF(regionRectF2.Right + 10, regionRectF2.Top));
        }
Example #13
0
        protected override void drawSelf(Graphics g)
        {
            int yRect = 0;
            g.DrawRectangle(new Pen(Color.Black, 1), 0, 0, this.Size.Width - 1, this.Size.Height - 1);

            //Vẽ TableName
            string nameTable = table.name;
            g.DrawRectangle(new Pen(Color.Black, 1), 0, 0, this.Size.Width-1, ShapeSetting.heightPieceShape);
            g.FillRectangle(ShapeSetting.brushTableName,new Rectangle(1, 1, this.Size.Width-2, ShapeSetting.heightPieceShape-1));
            g.DrawString(nameTable, new Font("Arial", 10), ShapeSetting.brushText, new Rectangle(10, yRect, this.Size.Width-1, ShapeSetting.heightPieceShape));

            //Vẽ Attribute
            int maxLength = maxLengthText();
            foreach (Column c in table.columns)
            {
                yRect += 20;
                string strAttribute = "";
                strAttribute += c.Name.PadRight(maxLength);
                strAttribute += " " + c.DataType.PadRight(10);
                if (c.PrimaryKey)
                    strAttribute += "(pk)";
                if(c.ForeignKey)
                    strAttribute += "(fk)";
                g.DrawString(strAttribute, this.Font, ShapeSetting.brushText, new Rectangle(10, yRect, this.Size.Width - 1, ShapeSetting.heightPieceShape));
            }
        }
Example #14
0
        /// <summary>
        /// Render the QuadTree into the given Graphics context
        /// </summary>
        /// <param name="graphics"></param>
        internal void Render(Graphics graphics)
        {
            m_quadTree.ForEach(delegate(QuadTreeNode<Item> node)
            {

                // draw the contents of this quad
                if (node.Contents != null)
                {
                    foreach (Item item in node.Contents)
                    {
                        using (Brush b = new SolidBrush(item.Color))
                            graphics.FillEllipse(b, Rectangle.Round(item.Rectangle));
                    }
                }

                // draw this quad

                // Draw the border
                Color color = GetColor(node);
                graphics.DrawRectangle(Pens.Black, Rectangle.Round(node.Bounds));

                // draw the inside of the border in a distinct colour
                using (Pen p = new Pen(color))
                {
                    Rectangle inside = Rectangle.Round(node.Bounds);
                    inside.Inflate(-1, -1);
                    graphics.DrawRectangle(p, inside);
                }

            });
        }
Example #15
0
 protected void DrawBackground(Graphics g, DrawState state)
 {
     Rectangle rc = ClientRectangle;
     // Draw background
     if (state == DrawState.Normal || state == DrawState.Disable)
     {
         g.FillRectangle(new SolidBrush(SystemColors.Control), rc);
         using (SolidBrush rcBrush = state == DrawState.Disable ?
             new SolidBrush(SystemColors.ControlDark) :
             new SolidBrush(SystemColors.ControlDarkDark))
         {
             // Draw border rectangle
             g.DrawRectangle(new Pen(rcBrush), rc.Left, rc.Top, rc.Width - 1, rc.Height - 1);
         }
     }
     else if ( state == DrawState.Hot || state == DrawState.Pressed  )
     {
         // Erase whaterver that was there before
         if ( state == DrawState.Hot )
             g.FillRectangle(new SolidBrush(ColorUtil.VSNetSelectionColor), rc);
         else
             g.FillRectangle(new SolidBrush(ColorUtil.VSNetPressedColor), rc);
         // Draw border rectangle
         g.DrawRectangle(SystemPens.Highlight, rc.Left, rc.Top, rc.Width-1, rc.Height-1);
     }
 }
        public override void Draw(RectangleF dirtyRect)
        {
            Graphics g = new Graphics();

            var ClientRectangle = new Rectangle((int)dirtyRect.X,
                                                (int)dirtyRect.Y,
                                                (int)dirtyRect.Width,
                                                (int)dirtyRect.Height);

            // Calculate the location and size of the drawing area
            // Within which we want to draw the graphics:
            //Rectangle ChartArea = ClientRectangle;
            Rectangle ChartArea = new Rectangle(50, 50,
                                                ClientRectangle.Width - 70, ClientRectangle.Height - 70);
            g.DrawRectangle(Pens.LightCoral, ChartArea);

            PlotArea = new Rectangle(ChartArea.Location, ChartArea.Size);
            PlotArea.Inflate(-offset, -offset);
            //Draw ClientRectangle and PlotArea using pen:
            g.DrawRectangle(Pens.Black, PlotArea);
            // Generate Sine and Cosine data points to plot:
            PointF[] pt1 = new PointF[nPoints];
            PointF[] pt2 = new PointF[nPoints];
            for (int i = 0; i < nPoints; i++)
            {
                pt1[i] = new PointF(i / 5.0f, (float)Math.Sin(i/5.0f));
                pt2[i] = new PointF(i / 5.0f, (float)Math.Cos(i/5.0f));
            }
            for (int i = 1; i < nPoints; i++)
            {
                g.DrawLine(Pens.Blue, Point2D(pt1[i - 1]), Point2D(pt1[i]));
                g.DrawLine(Pens.Red, Point2D(pt2[i - 1]), Point2D(pt2[i]));
            }
            g.Dispose();
        }
 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);
 }
Example #18
0
        public static void DrawNode( Graphics g, Node node )
        {
            if( node.Shape == NodeShape.Rectangle )
            {
                // Background
                g.FillRectangle(node.BackBrush,
                    node.Position.X + node.Box.X, node.Position.Y + node.Box.Y,
                    node.Box.Width, node.Box.Height);

                // Border
                if( node.BorderType == NodeBorderType.Single )
                {
                    g.DrawRectangle(node.BorderPen,
                        node.Position.X + node.Box.X, node.Position.Y + node.Box.Y,
                        node.Box.Width, node.Box.Height);
                }
                else if( node.BorderType == NodeBorderType.Double )
                {
                    g.DrawRectangle(node.BorderPen,
                        node.Position.X + node.Box.X, node.Position.Y + node.Box.Y,
                        node.Box.Width, node.Box.Height);

                    float diff = node.BorderPen.Width * 2;
                    g.DrawRectangle(node.BorderPen,
                        node.Position.X + node.Box.X + diff, node.Position.Y + node.Box.Y + diff,
                        node.Box.Width - 2 * diff, node.Box.Height - 2 * diff);
                }
            }
            else
            {
                // Background
                g.FillEllipse(node.BackBrush,
                    node.Position.X + node.Box.X, node.Position.Y + node.Box.Y,
                    node.Box.Width, node.Box.Height);

                // Border
                if( node.BorderType == NodeBorderType.Single )
                {
                    g.DrawEllipse(node.BorderPen,
                        node.Position.X + node.Box.X, node.Position.Y + node.Box.Y,
                        node.Box.Width, node.Box.Height);
                }
                else if( node.BorderType == NodeBorderType.Double )
                {
                    g.DrawEllipse(node.BorderPen,
                        node.Position.X + node.Box.X, node.Position.Y + node.Box.Y,
                        node.Box.Width, node.Box.Height);

                    float diff = node.BorderPen.Width * 2;
                    g.DrawEllipse(node.BorderPen,
                         node.Position.X + node.Box.X + diff, node.Position.Y + node.Box.Y + diff,
                        node.Box.Width - 2 * diff, node.Box.Height - 2 * diff);
                }
            }

            // Label
            if( node.LabelText != null )
                g.DrawString(node.LabelText, node.LabelFont, node.LabelBrush,
                    node.Position.X + node.LabelOffset.X, node.Position.Y + node.LabelOffset.Y);
        }
Example #19
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="g"></param>
 public void DrawButtons(Graphics g)
 {
     int pad = 20;
     int left = pad;
     int top = 20;
     Pen pen = new Pen(Color.LightGray);
     for (int i = Constants.EMPTY; i <= Constants.FINISH; i++)
     {
         switch (i)
         {
             case 0:
                 break;
             case 1:
                 g.FillRectangle(Brushes.White, left + 1, top + 1, 19, 19);
                 break;
             case 2:
                 pen = new Pen(Color.Green);
                 break;
             case 3:
                 pen = new Pen(Color.Red);
                 break;
         }
         g.DrawRectangle(pen, left, top, 20, 20);
         left += pad + 20;
     }
     g.DrawRectangle(new Pen(Color.LightGray), left, top, 24, 20);
     g.DrawString("Go", new Font("Times New Roman", 12), Brushes.White, left + 1, top + 1);
 }
 private void DrawPitch(Graphics g, ISimulation s)
 {
     var w = s.PitchBounds.Width;
     g.DrawEllipse(_linePen, -w / 10, -w / 10, w / 5, w / 5);
     g.DrawRectangle(_linePen, s.PitchBounds);
     g.DrawRectangle(_linePen, s.Teams[0].GoalBounds);
     g.DrawRectangle(_linePen, s.Teams[1].GoalBounds);
 }
Example #21
0
        public void Draw(Graphics g)
        {
            g.DrawRectangle(new Pen(Color.Red), rect);

            foreach (PosSizableRect pos in Enum.GetValues(typeof(PosSizableRect)))
            {
                g.DrawRectangle(new Pen(Color.Red), GetRect(pos));
            }
        }
Example #22
0
 public void paint(Graphics g)
 {
     Pen pen = new Pen(Color.White, 3);
     g.DrawRectangle(pen, offset.X, offset.Y, width, height);
     pen = new Pen(Color.LightBlue, 1);
     foreach (Slot slot in slots) {
         g.DrawRectangle(pen, offset.X + slot.position.X * Slot.size, offset.Y + slot.position.Y * Slot.size, Slot.size, Slot.size);
     }
 }
 private void TekenLogo(Graphics Tekengebied,
                         Pen penToUse,
                         int xPos,
                         int yPos)
 {
     Tekengebied.DrawRectangle(penToUse, xPos, yPos, 20, 20);
     Tekengebied.DrawRectangle(penToUse, xPos, yPos, 40, 40);
     Tekengebied.DrawRectangle(penToUse, xPos, yPos, 60, 60);
 }
 protected override void DrawCrosshair(Graphics g)
 {
     int rectOffset = 3;
     int rectSize = 4;
     g.DrawRectangle(new Pen(Color.Black), new Rectangle(rectOffset, lastPos.Y - rectSize,
         width - rectOffset * 2, rectSize * 2 + 1));
     g.DrawRectangle(new Pen(Color.White), new Rectangle(rectOffset + 1, lastPos.Y - rectSize + 1,
         width - rectOffset * 2 - 2, rectSize * 2 - 1));
 }
Example #25
0
 public static void DrawElementDebugBorder(Graphics zGraphics, ProjectLayoutElement zElement, int nX, int nY, bool bSelected)
 {
     // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1)
     zGraphics.TranslateTransform(nX, nY);
     zGraphics.DrawRectangle(s_zPenDebugBorder, zElement.x, zElement.y, zElement.width - 1, zElement.height - 1);
     if (bSelected)
     {
         zGraphics.DrawRectangle(m_zPenElementSelect, zElement.x - 2, zElement.y - 2, zElement.width + 3, zElement.height + 3);
     }
 }
		/// <summary></summary>
		/// <param name="box"></param>
		/// <param name="g"></param>
		public void PaintBackground(Rectangle box, Graphics g) {
			g.FillRectangle(brush, box);
			g.DrawRectangle(inner, 2, 2, box.Width - 3, box.Height - 4);
			g.DrawRectangle(outer, 1, 1, box.Width - 1, box.Height - 2);
			g.DrawLine(border, 1, box.Height, box.Width, box.Height);

			if (gloss != null) {
				gloss.PaintGloss(box, g);
			}
		}
Example #27
0
		public void Draw(Graphics graphics)
		{
			using (Pen p = new Pen(Color.FromArgb(80, 70, 70, 70), 1)) {
				float[] dashValues = { 6, 3 };
				p.DashPattern = dashValues;
				Rectangle r = new Rectangle(drawing.Location, drawing.Size);
				graphics.DrawRectangle(p, r);
				graphics.FillRectangle(Brushes.White, new Rectangle(r.Location.X - CORNER_SQUARE_SIZE, r.Location.Y - CORNER_SQUARE_SIZE,	CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));
				graphics.DrawRectangle(Pens.Blue, new Rectangle(r.Location.X - CORNER_SQUARE_SIZE, r.Location.Y - CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));

				graphics.FillRectangle(Brushes.White, new Rectangle(r.Location.X + r.Width, r.Location.Y - CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));
				graphics.DrawRectangle(Pens.Blue, new Rectangle(r.Location.X + r.Width, r.Location.Y - CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));

				graphics.FillRectangle(Brushes.White, new Rectangle(r.Location.X + (r.Width - CORNER_SQUARE_SIZE) / 2, r.Location.Y - CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));
				graphics.DrawRectangle(Pens.Blue, new Rectangle(r.Location.X + (r.Width - CORNER_SQUARE_SIZE) / 2, r.Location.Y - CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));



				graphics.FillRectangle(Brushes.White, new Rectangle(r.Location.X - CORNER_SQUARE_SIZE, r.Location.Y + r.Size.Height, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));
				graphics.DrawRectangle(Pens.Blue, new Rectangle(r.Location.X - CORNER_SQUARE_SIZE, r.Location.Y + r.Size.Height, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));


				graphics.FillRectangle(Brushes.White, new Rectangle(r.Location.X - CORNER_SQUARE_SIZE, r.Location.Y + (r.Size.Height - CORNER_SQUARE_SIZE) / 2, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));
				graphics.DrawRectangle(Pens.Blue, new Rectangle(r.Location.X - CORNER_SQUARE_SIZE, r.Location.Y + (r.Size.Height - CORNER_SQUARE_SIZE) / 2, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));

				graphics.FillRectangle(Brushes.White, new Rectangle(r.Location.X + r.Width, r.Location.Y + r.Size.Height, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));
				graphics.DrawRectangle(Pens.Blue, new Rectangle(r.Location.X + r.Width, r.Location.Y + r.Size.Height, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));

				graphics.FillRectangle(Brushes.White, new Rectangle(r.Location.X + (r.Width - CORNER_SQUARE_SIZE) / 2, r.Location.Y + r.Size.Height, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));
				graphics.DrawRectangle(Pens.Blue, new Rectangle(r.Location.X + (r.Width - CORNER_SQUARE_SIZE) / 2, r.Location.Y + r.Size.Height, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));

				graphics.FillRectangle(Brushes.White, new Rectangle(r.Location.X + r.Size.Width, r.Location.Y + (r.Size.Height - CORNER_SQUARE_SIZE) / 2, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));
				graphics.DrawRectangle(Pens.Blue, new Rectangle(r.Location.X + r.Size.Width, r.Location.Y + (r.Size.Height - CORNER_SQUARE_SIZE) / 2, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE));
			}
		}
Example #28
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            g = e.Graphics;

            Point[] Triangle =
            {
                new Point (100, 5),
                new Point(33, 108),
                new Point(167, 108),
            };
            g.DrawPolygon(p, Triangle);
            g.FillPolygon(b, Triangle);

            g.DrawRectangle(p, 33, 108, 134, 100);
            g.FillRectangle(b, 33, 108, 134, 100);
            
            g.FillEllipse(new SolidBrush(Color.Red), 85, 68, 30, 30);

            Point[] Door =
            {
                new Point(124, 167),
                new Point(124, 208),
                new Point(167, 167),
                new Point (167, 208),
            };
            g.DrawRectangle(p, 124, 167, 42, 41);
            g.FillRectangle(new SolidBrush (Color.Gray), 124, 167, 42, 41);

            g.DrawLine(p, 145, 190, 150, 190);

            g.DrawRectangle(p, 33, 130, 35, 35);
            g.FillRectangle(new SolidBrush(Color.White), 33, 130, 35, 35);
            g.DrawLine(p, 33, 148, 68, 148);
            g.DrawLine(p, 51, 130, 51, 165);

            g.DrawLine(p2, 334, 210, 334, 165);

            Point[] PolyPoints =
            {
                new Point (334, 165),
                new Point (334, 125),
                new Point (354, 136),
                new Point (354, 156),
                new Point (334, 165),
                new Point (314, 156),
                new Point (314, 136),
                new Point (334, 125),
            };
            g.DrawPolygon(p, PolyPoints);
            g.FillPolygon(new SolidBrush(Color.Yellow), PolyPoints);
            g.DrawPolygon(new Pen(Color.Red, 3), PolyPoints);

            g.DrawLine(new Pen (Color.Red, 3), 314, 136, 354, 156);
            g.DrawLine(new Pen(Color.Red, 3), 314, 156, 354, 136);
        }
        public static void DrawBorder(Graphics g,ViewStyle viewStyle,Rectangle controlRect,bool hot)
        {
            controlRect = new Rectangle(controlRect.X,controlRect.Y,controlRect.Width - 1,controlRect.Height - 1);

            if(hot){
                g.DrawRectangle(new Pen(viewStyle.BorderHotColor),controlRect);
            }
            else{
                g.DrawRectangle(new Pen(viewStyle.BorderColor),controlRect);
            }
        }
		public virtual void Draw (Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor) {
			bool is_themecolor = backColor.ToArgb () == ThemeEngine.Current.ColorControl.ToArgb () || backColor == Color.Empty ? true : false;
			CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor (backColor);
			Pen pen;
			
			switch (state) {
				case ButtonThemeState.Normal:
				case ButtonThemeState.Entered:
				case ButtonThemeState.Disabled:
					pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
					g.DrawLine (pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2);
					g.DrawLine (pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y);

					pen = is_themecolor ? SystemPens.Control : ResPool.GetPen (backColor);
					g.DrawLine (pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3);
					g.DrawLine (pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1);

					pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
					g.DrawLine (pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2);
					g.DrawLine (pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3);

					pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
					g.DrawLine (pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
					g.DrawLine (pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2);
					break;
				case ButtonThemeState.Pressed:
					g.DrawRectangle (ResPool.GetPen (foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);

					bounds.Inflate (-1, -1);
					pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
					g.DrawRectangle (pen, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
					break;
				case ButtonThemeState.Default:
					g.DrawRectangle (ResPool.GetPen (foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);

					bounds.Inflate (-1, -1);
					pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
					g.DrawLine (pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2);
					g.DrawLine (pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y);

					pen = is_themecolor ? SystemPens.Control : ResPool.GetPen (backColor);
					g.DrawLine (pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3);
					g.DrawLine (pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1);

					pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
					g.DrawLine (pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2);
					g.DrawLine (pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3);

					pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
					g.DrawLine (pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
					g.DrawLine (pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2);
					break;
			}
		}
Example #31
0
 private static void DrawToLanePreviewNoteFrame(System.Drawing.Graphics g, Rectangle rect, PreviewNote note)
 {
     if (note == null)
     {
         return;
     }
     using (var pen = new Pen(NoteGraphicsGenerator.GetColor(note.SelectedNote)))
     {
         g.DrawRectangle(pen, rect);
     }
 }
Example #32
0
        /* Draws a ractangle with given sides, coordinates Position.X & .Y
         * using given color) */

        public override void Draw(System.Drawing.Graphics g)
        {
            // Create a pen
            System.Drawing.Pen p = new System.Drawing.Pen(RgbColor);
            int x = Position.X;
            int y = Position.Y;

            // Draw a rectangle
            g.DrawRectangle(p, x, y, Width, Height);
            g.Flush();
        }
Example #33
0
 protected override void WndProc(ref Message m)
 {
     base.WndProc(ref m);
     if (m.Msg == WM_PAINT)
     {
         PaintInfoTip(ref m);
     }
     //绘制边框
     if (m.Msg == 0xf)//|| m.Msg == 0x133)
     {
         //拦截系统消息,获得当前控件进程以便重绘。
         //一些控件(如TextBox、Button等)是由系统进程绘制,重载OnPaint方法将不起作用.
         //所有这里并没有使用重载OnPaint方法绘制TextBox边框。
         //
         //MSDN:重写 OnPaint 将禁止修改所有控件的外观。
         //那些由 Windows 完成其所有绘图的控件(例如 Textbox)从不调用它们的 OnPaint 方法,
         //因此将永远不会使用自定义代码。请参见您要修改的特定控件的文档,
         //查看 OnPaint 方法是否可用。如果某个控件未将 OnPaint 作为成员方法列出,
         //则您无法通过重写此方法改变其外观。
         //
         //MSDN:要了解可用的 Message.Msg、Message.LParam 和 Message.WParam 值,
         //请参考位于 MSDN Library 中的 Platform SDK 文档参考。可在 Platform SDK(“Core SDK”一节)
         //下载中包含的 windows.h 头文件中找到实际常数值,该文件也可在 MSDN 上找到。
         IntPtr hDC = GetWindowDC(m.HWnd);
         if (hDC.ToInt32() == 0)
         {
             return;
         }
         Color dc = _losecolor;
         if (_losefocus == false)
         {
             dc = _borderColor;
         }
         if (_drawerror == true)
         {
             dc = _errorcolor; _drawerror = false;
         }
         System.Drawing.Pen pen = new Pen(dc, 2);
         //绘制边框
         System.Drawing.Graphics g  = Graphics.FromHdc(hDC);
         System.Drawing.Graphics g2 = Graphics.FromHdc(hDC);
         g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
         System.Drawing.Pen pen_hideback = new Pen(this.BackColor, 1);
         g2.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
         g.DrawRectangle(pen_hideback, 0, 0, this.Width - 1, this.Height - 1);
         g2.DrawLine(pen, new Point(0, this.Height - 2), new Point(this.Width, this.Height - 2));
         pen.Dispose();
         pen_hideback.Dispose();
         //返回结果
         m.Result = IntPtr.Zero;
         //释放
         ReleaseDC(m.HWnd, hDC);
     }
 }
Example #34
0
 public override void Paint(System.Drawing.Graphics g, int xOffset)
 {
     if (Fill)
     {
         g.FillRectangle(new SolidBrush(Colour), X, Y, Width, Height);
     }
     else
     {
         g.DrawRectangle(new Pen(Colour), X, Y, Width, Height);
     }
 }
Example #35
0
 public void Render(System.Drawing.Graphics g, PointF pos, SizeF layout)
 {
     using (Brush b = new SolidBrush(Color1))
     {
         g.DrawString(Text, Font1, b, new RectangleF(pos, layout), Format);
         if (ShowBorder)
         {
             g.DrawRectangle(Pens.Blue, pos.X, pos.Y, layout.Width, layout.Height);
         }
     }
 }
Example #36
0
        public override void Draw(System.Drawing.Graphics g)
        {
            Pen p = new Pen(Selected ? Color.Red : Color.Black);

            g.DrawRectangle(p, DrawRect);
            g.DrawRectangle(p, X, Y, Width - 1, 10);
            g.DrawString(Title, DCSFont, p.Brush, X, Y);
            if (WinButtonClose)
            {
                g.DrawRectangle(p, X + Width - 9, Y + 1, 7, 7);
            }
            if (WinButtonMaximize)
            {
                g.DrawRectangle(p, X + Width - 17, Y + 1, 7, 7);
            }
            if (WinButtonMinimize)
            {
                g.DrawRectangle(p, X + Width - 25, Y + 1, 7, 7);
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            using (
                System.Drawing.Graphics gSquare = this.squarePanel.CreateGraphics(),
                gCircle = this.circlePanel.CreateGraphics())
            {
                // Draw a filled square in the client area of
                // the squarePanel control.
                gSquare.FillRectangle(
                    Brushes.Red,
                    0,
                    0,
                    this.squarePanel.Width,
                    this.squarePanel.Height
                    );

                // If the Square option has been selected, draw a
                // border inside the squarePanel.
                if (this.lightShapeValue == MarqueeLightShape.Square)
                {
                    gSquare.DrawRectangle(
                        Pens.Black,
                        0,
                        0,
                        this.squarePanel.Width - 1,
                        this.squarePanel.Height - 1);
                }

                // Draw a filled circle in the client area of
                // the circlePanel control.
                gCircle.Clear(this.circlePanel.BackColor);
                gCircle.FillEllipse(
                    Brushes.Blue,
                    0,
                    0,
                    this.circlePanel.Width,
                    this.circlePanel.Height
                    );

                // If the Circle option has been selected, draw a
                // border inside the circlePanel.
                if (this.lightShapeValue == MarqueeLightShape.Circle)
                {
                    gCircle.DrawRectangle(
                        Pens.Black,
                        0,
                        0,
                        this.circlePanel.Width - 1,
                        this.circlePanel.Height - 1);
                }
            }
        }
Example #38
0
        public void Draw(System.Drawing.Graphics graphicsEngine, GameEntity gameEntity, System.Drawing.Image image)
        {
            TextureBrush textureBrush = new TextureBrush(image);
            Pen          blackPen     = new Pen(Color.Black);

            textureBrush.WrapMode = WrapMode.TileFlipX;
            graphicsEngine.FillRectangle(textureBrush, gameEntity.GetRectangle());
            graphicsEngine.DrawRectangle(blackPen, gameEntity.GetRectangle());
            blackPen.Dispose();
            textureBrush.Dispose();
        }
Example #39
0
        public override void OnDraw(System.Drawing.Graphics g)
        {
            if (mouseDown)
            {
                Rectangle drawingArea = area;
                drawingArea.Offset((int)(diagram.AutoScrollPosition.X / diagram.Zoom), (int)(diagram.AutoScrollPosition.Y / diagram.Zoom));

                drawingArea = drawingArea.Zoom(diagram.Zoom);
                g.DrawRectangle(Pens.Green, drawingArea);
            }
        }
Example #40
0
 private void SDraw(System.Drawing.Graphics Gr, bool b, Pen Pn, int x, int y, int w, int h)
 {
     if (b)
     {
         Gr.FillRectangle(new System.Drawing.SolidBrush(Pn.Color), x, y, w, h);
     }
     else
     {
         Gr.DrawRectangle(Pn, x, y, w, h);
     }
 }
Example #41
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            Pen draw = new Pen(Color.DarkRed, 1);

            System.Drawing.Graphics gr = this.CreateGraphics();

            if (Control.MouseButtons == MouseButtons.Left)
            {
                gr.DrawRectangle(draw, MousePosition.X, MousePosition.Y - 40, 1, 1);
            }
        }
Example #42
0
        /// <summary>
        /// Function to draw the main gradient display.
        /// </summary>
        /// <param name="panelGraphics">Graphics interface for the panel.</param>
        private void DrawGradientDisplay(System.Drawing.Graphics panelGraphics = null)
        {
            if (_gradDisplayImage == null)
            {
                return;
            }

            var region = new Rectangle(0, 0, _gradDisplayImage.Width, _gradDisplayImage.Height);

            using (System.Drawing.Graphics gradLayer = System.Drawing.Graphics.FromImage(_gradientImage))
            {
                using (Brush brush = UpdateBrush(panelGradientDisplay.ClientRectangle, false))
                {
                    gradLayer.InterpolationMode  = InterpolationMode.High;
                    gradLayer.CompositingMode    = CompositingMode.SourceOver;
                    gradLayer.CompositingQuality = CompositingQuality.HighQuality;
                    gradLayer.Clear(Color.Transparent);
                    gradLayer.FillRectangle(brush, region);
                }
            }

            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(_gradDisplayImage))
            {
                g.InterpolationMode  = InterpolationMode.High;
                g.CompositingMode    = CompositingMode.SourceOver;
                g.CompositingQuality = CompositingQuality.HighQuality;

                using (Brush backBrush = new TextureBrush(Resources.Pattern, WrapMode.Tile))
                {
                    g.FillRectangle(backBrush, region);
                    g.DrawImage(_gradientImage, new Point(0, 0));
                    g.DrawRectangle(Pens.Black, new Rectangle(0, 0, region.Width - 1, region.Height - 1));
                }
            }

            System.Drawing.Graphics graphicsSurface = panelGraphics;

            try
            {
                if (panelGraphics == null)
                {
                    graphicsSurface = panelGradientDisplay.CreateGraphics();
                }

                graphicsSurface.DrawImage(_gradDisplayImage, new Point(0, 0));
            }
            finally
            {
                if ((graphicsSurface != null) && (panelGraphics == null))
                {
                    graphicsSurface.Dispose();
                }
            }
        }
Example #43
0
        /// <summary>
        /// Paint me
        /// </summary>
        /// <param name="g"></param>
        protected override void OnPaint(System.Drawing.Graphics g)
        {
            if (Labels.Count == 0)
            {
                return;
            }
            else if (Labels.Count == 1)
            {
                StringFormat tsf = new StringFormat();
                tsf.Alignment = StringAlignment.Center;
                //GraphicsContainer gc1 = g.BeginContainer();
                SizeF ys = g.MeasureString(Labels[0], Font, Height, tsf);
                g.RotateTransform(-90);
                g.DrawString(Labels[0], Font, new SolidBrush(ForeColor),
                             new RectangleF(new PointF(-Height, 0), new SizeF(Height, ys.Height)), tsf);
                //g.EndContainer(gc1);

//				//Add Y title height to ChControl X coordinate
//				x += (int)Math.Ceiling(ys.Height);
            }
            else if (Labels.Count > 1)
            {
                //Draw Legend
                SizeF  ys;
                double ys_height = 5.0f;
                string ly;
                int    x = 5;
                for (int i = 0; i < Labels.Count; i++)
                {
                    ly = Labels[i];

                    ys = g.MeasureString(ly, Font);

                    if (showcolors)
                    {
                        g.FillRectangle(new SolidBrush((Color)colors[i]), 10, (float)ys_height + 3, 5, ys.Height - 6);
                        x = 20;
                    }

                    g.DrawString(ly, Font, new SolidBrush(ForeColor), x, (float)ys_height);

                    if (i < Labels.Count - 1)
                    {
                        ys_height += ys.Height + margin;
                    }
                    else
                    {
                        ys_height += margin;
                    }
                }

                g.DrawRectangle(new Pen(ForeColor), 0, 0, Width - 1, Height - 1);
            }
        }
Example #44
0
        private System.Drawing.Image CreateCheckCodeImage(string checkCode)
        {
            System.Drawing.Bitmap   image = new System.Drawing.Bitmap((checkCode.Length * 20), 40);//產生圖片,寬20*位數,高40像素
            System.Drawing.Graphics g     = Graphics.FromImage(image);


            //生成隨機生成器
            Random random    = new Random(Guid.NewGuid().GetHashCode());
            int    int_Red   = 0;
            int    int_Green = 0;
            int    int_Blue  = 0;

            int_Red   = random.Next(256); //產生0~255
            int_Green = random.Next(256); //產生0~255
            int_Blue  = (int_Red + int_Green > 400 ? 0 : 400 - int_Red - int_Green);
            int_Blue  = (int_Blue > 255 ? 255 : int_Blue);

            //清空圖片背景色
            //g.Clear(Color.FromArgb(int_Red, int_Green, int_Blue));
            g.Clear(Color.FromKnownColor(KnownColor.Orange));

            //畫圖片的背景噪音線
            for (int i = 0; i <= 24; i++)
            {
                int x1 = random.Next(image.Width);
                int x2 = random.Next(image.Width);
                int y1 = random.Next(image.Height);
                int y2 = random.Next(image.Height);

                g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);

                g.DrawEllipse(new Pen(Color.DarkViolet), new System.Drawing.Rectangle(x1, y1, x2, y2));
            }

            Font font = new System.Drawing.Font("Arial", 20, (System.Drawing.FontStyle.Bold));

            System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.DarkRed, 1.2F, true);

            g.DrawString(checkCode, font, brush, 2, 2);
            for (int i = 0; i <= 99; i++)
            {
                //畫圖片的前景噪音點
                int x = random.Next(image.Width);
                int y = random.Next(image.Height);

                image.SetPixel(x, y, Color.FromArgb(random.Next()));
            }

            //畫圖片的邊框線
            g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);


            return(image);
        }
Example #45
0
        /// <summary>
        /// Paints one color button
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="color"></param>
        /// <param name="hotTrack"></param>
        /// <param name="selected"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        private Rectangle PaintColor(System.Drawing.Graphics graphics, Color color, bool hotTrack, bool selected, int x, int y)
        {
            // Button inside rectangle
            Rectangle mainRec = new Rectangle(x + 3, y + 3, 11, 11);
            // Button border rectangle
            Rectangle borderRec = new Rectangle(x, y, 17, 17);
            // Check if the button is selected and HotTrack ( no the same color)
            bool selectedAndHotTrack = selected && hotTrack;

            // Paints the button using the brushes needed
            using (Brush brush = new SolidBrush(color))
                using (Brush hotTrackBrush = new SolidBrush(CustomColors.ButtonHoverLight))
                    using (Brush selectedBrush = new SolidBrush(CustomColors.ButtonHoverDark))
                        using (Brush selectedHotTrackBrush = new SolidBrush(CustomColors.SelectedAndHover))
                            using (Pen selectedPen = new Pen(CustomColors.SelectedBorder))
                                using (Pen borderPen = new Pen(CustomColors.ButtonBorder))
                                {
                                    // Paints the rectangle with the Track/Selected color
                                    // if this color is selected/hottrack
                                    if (selectedAndHotTrack)
                                    {
                                        graphics.FillRectangle(selectedHotTrackBrush, borderRec);
                                        graphics.DrawRectangle(selectedPen, borderRec);
                                    }
                                    else if (hotTrack)
                                    {
                                        graphics.FillRectangle(hotTrackBrush, borderRec);
                                        graphics.DrawRectangle(selectedPen, borderRec);
                                    }
                                    else if (selected)
                                    {
                                        graphics.FillRectangle(selectedBrush, borderRec);
                                        graphics.DrawRectangle(selectedPen, borderRec);
                                    }
                                    // Fills the rectangle with the current color, paints
                                    // the background.
                                    graphics.FillRectangle(brush, mainRec);
                                    graphics.DrawRectangle(borderPen, mainRec);
                                }
            return(borderRec);
        }
Example #46
0
        private void cell(int i, int j)
        {
            int x, y;

            x = i * (cw + 2);
            y = j * (ch + 2) + menuStrip1.Height;
            if (field[i, j] > 200)
            {
                g.FillRectangle(SystemBrushes.Control, x, y, cw + 2, ch + 2);
            }
            if (field[i, j] > 100 && field[i, j] < 200)
            {
                g.DrawImage(pics, new Rectangle(x + 1, y + 1, cw, ch), new Rectangle((field[i, j] - 101) * cw, 0, cw, ch), GraphicsUnit.Pixel);
                g.DrawRectangle(Pens.Black, x + 1, y + 1, cw, ch);
            }
            if (field[i, j] > 0 && field[i, j] < 100)
            {
                g.FillRectangle(SystemBrushes.Control, x + 1, y + 1, cw, ch);
                g.DrawRectangle(Pens.Black, x + 1, y + 1, cw, ch);
            }
        }
Example #47
0
        private void DrawRectangle(int x, int y)
        {
            System.Drawing.Pen myPen;
            myPen = new System.Drawing.Pen(System.Drawing.Color.MediumBlue);
            System.Drawing.Graphics formGraphics = this.tab_AI.CreateGraphics();
            formGraphics.DrawRectangle(myPen, new Rectangle(x, y, 5, 5));
            SolidBrush _brush = new SolidBrush(Color.MediumBlue);

            formGraphics.FillRectangle(_brush, x, y, 5, 5);
            myPen.Dispose();
            formGraphics.Dispose();
        }
Example #48
0
 private void frmDrawInstance_MouseMove(object sender, MouseEventArgs e)
 {
     if (_isSet)
     {
         _rect.X      = Math.Min(e.X, _initial[0]);
         _rect.Y      = Math.Min(e.Y, _initial[1]);
         _rect.Width  = Math.Abs(e.X - _initial[0]);
         _rect.Height = Math.Abs(e.Y - _initial[1]);
         formGraphics.Clear(_background);
         formGraphics.DrawRectangle(_drawPen, _rect);
     }
 }
Example #49
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                formattedValue = "";
                Handler.Paint(graphics, clipBounds, ref cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

                float?progressVal;

                if (!(progressVal = value as float?).HasValue)
                {
                    return;
                }

                float  percentage = (float)progressVal;
                string progress   = (int)(progressVal * 100f) + "%";

                sd.Rectangle paintRect = new sd.Rectangle(cellBounds.X + 1, cellBounds.Y + 2, cellBounds.Width - 2, cellBounds.Height - 4);

                PaintBorder(graphics, clipBounds, paintRect, cellStyle, advancedBorderStyle);

                sd.Color bkColor;
                if (elementState == swf.DataGridViewElementStates.Selected)
                {
                    bkColor = cellStyle.SelectionBackColor;
                }
                else
                {
                    bkColor = cellStyle.BackColor;
                }

                using (sd.SolidBrush backBrush = new sd.SolidBrush(bkColor))
                    graphics.FillRectangle(backBrush, paintRect);

                if (swf.ProgressBarRenderer.IsSupported)
                {
                    swf.ProgressBarRenderer.DrawHorizontalBar(graphics, paintRect);

                    sd.Rectangle barBounds = new sd.Rectangle(paintRect.X + 2, paintRect.Y + 2, paintRect.Width - 4, paintRect.Height - 4);
                    barBounds.Width = (int)Math.Round(barBounds.Width * percentage);
                    swf.ProgressBarRenderer.DrawHorizontalChunks(graphics, barBounds);
                }
                else
                {
                    sd.Rectangle barBounds = new sd.Rectangle(paintRect.X + 2, paintRect.Y + 2, paintRect.Width - 4, paintRect.Height - 3);
                    barBounds.Width = (int)Math.Round(barBounds.Width * percentage);

                    graphics.FillRectangle(sd.Brushes.LightGray, paintRect);
                    graphics.DrawRectangle(sd.Pens.Black, paintRect);
                    graphics.FillRectangle(new sd.SolidBrush(sd.Color.FromArgb(0, 216, 35)), barBounds);
                }

                swf.TextRenderer.DrawText(graphics, progress, cellStyle.Font, paintRect, cellStyle.ForeColor, swf.TextFormatFlags.HorizontalCenter | swf.TextFormatFlags.VerticalCenter);
            }
Example #50
0
        public void NewRect(Rectangle rectangle)
        {
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.DarkOrchid);
            System.Drawing.Pen        myPen   = new System.Drawing.Pen(myBrush);
            myPen.Width = myPen.Width * 12;
            myGraphics  = mainPnl.CreateGraphics();
            myGraphics.DrawRectangle(myPen, rectangle);
            allGraphics.Add(rectangle);

            myBrush.Dispose();
            myPen.Dispose();
        }
Example #51
0
 public void DrawRegion(int a, int b, int c, int d)
 {
     startPointX = a;
     endPointX   = a + c;
     startPointY = b;
     endPointY   = b + d;
     System.Drawing.Graphics formGraphics = this.CreateGraphics();
     using (var p = new Pen(Color.Blue, 5))
     {
         formGraphics.DrawRectangle(p, a, b, c, d);
     }
 }
Example #52
0
        //
        public override void draw(System.Drawing.Graphics dc)
        {
            int       centerX = 0;
            int       centerY = 0;
            SizeF     fontSize;
            Brush     brushTxt;
            Rectangle rect;
            Font      font;
            Point     imageLoc = Location;
            String    sText    = mStrText;

            if (mbDrag)
            {
                //return;
                rect = new Rectangle(this.CurrentPositionX,
                                     this.CurrentPositionY,
                                     this.ItemSize.Width,
                                     this.ItemSize.Height);
            }

            font     = new Font(mFontFamily, mfFontSize, mFontStyle);
            fontSize = dc.MeasureString(Text, font);

            // Need to verify this code
            if (fontSize.Width > Width)
            {
                int len = mStrText.Length;
                int sub = (int)(len * Width / fontSize.Width);
                sText          = mStrText.Substring(0, sub);
                fontSize.Width = Width - 1;
            }

            centerX = ItemSize.Width / 2 - (int)fontSize.Width / 2;

            centerY  = ItemSize.Height / 2 - (int)fontSize.Height / 2;
            centerX += CurrentPositionX;
            centerY += CurrentPositionY;

            brushTxt = new SolidBrush(mClrText);
            float[] dashValues = { 5, 2, 10, 4 };
            Pen     blackPen   = new Pen(Color.Black, 1);

            //blackPen.DashPattern = dashValues;
            dc.FillRectangle(Brushes.Silver, this.CurrentPositionX, this.CurrentPositionY, this.Width, this.Height);
            dc.DrawRectangle(blackPen, this.CurrentPositionX, this.CurrentPositionY, this.Width, this.Height);

            dc.DrawString(sText,
                          font,
                          brushTxt,
                          centerX,
                          centerY);
            font.Dispose();
        }
Example #53
0
 /// <summary>
 /// if the mouse has clicked in a certain area (Debug Version)
 /// </summary>
 /// <param name="bounds">Target area</param>
 /// <param name="g">Traget graphics</param>
 /// <returns>True or false</returns>
 public static bool MousePressedArea(Bounds bounds, System.Drawing.Graphics g)
 {
     g.DrawRectangle(new Pen(Color.Green), bounds.points[0].x, bounds.points[0].y, bounds.points[3].x, bounds.points[3].y);
     if (MouseEnter(bounds))
     {
         return(MOUSE_LEFT_BUTTON);
     }
     else
     {
         return(false);
     }
 }
Example #54
0
 protected override void InnerDraw(System.Drawing.Graphics g, bool selected)
 {
     using (Brush background = new HatchBrush(HatchStyle.LargeCheckerBoard, Color.White, Color.LightGray))
     {
         g.FillRectangle(background, Area);
     }
     using (var pen = new Pen(Brushes.Red, 2))
     {
         g.DrawRectangle(pen, Area);
         g.DrawString(Text, Font, Brushes.Black, Area.Location);
     }
 }
Example #55
0
        public void DrawBackground(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Drawing.Color backColor)
        {
            graphics.FillRectangle(new SolidBrush(backColor), bounds);

            using (Pen borderPen = new Pen(_ProfessionalColorTable.ToolStripBorder, 1))
            {
                bounds.Width--;
                bounds.Height--;

                graphics.DrawRectangle(borderPen, bounds);
            }
        }
Example #56
0
        private void button1_Click(object sender, EventArgs e)
        {
            Rectangle rect = new Rectangle(20, 100, 75, 75);

            Pen pen = new Pen(Color.Red);

            formGraphics = this.CreateGraphics();
            formGraphics.DrawRectangle(pen, rect);

            pen.Dispose();
            formGraphics.Dispose();
        }
Example #57
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == 0xf || m.Msg == 0x133)
            {
                IntPtr hDC = GetWindowDC(m.HWnd);
                if (hDC.ToInt32() == 0) return;

                System.Drawing.Graphics g = Graphics.FromHdc(hDC);
                if (isMouseEnter)
                {
                    g.DrawRectangle(new Pen(Color.Blue), new Rectangle(0, 0, this.Width - 1, this.Height - 1));
                }
                else
                {
                    g.DrawRectangle(new Pen(Color.Gray), new Rectangle(0, 0, this.Width - 1, this.Height - 1));
                }
                m.Result = IntPtr.Zero;
                ReleaseDC(m.HWnd, hDC);
            }
        }
Example #58
0
 private void resctSizeIncreaseSize_Click(object sender, EventArgs e)
 {
     if (RectSize < 180 || RectSize == 180)
     {
         rectSizePanel.Refresh();
         RectSize = RectSize + 5;
         System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(selectedPen.Color);
         selectedPen.Width = PenSize;
         Font font = new Font("Times New Roman", 12.0f);
         rectSizePanelGrapics.DrawString(rectText.Text, font, myBrush, 4, 4);
         if (checkBox1.Checked)
         {
             rectSizePanelGrapics.FillRectangle(myBrush, new Rectangle(4, 4, RectSize, RectSize));
         }
         else
         {
             rectSizePanelGrapics.DrawRectangle(selectedPen, new Rectangle(4, 4, RectSize, RectSize));
         }
         //myBrush.Dispose();
     }
 }
Example #59
0
        public override void Render(System.Drawing.Graphics g)
        {
            if (this.m_SharesLocation && !this.IsSelected)
            {
                Rectangle rc = new Rectangle(this.Bounds.Left - 8, this.Bounds.Top - 8, this.Bounds.Width, this.Bounds.Height);

                g.FillRectangle(this.m_StaticBkBrush, rc);
                g.DrawRectangle(this.m_StaticBorderPen, rc);
            }

            base.Render(g);
        }
Example #60
0
        /// <summary>
        /// 获得操作系统消息
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == 0xf || m.Msg == 0x133)
            {
                //拦截系统消息,获得当前控件进程以便重绘。

                IntPtr hDC = GetWindowDC(m.HWnd);
                if (hDC.ToInt32() == 0)
                {
                    return;
                }

                //只有在边框样式为FixedSingle时自定义边框样式才有效
                if (this.BorderStyle == BorderStyle.FixedSingle)
                {
                    //边框Width为1个像素
                    System.Drawing.Pen pen = new Pen(this._BorderColor, 1);;

                    if (this._HotTrack)
                    {
                        if (this.Focused)
                        {
                            pen.Color = this._HotColor;
                        }
                        else
                        {
                            if (this._IsMouseOver)
                            {
                                pen.Color = this._HotColor;
                            }
                            else
                            {
                                pen.Color = this._BorderColor;
                            }
                        }
                    }
                    //绘制边框
                    System.Drawing.Graphics g = Graphics.FromHdc(hDC);
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    g.DrawRectangle(pen, 0, 0, this.Width - 1, this.Height - 1);
                    pen.Dispose();
                }
                //返回结果
                m.Result = IntPtr.Zero;
                //释放
                ReleaseDC(m.HWnd, hDC);
            }
            else if (m.Msg == 0x0018)
            {
                this.SetWatermark();
            }
        }