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


C# SolidBrush类代码示例

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


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

示例1: CreateImage

    private void CreateImage()
    {
        string code = GetRandomText();

        Bitmap bitmap = new Bitmap(200, 50, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

        Graphics g = Graphics.FromImage(bitmap);
        Pen pen = new Pen(Color.Yellow);
        Rectangle rect = new Rectangle(0, 0, 200, 50);

        SolidBrush b = new SolidBrush(Color.Black);
        SolidBrush blue = new SolidBrush(Color.Blue);

        int counter = 0;

        g.DrawRectangle(pen, rect);
        g.FillRectangle(b, rect);

        for (int i = 0; i < code.Length; i++)
        {
            g.DrawString(code[i].ToString(), new Font("Verdena", 10 + rand.Next(14, 18)), blue, new PointF(10 + counter, 10));
            counter += 20;
        }

        DrawRandomLines(g);

        bitmap.Save(Response.OutputStream, ImageFormat.Gif);

        g.Dispose();
        bitmap.Dispose();
    }
开发者ID:karimkhanp,项目名称:Online_Education_Examinations,代码行数:31,代码来源:CaptchaControl.aspx.cs

示例2: Blockchange2

        protected override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
            RevertAndClearState(p, x, y, z);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            GetRealBlock(type, extType, p, ref cpos);
            DrawOp drawOp = null;
            Brush brush = new SolidBrush(cpos.type, cpos.extType);
            
            if (y != cpos.y) {
                Player.SendMessage(p, "The two edges of the pyramid must be on the same level");
                return;
            }

            switch (cpos.solid) {
                case SolidType.solid:
                    drawOp = new PyramidSolidDrawOp(); break;
                case SolidType.hollow:
                    drawOp = new PyramidHollowDrawOp(); break;
                case SolidType.reverse:
                    drawOp = new PyramidReverseDrawOp(); break;
            }
            
            ushort x1 = Math.Min(cpos.x, x), x2 = Math.Max(cpos.x, x);
            ushort y1 = Math.Min(cpos.y, y), y2 = Math.Max(cpos.y, y);
            ushort z1 = Math.Min(cpos.z, z), z2 = Math.Max(cpos.z, z);            
            if (!DrawOp.DoDrawOp(drawOp, brush, p, x1, y1, z1, x2, y2, z2))
                return;
            if (p.staticCommands)
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:29,代码来源:CmdPyramid.cs

示例3: CreateImage

    /// <summary>
    /// ����ͼƬ
    /// </summary>
    /// <param name="checkCode">�����</param>
    private void CreateImage(string checkCode)
    {
        int iwidth = (int)(checkCode.Length * 11.5);//����������趨ͼƬ���
        Bitmap image = new Bitmap(iwidth, 20);//����һ������
        Graphics g = Graphics.FromImage(image);//�ڻ����϶����ͼ��ʵ��
        Font f = new Font("Arial",10,FontStyle.Bold);//���壬��С����ʽ
        Brush b = new SolidBrush(Color.Black);//������ɫ
        //g.FillRectangle(new System.Drawing.SolidBrush(Color.Blue),0,0,image.Width, image.Height);
        g.Clear(Color.White);//������ɫ
        g.DrawString(checkCode, f, b, 3, 3);

        Pen blackPen = new Pen(Color.Black, 0);
        Random rand = new Random();
        /*�����
        for (int i = 0; i < 5; i++)
        {
            int y = rand.Next(image.Height);
            g.DrawLine(blackPen, 0, y, image.Width, y);
        }
        */
        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        Response.ClearContent();
        Response.ContentType = "image/Jpeg";
        Response.BinaryWrite(ms.ToArray());
        g.Dispose();
        image.Dispose();
    }
开发者ID:vtmer,项目名称:NewStudent,代码行数:32,代码来源:checkCode.aspx.cs

示例4: LetterWatermark

    /// <summary>
    /// 文字水印处理方法
    /// </summary>
    /// <param name="path">图片路径(绝对路径)</param>
    /// <param name="size">字体大小</param>
    /// <param name="letter">水印文字</param>
    /// <param name="color">颜色</param>
    /// <param name="location">水印位置</param>
    public static string LetterWatermark(string path, int size, string letter, Color color, string location)
    {
        #region

        string kz_name = Path.GetExtension(path);
        if (kz_name == ".jpg" || kz_name == ".bmp" || kz_name == ".jpeg")
        {
            DateTime time = DateTime.Now;
            string filename = "" + time.Year.ToString() + time.Month.ToString() + time.Day.ToString() + time.Hour.ToString() + time.Minute.ToString() + time.Second.ToString() + time.Millisecond.ToString();
            Image img = Bitmap.FromFile(path);
            Graphics gs = Graphics.FromImage(img);
            ArrayList loca = GetLocation(location, img, size, letter.Length);
            Font font = new Font("宋体", size);
            Brush br = new SolidBrush(color);
            gs.DrawString(letter, font, br, float.Parse(loca[0].ToString()), float.Parse(loca[1].ToString()));
            gs.Dispose();
            string newpath = Path.GetDirectoryName(path) + filename + kz_name;
            img.Save(newpath);
            img.Dispose();
            File.Copy(newpath, path, true);
            if (File.Exists(newpath))
            {
                File.Delete(newpath);
            }
        }
        return path;

        #endregion
    }
开发者ID:kcly3027,项目名称:knowledge,代码行数:37,代码来源:ImageClass.cs

示例5: Paint

        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, 
            DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle,
            DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            if (null == value) value = 0;
             int progressVal;
            if (value != null)
                progressVal = (int) value;
            else
                progressVal = 1;

            float percentage = ((float)progressVal / 100.0f); // Need to convert to float before division; otherwise C# returns int which is 0 for anything but 100%.
            Brush backColorBrush = new SolidBrush(cellStyle.BackColor);
            Brush foreColorBrush = new SolidBrush(cellStyle.ForeColor);
            // Draws the cell grid
            base.Paint(g, clipBounds, cellBounds,
             rowIndex, cellState, value, formattedValue, errorText,
             cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));
            if (percentage > 0.0) {
                // Draw the progress bar and the text
                g.FillRectangle(new SolidBrush(Color.FromArgb(163, 189, 242)), cellBounds.X + 2, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 4)), cellBounds.Height - 4);
                g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreColorBrush, cellBounds.X + 6, cellBounds.Y + 4);
            } else {
                // draw the text
                if (null != this.DataGridView.CurrentRow && this.DataGridView.CurrentRow.Index == rowIndex)
                    g.DrawString(progressVal.ToString() + "%", cellStyle.Font, new SolidBrush(cellStyle.SelectionForeColor), cellBounds.X + 6, cellBounds.Y + 4);
                else
                    g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreColorBrush, cellBounds.X + 6, cellBounds.Y + 4);
            }
        }
