当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.DrawRectangle方法代码示例

本文整理汇总了C#中Graphics.DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawRectangle方法的具体用法?C# Graphics.DrawRectangle怎么用?C# Graphics.DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graphics的用法示例。


在下文中一共展示了Graphics.DrawRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

 public override void Draw(Graphics gr)
 {
     if (Ready)
         {
             gr.DrawRectangle(Pens.Green, Left, Top, Right, Bottom);
         }
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: Run

        public static void Run()
        {
            // ExStart:DrawingRectangle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages() + "SampleRectangle_out.bmp";

            // Creates an instance of FileStream
            using (FileStream stream = new FileStream(dataDir, FileMode.Create))
            {
                // Create an instance of BmpOptions and set its various properties
                BmpOptions saveOptions = new BmpOptions();
                saveOptions.BitsPerPixel = 32;

                // Set the Source for BmpOptions and Create an instance of Image
                saveOptions.Source = new StreamSource(stream);
                using (Image image = Image.Create(saveOptions, 100, 100))
                {
                    // Create and initialize an instance of Graphics class,  Clear Graphics surface, Draw a rectangle shapes and  save all changes.
                    Graphics graphic = new Graphics(image);
                    graphic.Clear(Color.Yellow);
                    graphic.DrawRectangle(new Pen(Color.Red), new Rectangle(30, 10, 40, 80));
                    graphic.DrawRectangle(new Pen(new SolidBrush(Color.Blue)), new Rectangle(10, 30, 80, 40));
                    image.Save();
                }
            }
            // ExEnd:DrawingRectangle
        }
开发者ID:aspose-imaging,项目名称:Aspose.Imaging-for-.NET,代码行数:27,代码来源:DrawingRectangle.cs

示例3: Draw

    public void Draw(Graphics graphics, Size buffersize)
    {
        //store transform, (like opengl's glPushMatrix())
        Matrix mat1 = graphics.Transform;

        //transform into position
        graphics.TranslateTransform(m_position.X, m_position.Y);
        graphics.RotateTransform(m_angle/(float)Math.PI * 180.0f);

        try
        {
            //draw body
            graphics.DrawRectangle(new Pen(m_color), rect);

            //draw line in the "forward direction"
            graphics.DrawLine(new Pen(Color.Yellow), 1, 0, 1, 5);
        }
        catch(OverflowException exc)
        {
            //physics overflow :(
        }

        //restore transform
        graphics.Transform = mat1;
    }
开发者ID:zenmumbler,项目名称:GranZero,代码行数:25,代码来源:RigidBody.cs

示例4: drawPoints

    /// <summary>
    /// Malt die Punkte auf dem Bildschirm auf
    /// und beschriftet sie mit den Koordinaten
    /// </summary>
    /// <param name="gr">Graphics-Objekt, auf dem gezeichnet wird</param>
    public void drawPoints(Graphics gr)
    {
        foreach(Point point in this.points) {
            gr.DrawRectangle(Pens.Black,
                             point.x*SCALE_FACTOR,
                             point.y*SCALE_FACTOR,
                             .5f,
                             .5f);

            //Punkte beschriften:
            gr.DrawString("(" + point.x + "|" + point.y + ")",
                          new Font("Arial.ttf", 8, FontStyle.Bold),
                          Brushes.Black,
                          point.x*SCALE_FACTOR,
                          point.y*SCALE_FACTOR);
        }
    }
开发者ID:tobbi,项目名称:Algorithmen-Hausarbeit-2012,代码行数:22,代码来源:geoGraph.cs

示例5: renderObjects

 public void renderObjects(Graphics g, int curScale)
 {
   for (int i = 0; i < 64; i++)
   {
       byte b1  = Globals.romdata[0x2BE4D + i*6];
       byte b2  = Globals.romdata[0x2BE4D + i*6 + 1];
       byte b3  = Globals.romdata[0x2BE4D + i*6 + 2];
       byte b4  = Globals.romdata[0x2BE4D + i*6 + 3];
       byte b5  = Globals.romdata[0x2BE4D + i*6 + 4];
       byte b6  = Globals.romdata[0x2BE4D + i*6 + 5];
       var rect = new Rectangle(32*curScale*(i+1), 8*32*curScale, 32*curScale*(i+2), (curScale*32*8)+80);
       g.DrawRectangle(new Pen(Color.Red, 4.0f), rect);
       g.DrawString(String.Format("{0:X2}", b1), new Font("Arial", 8), Brushes.Red, rect);
       g.DrawString(String.Format("{0:X2}", b2), new Font("Arial", 8), Brushes.Red, rect.X + 16, rect.Y);
       g.DrawString(String.Format("{0:X2}", b3), new Font("Arial", 8), Brushes.Red, rect.X + 32, rect.Y);
       g.DrawString(String.Format("{0:X2}", b4), new Font("Arial", 8), Brushes.Red, rect.X + 0 , rect.Y+16);
       g.DrawString(String.Format("{0:X2}", b5), new Font("Arial", 8), Brushes.Red, rect.X + 16, rect.Y+16);
       g.DrawString(String.Format("{0:X2}", b6), new Font("Arial", 8), Brushes.Red, rect.X + 32, rect.Y+16);
   }
 }
开发者ID:ghostdogtm,项目名称:CadEditor,代码行数:20,代码来源:Settings_Battletoads-1.cs

示例6: drawObject

    public static void drawObject(Graphics g, ObjectRec curObject, bool isSelected, float curScale, ImageList objectSprites)
    {
        //don't render commands
        if (curObject.type >= 0xFF00)
          return;

        var dict = curObject.additionalData;
        var myFont = new Font(FontFamily.GenericSansSerif, 6.0f);
        int x = curObject.x, y = curObject.y;
        int addX = dict["addX"];
        int addY = dict["addY"];
        int fromFloor = dict["fromFloor"];

        /*if (curObject.type < objectSprites.Images.Count)
        {
        var p1 = new Point((int)(x * curScale) - 8, (int)(y * curScale) - 8);
        var p2 = new Point(p1.X + (int)(addX/2 * curScale) - 8,  p1.Y + (int)(addY/2 * curScale) - 8);
        g.DrawImage(objectSprites.Images[curObject.type], p1);
        if (fromFloor == 0)
        {
          g.DrawImage(objectSprites.Images[curObject.type],p2);
          g.DrawLine(new Pen(Brushes.Red), p1, p2);
        }
        }
        else*/
        {
        var p1 = new Point((int)(x * curScale) - 8, (int)(y * curScale) - 8);
        g.FillRectangle(Brushes.Black, new Rectangle(p1, new Size(16, 16)));
        g.DrawString(curObject.type.ToString("X3"), myFont, Brushes.White, p1);
        if (fromFloor == 0)
        {
          var p2 = new Point(p1.X + (int)(addX/2 * curScale) - 8, p1.Y + (int)(addY/2 * curScale) - 8);
          g.FillRectangle(Brushes.Green, new Rectangle(p2, new Size(16, 16)));
          g.DrawString(curObject.type.ToString("X3"), myFont, Brushes.White, p2);
          g.DrawLine(new Pen(Brushes.Red), p1, p2);
        }
        }
        if (isSelected)
        g.DrawRectangle(new Pen(Brushes.Red, 2.0f), new Rectangle((int)(x * curScale) - 8, (int)(y * curScale) - 8, 16, 16));
    }
开发者ID:ProtonNoir,项目名称:CadEditor,代码行数:40,代码来源:Settings_CHC-Utils.cs

示例7: OnPaint

    protected override void OnPaint(PaintEventArgs e)
    {
        B = new Bitmap(Width, Height);
        G = Graphics.FromImage(B);
        G.Clear(C1);
        G.FillRectangle(B1, R1);

        if (_Progress > 0)
        {
            G.FillRectangle(B2, R2);

            G.FillRectangle(B3, 2, 3, R2.Width, 4);
            G.DrawRectangle(P1, 4, 4, R2.Width - 4, Height - 8);

            G.DrawRectangle(P2, 2, 2, R2.Width - 1, Height - 5);
        }

        G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1);
        e.Graphics.DrawImage(B, 0, 0);
        G.Dispose();
        B.Dispose();
    }
