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


C# Graphics.FillRectangle方法代码示例

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


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

示例1: FillPill

        public static void FillPill(Brush b, RectangleF rect, Graphics g)
        {
            if (rect.Width > rect.Height)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillEllipse(b, new RectangleF(rect.Left, rect.Top, rect.Height, rect.Height));
                g.FillEllipse(b, new RectangleF(rect.Left + rect.Width - rect.Height, rect.Top, rect.Height, rect.Height));

                var w = rect.Width - rect.Height;
                var l = rect.Left + ((rect.Height) / 2);
                g.FillRectangle(b, new RectangleF(l, rect.Top, w, rect.Height));
                g.SmoothingMode = SmoothingMode.Default;
            }
            else if (rect.Width < rect.Height)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillEllipse(b, new RectangleF(rect.Left, rect.Top, rect.Width, rect.Width));
                g.FillEllipse(b, new RectangleF(rect.Left, rect.Top + rect.Height - rect.Width, rect.Width, rect.Width));

                var t = rect.Top + (rect.Width / 2);
                var h = rect.Height - rect.Width;
                g.FillRectangle(b, new RectangleF(rect.Left, t, rect.Width, h));
                g.SmoothingMode = SmoothingMode.Default;
            }
            else if (rect.Width == rect.Height)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillEllipse(b, rect);
                g.SmoothingMode = SmoothingMode.Default;
            }
        }
开发者ID:reward-hunters,项目名称:PrintAhead,代码行数:31,代码来源:TrackBarDrawingHelper.cs

示例2: DrawAppointment

        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);
                }
        }
开发者ID:bshultz,项目名称:ctasks,代码行数:60,代码来源:Office11Renderer.cs

示例3: Paint

                 protected internal override void Paint(Graphics gr)
                 {           
                   var hf = CandleView.BAR_WIDTH / 2;

                   if (m_View.Kind== ViewKind.SideBySide)
                   {
                       var hh = Host.Height / Host.Zoom;

                       gr.FillRectangle(Brushes.Green, this.Left, hh - m_Lay_BuyHeight, hf, m_Lay_BuyHeight);
                       gr.FillRectangle(Brushes.Red, this.Left+hf, hh - m_Lay_SellHeight, hf, m_Lay_SellHeight);
                   }
                   else if (m_View.Kind== ViewKind.Stacked)
                   {
                      var hh = Host.Height / Host.Zoom;

                      gr.FillRectangle(Brushes.Green, this.Left, hh - m_Lay_BuyHeight, CandleView.BAR_WIDTH, m_Lay_BuyHeight);
                      gr.FillRectangle(Brushes.Red, this.Left, hh - m_Lay_BuyHeight-m_Lay_SellHeight, CandleView.BAR_WIDTH, m_Lay_SellHeight);
                   }
                   else//centered
                   {
                      var mid = (Host.Height / 2) / Host.Zoom;

                      gr.FillRectangle(Brushes.Green, this.Left, mid - m_Lay_BuyHeight, CandleView.BAR_WIDTH, m_Lay_BuyHeight);
                      gr.FillRectangle(Brushes.Red, this.Left, mid, CandleView.BAR_WIDTH, m_Lay_SellHeight);
                   }
                 }
开发者ID:vlapchenko,项目名称:nfx,代码行数:26,代码来源:CandleBuySellView.cs

示例4: PaintSquare

        protected override void PaintSquare(Graphics graphics, Rectangle clipRectangle, int pipeWidth, bool isHighlighted, bool isFrozen, bool isFlooded)
        {
            /* pipe brush - if flooded, it's red, otherwise silver */
            Brush pipeBrush = isFlooded ? Brushes.Red : Brushes.Silver;

            int x = (clipRectangle.Width - pipeWidth) / 2;
            int y = clipRectangle.Y;
            int w = pipeWidth;
            int h = clipRectangle.Height - x;

            /* pipe rectangle, first upside */
            Rectangle pipeRectangle = new Rectangle(x, y, w, h);
            graphics.FillRectangle(pipeBrush, pipeRectangle);

            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x, y), new Point(x, y + h - pipeWidth));
            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x + w, y), new Point(x + w, y + h));

            x = clipRectangle.X;
            y = (clipRectangle.Height - pipeWidth) / 2;
            w = clipRectangle.Width - y;
            h = pipeWidth;

            /* pipe rectangle, second leftside */
            pipeRectangle = new Rectangle(x, y, w - BORDER_WIDTH, h);
            graphics.FillRectangle(pipeBrush, pipeRectangle);

            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x, y), new Point(x + w - pipeWidth, y));
            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x, y + h), new Point(x + w, y + h));
        }
