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


C# Drawing.SolidBrush类代码示例

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


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

示例1: 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

示例2: Mark

        public Image Mark( Image image, string waterMarkText )
        {
            WatermarkText = waterMarkText;

            Bitmap originalBmp = (Bitmap)image;

            // avoid "A Graphics object cannot be created from an image that has an indexed pixel format." exception
            Bitmap tempBitmap = new Bitmap(originalBmp.Width, originalBmp.Height);
            // From this bitmap, the graphics can be obtained, because it has the right PixelFormat
            Graphics g = Graphics.FromImage(tempBitmap);

            using (Graphics graphics = Graphics.FromImage(tempBitmap))
            {
                // Draw the original bitmap onto the graphics of the new bitmap
                g.DrawImage(originalBmp, 0, 0);
                var size =
                    graphics.MeasureString(WatermarkText, Font);
                var brush =
                    new SolidBrush(Color.FromArgb(255, Color));
                graphics.DrawString
                    (WatermarkText, Font, brush,
                    GetTextPosition(image, size));
            }

            return tempBitmap as Image;
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:26,代码来源:ApplyWatermark.cs

示例3: DrawGraphics

        void DrawGraphics(Object sender, PaintEventArgs PaintNow)
        {
            Rectangle Dot = new Rectangle(SpriteX, SpriteY, SpriteWidth, SpriteHeight); // Create rectangle (start position, and size X & Y)
            SolidBrush WhiteBrush = new SolidBrush(Color.White); // Create Brush(Color) to paint rectangle

            PaintNow.Graphics.FillRectangle(WhiteBrush, Dot);
        }
开发者ID:JeremiahZhang,项目名称:AKA,代码行数:7,代码来源:Program.cs

示例4: DoPaint

 public override void DoPaint(Graphics g)
 {
     using (Brush b = new SolidBrush(ZenParams.WindowColor))
     {
         g.FillRectangle(b, 0, 0, Width, Height);
     }
 }
开发者ID:sheeeng,项目名称:Zydeo,代码行数:7,代码来源:SettingsControl.cs

示例5: PaintVoxel

        void PaintVoxel(Graphics graphics, int i, int j)
        {
            Brush brushVoxel_True = new SolidBrush(Color.FromArgb(181, 230, 29));
            Brush brushVoxel_False = new SolidBrush(Color.FromArgb(240, 240, 240));

            graphics.FillRectangle(VoxelsData[i, j] ? brushVoxel_True : brushVoxel_False, VoxelSize * i + 1, VoxelSize * j + 1, VoxelSize - 1, VoxelSize - 1);
        }
开发者ID:xdray,项目名称:CubeWorld,代码行数:7,代码来源:MainForm.cs

示例6: DoPaint

		void DoPaint()
		{
			if (bmp != null)
			{
				using (Graphics g = CreateGraphics())
				{
					g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
					g.InterpolationMode = InterpolationMode.NearestNeighbor;
					g.CompositingMode = CompositingMode.SourceCopy;
					g.CompositingQuality = CompositingQuality.HighSpeed;
					if (ScaleImage)
					{
						g.InterpolationMode = InterpolationMode.NearestNeighbor;
						g.PixelOffsetMode = PixelOffsetMode.Half;
						g.DrawImage(bmp, 0, 0, Width, Height);
					}
					else
					{
						using (var sb = new SolidBrush(Color.Black))
						{
							g.FillRectangle(sb, bmp.Width, 0, Width - bmp.Width, Height);
							g.FillRectangle(sb, 0, bmp.Height, bmp.Width, Height - bmp.Height);
						}
						g.DrawImageUnscaled(bmp, 0, 0);
					}
				}
			}

			CleanupDisposeQueue();
		}
开发者ID:henke37,项目名称:BizHawk,代码行数:30,代码来源:ViewportPanel.cs

示例7: RenderStuff

        /// <summary> The Main "Loop" of our program </summary>
        /// <remarks>Since this is Event based, the Form Window is only
        /// updated when something happens: like a mouse being moved.
        /// Otherwise, no resources are being used</remarks>
        void RenderStuff(Object sender, PaintEventArgs PaintNow)
        {
            Rectangle Dot = new Rectangle(SpriteX, SpriteY, 2, 2); // Create rectangle (start position, and size X & Y)
            SolidBrush WhiteBrush = new SolidBrush(Color.White); // Create Brush(Color) to paint rectangle

            PaintNow.Graphics.FillRectangle(WhiteBrush, Dot); // Play Parcheesi!
        }
开发者ID:JeremiahZhang,项目名称:AKA,代码行数:11,代码来源:MouseMove.cs

示例8: DrawCheckBackground3DLite

        protected void DrawCheckBackground3DLite(PaintEventArgs e, Rectangle bounds, Color checkColor, Color checkBackground, ColorData colors, bool disabledColors) {
            Graphics g = e.Graphics;            
            
            Color field = checkBackground;
            if (!Control.Enabled && disabledColors) {
                field = SystemColors.Control;
            }

            using (Brush fieldBrush = new SolidBrush(field)) {
                using (Pen dark = new Pen(colors.buttonShadow),
                       light = new Pen(colors.buttonFace),
                       lightlight = new Pen(colors.highlight)) {

                    bounds.Width--;
                    bounds.Height--;
                    // fall a little short of SW, NW, NE, SE because corners come out nasty
                    g.DrawPie(dark, bounds, (float)(135 + 1), (float)(90 - 2));
                    g.DrawPie(dark, bounds, (float)(225 + 1), (float)(90 - 2));
                    g.DrawPie(lightlight, bounds, (float)(315 + 1), (float)(90 - 2));
                    g.DrawPie(lightlight, bounds, (float)(45 + 1), (float)(90 - 2));
                    bounds.Inflate(-1, -1);
                    g.FillEllipse(fieldBrush, bounds);
                    g.DrawEllipse(light, bounds);
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:26,代码来源:RadioButtonBaseAdapter.cs

示例9: dataSelectionList_DrawSubItem

        private void dataSelectionList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            Color color;
            switch (e.ColumnIndex)
            {
                case 2:
                    color = Color.FromArgb(int.Parse(e.SubItem.Text));

                    Rectangle rect = e.Bounds;
                    rect.Inflate(-4, -2);

                    using (SolidBrush brush = new SolidBrush(color))
                    {
                        e.Graphics.FillRectangle(brush, rect);
                        e.Graphics.DrawRectangle(Pens.Black, rect);
                    }
                    break;
                case 3:
                    float x1 = e.SubItem.Bounds.X;
                    float x2 = e.SubItem.Bounds.X + e.SubItem.Bounds.Width;
                    float y = e.SubItem.Bounds.Y + e.SubItem.Bounds.Height / 2;

                    color = Color.FromArgb(int.Parse(e.Item.SubItems[2].Text));
                    float thickness = float.Parse(e.Item.SubItems[1].Text);

                    using (Pen pen = new Pen(color, thickness))
                    {
                        e.Graphics.DrawLine(pen, x1, y, x2, y);
                    }
                    break;
                default:
                    e.DrawDefault = true;
                    break;
            }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:35,代码来源:StockIndicatorSelectorDialog.cs

示例10: pnl_painter_MouseMove

        private void pnl_painter_MouseMove(object sender, MouseEventArgs e)
        {
            Brush brush1 = new SolidBrush(Color.Black);
            if (rdo_black.Checked) color = "black";
            else if (rdo_blue.Checked) color = "blue";
            else if (rdo_red.Checked) color = "red";
            switch (color)
            {
                case "black": brush1 = new SolidBrush(Color.Black); break;
                case "blue": brush1 = new SolidBrush(Color.Blue); break;
                case "red": brush1 = new SolidBrush(Color.Red); break;
            }
            if (rdo_small.Checked) size = 4;
            else if (rdo_middle.Checked) size = 8;
            else if (rdo_large.Checked) size = 12;

            x2 = e.X;
            y2 = e.Y;

            Pen pen1 = new Pen(brush1, size);
            pen1.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Flat);
            //pen1.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
            if (shouldPaint)
            {
                Graphics graphics = pnl_painter.CreateGraphics();
                //graphics.FillEllipse(brush1, e.X, e.Y, size, size);
                graphics.DrawLine(pen1, x1, y1, x2, y2);
                graphics.Dispose();
            }

            x1 = e.X;
            y1 = e.Y;
        }
开发者ID:maxzhx,项目名称:DrawingBoard,代码行数:33,代码来源:Form1.cs

示例11: OnDrawDay

        public override void OnDrawDay(CalendarRendererDayEventArgs e)
        {
            Rectangle r = e.Day.Bounds;

            if (e.Day.Selected)
            {
                using (Brush b = new SolidBrush(ColorTable.DayBackgroundSelected))
                {
                    e.Graphics.FillRectangle(b, r); 
                }
            }
            else if (e.Day.Date.Month % 2 == 0)
            {
                using (Brush b = new SolidBrush(ColorTable.DayBackgroundEven))
                {
                    e.Graphics.FillRectangle(b, r);
                }
            }
            else
            {
                using (Brush b = new SolidBrush(ColorTable.DayBackgroundOdd))
                {
                    e.Graphics.FillRectangle(b, r);
                }
            }

            base.OnDrawDay(e);
        }
开发者ID:Hujairi,项目名称:CMS,代码行数:28,代码来源:CalendarSystemRenderer.cs

示例12: OnPaint

        protected override void OnPaint(PaintEventArgs pevent)
        {
            var g = pevent.Graphics;
            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            g.Clear(Parent.BackColor);

            //Hover
            Color c = SkinManager.GetFlatButtonHoverBackgroundColor();
            using (Brush b = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A), c.RemoveAlpha())))
                g.FillRectangle(b, ClientRectangle);

            //Ripple
            if (animationManager.IsAnimating())
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
                for (int i = 0; i < animationManager.GetAnimationCount(); i++)
                {
                    var animationValue = animationManager.GetProgress(i);
                    var animationSource = animationManager.GetSource(i);

                    using (Brush rippleBrush = new SolidBrush(Color.FromArgb((int)(101 - (animationValue * 100)), Color.Black)))
                    {
                        var rippleSize = (int)(animationValue * Width * 2);
                        g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
                    }
                }
                g.SmoothingMode = SmoothingMode.None;
            }
			g.DrawString(Text.ToUpper(), SkinManager.ROBOTO_MEDIUM_10, Enabled ? (Primary ? SkinManager.ColorScheme.PrimaryBrush : SkinManager.GetPrimaryTextBrush()) : SkinManager.GetFlatButtonDisabledTextBrush(), ClientRectangle, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:Google-Play-Music-Desktop-Player-UNOFFICIAL-,代码行数:31,代码来源:MaterialFlatButton.cs

示例13: button4_Click

        private void button4_Click(object sender, EventArgs e)
        {
            // mostrar un blanco
            Graphics papel = pictureBox1.CreateGraphics();
            Brush brocha = new SolidBrush(Color.Yellow);

            float xOrigen =30, yOrigen = 30;
      
            // iterar para mostrar la diana 
            for (int i = 0, delta = 100; i < 5; i++ , delta += 50)
            {
                switch (delta)
                {
                    case 300 :
                        Brush b1 = new SolidBrush(Color.White);
                        papel.FillEllipse(b1, xOrigen, yOrigen, xOrigen + delta, yOrigen + delta);
                    break;

                    case 200:
                          Brush b2 = new SolidBrush(Color.Red);
                        papel.FillEllipse(b2, xOrigen, yOrigen, xOrigen + delta, yOrigen + delta);
                    break;

                    case 100:
                          Brush b3 = new SolidBrush(Color.Blue);
                        papel.FillEllipse(b3, xOrigen, yOrigen, xOrigen + delta, yOrigen + delta);
                    break;

                }
                
            }

        }
开发者ID:Arthyom,项目名称:C-Xmpls,代码行数:33,代码来源:Form2.cs

示例14: DrawBackgroundImage

 public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
 {
     if (g == null)
     {
         throw new ArgumentNullException("g");
     }
     if (backgroundImageLayout == ImageLayout.Tile)
     {
         using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile))
         {
             if (scrollOffset != Point.Empty)
             {
                 Matrix transform = brush.Transform;
                 transform.Translate((float) scrollOffset.X, (float) scrollOffset.Y);
                 brush.Transform = transform;
             }
             g.FillRectangle(brush, clipRect);
             return;
         }
     }
     Rectangle rect = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout);
     if ((rightToLeft == RightToLeft.Yes) && (backgroundImageLayout == ImageLayout.None))
     {
         rect.X += clipRect.Width - rect.Width;
     }
     using (SolidBrush brush2 = new SolidBrush(backColor))
     {
         g.FillRectangle(brush2, clipRect);
     }
     if (!clipRect.Contains(rect))
     {
         if ((backgroundImageLayout == ImageLayout.Stretch) || (backgroundImageLayout == ImageLayout.Zoom))
         {
             rect.Intersect(clipRect);
             g.DrawImage(backgroundImage, rect);
         }
         else if (backgroundImageLayout == ImageLayout.None)
         {
             rect.Offset(clipRect.Location);
             Rectangle destRect = rect;
             destRect.Intersect(clipRect);
             Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size);
             g.DrawImage(backgroundImage, destRect, rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height, GraphicsUnit.Pixel);
         }
         else
         {
             Rectangle rectangle4 = rect;
             rectangle4.Intersect(clipRect);
             Rectangle rectangle5 = new Rectangle(new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y), rectangle4.Size);
             g.DrawImage(backgroundImage, rectangle4, rectangle5.X, rectangle5.Y, rectangle5.Width, rectangle5.Height, GraphicsUnit.Pixel);
         }
     }
     else
     {
         ImageAttributes imageAttr = new ImageAttributes();
         imageAttr.SetWrapMode(WrapMode.TileFlipXY);
         g.DrawImage(backgroundImage, rect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttr);
         imageAttr.Dispose();
     }
 }
开发者ID:zhushengwen,项目名称:example-zhushengwen,代码行数:60,代码来源:CmbControlPaintEx.cs

示例15: UpdateImage

        public void UpdateImage()
        {
            if (!showCheckBox.Checked)
                return;

            Graphics g = pictureBox.CreateGraphics();
            int x;
            int y;
            Pen activeColumnPen = new Pen(new SolidBrush(Color.Gray));
            Pen inactiveColumnPen = new Pen(new SolidBrush(Color.White));
            Brush activeColumnBrush = new SolidBrush(Color.Gray);
            Brush inactiveColumnBrush = new SolidBrush(Color.White);
            for (int ix = 0; ix < _inputs.Width; ix++)
            {
                for (int iy = 0; iy < _inputs.Height; iy++)
                {
                    x = (int)(ix * 5);
                    y = (int)(iy * 5);
                    if (_inputs[ix, iy].GetActive(0))
                        g.FillRectangle(activeColumnBrush, x, y, cellWidth, cellHeight);
                    else
                        g.FillRectangle(inactiveColumnBrush, x, y, cellWidth, cellHeight);
                }
            }
        }
开发者ID:avogab,项目名称:dooHTM,代码行数:25,代码来源:Cellls2dViewer.cs


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