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


C# Graphics.FillRectangles方法代码示例

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


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

示例1: DrawRectangles

        public static void DrawRectangles(Graphics graphics, List<RectangleF> rectangles, Color color)
        {
            if (rectangles.Count > 0)
            {
                var brush = new SolidBrush(color);

                graphics.FillRectangles(brush, rectangles.ToArray());
            }
        }
开发者ID:zlynn1990,项目名称:SpaceSim,代码行数:9,代码来源:RenderUtils.cs

示例2: DrawHUD

        /// <summary>
        /// Draws the HUD.
        /// </summary>
        /// <param name="src">The SRC.</param>
        /// <param name="dst">The DST.</param>
        public void DrawHUD(Bitmap src, Bitmap dst)
        {
            try
            {
                _transparentBrush.Color = _color;
                _pen1.Color = _color;
                _pen2.Color = _color;

                //_brush.Color = _color_brush;

                //Initialize Graphics
                _g = Graphics.FromImage(src);
                _g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                _g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
                _g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; //.ClearTypeGridFit;

                // Draw top and bottom black bands
                _rectangleTextBkg[0] = new Rectangle(0, 0, _videoWidth, 20);
                _rectangleTextBkg[1] = new Rectangle(0, _videoHeight - 20, _videoWidth, _videoHeight);
                _g.FillRectangles(_brush, _rectangleTextBkg);
                _s = DateTime.Now.ToString();
                _s += " " + _message;
                _g.DrawString(_s, _fontOverlay, _transparentBrush, (RectangleF)_rectangleTextBkg[1], _format2);

                // Draw numeric boxes for:
                // 1. Heading
                _rectangleHUD[0] = new Rectangle((_videoWidth / 2) - 25, 30, 50, 15);
                // 2. Altitude
                _rectangleHUD[1] = new Rectangle(_videoWidth - 95, (_videoHeight / 2) - 8, 50, 15);
                // 3. Speed
                _rectangleHUD[2] = new Rectangle(45, (_videoHeight / 2) - 8, 50, 15);
                //_g.DrawRectangles(_pen1, _rectangleHUD);
                _g.FillRectangles(_brush, _rectangleHUD);

                //Draw numeric values inside each box:
                // 1. Heading
                _g.DrawString(_headingMagneticNorth.ToString(), _transparentFont, _transparentBrush, (RectangleF)_rectangleHUD[0], _format1);
                // 2. Altitude
                _g.DrawString(_altitude.ToString(), _transparentFont, _transparentBrush, (RectangleF)_rectangleHUD[1], _format1);
                //3. Speed
                _g.DrawString(_speed.ToString(), _transparentFont, _transparentBrush, (RectangleF)_rectangleHUD[2], _format1);

                //Draw aircraft indicator
                _pointsHUD3[0].X = _videoWidth / 2 - 20;
                _pointsHUD3[0].Y = _videoHeight / 2;

                _pointsHUD3[1].X = _videoWidth / 2 - 10;
                _pointsHUD3[1].Y = _videoHeight / 2;

                _pointsHUD3[2].X = _videoWidth / 2 - 5;
                _pointsHUD3[2].Y = _videoHeight / 2 + 10;

                _pointsHUD3[3].X = _videoWidth / 2;
                _pointsHUD3[3].Y = _videoHeight / 2 + 3;

                _pointsHUD3[4].X = _videoWidth / 2 + 5;
                _pointsHUD3[4].Y = _videoHeight / 2 + 10;

                _pointsHUD3[5].X = _videoWidth / 2 + 10;
                _pointsHUD3[5].Y = _videoHeight / 2;

                _pointsHUD3[6].X = _videoWidth / 2 + 20;
                _pointsHUD3[6].Y = _videoHeight / 2;
                _g.DrawLines(_pen1, _pointsHUD3);

                // Draw horizontal speed indicator
                Rectangle rectangleObj = new Rectangle(_videoWidth / 2 - _reticlesize / 2, _videoHeight / 2 - _reticlesize / 2, _reticlesize, _reticlesize);
                _g.DrawEllipse(_pen1, rectangleObj);
                // this line should represent the horizontal direction and speed up to X m/s
                _pointsHUD1[0].X = _videoWidth / 2 + 20;
                _pointsHUD1[0].Y = _videoHeight / 2 - 30;
                _pointsHUD1[1].X = _videoWidth / 2;
                _pointsHUD1[1].Y = _videoHeight / 2;
                _g.DrawLines(_pen1, _pointsHUD1);

                double pitch = _pitch;
                if (_pitch >= 90)
                    pitch = 180 - _pitch;
                if (_pitch <= -90)
                    pitch = -180 - _pitch;

                // save existing matrices
                _oldState = _g.Save();

                //yaw
                _g.TranslateTransform((float)_yaw * _yaw_resolution, 0, MatrixOrder.Append);

                //pitch
                _g.TranslateTransform(0, (float)pitch * _pitch_resolution, MatrixOrder.Append);
                if (_pitch >= 90 || _pitch <= -90)
                    _g.RotateTransform((float)180, MatrixOrder.Append);

                // make rotation point the origin
                _g.TranslateTransform(-_videoWidth / 2, -_videoHeight / 2);
                // roll
//.........这里部分代码省略.........
开发者ID:culiniac,项目名称:quavs,代码行数:101,代码来源:HUD.cs

示例3: DrawDropShadow

        /// <summary>
        ///   Draws a drop shadow.
        /// </summary>
        /// <param name="g">The graphics. </param>
        /// <param name="viewPort"> The view port. </param>
        protected virtual void DrawDropShadow(Graphics g, Rectangle viewPort)
        {
            Rectangle rightEdge;
            Rectangle bottomEdge;

            rightEdge = new Rectangle(viewPort.Right + 1, viewPort.Top + this.DropShadowSize, this.DropShadowSize, viewPort.Height);
            bottomEdge = new Rectangle(viewPort.Left + this.DropShadowSize, viewPort.Bottom + 1, viewPort.Width + 1, this.DropShadowSize);

            using (Brush brush = new SolidBrush(this.ImageBorderColor))
            {
                g.FillRectangles(brush, new[]
                                {
                                  rightEdge, bottomEdge
                                });
            }
        }
开发者ID:Behzadkhosravifar,项目名称:SignalR,代码行数:21,代码来源:ImageBox.cs

示例4: drawNodeRect

 private void drawNodeRect(Graphics g, XmlNode source, PointF margin)
 {
     Pen pen;
     PointF location = this.getLocationAttribute(source);
     location.X += margin.X;
     location.Y += margin.Y;
     SizeF size = this.getSizeAttribute(source);
     bool flag = true;
     if (source.Name != "rectangle")
     {
         string str = XmlFunc.getStringAttribute(source, "BorderStyle").Trim();
         if (str.Length == 0)
         {
             str = this.defaultProerty(source.Name, "BorderStyle");
             if (str == null)
             {
                 str = BorderStyle.None.ToString();
             }
         }
         flag = !(str == BorderStyle.None.ToString());
     }
     if (source.Name == "rectangle")
     {
         pen = this.getPenAttribute(source);
     }
     else
     {
         pen = new Pen(Color.Black);
     }
     using (pen)
     {
         using (SolidBrush brush = this.getBrushAttribute(source))
         {
             if (brush != null)
             {
                 RectangleF ef2 = new RectangleF(location, size);
                 RectangleF[] rects = new RectangleF[] { ef2 };
                 g.FillRectangles(brush, rects);
             }
         }
         if (flag)
         {
             g.DrawRectangle(pen, location.X, location.Y, size.Width, size.Height);
         }
     }
 }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:46,代码来源:Print.cs

示例5: DrawAt


//.........这里部分代码省略.........
            y = PADDING;  // 
            height = rect.Height - 2 * y;   // 计算出高度
            width = rect.Height > SUBVIEW_WIDTH ? rect.Height : SUBVIEW_WIDTH;     // 计算出宽度
            width -= 2 * x;
            Image img = null;
            if (!string.IsNullOrEmpty(this.LeftImage))
            {
                img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.LeftImage));
            }

            if (null != img)
            {
                gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y);
            }

            /* 右图标 */
            x = rect.Width - PADDING - width;
            /*Image*/
            img = null;
            if (!string.IsNullOrEmpty(this.RightImage))
            {
                img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.RightImage));
            }

            if (null != img)
            {
                gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y);
            }

            /* 中间数字 */
            string valueString = null;
            if (KNXDigitalAdjustment.EDigitalNumber.OneDigit == this.DigitalNumber)
            {
                valueString = "8";
            }
            else if (KNXDigitalAdjustment.EDigitalNumber.TwoDigit == this.DigitalNumber)
            {
                valueString = "88";
            }
            else if (KNXDigitalAdjustment.EDigitalNumber.ThreeDigit == this.DigitalNumber)
            {
                valueString = "888";
            }

            if (null != valueString)
            {
                valueString += this.Unit.GetDescription();

                Color fontColor = this.FontColor;
                Font font = new Font("宋体", this.FontSize);
                StringFormat format = new StringFormat();

                format.Alignment = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;
                Size size = TextRenderer.MeasureText(valueString, font);
                x = PADDING;
                y = PADDING;
                width = rect.Width - 2 * x;
                height = rect.Height - 2 * y;
                Rectangle rectText = new Rectangle(rect.X+x, rect.Y+y, width, height);
                gp.DrawString(valueString, font, new SolidBrush(fontColor), rectText, format);
            }

            if (EBool.Yes == this.DisplayBorder)
            {
                Color borderColor = this.BorderColor;
                DrawRoundRectangle(gp, new Pen(borderColor, 1), rect, this.Radius, 1.0f);
            }

            g.DrawImage(bm,
                this.VisibleRectInPage,
                new Rectangle(new Point(this.VisibleRectInPage.X - this.RectInPage.X, this.VisibleRectInPage.Y - this.RectInPage.Y), this.VisibleRectInPage.Size),
                GraphicsUnit.Pixel);

            this.FrameIsVisible = false;
            if (ControlState.Move == this.State)
            {
                Pen pen = new Pen(Color.Navy, 2.0f);
                DrawRoundRectangle(g, pen, this.RectInPage, this.Radius, 1.0f);
            }
            else if (this.IsSelected)
            {
                this.SetFrame();
                Pen pen = new Pen(Color.LightGray, 1.0f);
                pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果
                g.DrawLine(pen, this.LinePoints[0], this.LinePoints[1]);
                g.DrawLine(pen, this.LinePoints[2], this.LinePoints[3]);
                g.DrawLine(pen, this.LinePoints[4], this.LinePoints[5]);
                g.DrawLine(pen, this.LinePoints[6], this.LinePoints[7]);
                g.DrawLine(pen, this.LinePoints[8], this.LinePoints[9]);
                g.DrawLine(pen, this.LinePoints[10], this.LinePoints[11]);
                g.DrawLine(pen, this.LinePoints[12], this.LinePoints[13]);
                g.DrawLine(pen, this.LinePoints[14], this.LinePoints[15]);

                g.FillRectangles(Brushes.White, this.SmallRects); //填充8个小矩形的内部
                g.DrawRectangles(Pens.Black, this.SmallRects);  //绘制8个小矩形的黑色边线

                this.FrameIsVisible = true;
            }
        }
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:101,代码来源:DigitalAdjustmentNode.cs