开发者ID:ilkerde,项目名称:pipemania,代码行数:29,代码来源:EdgeUpLeftPipePainter.cs

示例5: DrawFormBackgroud

        public void DrawFormBackgroud(Graphics g, Rectangle r)
        {
            drawing = new Bitmap(this.Width, this.Height, g);
            gg = Graphics.FromImage(drawing);

            Rectangle shadowRect = new Rectangle(r.X, r.Y, r.Width, 10);
            Rectangle gradRect = new Rectangle(r.X, r.Y + 9, r.Width, 42);
            //LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 41, 61), Color.FromArgb(47, 64, 94), LinearGradientMode.Vertical);
            LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 61, 41), Color.FromArgb(47, colorR, 64), LinearGradientMode.Vertical);
            //LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.FromArgb(47, 64, 94), Color.FromArgb(49, 66, 95), LinearGradientMode.Vertical);
            LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.Green, Color.DarkGreen, LinearGradientMode.Vertical);
            ColorBlend blend = new ColorBlend();

            // Set multi-color gradient
            blend.Positions = new[] { 0.0f, 0.35f, 0.5f, 0.65f, 1.0f };
            //blend.Colors = new[] { Color.FromArgb(47, 64, 94), Color.FromArgb(64, 88, 126), Color.FromArgb(66, 90, 129), Color.FromArgb(64, 88, 126), Color.FromArgb(49, 66, 95) };
            blend.Colors = new[] { Color.FromArgb(47,colorR, 64), Color.FromArgb(64, colorR+32, 88), Color.FromArgb(66, colorR+35, 90), Color.FromArgb(64, colorR+32, 88), Color.FromArgb(49, colorR+1, 66) };
            grad.InterpolationColors = blend;
            Font myf=new System.Drawing.Font(this.Font.FontFamily,16);
            // Draw basic gradient and shadow
            //gg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            gg.FillRectangle(grad, gradRect);
            gg.FillRectangle(shadow, shadowRect);
            gg.DrawString("Добавить один ПК", myf, Brushes.GhostWhite, new PointF(55, 15));
            gg.DrawImage(Properties.Resources.singleAdd1.ToBitmap(), 10, 10,32,32);

            g.DrawImageUnscaled(drawing, 0, 0);
            gg.Dispose();

            // Draw checkers
            //g.FillRectangle(checkers, r);
        }
开发者ID:fenriv,项目名称:NetOpen,代码行数:32,代码来源:SinglePCAdd.cs

示例6: PaintSquare

        protected override void PaintSquare(Graphics graphics, Rectangle clipRectangle, int pipeWidth, bool isHighlighted, bool isFrozen, bool isFlooded, FloodProgress floodProgress)
        {
            /* paint square as usual */
            this.PaintSquare(graphics, clipRectangle, pipeWidth, isHighlighted, isFrozen, isFlooded);

            int x = (clipRectangle.Width - pipeWidth) / 2;
            int y = clipRectangle.Y;
            int w = pipeWidth;
            int h = clipRectangle.Height;

            /* flooding ? */
            if (!isFlooded)
            {
                /* calculate height to fill */
                int fill = floodProgress.GetRatio(clipRectangle.Height);

                /* check direction */
                if (floodProgress.Direction == Direction.Down)
                {
                    /* flood rectangle */
                    Rectangle floodRectangle = new Rectangle(x, y, w, fill);

                    /* fill rectangle */
                    graphics.FillRectangle(Brushes.Red, floodRectangle);
                }
                else if (floodProgress.Direction == Direction.Up)
                {
                    /* flood rectangle */
                    Rectangle floodRectangle = new Rectangle(x, h - fill, w, fill);

                    /* fill rectangle */
                    graphics.FillRectangle(Brushes.Red, floodRectangle);
                }
            }
        }
开发者ID:ilkerde,项目名称:pipemania,代码行数:35,代码来源:StraightVerticalPipePainter.cs