开发者ID:noxdafox,项目名称:clips,代码行数:30,代码来源:DataGridViewProgressColumn.cs

示例6: OnPaint

    protected override void OnPaint(PaintEventArgs pevent)
    {
        var g = pevent.Graphics;
        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.Clear(Parent.BackColor);

        Rectangle BGEllipse = new Rectangle(0, 0, 18, 18);

        EnabledCheckedColor = ColorTranslator.FromHtml(HexColor);
        SolidBrush BG = new SolidBrush(Enabled ? Checked ? EnabledCheckedColor : EnabledUnCheckedColor : DisabledColor);

        //RadioButton BG
        if (Checked)
        {
            g.FillEllipse(new SolidBrush(Color.FromArgb(Alpha, BG.Color)), BGEllipse);
            g.FillEllipse(new SolidBrush(Color.White), new Rectangle(2, 2, 14, 14));
        }
        else
        {
            g.FillEllipse(BG, BGEllipse);
            g.FillEllipse(new SolidBrush(Color.White), new Rectangle(2, 2, 14, 14));
        }       

        g.FillEllipse(BG, new Rectangle(PointAnimationNum, PointAnimationNum, SizeAnimationNum, SizeAnimationNum));       

        //RadioButton Text
        g.DrawString(Text, font.Roboto_Medium10, new SolidBrush(Enabled ? EnabledStringColor : DisabledStringColor), 20, 0);
    }