示例6: DrawBoard

 private void DrawBoard(Graphics graphics)
 {
     int board_box_size = (int)(BoardPicBox.Width / size_);
     Brush white = Brushes.SandyBrown;
     Brush black = Brushes.Brown;
     for (int i = 0; i < size_; i++) {
         for (int j = 0; j < size_; j++) {
             Brush brush;
             if ((i + j) % 2 == 0) {
                 brush = white;
             } else {
                 brush = black;
             }
             Rectangle r = new Rectangle(i * board_box_size, j * board_box_size, board_box_size, board_box_size);
             graphics.FillRectangles(brush,new Rectangle[]{r});
         }
     }
 }
开发者ID:esonghori,项目名称:NQueensGenetic,代码行数:18,代码来源:MainForm.cs

示例7: PaintGrid

        private void PaintGrid(Graphics graphics, Brush cellBrush, Pen gridPen)
        {
            isDrawing = true;

            if (state.State == null)
            {
                return;
            }

            int cellSize = PowerTwos.Get(tbZoom.Value);
            int padding = PowerTwos.Get(tbZoom.Value - 2);

            int totalSize = cellSize + padding;
            int width = state.State.GetLength(0) * totalSize;

            int xOffset = -(int)(scrollH.Value * width * 0.01f);
            int yOffset = -(int)(scrollV.Value * width * 0.01f);

            graphics.DrawRectangle(gridPen, xOffset, yOffset, width, width);

            Rectangle[] cells = new Rectangle[state.Population + 50];
            int index = 0;

            for (int y = 0; y < state.State.GetLength(0); y++)
            {
                for (int x = 0; x < state.State.GetLength(1); x++)
                {
                    if (state.State[y, x])
                    {
                        cells[index++] = new Rectangle(x * totalSize + xOffset,
                            y * totalSize + yOffset, cellSize, cellSize);
                    }
                }
            }

            graphics.FillRectangles(cellBrush, cells);

            isDrawing = false;
        }