示例7: DrawListBoxItem

        protected void DrawListBoxItem(Graphics g, Rectangle bounds, int index, bool selected, bool editSel)
        {
            // Draw List box item
            if ( index != -1)
            {
                if ( selected && !editSel)
                    // Draw highlight rectangle
                    g.FillRectangle(new SolidBrush(SystemColors.Highlight), bounds.Left, bounds.Top, bounds.Width, bounds.Height);
                else
                    // Erase highlight rectangle
                    g.FillRectangle(new SolidBrush(SystemColors.Window), bounds.Left, bounds.Top, bounds.Width, bounds.Height);

                string colorName = (string)this.Items[index];
                Color currentColor = Color.FromName(colorName);

                Brush brush;
                if ( selected )
                    brush =  new SolidBrush(SystemColors.HighlightText);
                else
                    brush = new SolidBrush(SystemColors.MenuText);

                g.FillRectangle(new SolidBrush(currentColor), bounds.Left+2, bounds.Top+2, 20, bounds.Height-4);
                Pen blackPen = new Pen(new SolidBrush(Color.Black), 1);
                g.DrawRectangle(blackPen, new Rectangle(bounds.Left+1, bounds.Top+1, 21, bounds.Height-3));
                g.DrawString(colorName, SystemInformation.MenuFont, brush, new Point(bounds.Left + 28, bounds.Top));
            }
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:27,代码来源:ColorListBox.cs

示例8: DrawValueLine

 public static void DrawValueLine(Graphics g, int value, int x, int y, int width, int height)
 {
     Color colorStart;
     Color colorEnd;
     int value100 = value/100;
     int value1 = value%100;
     if (value100 >= 1)
     {
         colorStart = NarlonLib.Drawing.DrawTool.HSL2RGB(value100 * 0.1-0.1, 0.4, 0.5);
         colorEnd = NarlonLib.Drawing.DrawTool.HSL2RGB(value100 * 0.1-0.1, 1, 0.5);
         using (Brush b1 = new LinearGradientBrush(new Rectangle(x, y, width, 10), colorStart, colorEnd, LinearGradientMode.Horizontal))
         {
             g.FillRectangle(b1, x, y, width, 10);
         }
     }
     if (value1 >= 1)
     {
         colorStart = NarlonLib.Drawing.DrawTool.HSL2RGB(value100 * 0.1, 0.4, 0.5);
         colorEnd = NarlonLib.Drawing.DrawTool.HSL2RGB(value100 * 0.1, 1, 0.5);
         using (Brush b1 = new LinearGradientBrush(new Rectangle(x, y, value1 *width/100, 10), colorStart, colorEnd, LinearGradientMode.Horizontal))
         {
             g.FillRectangle(b1, x, y, value1 * width/ 100, 10);
         }
     }
 }
开发者ID:narlon,项目名称:TOMClassic,代码行数:25,代码来源:PaintTool.cs

示例9: RaisedInnerBorder

        private static void RaisedInnerBorder(Graphics g, Brush dark, Rectangle r, Brush light) {
            g.FillRectangle(light, r.Left, r.Top, r.Width - 1, 1);
            g.FillRectangle(light, r.Left, r.Top, 1, r.Height - 1);

            g.FillRectangle(dark, r.Right - 1, r.Top, 1, r.Height);
            g.FillRectangle(dark, r.Left, r.Bottom - 1, r.Width, 1);
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:DrawingTools.cs

示例10: DrawSpectrum

        private void DrawSpectrum(Graphics g)
        {
            const int offset = 20;

            _data.SpectrumData = _data.SpectrumData
                .Select(f => 1 - Math.Pow(1 - f, 3))
                .Select(f => (float)f)
                //.Where(f=>f > 0.1)
                .ToList();

            if (!_data.SpectrumData.Any())
                return;

            float barWidth = Math.Max((Width / _data.SpectrumData.Count), 2);
            for (int i = 0; i < _data.SpectrumData.Count; i++) {
                var value = Math.Abs(_data.SpectrumData[i]); // value should always be between 0 : 1.0

                float x = i * barWidth;
                float y = (value * Height * 0.5f);
                float G = (127 + (value * 128));
                float B = (int)(255 / Width * x);
                float R = (int)(DateTime.Now.Millisecond * 0.15);

                var brush = new SolidBrush(Color.FromArgb((int)R, (int)G, (int)B));
                g.FillRectangle(brush, x, Height / 2 + offset, barWidth, y);
                g.FillRectangle(brush, x, Height / 2 - offset - y, barWidth, y);
            }
        }
开发者ID:nathanchere,项目名称:nFMOD,代码行数:28,代码来源:FftVisualisationPictureBox.cs

示例11: DrawListBoxItem

        protected void DrawListBoxItem(Graphics g, Rectangle bounds, int Index, bool selected, bool editSel)
        {
            // Draw List box item
              if ( Index != -1)
              {
            if ( selected )
            {
              // Draw highlight rectangle
              Brush b = ColorUtil.VSNetSelectionBrush;
              g.FillRectangle(b, bounds.Left, bounds.Top, bounds.Width, bounds.Height);

              Pen p = ColorUtil.VSNetBorderPen;
              g.DrawRectangle(p, bounds.Left, bounds.Top, bounds.Width-1, bounds.Height-1);
            }
            else
            {
              // Erase highlight rectangle
              g.FillRectangle(SystemBrushes.Window, bounds.Left, bounds.Top, bounds.Width, bounds.Height);
            }

            string item = (string)Items[Index];
            Color currentColor = Color.FromName(item);

            using ( Brush b = new SolidBrush(currentColor) )
            {
              g.FillRectangle(new SolidBrush(currentColor), bounds.Left+2, bounds.Top+2, 20, bounds.Height-4);
            }
            g.DrawRectangle(Pens.Black, new Rectangle(bounds.Left+1, bounds.Top+1, 21, bounds.Height-3));
            g.DrawString(item, SystemInformation.MenuFont, SystemBrushes.ControlText, new Point(bounds.Left + 28, bounds.Top));

              }
        }
开发者ID:tiankongldp,项目名称:MyTestApplication,代码行数:32,代码来源:ColorListBox.cs

示例12: DrawBackground

 public override void DrawBackground(Graphics graphics, Rectangle bounds)
 {
     var rect = Rectangle.Inflate(bounds, 0, 0);
     switch (_state)
     {
         //case 2: //hot
         //    //TODO
         //    break;
         case 3: //pressed
             rect.Inflate(-2, -2);
             graphics.FillRectangle(SystemBrushes.ControlLight, rect);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.SunkenOuter, Border3DSide.Bottom | Border3DSide.Right);
             rect.Inflate(-1, -1);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.Sunken, Border3DSide.Top | Border3DSide.Left);
             rect.Inflate(-1, -1);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.SunkenInner, Border3DSide.Top | Border3DSide.Left);
             break;
         //case 6: //hot+pressed
         //    //TODO
         //    break;
         default: //normal, also fallback
             rect.Inflate(-2, -2);
             graphics.FillRectangle(SystemBrushes.ControlLight, rect);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.Raised, Border3DSide.Bottom | Border3DSide.Right);
             rect.Inflate(-1, -1);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.RaisedInner, Border3DSide.Top | Border3DSide.Left);
             break;
     }
 }