开发者ID:uberm,项目名称:BitcoinMiner,代码行数:22,代码来源:BullTheme.cs

示例8: DrawBingoCard

        public void DrawBingoCard(Point pt, Size sz, BingoTable table, System.Drawing.Color tableColor, ref Graphics graphicsObj)
        {
            List<string> data = new List<string>(table.items);
            data.Sort();

            Pen myPen = new Pen(tableColor, 2);
            Brush whiteBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            Brush blackBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            Rectangle rect = new Rectangle(pt, sz);
            graphicsObj.FillRectangle(whiteBrush, rect);

            int startX = pt.X;
            int startY = pt.Y;
            int endX = sz.Width + pt.X;
            int endY = sz.Height + pt.Y;

            //If free space is enabled, then we have to find the mean and median of rows and cols so we know where to put the free space
            int rowMedian = -1;
            int colMedian = -1;
            bool thisIsAFreeSpace = false;
            if (table.printFreeSpace == true)
            {
                rowMedian = (int)((float)table.rowSize / 2 - 0.5);
                colMedian = (int)((float)table.colSize / 2 - 0.5);
            }

            int squareWidth = sz.Width / table.colSize;
            int squareHeight;

            if (table.printTitle == true)
            {
                squareHeight = sz.Height / (table.rowSize + 1);                         //Adjust the square height if we have a title
                graphicsObj.DrawRectangle(myPen, pt.X, pt.Y, sz.Width, squareHeight);   //Draw the title rectangle

                int titleNumChars = table.titleText.Length;
                int titleOneCharWidth = sz.Width / titleNumChars;                       //Figure out how much space one character of the title occupies

                char[] titleCharArray = table.titleText.ToCharArray();

                int counter = 0;
                foreach (char item in titleCharArray)                                   //For each character in the title, go through the loop
                {
                    float itemFontSize = 150;                                           //Starting font size
                    Font itemFont = new Font(FontFamily.GenericMonospace, itemFontSize);
                    SizeF itemSize = graphicsObj.MeasureString(item.ToString(), itemFont);  //Initial graphic size

                    while (((int)itemSize.Width > titleOneCharWidth) || ((int)itemSize.Height > squareHeight))  //Loop while the size is greater than the box size (titleOneCharWidth)
                    {
                        itemFontSize -= 1;
                        if (itemFontSize <= 0)
                        {
                            itemFontSize = 1;
                            break;
                        } //Avoid badness

                        itemFont = new Font(FontFamily.GenericMonospace, itemFontSize);                         //Decrease font size by 1 and then create new font item
                        itemSize = graphicsObj.MeasureString(item.ToString(), itemFont);                        //Re-measure
                    }   //1) Decrease itemFontSize, re-measure the height and width, if new height and width are bigger than the box then repeat

                    float offset = (titleOneCharWidth - itemSize.Width) / 2;        //The offset is the amount I have to move the start point in order to center the text within the box (titleOneCharWidth)
                    graphicsObj.DrawString(item.ToString(), itemFont, blackBrush, (float)pt.X + offset + counter * titleOneCharWidth, (float)(pt.Y + ((squareHeight - itemSize.Height)/2)));

                    counter += 1;                                                   //Counter keeps track of which titleOneCharWidth box we are in.
                }

                pt.Y = pt.Y + squareHeight;     //Move the Y point down one box size in order to allow for the title

            } //Square height needs to account for the title
            else
            {
                squareHeight = sz.Height / table.rowSize;
            } //Square height doesn't need to account for the title

            for (int rows = 0; rows < table.rowSize; rows++)
            {
                for (int cols = 0; cols < table.colSize; cols++)
                {

                    int xPos = pt.X + cols * squareWidth;
                    int yPos = pt.Y + rows * squareHeight;

                    Rectangle temp = new Rectangle(xPos, yPos, squareWidth, squareHeight);
                    // Rectangle rect2 = new Rectangle(pt.X, pt.Y, squareWidth, squareHeight);
                    graphicsObj.DrawRectangle(myPen, temp);

                    //TextTime!
                    //At this point, we are in a box that has point x, y = (pt.X + cols * squareWidth), (pt.Y + rows * squareHeight)
                    //The box has dimensions of squareWidth and squareHeight.
                    //So, for each word passed to us we must
                    //0) Split on the spaces if a input string is made up entirely of words
                    //1) find the minimum size that will fit in the box
                    //2) Find the vertical and horizontal center
                    //3) Paint the word in the center of the box
                    //This code will take the word list, randomize it, and print the first row * col items

                    Random rand = new Random(table.RandSeed);

                    string itemString = "";
                    int randomIndex = 0;
//.........这里部分代码省略.........
开发者ID:xyzio,项目名称:bingowords,代码行数:101,代码来源:BingoFuncs.cs

示例9: DrawHeader

	// The funtion that print the title, page number, and the header row
	private void DrawHeader(Graphics g) {
		CurrentY = (float)TopMargin;
		// Printing the page number (if isWithPaging is set to true)
		if(IsWithPaging) {
			PageNumber++;
			string PageString = "Page " + PageNumber.ToString();
			StringFormat PageStringFormat = new StringFormat();
			PageStringFormat.Trimming = StringTrimming.Word;
			PageStringFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
			PageStringFormat.Alignment = StringAlignment.Far;
			Font PageStringFont = new Font("Tahoma",8,FontStyle.Regular,GraphicsUnit.Point);
			RectangleF PageStringRectangle = new RectangleF((float)LeftMargin,CurrentY,(float)PageWidth - (float)RightMargin - (float)LeftMargin,g.MeasureString(PageString,PageStringFont).Height);
			g.DrawString(PageString,PageStringFont,new SolidBrush(Color.Black),PageStringRectangle,PageStringFormat);
			CurrentY += g.MeasureString(PageString,PageStringFont).Height;
		}
		// Printing the title (if IsWithTitle is set to true)
		if(IsWithTitle) {
			StringFormat TitleFormat = new StringFormat();
			TitleFormat.Trimming = StringTrimming.Word;
			TitleFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
			if(IsCenterOnPage){
				TitleFormat.Alignment = StringAlignment.Center;
			}
			else{
				TitleFormat.Alignment = StringAlignment.Near;
			}
			RectangleF TitleRectangle = new RectangleF((float)LeftMargin,CurrentY,(float)PageWidth - (float)RightMargin - (float)LeftMargin,g.MeasureString(TheTitleText,TheTitleFont).Height);
			g.DrawString(TheTitleText,TheTitleFont,new SolidBrush(TheTitleColor),TitleRectangle,TitleFormat);
			CurrentY += g.MeasureString(TheTitleText,TheTitleFont).Height;
		}
		// Calculating the starting x coordinate that the printing process will start from
		float CurrentX = (float)LeftMargin;
		if(IsCenterOnPage){
			CurrentX += (((float)PageWidth - (float)RightMargin - (float)LeftMargin) - mColumnPointsWidth[mColumnPoint]) / 2.0F;
		}
		// Setting the HeaderFore style
		Color HeaderForeColor = TheDataGridView.ColumnHeadersDefaultCellStyle.ForeColor;
		if(HeaderForeColor.IsEmpty){ // If there is no special HeaderFore style, then use the default DataGridView style
			HeaderForeColor = TheDataGridView.DefaultCellStyle.ForeColor;
		}
		SolidBrush HeaderForeBrush = new SolidBrush(HeaderForeColor);
		// Setting the HeaderBack style
		Color HeaderBackColor = TheDataGridView.ColumnHeadersDefaultCellStyle.BackColor;
		if(HeaderBackColor.IsEmpty){ // If there is no special HeaderBack style, then use the default DataGridView style
			HeaderBackColor = TheDataGridView.DefaultCellStyle.BackColor;
		}
		SolidBrush HeaderBackBrush = new SolidBrush(HeaderBackColor);
		// Setting the LinePen that will be used to draw lines and rectangles (derived from the GridColor property of the DataGridView control)
		Pen TheLinePen = new Pen(TheDataGridView.GridColor,1);
		// Setting the HeaderFont style
		Font HeaderFont = TheDataGridView.ColumnHeadersDefaultCellStyle.Font;
		if(HeaderFont == null){ // If there is no special HeaderFont style, then use the default DataGridView font style
			HeaderFont = TheDataGridView.DefaultCellStyle.Font;
		}
		// Calculating and drawing the HeaderBounds        
		RectangleF HeaderBounds = new RectangleF(CurrentX,CurrentY,mColumnPointsWidth[mColumnPoint],RowHeaderHeight);
		g.FillRectangle(HeaderBackBrush,HeaderBounds);
		// Setting the format that will be used to print each cell of the header row
		StringFormat CellFormat = new StringFormat();
		CellFormat.Trimming = StringTrimming.Word;
		CellFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
		// Printing each visible cell of the header row
		RectangleF CellBounds;
		float ColumnWidth;
		for(int i = (int)mColumnPoints[mColumnPoint].GetValue(0);i < (int)mColumnPoints[mColumnPoint].GetValue(1);i++) {
			if(!TheDataGridView.Columns[i].Visible) continue; // If the column is not visible then ignore this iteration
			ColumnWidth = ColumnsWidth[i];
			// Check the CurrentCell alignment and apply it to the CellFormat
			if(TheDataGridView.ColumnHeadersDefaultCellStyle.Alignment.ToString().Contains("Right"))
				CellFormat.Alignment = StringAlignment.Far;
			else if(TheDataGridView.ColumnHeadersDefaultCellStyle.Alignment.ToString().Contains("Center"))
				CellFormat.Alignment = StringAlignment.Center;
			else
				CellFormat.Alignment = StringAlignment.Near;
			CellBounds = new RectangleF(CurrentX,CurrentY,ColumnWidth,RowHeaderHeight);
			// Printing the cell text
			g.DrawString(TheDataGridView.Columns[i].HeaderText,HeaderFont,HeaderForeBrush,CellBounds,CellFormat);
			// Drawing the cell bounds
			if(TheDataGridView.RowHeadersBorderStyle != DataGridViewHeaderBorderStyle.None) // Draw the cell border only if the HeaderBorderStyle is not None
				g.DrawRectangle(TheLinePen,CurrentX,CurrentY,ColumnWidth,RowHeaderHeight);
			CurrentX += ColumnWidth;
		}
		CurrentY += RowHeaderHeight;
	}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:85,代码来源:FormEligibilityResponseDisplay.cs

示例10: OnPaint

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.Clear(BackColor);

        GP1 = DrawArrow(6, 4, false);
        GP2 = DrawArrow(7, 5, false);

        G.FillPath(B1, GP2);
        G.FillPath(B2, GP1);

        GP3 = DrawArrow(Width - 11, 4, true);
        GP4 = DrawArrow(Width - 10, 5, true);

        G.FillPath(B1, GP4);
        G.FillPath(B2, GP3);

        if (ShowThumb)
        {
            G.FillRectangle(B1, Thumb);
            G.DrawRectangle(P1, Thumb);
            G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2);

            int X = 0;
            int LX = Thumb.X + (Thumb.Width / 2) - 3;

            for (int I = 0; I <= 2; I++)
            {
                X = LX + (I * 3);

                G.DrawLine(P1, X, Thumb.Y + 5, X, Thumb.Bottom - 5);
                G.DrawLine(P2, X + 1, Thumb.Y + 5, X + 1, Thumb.Bottom - 5);
            }
        }

        G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1);
        G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3);
    }