开发者ID:ChristopheSteininger,项目名称:GameofLife,代码行数:39,代码来源:MainForm.cs

示例8: DrawMap


//.........这里部分代码省略.........
                    DrawCustomFeatureLayers(ref g, mTransMatrix, CurExt);
                }

                //*** Draw North Symbol only for Main Map not for Insets
                g.SmoothingMode = SmoothingMode.AntiAlias;
                if (m_NorthSymbol == true)
                {
                    Font _Font = new Font("Webdings", m_NorthSymbolSize);
                    SolidBrush _Brush = new SolidBrush(m_NorthSymbolColor);
                    //g.DrawString("l", _Font, _Brush, m_NorthSymbolPosition.X, m_NorthSymbolPosition.Y)
                    g.DrawString("l", _Font, _Brush, m_Width - 60, m_Height - 60);
                    _Font.Dispose();
                    _Brush.Dispose();
                }
                g.SmoothingMode = SmoothingMode.None;

                //*** Display Map Scale Enhancement 11 May 2006
                try
                {
                    if (m_Scale == true)
                    {
                        int iScaleWidth = (int)(m_Width / 2.5);
                        int iScaleHeight = 5;
                        int iBlockCount = 5;
                        int iBlockWidth = (int)iScaleWidth / iBlockCount;
                        int iOrgX = 10;
                        int iOrgY = (int)(m_Height - 20);
                        double dMapWidth;
                        double dBlockWidth;

                        {
                            dMapWidth = GetDistance(m_CurrentExtent.X, m_CurrentExtent.Y, m_CurrentExtent.X + m_CurrentExtent.Width, m_CurrentExtent.Y);
                        }

                        dBlockWidth = dMapWidth / m_Width * iBlockWidth;
                        if (dBlockWidth > 2)
                        {
                            dBlockWidth = (int)dBlockWidth;
                        }
                        else
                        {
                            dBlockWidth = Math.Round(dBlockWidth, 1);
                        }

                        //*** Create array of rectagle to be filled with alternate colors
                        Rectangle[] Rect1 = new Rectangle[3];
                        Rectangle[] Rect2 = new Rectangle[2];
                        Rect1[0] = new Rectangle(iOrgX, iOrgY, iBlockWidth, iScaleHeight);
                        Rect2[0] = new Rectangle(iOrgX + iBlockWidth, iOrgY, iBlockWidth, iScaleHeight);
                        Rect1[1] = new Rectangle(iOrgX + iBlockWidth * 2, iOrgY, iBlockWidth, iScaleHeight);
                        Rect2[1] = new Rectangle(iOrgX + iBlockWidth * 3, iOrgY, iBlockWidth, iScaleHeight);
                        Rect1[2] = new Rectangle(iOrgX + iBlockWidth * 4, iOrgY, iBlockWidth, iScaleHeight);

                        //*** Fill alternate band of rectangles
                        g.FillRectangles(Brushes.Red, Rect1);
                        g.FillRectangles(Brushes.Blue, Rect2);

                        //*** Draw Text for Scale measurements
                        Font oFont = new Font("Arial", 7);
                        StringFormat oStringFormat = new StringFormat();
                        oStringFormat.FormatFlags = StringFormatFlags.NoClip;
                        oStringFormat.Alignment = StringAlignment.Center;
                        g.DrawString(m_ScaleUnitText, oFont, Brushes.Black, iOrgX, iOrgY + iScaleHeight + 1, oStringFormat);
                        g.DrawString(dBlockWidth.ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth, iOrgY + iScaleHeight + 1, oStringFormat);
                        g.DrawString((dBlockWidth * 2).ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth * 2, iOrgY + iScaleHeight + 1, oStringFormat);
                        g.DrawString((dBlockWidth * 3).ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth * 3, iOrgY + iScaleHeight + 1, oStringFormat);
                        g.DrawString((dBlockWidth * 4).ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth * 4, iOrgY + iScaleHeight + 1, oStringFormat);
                        g.DrawString((dBlockWidth * 5).ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth * 5, iOrgY + iScaleHeight + 1, oStringFormat);
                        oFont.Dispose();

                    }
                }
                catch (Exception ex)
                {

                }

                //*** Draw Label
                DrawLabel(ref g, mTransMatrix, CurExt);

                //*** For Web Version Save Image File to the specified path
                if (p_FileName.Length > 0)
                {
                    //_BitMap.MakeTransparent(Color.Transparent)
                    if (File.Exists(p_FileName))
                        File.Delete(p_FileName);
                    FileStream _File = new FileStream(p_FileName, FileMode.Create);
                    _BitMap.Save(_File, ImageFormat.Png);
                    _File.Flush();
                    _File.Close();
                    //_BitMap.Save(p_FileName, Imaging.ImageFormat.Png)
                    _BitMap.Dispose();
                    g.Dispose();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
            }
        }