开发者ID:mr-amini,项目名称:ComU,代码行数:28,代码来源:LollipopRadioButton.cs

示例7: ValidateCode

    private void ValidateCode( string VNum )
    {
        Bitmap Img = null;
        Graphics g = null;
        MemoryStream ms = null;

        int gheight = VNum.Length * 10;
        Img = new Bitmap( gheight, 15 );
        g = Graphics.FromImage( Img );
        //背景颜色
        g.Clear( Color.White );
        //文字字体
        Font f = new Font( "宋体", 10 );
        //文字颜色
        SolidBrush s = new SolidBrush( Color.Red );
        g.DrawString( VNum, f, s, 3, 3 );
        ms = new MemoryStream();
        Img.Save( ms, ImageFormat.Jpeg );
        Response.ClearContent();
        Response.ContentType = "images/Jpeg";
        Response.BinaryWrite( ms.ToArray() );
        g.Dispose();
        Img.Dispose();
        Response.End();
    }
开发者ID:lincoln56,项目名称:robinerp,代码行数:25,代码来源:Getcode.aspx.cs

示例8: AddWatermark

    public void AddWatermark(string filename, ImageFormat imageFormat, Stream outputStream, HttpContext ctx)
    {
        Image bitmap = Image.FromFile(filename);
        Font font = new Font("Arial", 13, FontStyle.Bold, GraphicsUnit.Pixel);
        Random rnd = new Random();
        Color color = Color.FromArgb(200, rnd.Next(255), rnd.Next(255), rnd.Next(255)); //Adds a black watermark with a low alpha value (almost transparent).
        Point atPoint = new Point(bitmap.Width / 2 - 40, bitmap.Height / 2 - 7); //The pixel point to draw the watermark at (this example puts it at 100, 100 (x, y)).
        SolidBrush brush = new SolidBrush(color);

        string watermarkText = "voobrazi.by";

        Graphics graphics;
        try
        {
            graphics = Graphics.FromImage(bitmap);
        }
        catch
        {
            Image temp = bitmap;
            bitmap = new Bitmap(bitmap.Width, bitmap.Height);
            graphics = Graphics.FromImage(bitmap);
            graphics.DrawImage(temp, new Rectangle(0, 0, bitmap.Width, bitmap.Height), 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel);
            temp.Dispose();
        }

        graphics.DrawString(watermarkText, font, brush, atPoint);
        graphics.Dispose();

        bitmap.Save(outputStream, imageFormat);
        bitmap.Dispose();
    }
开发者ID:juliakolesen,项目名称:voobrazi.by,代码行数:31,代码来源:ImageHttpHandler.cs

示例9: HexView

	public HexView()
	{
		// Setup drawing objects
		NormalFontBrush = new SolidBrush(Color.Black);
		NormalFont = new Font("Courier New", 10);
        vsAddr.ValueChanged += this.VsAddr_ValueChanged;
	}
开发者ID:danlb2000,项目名称:Atari-Disk-Explorer,代码行数:7,代码来源:HexView.cs