开发者ID:massimoca,项目名称:Wedit,代码行数:38,代码来源:Theme.cs

示例11: AlgorithmDrawable

 /// <summary>
 /// Алгоритм отрисовки кисти
 /// </summary>
 /// <param name="graphics"></param>
 /// <param name="gameTime"></param>
 /// <param name="rectangle"></param>
 public override void AlgorithmDrawable(Graphics graphics, GameTime gameTime, Rectangle rectangle)
 {
     graphics.DrawRectangle(rectangle, Color, BorderLenght);
 }
开发者ID:gavrilyuc,项目名称:xnaControl,代码行数:10,代码来源:DefaultBorderBrush.cs

示例12: DrawRectangles

 /// <summary>
 /// Draws the rectangles for debug purposes
 /// </summary>
 /// <param name="g"></param>
 internal void DrawRectangles(Graphics g)
 {
     foreach (CssBox b in Rectangles.Keys)
     {
         if (float.IsInfinity(Rectangles[b].Width))
             continue;
         g.FillRectangle(new SolidBrush(Color.FromArgb(50, Color.Black)),
             Rectangle.Round(Rectangles[b]));
         g.DrawRectangle(Pens.Red, Rectangle.Round(Rectangles[b]));
     }
 }
开发者ID:krikelin,项目名称:LerosClient,代码行数:15,代码来源:CssLineBox.cs