开发者ID:SDRC-India,项目名称:sdrcdevinfo,代码行数:101,代码来源:Map.cs

示例9: DrawMarks

        private void DrawMarks(Graphics g, MarkCollection marks, Color markColor)
        {
            Rectangle[] rectangles = marks.GetRectanglesForVisibleMarks(this);

            if (rectangles == null || rectangles.Length == 0)
                return;

            if (AddinSettings.Instance.FilledMarks)
            {
                List<Rectangle> rectsToFilling = new List<Rectangle>();

                uint nativeBorderColor = (uint)markColor.R | (uint)markColor.G << 8 | (uint)markColor.B << 16;

                IntPtr hdc = g.GetHdc();

                for (int i = 0; i < rectangles.Length; i++)
                {
                    var rect = rectangles[i];

                    int score = 0;
                    if (Gdi32.GetPixel(hdc, rect.Left, rect.Top) == nativeBorderColor) score++;
                    if (Gdi32.GetPixel(hdc, rect.Left, rect.Bottom) == nativeBorderColor) score++;
                    if (score < 2 && Gdi32.GetPixel(hdc, rect.Right, rect.Bottom) == nativeBorderColor) score++;
                    if (score < 2 && Gdi32.GetPixel(hdc, rect.Right, rect.Top) == nativeBorderColor) score++;

                    bool isBorderDrawn = score >= 2;

                    if (!isBorderDrawn)
                        rectsToFilling.Add(rect);
                }

                g.ReleaseHdc();

                if (rectsToFilling.Count > 0)
                {
                    using (var bodyBrush = new SolidBrush(Color.FromArgb(32, markColor)))
                        g.FillRectangles(bodyBrush, rectsToFilling.ToArray());

                    //using (var borderPen = new Pen(markColor))
                    //    g.DrawRectangles(borderPen, rectsToFilling.ToArray());
                }
            }

            //Draw borders
            using (var borderPen = new Pen(markColor))
                g.DrawRectangles(borderPen, rectangles);
        }