开发者ID:bsandru,项目名称:tasksharp,代码行数:29,代码来源:ClassicStyleRenderer.cs

示例13: DrawBackground

 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);
     }
 }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:26,代码来源:ButtonEx.cs

示例14: drawnShap

        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);
                }

            }

        }
开发者ID:uynguyen,项目名称:MyCollaborativePainting,代码行数:31,代码来源:MyRectangle.cs

示例15: Paint

        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            if (Image != null)
            {
                base.Paint(graphics, clipBounds,
                           new Rectangle(cellBounds.X + Image.Width, cellBounds.Y, cellBounds.Width - Image.Height,cellBounds.Height),
                           rowIndex, cellState, value, formattedValue,errorText, cellStyle, advancedBorderStyle, paintParts);

                if ((cellState & DataGridViewElementStates.Selected) != 0)
                {
                    graphics.FillRectangle(
                        new SolidBrush(this.DataGridView.DefaultCellStyle.SelectionBackColor)
                        , cellBounds.X, cellBounds.Y, Image.Width, cellBounds.Height);
                }
                else
                {
                    graphics.FillRectangle(new SolidBrush(this.DataGridView.DefaultCellStyle.BackColor),
                                           cellBounds.X, cellBounds.Y, Image.Width, cellBounds.Height);
                }
                graphics.DrawImage(Image, cellBounds.X, cellBounds.Y+2, Image.Width,
                                         Math.Min(Image.Height,cellBounds.Height));

            }
            else
            {
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
            }
        }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:28,代码来源:DataGridViewTextAndImageCell.cs


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