示例10: Blockchange2

        protected override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
            RevertAndClearState(p, x, y, z);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            GetRealBlock(type, extType, p, ref cpos);
            DrawOp drawOp = null;
            Brush brush = null;

            switch (cpos.solid) {
                case SolidType.solid:
                    drawOp = new CuboidDrawOp(); break;
                case SolidType.hollow:
                    drawOp = new CuboidHollowsDrawOp(); break;
                case SolidType.walls:
                    drawOp = new CuboidWallsDrawOp(); break;
                case SolidType.holes:
                    drawOp = new CuboidHolesDrawOp(); break;
                case SolidType.wire:
                    drawOp = new CuboidWireframeDrawOp(); break;
                case SolidType.random:
                    drawOp = new CuboidDrawOp();
                    brush = new RandomBrush(cpos.type, cpos.extType); break;
            }
            
            if (brush == null) brush = new SolidBrush(cpos.type, cpos.extType);
            ushort x1 = Math.Min(cpos.x, x), x2 = Math.Max(cpos.x, x);
            ushort y1 = Math.Min(cpos.y, y), y2 = Math.Max(cpos.y, y);
            ushort z1 = Math.Min(cpos.z, z), z2 = Math.Max(cpos.z, z);            
            if (!DrawOp.DoDrawOp(drawOp, brush, p, x1, y1, z1, x2, y2, z2))
                return;
            if (p.staticCommands)
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:32,代码来源:CmdCuboid.cs

示例11: DrawBg

            public override void DrawBg(System.Drawing.Graphics g, System.Drawing.Rectangle rect, System.Drawing.Drawing2D.SmoothingMode smooth)
            {
                using (SolidBrush backBrush = new SolidBrush(BgColor))
                    g.FillRectangle(backBrush, rect);

                g.SmoothingMode = smooth;
            }
开发者ID:AndrianDTR,项目名称:Atlantic,代码行数:7,代码来源:Office12Renderer.cs

示例12: OnDrawItem

    protected override void OnDrawItem(DrawItemEventArgs e)
    {
        RectangleF tabFill = (RectangleF)GetTabRect(e.Index);

        if (e.Index == SelectedIndex)
        {
            Brush textBrush = new SolidBrush(Color.Black);
            Brush fillBrush = new SolidBrush(Color.White);
            e.Graphics.FillRectangle(fillBrush, tabFill);
            e.Graphics.DrawString(TabPages[e.Index].Text, Font, textBrush, new Point(e.Bounds.X + 5, e.Bounds.Y + 5));
            int offset = (e.Bounds.Height - 16) / 2;
            e.Graphics.DrawImage(Image.FromFile(pathCloseImg), e.Bounds.X + e.Bounds.Width - 20, e.Bounds.Y + offset);
            textBrush.Dispose();
            fillBrush.Dispose();
        }
        else
        {
            Brush textBrush = new SolidBrush(Color.White);
            Brush fillBrush = new SolidBrush(Color.DimGray);
            e.Graphics.FillRectangle(fillBrush, tabFill);
            fillBrush.Dispose();
            e.Graphics.DrawString(TabPages[e.Index].Text, Font, textBrush, new Point(e.Bounds.X + 5, e.Bounds.Y + 3));
            int offset = (e.Bounds.Height - 16) / 2;
            e.Graphics.DrawImage(Image.FromFile(pathCloseImg), e.Bounds.X + e.Bounds.Width - 20, e.Bounds.Y + offset + 2);
            textBrush.Dispose();
            fillBrush.Dispose();
        }
    }
开发者ID:TylerDev905,项目名称:CSharpCustomTabs,代码行数:28,代码来源:TabControlEx.cs