开发者ID:hxhlb,项目名称:wordlight,代码行数:47,代码来源:TextView.cs

示例10: PaintDecoration

        protected void PaintDecoration(Graphics graphics)
        {
            // Paint the glass effect.
            Brush brush = null;
            Pen pen = null;

            try
            {
                var rectangles = new Rectangle[4];

                brush = new SolidBrush(SystemColors.Control);
                pen = new Pen(new SolidBrush(Color.FromArgb(223, 223, 223)));

                // Gibt die höhe des/der linken und rechten Rechteckes/Linie an
                int sideHeight = ClientRectangle.Height - this.decorationMargin.Top - this.decorationMargin.Bottom;
                int bottomY = ClientRectangle.Height - this.decorationMargin.Bottom;
                int rightX = ClientRectangle.Width - this.decorationMargin.Right;

                // Top
                rectangles[0] = new Rectangle(0, 0, ClientRectangle.Width, this.decorationMargin.Top);
                // Bottom
                rectangles[1] = new Rectangle(0, bottomY, ClientRectangle.Width, this.decorationMargin.Bottom);
                // Left
                rectangles[2] = new Rectangle(0, this.decorationMargin.Top, this.decorationMargin.Left, sideHeight);
                // Right
                rectangles[3] = new Rectangle(rightX, this.decorationMargin.Top, this.decorationMargin.Right, sideHeight);

                graphics.FillRectangles(brush, rectangles);

                if (bottomY > this.decorationMargin.Top && rightX > this.decorationMargin.Left)
                {
                    // Top-Left to Top-Right
                    if (this.decorationMargin.Top > 0)
                    {
                        graphics.DrawLine(pen, new Point(this.decorationMargin.Left, this.decorationMargin.Top), new Point(rightX, this.decorationMargin.Top));
                    }
                    // Top-Right To Bottom-Right
                    if (this.decorationMargin.Right > 0)
                    {
                        graphics.DrawLine(pen, new Point(rightX, this.decorationMargin.Top), new Point(rightX, bottomY));
                    }

                    // Bottom-Right To BottomLeft
                    if (this.decorationMargin.Bottom > 0)
                    {
                        graphics.DrawLine(pen, new Point(rightX, bottomY), new Point(this.decorationMargin.Left, bottomY));
                    }
                    // Bottom-Left To Top-Left
                    if (this.decorationMargin.Left > 0)
                    {
                        graphics.DrawLine(pen, new Point(this.decorationMargin.Left, bottomY), new Point(this.decorationMargin.Left, this.decorationMargin.Top));
                    }
                }
            }
            finally
            {
                if (brush != null)
                {
                    brush.Dispose();
                }
                if (pen != null)
                {
                    pen.Dispose();
                }
            }
        }