示例13: DrawByStock

 public void DrawByStock(Graphics gDC)
 {
     Pen pen = null;
     Rectangle rect = default(Rectangle);
     Rectangle rect2 = default(Rectangle);
     SolidBrush solidBrush = null;
     Font font = null;
     SizeF sizeF = default(SizeF);
     bool flag = false;
     try
     {
         List<clsVolumeItem> list = new List<clsVolumeItem>();
         this.m_Font = new Font(this.m_FontName, this.m_FontSize, FontStyle.Bold);
         int num = Convert.ToInt32(gDC.MeasureString("I", this.m_Font).Height);
         solidBrush = new SolidBrush(this.m_BgColor);
         rect2 = new Rectangle(0, 0, this.m_Rect.Width, num);
         gDC.FillRectangle(solidBrush, rect2);
         this.m_Font = new Font(this.m_FontName, this.m_FontSize, FontStyle.Regular);
         rect2 = new Rectangle(5, num + 1, this.m_Rect.Width - 10, this.m_Rect.Height - num - 30);
         this.sngTop = num + 5;
         this.sngBottom = this.m_Rect.Height - num - 50;
         pen = new Pen(Color.DimGray);
         gDC.DrawRectangle(pen, rect2);
         int x = rect2.Left;
         int x2 = rect2.Right;
         pen.DashStyle = DashStyle.Dash;
         pen.Color = ColorTranslator.FromHtml("#333333");
         for (int i = 1; i <= 9; i++)
         {
             int num2 = rect2.Top + Convert.ToInt32(rect2.Height / 10) * i;
             int y = num2;
             gDC.DrawLine(pen, x, num2, x2, y);
         }
         int num3 = 0;
         this.sfDraw.Alignment = StringAlignment.Center;
         int num4 = rect2.Width / (this._itemsByStock.Count * 3);
         num3 = rect2.Width / (this._itemsByStock.Count + 1) - num4;
         if (num3 > 120)
         {
             num3 = 120;
         }
         double num5 = this.GetMaxValue() * 100.0 / 90.0;
         float num6 = (float)(num3 * this._itemsByStock.Count + num4 * (this._itemsByStock.Count - 1));
         int num7 = Convert.ToInt32(((float)rect2.Width - num6) / 2f);
         int num8 = rect2.Left + num7;
         if (this._itemsByStock.Count > 0)
         {
             int num9 = 0;
             string text;
             foreach (ItemByStock current in this._itemsByStock)
             {
                 solidBrush.Dispose();
                 solidBrush = new SolidBrush(this.m_BgColor);
                 rect = new Rectangle(num8, this.sngTop + 1, num3, this.sngBottom - 1);
                 gDC.FillRectangle(solidBrush, rect);
                 x = rect.Left - 1;
                 x2 = rect.Right + 1;
                 pen.DashStyle = DashStyle.Dash;
                 pen.Color = ColorTranslator.FromHtml("#333333");
                 for (int i = 1; i <= 9; i++)
                 {
                     int num2 = rect2.Top + Convert.ToInt32(rect2.Height / 10) * i;
                     int y = num2;
                     gDC.DrawLine(pen, x, num2, x2, y);
                 }
                 pen.Color = Color.DarkGray;
                 solidBrush.Dispose();
                 if (current.Profit > 0.0)
                 {
                     solidBrush = new SolidBrush(this.m_BuyColor);
                 }
                 else if (current.Profit < 0.0)
                 {
                     solidBrush = new SolidBrush(this.m_SellColor);
                 }
                 else
                 {
                     solidBrush = new SolidBrush(this.m_VolumeColor);
                 }
                 double num10 = current.Value * 100.0 / num5;
                 num10 = 100.0 - num10;
                 int num11 = rect2.Top + Convert.ToInt32((double)rect2.Height * num10 / 100.0);
                 rect = new Rectangle(num8, num11, num3, rect2.Top + rect2.Height - num11);
                 gDC.FillRectangle(solidBrush, rect);
                 int num12 = num8;
                 int num13 = num11 - num + 2;
                 list.Add(new clsVolumeItem(num12, num13, current.Value));
                 if (this._itemsByStock.Count < 15)
                 {
                     font = new Font(this.m_FontName, this.m_FontSize);
                 }
                 else
                 {
                     font = new Font(this.m_FontName, this.m_FontSize - 2f);
                 }
                 solidBrush.Dispose();
                 solidBrush = new SolidBrush(this.m_VolumeColor);
                 text = current.Stock;
                 sizeF = gDC.MeasureString(text, font);
                 num13 = rect2.Bottom + 4;
//.........这里部分代码省略.........
开发者ID:Padungsak,项目名称:efinTradePlus,代码行数:101,代码来源:clsGraphPanel.cs

示例14: Draw

 public void Draw(Graphics gDC)
 {
     Pen pen = null;
     Rectangle rect = default(Rectangle);
     Rectangle rect2 = default(Rectangle);
     SolidBrush solidBrush = null;
     Font font = null;
     SizeF sizeF = default(SizeF);
     bool flag = false;
     try
     {
         List<clsVolumeItem> list = new List<clsVolumeItem>();
         this.m_Font = new Font(this.m_FontName, this.m_FontSize, FontStyle.Bold);
         int num = Convert.ToInt32(gDC.MeasureString("I", this.m_Font).Height);
         solidBrush = new SolidBrush(this.m_BgColor);
         rect2 = new Rectangle(0, 0, this.m_Rect.Width, num);
         gDC.FillRectangle(solidBrush, rect2);
         this.m_Font = new Font(this.m_FontName, this.m_FontSize, FontStyle.Regular);
         rect2 = new Rectangle(5, num + 1, this.m_Rect.Width - 10, this.m_Rect.Height - num - 30);
         this.sngTop = num + 5;
         this.sngBottom = this.m_Rect.Height - num - 50;
         pen = new Pen(Color.DimGray);
         gDC.DrawRectangle(pen, rect2);
         int x = rect2.Left;
         int x2 = rect2.Right;
         pen.DashStyle = DashStyle.Dash;
         pen.Color = ColorTranslator.FromHtml("#333333");
         for (int i = 1; i <= 9; i++)
         {
             int num2 = rect2.Top + Convert.ToInt32(rect2.Height / 10) * i;
             int y = num2;
             gDC.DrawLine(pen, x, num2, x2, y);
         }
         int num3 = 0;
         this.sfDraw.Alignment = StringAlignment.Center;
         int num4 = rect2.Width / (this._graphItems.Count * 3);
         num3 = rect2.Width / (this._graphItems.Count + 1) - num4;
         if (num3 > 120)
         {
             num3 = 120;
         }
         long num5 = this.GetMaxVolume() * 100L / 90L;
         float num6 = (float)(num3 * this._graphItems.Count + num4 * (this._graphItems.Count - 1));
         int num7 = Convert.ToInt32(((float)rect2.Width - num6) / 2f);
         int num8 = rect2.Left + num7;
         if (this._graphItems.Count > 0)
         {
             int num9 = 0;
             string text;
             foreach (VolumeGraphItem current in this._graphItems)
             {
                 solidBrush.Dispose();
                 solidBrush = new SolidBrush(this.m_BgColor);
                 rect = new Rectangle(num8, this.sngTop + 1, num3, this.sngBottom - 1);
                 gDC.FillRectangle(solidBrush, rect);
                 x = rect.Left - 1;
                 x2 = rect.Right + 1;
                 pen.DashStyle = DashStyle.Dash;
                 pen.Color = ColorTranslator.FromHtml("#333333");
                 for (int i = 1; i <= 9; i++)
                 {
                     int num2 = rect2.Top + Convert.ToInt32(rect2.Height / 10) * i;
                     int y = num2;
                     gDC.DrawLine(pen, x, num2, x2, y);
                 }
                 pen.Color = Color.DarkGray;
                 solidBrush.Dispose();
                 solidBrush = new SolidBrush(this.m_VolumeColor);
                 double num10 = (double)(current.AccVol * 100L / num5);
                 num10 = 100.0 - num10;
                 int num11 = rect2.Top + Convert.ToInt32((double)rect2.Height * num10 / 100.0);
                 rect = new Rectangle(num8, num11, num3, rect2.Top + rect2.Height - num11);
                 gDC.FillRectangle(solidBrush, rect);
                 int num12 = num8;
                 int num13 = num11 - num + 2;
                 list.Add(new clsVolumeItem(num12, num13, (double)current.AccVol));
                 solidBrush.Dispose();
                 if (this.ActiveType.DisplayBuySell == enumDisplayBuySell.Yes)
                 {
                     solidBrush = new SolidBrush(this.m_SellColor);
                 }
                 else
                 {
                     solidBrush = new SolidBrush(this.m_VolumeColor);
                 }
                 num10 = (double)((current.SellVol + current.BuyVol) * 100L / num5);
                 num10 = 100.0 - num10;
                 num11 = rect2.Top + Convert.ToInt32((double)rect2.Height * num10 / 100.0);
                 rect = new Rectangle(num8, num11, num3, rect2.Top + rect2.Height - num11);
                 gDC.FillRectangle(solidBrush, rect);
                 solidBrush.Dispose();
                 if (this.ActiveType.DisplayBuySell == enumDisplayBuySell.Yes)
                 {
                     solidBrush = new SolidBrush(this.m_BuyColor);
                 }
                 else
                 {
                     solidBrush = new SolidBrush(this.m_VolumeColor);
                 }
                 num10 = (double)(current.BuyVol * 100L / num5);
//.........这里部分代码省略.........
开发者ID:Padungsak,项目名称:efinTradePlus,代码行数:101,代码来源:clsGraphPanel.cs

示例15: PaintMainFormArea

 private void PaintMainFormArea(Graphics graphics, Rectangle cropArea)
 {
     if (highlight)
         outlinePen.Color = currentColorTable.LineHighlightColor;
     else
         outlinePen.Color = currentColorTable.LineColor;
     graphics.FillRectangle(areaBrush, cropArea);
     graphics.DrawRectangle(outlinePen, cropArea);
 }
开发者ID:vantruc,项目名称:skimpt,代码行数:9,代码来源:camera.cs


注:本文中的Graphics.DrawRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。