示例13: TicTacToeClientForm_Load

    private bool done = false; // true when game is over                 

    // initialize variables and thread for connecting to server
    private void TicTacToeClientForm_Load(object sender, EventArgs e)
    {
        board = new Square[3, 3];

        // create 9 Square objects and place them on the board
        board[0, 0] = new Square(board0Panel, ' ', 0);
        board[0, 1] = new Square(board1Panel, ' ', 1);
        board[0, 2] = new Square(board2Panel, ' ', 2);
        board[1, 0] = new Square(board3Panel, ' ', 3);
        board[1, 1] = new Square(board4Panel, ' ', 4);
        board[1, 2] = new Square(board5Panel, ' ', 5);
        board[2, 0] = new Square(board6Panel, ' ', 6);
        board[2, 1] = new Square(board7Panel, ' ', 7);
        board[2, 2] = new Square(board8Panel, ' ', 8);

        // create a SolidBrush for writing on the Squares
        brush = new SolidBrush(Color.Black);

        // make connection to server and get the associated
        // network stream                                  
        connection = new TcpClient("127.0.0.1", 50000);
        stream = connection.GetStream();
        writer = new BinaryWriter(stream);
        reader = new BinaryReader(stream);

        // start a new thread for sending and receiving messages
        outputThread = new Thread(new ThreadStart(Run));
        outputThread.Start();
    } // end method TicTacToeClientForm_Load
开发者ID:Fanarito,项目名称:FOR3A,代码行数:32,代码来源:TicTacToeClient.cs

示例14: CreateImage

    private void CreateImage()
    {
        Session["captcha.guid"] = Guid.NewGuid().ToString ("N");
        string code = GetRandomText();

        Bitmap bitmap = new Bitmap(WIDTH,HEIGHT,System.Drawing.Imaging.PixelFormat.Format32bppArgb);

        Graphics g = Graphics.FromImage(bitmap);
        Pen pen = new Pen(Color.DarkSlateGray);
        Rectangle rect = new Rectangle(0,0,WIDTH,HEIGHT);

        SolidBrush background = new SolidBrush(Color.AntiqueWhite);
        SolidBrush textcolor = new SolidBrush(Color.DarkSlateGray);

        int counter = 0;

        g.DrawRectangle(pen, rect);
        g.FillRectangle(background, rect);

        for (int i = 0; i < code.Length; i++)
        {
            g.DrawString(code[i].ToString(),
                         new Font("Verdana", 10 + rand.Next(6, 14)),
                         textcolor,
                         new PointF(10 + counter, 10));
            counter += 25;
        }

        DrawRandomLines(g);

        bitmap.Save(Response.OutputStream,ImageFormat.Gif);

        g.Dispose();
        bitmap.Dispose();
    }
开发者ID:nageshverma2003,项目名称:TrackProtectSource,代码行数:35,代码来源:CaptchaControl.aspx.cs

示例15: ApplyTextWatermark

    protected override void ApplyTextWatermark(ImageProcessingActionExecuteArgs args, Graphics g)
    {
        // Draw a filled rectangle
        int rectangleWidth = 14;
        using (Brush brush = new SolidBrush(Color.FromArgb(220, Color.Red)))
        {
            g.FillRectangle(brush, new Rectangle(args.Image.Size.Width - rectangleWidth, 0, rectangleWidth, args.Image.Size.Height));
        }

        using (System.Drawing.Drawing2D.Matrix transform = g.Transform)
        {
            using (StringFormat stringFormat = new StringFormat())
            {
                // Vertical text (bottom -> top)
                stringFormat.FormatFlags = StringFormatFlags.DirectionVertical;
                transform.RotateAt(180F, new PointF(args.Image.Size.Width / 2, args.Image.Size.Height / 2));
                g.Transform = transform;

                // Align: top left, +2px displacement 
                // (because of the matrix transformation we have to use inverted values)
                base.ContentAlignment = ContentAlignment.MiddleLeft;
                base.ContentDisplacement = new Point(-2, -2);

                base.ForeColor = Color.White;
                base.Font.Size = 10;

                // Draw the string by invoking the base Apply method
                base.StringFormat = stringFormat;
                base.ApplyTextWatermark(args, g);
                base.StringFormat = null;
            }
        }
    }
开发者ID:Gordon-from-Blumberg,项目名称:Piczard.Examples,代码行数:33,代码来源:MyInheritedFilter.cs


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