开发者ID:schakko,项目名称:bootstrap-net,代码行数:66,代码来源:AeroForm.cs

示例11: Draw

        /// <summary>
        /// Draws the grid to the graphics device
        /// </summary>
        /// <param name="graphics">The graphics for drawing</param>
        public void Draw(Graphics graphics)
        {
            // Clear the old set of states
            for(int s = 1; s < CellState.NUM_STATES; s++)
                cellRectangles[s].Clear();

            // Concurrently determine which batch each cell should
            // be drawn in.
            GridLoopParallel((x, y) =>
            {
                Cell currentCell = cells[x, y];
                int stateId = currentCell.state;

                if (stateId == 0)
                    return;

                lock (cellRectangles) { cellRectangles[stateId].Add(currentCell.visualRect); }
            });

            // Concurrently convert each list to an array
            // Skip element 0
            Rectangle[][] rectArray = new Rectangle[CellState.NUM_STATES][];
            Parallel.For(1, CellState.NUM_STATES, s =>
            {
                rectArray[s] = cellRectangles[s].ToArray();
            });

            // Linearly draw each rectangle brush with the
            // appropriate colour from the palette
            for(int s = 0; s < CellState.NUM_STATES; s++)
            {
                // If this is the lowest depth, fill the entire screen,
                // instead, fill the set of rectangles
                if (s == 0)
                    graphics.Clear(palette.StateToColor(s));
                else if (rectArray[s] != null && rectArray[s].Length > 0)
                    graphics.FillRectangles(palette.StateToBrush(s), rectArray[s]);
            }
        }
开发者ID:ddoodm,项目名称:Demon-Automata-Threaded,代码行数:43,代码来源:CellGrid.cs

示例12: ProcessPaint

        private void ProcessPaint(Graphics gfx = null)
        {
            bool needDispose = gfx == null;
            if (gfx == null) gfx = Placeholder.CreateGraphics();

            // draw background
            var backRect = new Rectangle(Placeholder.Location.X, Placeholder.Location.Y, Placeholder.Width, Placeholder.Height);
            gfx.FillRectangle(SystemBrushes.Control, backRect);

            // draw main image
            var imgRect = new Rectangle();
            if (mainImage.Width > Placeholder.Width || mainImage.Height > Placeholder.Height)
            {
                imgRect.X = imgRect.X = 0;
                imgRect.Width = imgRect.Height = Placeholder.Width;
            }
            else
            {
                imgRect.X = (Placeholder.Width  - mainImage.Width) / 2;
                imgRect.Y = (Placeholder.Height - mainImage.Height) / 2;
                imgRect.Width  = mainImage.Width;
                imgRect.Height = mainImage.Height;
            }
            gfx.DrawImage(mainImage, imgRect);

            // draw crop rectangles
            if (!crop || Math.Abs(mainImage.Width - mainImage.Height) <= 1) return;

            using (var brush = new SolidBrush(Color.FromArgb(128, 0, 0, 0)))
            {
                var r = new Rectangle[2];
                int unused = Math.Abs(mainImage.Width - mainImage.Height);
                if (mainImage.Width > mainImage.Height)
                {
                    r[0] = new Rectangle(imgRect.Location.X,                                   imgRect.Location.Y, unused / 2, mainImage.Height);
                    r[1] = new Rectangle(imgRect.Location.X + imgRect.Size.Width - unused / 2, imgRect.Location.Y, unused / 2, mainImage.Height);
                }
                else
                {
                    r[0] = new Rectangle(imgRect.Location.X, imgRect.Location.Y,                                    mainImage.Width, unused / 2);
                    r[1] = new Rectangle(imgRect.Location.X, imgRect.Location.Y + imgRect.Size.Height - unused / 2, mainImage.Width, unused / 2);
                }

                gfx.FillRectangles(brush, r);
            }

            if(needDispose) gfx.Dispose();
        }
开发者ID:tommiv,项目名称:Artwork-Stack,代码行数:48,代码来源:ShowFull.cs

示例13: Draw

        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            RectangleF pixRect = this.Location.TransformRect(pane);

            //GraphPane gPane = pane as GraphPane;

            //System.Diagnostics.Trace.WriteLine("XScale " + gPane.XAxis.Scale);
            //System.Diagnostics.Trace.WriteLine("YScale " + gPane.YAxis.Scale);

            //System.Diagnostics.Trace.WriteLine(pixRect.X);

            if (Math.Abs(pixRect.Left) < 100000 &&
                    Math.Abs(pixRect.Top) < 100000 &&
                    Math.Abs(pixRect.Right) < 100000 &&
                    Math.Abs(pixRect.Bottom) < 100000)
            {
                GraphicsState state = g.Save();

                g.SmoothingMode = SmoothingMode.AntiAlias;

                Matrix matrix = g.Transform;

                matrix.RotateAt(Angle, Center(pixRect));
                //matrix.Rotate(Angle);

                g.Transform = matrix;
                if (_fill.IsVisible)
                    using (Brush brush = _fill.MakeBrush(pixRect))
                        g.FillEllipse(brush, pixRect);

                if (_border.IsVisible)
                    using (Pen pen = _border.GetPen(pane, scaleFactor))
                    {
                        if (IsMoving)
                        {
                            // Set the DashCap to round.
                            pen.DashCap = DashCap.Round;

                            // Create a custom dash pattern.
                            pen.DashPattern = new float[] { 4.0F, 4.0F };
                        }

                        g.DrawEllipse(pen, pixRect);

                        if (IsSelected)
                        {
                            Brush brush = new SolidBrush(Color.White);

                            g.FillRectangles(brush, EdgeRects(pane));

                            pen.DashStyle = DashStyle.Solid;

                            g.DrawRectangles(pen, EdgeRects(pane));
                        }
                    }

                g.Restore(state);
            }
        }
开发者ID:sntree,项目名称:ZedGraph,代码行数:82,代码来源:EllipseObj.cs

示例14: drawNodes

        private void drawNodes(IEnumerable<ICoordinate> nodes, Graphics g, MapToClientDelegate MapToClient, Color color, int offsetX, int offsetY)
        {
            if (nodes.Count() <= 0)
                return;

            using (Pen p = new Pen(color))
            {
                Point[] points = new Point[nodes.Count()];

                int i = 0;
                foreach (ICoordinate c in nodes)
                {
                    points[i] = MapToClient(c);
                    points[i].X += offsetX;
                    points[i].Y += offsetY;
                    i++;
                }

                Rectangle[] rectangles = new Rectangle[points.Length];

                int ns = this.NodeSize;
                for (i = 0; i < points.Length; i++)
                    rectangles[i] = new Rectangle((int)points[i].X - ns,
                        (int)points[i].Y - ns, ns * 2, ns * 2);

                using (Brush b = new SolidBrush(color))
                {
                    g.FillRectangles(b, rectangles);
                }
                g.DrawRectangles(p, rectangles);
            }
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:32,代码来源:GeometryEditor.cs

示例15: Render


//.........这里部分代码省略.........
                                        labels.Add(lbl);
                                }
                            }
                            else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.Largest)
                            {
                                GeometryCollection coll = (feature.Geometry as GeometryCollection);
                                if (coll.NumGeometries > 0)
                                {
                                    double largestVal = 0;
                                    int idxOfLargest = 0;
                                    for (int j = 0; j < coll.NumGeometries; j++)
                                    {
                                        Geometry geom = coll.Geometry(j);
                                        if (geom is LineString && ((LineString) geom).Length > largestVal)
                                        {
                                            largestVal = ((LineString) geom).Length;
                                            idxOfLargest = j;
                                        }
                                        if (geom is MultiLineString && ((MultiLineString) geom).Length > largestVal)
                                        {
                                            largestVal = ((MultiLineString)geom).Length;
                                            idxOfLargest = j;
                                        }
                                        if (geom is Polygon && ((Polygon) geom).Area > largestVal)
                                        {
                                            largestVal = ((Polygon) geom).Area;
                                            idxOfLargest = j;
                                        }
                                        if (geom is MultiPolygon && ((MultiPolygon) geom).Area > largestVal)
                                        {
                                            largestVal = ((MultiPolygon) geom).Area;
                                            idxOfLargest = j;
                                        }
                                    }

                                    BaseLabel lbl = CreateLabel(feature, coll.Geometry(idxOfLargest), text, rotation, priority, style,
                                                            map, g, _getLocationMethod);
                                    if (lbl != null)
                                        labels.Add(lbl);
                                }
                            }
                        }
                        else
                        {
                            BaseLabel lbl = CreateLabel(feature, feature.Geometry, text, rotation, priority, style, map, g, _getLocationMethod);
                            if (lbl != null)
                                labels.Add(lbl);
                        }
                    }
                }
                if (labels.Count > 0) //We have labels to render...
                {
                    if (Style.CollisionDetection && _labelFilter != null)
                        _labelFilter(labels);
                    
                    for (int i = 0; i < labels.Count; i++)
                    {   
                        // Don't show the label if not necessary
                        if (!labels[i].Show)
                        {
                            continue;
                        }

                        if (labels[i] is Label)
                        {
                            var label = labels[i] as Label;
                            if (label.Style.IsTextOnPath == false || label.TextOnPathLabel==null)
                            {
                                VectorRenderer.DrawLabel(g, label.Location, label.Style.Offset,
                                                            label.Style.Font, label.Style.ForeColor,
                                                            label.Style.BackColor, Style.Halo, label.Rotation,
                                                            label.Text, map);
                            }
                            else
                            {
                                if (label.Style.BackColor != null && label.Style.BackColor != System.Drawing.Brushes.Transparent)
                                {
                                    //draw background
                                    if (label.TextOnPathLabel.RegionList.Count > 0)
                                    {
                                        g.FillRectangles(labels[i].Style.BackColor, labels[i].TextOnPathLabel.RegionList.ToArray());
                                        //g.FillPolygon(labels[i].Style.BackColor, labels[i].TextOnPathLabel.PointsText.ToArray());
                                    }
                                }
                                label.TextOnPathLabel.DrawTextOnPath();
                            }
                        }
                        else if (labels[i] is PathLabel)
                        {
                            var plbl = labels[i] as PathLabel;
                            var lblStyle = plbl.Style;
                            g.DrawString(lblStyle.Halo, new SolidBrush(lblStyle.ForeColor), plbl.Text,
                                         lblStyle.Font.FontFamily, (int) lblStyle.Font.Style, lblStyle.Font.Size,
                                         lblStyle.GetStringFormat(), lblStyle.IgnoreLength, plbl.Location);
                        }
                    }
                }
            }
            base.Render(g, map);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:101,代码来源:LabelLayer.cs


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