Dispose() public method

public Dispose ( bool disposing ) : void
disposing bool
return void
コード例 #1
1
        /// <summary>
        /// 主要作業方法
        /// </summary>
        public Image Operation()
        {
            Graphics g = Graphics.FromImage(image);
            _mask_pos_x = (image.Width / 2) + _Xoffset;
            SizeF steSize = new SizeF();
            for (int i = _FontMaxSize; i >= _FontMinSize; i--)
            {
                using (Font testFont = new Font(_FontFamily, i, FontStyle.Bold))
                {
                    steSize = g.MeasureString(_text, testFont);

                    if ((ushort)steSize.Width < (ushort)_Width || i == _FontMinSize)
                    {

                        using (SolidBrush semiTransBrush = new SolidBrush(_fontcolor))
                        {
                            StringFormat StrFormat = new StringFormat();
                            StrFormat.Alignment = StringAlignment.Center;
                            g.DrawString(_text, testFont, semiTransBrush, new PointF(_mask_pos_x, _mask_pos_y), StrFormat);
                            semiTransBrush.Dispose();
                        }
                        testFont.Dispose();
                        break;
                    }
                }
            }

            return image;
        }
コード例 #2
0
    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();
        }
    }
コード例 #3
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            // TODO: 在此处添加自定义绘制代码
            if (dataButtonInfo.FreshEnable)
            {
                dataButtonInfo.FreshEnable = false;
                base.Text = GetShowData();
            }
            /*************************************为控件绘制文本属性**************************/
            StringFormat fontAlignMent = new StringFormat();
            String       strText       = this.Text;
            Rectangle    textRect      = GetTextRect();//获得图形矩形
            Font         textFont      = new System.Drawing.Font(this.Font.Name, this.Font.Size, this.Font.Style);
            SolidBrush   fontBrush     = new System.Drawing.SolidBrush(this.ForeColor);

            fontAlignMent.Alignment     = StringAlignment.Center;//设置字体显示时候的对齐方式
            fontAlignMent.LineAlignment = StringAlignment.Center;
            String text = this.Text;

            if (System.Environment.OSVersion.Platform == PlatformID.WinCE && (dataButtonInfo.DataInfo != null && dataButtonInfo.DataInfo.UnitType != UnitType.Null))
            {
                text += " " + GetUnitString();
            }
            pe.Graphics.DrawString(text, textFont, fontBrush, textRect, fontAlignMent);
            if (dataButtonInfo.FrameColor != Color.Empty)
            {
                //pe.Graphics.FillRectangle()
                DrawFrame(pe.Graphics);
            }
            fontBrush.Dispose();
            fontAlignMent.Dispose();
            textFont.Dispose();
            fontBrush.Dispose();
            base.OnPaint(pe);
        }
コード例 #4
0
ファイル: ItemUseRegion.cs プロジェクト: narlon/TOMClassic
        public override void Draw(Graphics g)
        {
            if (nid > 0)
            {
                int itemCount = UserProfile.Profile.InfoBag.GetItemCount(nid);
                bool isEnough = itemCount >= need;

                g.DrawImage(DataType.Items.HItemBook.GetHItemImage(nid), x, y, width, height);
                if (IsIn && isEnough)
                {
                    g.DrawImage(DataType.Items.HItemBook.GetHItemImage(nid), x+3, y+3, width-6, height-6);
                }
                if (!isEnough)
                {//灰色遮罩
                    Brush brush = new SolidBrush(Color.FromArgb(120, Color.Black));
                    g.FillRectangle(brush, x, y, width, height);
                    brush.Dispose();
                }

                Font fontsong = new Font("宋体", 7*1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
                g.DrawString(string.Format("{0}/{1}", need, itemCount), fontsong, isEnough ? Brushes.White : Brushes.Red, x + 1, y + 18);
                fontsong.Dispose();
            }

            foreach (IRegionDecorator decorator in decorators)
            {
                decorator.Draw(g, x, y, width, height);
            }
        }
コード例 #5
0
        void FormSplashScreen_Paint(object sender, PaintEventArgs e) {

            if ( Natives.CanUseAero ) {
                Natives.FillBlackRegion(e.Graphics, ClientRectangle);
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                var gDevPath = new GraphicsPath();
                var gLogPath = new GraphicsPath();
                var brush = new SolidBrush(Color.FromArgb(0x99, Color.Black));

                gDevPath.AddString(_devList, DrawingFont.FontFamily, (int)FontStyle.Regular, Constants.DEV_TEXT_SIZE,
                                                    new Point(Constants.LOGO_WIDTH + Constants.PADDING, Constants.TEXT_HEIGHT + Constants.PADDING), StringFormat.GenericDefault);

                gLogPath.AddString(LogMessage, DrawingFont.FontFamily, (int)FontStyle.Bold, Constants.LOG_TEXT_SIZE, new Point(Constants.PADDING, Height - 65 - Constants.PADDING), StringFormat.GenericDefault);

                e.Graphics.DrawImage(HammerBitmap, Constants.PADDING, Constants.PADDING, Constants.LOGO_WIDTH, Constants.LOGO_HEIGHT);
                e.Graphics.DrawImage(MCForgeBitmap, Constants.LOGO_WIDTH + Constants.PADDING, Constants.PADDING, Constants.TEXT_WIDTH, Constants.TEXT_HEIGHT);
                e.Graphics.FillPath(brush, gDevPath);
                e.Graphics.FillPath(brush, gLogPath);


                gDevPath.Dispose();
                gLogPath.Dispose();
                brush.Dispose();
            }
        }
コード例 #6
0
        public void DrawPDF417(ref Graphics g)
        {
            g.Clear(this.backcolor);
            SolidBrush brush = new SolidBrush(this.forecolor);
            int x = this.leftmargin;
            int y = this.topmargin;
            SizeF ef = g.MeasureString(this.bottomcomment, this.txtFont, 0x7fffffff, StringFormat.GenericTypographic);
            for (int i = 0; i < this.encodebinarystr.Length; i++)
            {
                char ch = this.encodebinarystr[i];
                switch (ch)
                {
                    case '0':
                        x += this.modulewidth;
                        break;

                    case '1':
                        g.FillRectangle(brush, x, y, this.modulewidth, this.moduleheight);
                        x += this.modulewidth;
                        break;

                    default:
                        if (ch == 'Z')
                        {
                            y += this.moduleheight;
                            x = this.leftmargin;
                        }
                        break;
                }
            }
            g.DrawString(this.topcomment, this.txtFont, brush, (float) this.topcommentleftmargin, (float) this.topcommenttopmargin);
            //g.DrawString(" ", this.txtFont, brush, (float) 0f, (float) (this.symbolheight - ef.Height));
            brush.Dispose();
        }
コード例 #7
0
 public override System.Drawing.Bitmap GetNext()
 {
     if (this.nowState == MarqueeDisplayState.First)
     {
         this.nowPosition = (int)this.nowPositionF;
         int arg_2C_0 = (this.newBitmap.Width - this.nowPosition) / 2;
         System.Drawing.Bitmap   bitmap   = new System.Drawing.Bitmap(this.newBitmap);
         System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
         this.GetLeft(this.nowPosition);
         System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Silver);
         System.Drawing.Bitmap     bitmap2    = new System.Drawing.Bitmap(this.newBitmap.Width, this.newBitmap.Height);
         System.Drawing.Graphics   graphics2  = System.Drawing.Graphics.FromImage(bitmap2);
         graphics2.Clear(System.Drawing.Color.Black);
         graphics2.FillPolygon(solidBrush, this.pointLeft);
         graphics2.Dispose();
         bitmap2.MakeTransparent(System.Drawing.Color.Silver);
         graphics.DrawImage(bitmap2, new System.Drawing.Point(0, 0));
         bitmap2.Dispose();
         solidBrush.Dispose();
         graphics.Dispose();
         this.nowPositionF -= this.step;
         if (this.nowPositionF <= 0f)
         {
             this.nowState = MarqueeDisplayState.Stay;
         }
         return(bitmap);
     }
     return(null);
 }
コード例 #8
0
ファイル: MiniItemViewItem.cs プロジェクト: narlon/TOMClassic
        public void Draw(Graphics g, bool enable)
        {
            Image back = PicLoader.Read("System", "ItemGrid.JPG");
            g.DrawImage(back, x+3, y+3, 32, 32);
            back.Dispose();

            if (itemPos >= 0)
            {
                Font font = new Font("Aril", 11*1.33f, FontStyle.Bold, GraphicsUnit.Pixel);
                if (enable)
                {
                    g.DrawImage(HItemBook.GetHItemImage(UserProfile.InfoBag.Items[itemPos].Type), x + 3, y + 3, 32, 32);
                }
                else
                {
                    Rectangle ret = new Rectangle(x + 3, y + 3, 32, 32);
                    g.DrawImage(HItemBook.GetHItemImage(UserProfile.InfoBag.Items[itemPos].Type), ret, 0, 0, 64, 64, GraphicsUnit.Pixel, HSImageAttributes.ToGray);
                }

                g.DrawString(UserProfile.InfoBag.Items[itemPos].Value.ToString(), font, Brushes.Black, x + 4, y + 4);
                g.DrawString(UserProfile.InfoBag.Items[itemPos].Value.ToString(), font, Brushes.White, x + 3, y + 3);

                if (percent>1)
                {
                    Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black));
                    g.FillRectangle(brush, x, y, 35, 35*percent/100);
                    brush.Dispose();
                }

                font.Dispose();
            }
        }
コード例 #9
0
ファイル: cLight.cs プロジェクト: whztt07/HPL1Engine
		public override void Draw(Graphics aGfx,int alWorldX,int alWorldY ,eEditMode mMode, bool abSelected)
		{
			Color Col;
			
			if(mMode == eEditMode.Lights)
			{
				Col = abSelected?Color.FromArgb(80,255,80):Color.FromArgb(255,0,255);
				
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-10-alWorldX,mlY-10-alWorldY,
					20,20);
				CenterBrush.Dispose();
			}
			else
			{
				Col = Color.Gray;
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-3-alWorldX,mlY-3-alWorldY,
					6,6);
				CenterBrush.Dispose();
			}


            Pen OuterPen = new Pen(Col);
			aGfx.DrawEllipse(OuterPen,mlX-mfRadius-alWorldX,mlY-mfRadius-alWorldY,
							mfRadius*2,mfRadius*2);
			OuterPen.Dispose();
		}
コード例 #10
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            // Calling the base class OnPaint
            base.OnPaint(pe);

            // diplay mask
            System.Drawing.Font       drawFont       = new System.Drawing.Font(FontFamily.GenericMonospace, 8.0F);
            System.Drawing.SolidBrush drawBrush      = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            System.Drawing.SolidBrush drawBrushGreen = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(123, 194, 205));

            bmpBackground.MakeTransparent(Color.Yellow);
            pe.Graphics.DrawImageUnscaled(bmpBackground, 0, 0);

            for (int i = 0; i < 8; i++)
            {
                pe.Graphics.DrawString(String.Format("{0:0}", RC_Values[i]), drawFont, drawBrush, 165, bar_pos[i] - 13);
                int w = (int)((RC_Values[i] - 1000) / (double)(1000 / 120));
                if (w < 0)
                {
                    w = 0;
                }
                if (w > 120)
                {
                    w = 120;
                }

                pe.Graphics.FillRectangle(drawBrushGreen, 41, bar_pos[i] - 9, w - 1, 8);
            }

            drawFont.Dispose();
            drawBrush.Dispose();
            drawBrushGreen.Dispose();
        }
コード例 #11
0
ファイル: Form9.cs プロジェクト: kanke/cal
        private void monthCalendar1_DayRender(object sender, Pabo.Calendar.DayRenderEventArgs e)
        {
            Brush bgBrush =  new SolidBrush(Color.White);
            Brush dateBrush = new SolidBrush(Color.Black);
            Font dateFont = new Font("Microsoft Sans Serif",(float)8.25);
            StringFormat dateAlign = new StringFormat();

            dateAlign.Alignment = StringAlignment.Far;
            dateAlign.LineAlignment = StringAlignment.Near;

            Rectangle rect = new Rectangle(0,0,e.Width,e.Height);

            // Set OwnerDraw = true to override built in formatting...
            e.OwnerDraw = true;
            // ...then Draw the appearance of the date
            e.Graphics.FillRectangle(bgBrush,rect);
            e.Graphics.DrawString(e.Date.Day.ToString(),
                   dateFont,dateBrush,rect,dateAlign);

            // Clean up
            bgBrush.Dispose();
            dateBrush.Dispose();
            dateAlign.Dispose();
            dateFont.Dispose();
        }
コード例 #12
0
        public void DrawString(Graphics formGraphics)
        {
            string drawString         = "New Game";
            string drawString1        = "Quit";
            string score              = "High score";
            PrivateFontCollection pfc = new PrivateFontCollection();

            pfc.AddFontFile("SHOWG.TTF");
            string howtoplay = "How to play";

            System.Drawing.Font       drawFont   = new System.Drawing.Font(pfc.Families[0], 18, FontStyle.Regular);
            System.Drawing.Font       drawFont1  = new System.Drawing.Font(pfc.Families[0], font);
            System.Drawing.SolidBrush drawBrush  = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
            System.Drawing.SolidBrush drawBrush1 = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick);
            float x = 150.0F;
            float y = 50.0F;

            System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
            formGraphics.DrawString(drawString, drawFont, drawBrush, 90, 80, drawFormat);
            formGraphics.DrawString(drawString1, drawFont, drawBrush, 120, 180, drawFormat);
            formGraphics.DrawString(score, drawFont1, drawBrush1, 610, 500, drawFormat);
            drawFont = new System.Drawing.Font(pfc.Families[0], 14, FontStyle.Regular);
            formGraphics.DrawString(howtoplay, drawFont, drawBrush, 285, 285, drawFormat);
            drawFont.Dispose();
            drawBrush.Dispose();
            drawBrush1.Dispose();
        }
コード例 #13
0
        public override void Draw(Graphics g, int dx, int dy, float zoom)
        {
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            myBrush.Color = this.Trasparency(Color.Black, 80);
            System.Drawing.Pen whitePen = new System.Drawing.Pen(System.Drawing.Color.White);
            System.Drawing.Pen myPen    = new System.Drawing.Pen(System.Drawing.Color.Blue, 1.5f);
            myPen.DashStyle = DashStyle.Dash;

            g.FillRectangle(myBrush, new RectangleF((this.X + dx) * zoom, (this.Y + dy) * zoom, (this.X1 - this.X) * zoom, (this.Y1 - this.Y) * zoom));
            g.DrawRectangle(whitePen, (this.X + dx) * zoom, (this.Y + dy) * zoom, (this.X1 - this.X) * zoom, (this.Y1 - this.Y) * zoom);

            //CENTER POINT
            float midX, midY = 0;

            midX = (this.X1 - this.X) / 2;
            midY = (this.Y1 - this.Y) / 2;

            PointF Hp = new PointF(0, 25);

            PointF RotHP = this.rotatePoint(Hp, this._rotation);

            RotHP.X += this.X;
            RotHP.Y += this.Y;
            g.FillEllipse(myBrush, (RotHP.X + midX + dx - 3) * zoom, (RotHP.Y + dy - 3 + midY) * zoom, 6 * zoom, 6 * zoom);
            g.DrawEllipse(whitePen, (RotHP.X + midX + dx - 3) * zoom, (RotHP.Y + dy - 3 + midY) * zoom, 6 * zoom, 6 * zoom);
            g.DrawLine(myPen, (this.X + midX + dx) * zoom, (this.Y + midY + dy) * zoom, (RotHP.X + midX + dx) * zoom, (RotHP.Y + midY + dy) * zoom);

            myPen.Dispose();
            myBrush.Dispose();
            whitePen.Dispose();
        }
コード例 #14
0
        public static void imageWrite()
        {
            System.Drawing.SolidBrush fontBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);

            System.Net.WebClient wc = new System.Net.WebClient();
            string webData          = wc.DownloadString("https://icanhazdadjoke.com/");

            if (!!GetFirstParagraph(webData).Contains("€") || !!GetFirstParagraph(webData).Contains("™") || !!GetFirstParagraph(webData).Contains("â"))
            {
                Console.WriteLine("Bad text found! Rerouting for new joke... Text was: " + GetFirstParagraph(webData));
                imageWrite();
            }
            else
            {
                Bitmap   bitMapImage  = new System.Drawing.Bitmap(@"C:\Users\TorinPC\Pictures\Camera Roll\Random\WallpaperMoving\wp8.jpg");
                Graphics graphicImage = Graphics.FromImage(bitMapImage);
                graphicImage.SmoothingMode = SmoothingMode.AntiAlias;
                graphicImage.DrawString(GetFirstParagraph(webData), new Font("Sego UI", 10, FontStyle.Bold), fontBrush, new Point(2, 1060));
                //graphicImage.DrawArc(new Pen(Color.Red, 3), 90, 235, 150, 50, 0, 360);
                //Save the new image to the response output stream.
                bitMapImage.Save(@"C:\Users\TorinPC\Pictures\Camera Roll\Random\WallpaperMoving\currentWallpaper.jpg", ImageFormat.Jpeg);
                SetBackgroud(@"C:\Users\TorinPC\Pictures\Camera Roll\Random\WallpaperMoving\currentWallpaper.jpg");

                bitMapImage.Dispose(); // This saves ~6mb of memory.
                graphicImage.Dispose();
                wc.Dispose();
                fontBrush.Dispose();
            }
        }
コード例 #15
0
 public override System.Drawing.Bitmap GetNext()
 {
     if (this.nowState == MarqueeDisplayState.First)
     {
         this.nowPosition = (int)this.nowPositionF;
         int num = (this.newBitmap.Width - this.nowPosition) / 2;
         System.Drawing.Bitmap   bitmap   = new System.Drawing.Bitmap(this.newBitmap);
         System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
         System.Drawing.Brush    brush    = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
         graphics.FillRectangle(brush, new System.Drawing.Rectangle(0, 0, num, this.newBitmap.Height));
         graphics.FillRectangle(brush, new System.Drawing.Rectangle(num + this.nowPosition, 0, num, this.newBitmap.Height));
         brush.Dispose();
         System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red);
         graphics.DrawLine(pen, new System.Drawing.Point(num, 0), new System.Drawing.Point(num, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num - 1, 0), new System.Drawing.Point(num - 1, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num - 2, 0), new System.Drawing.Point(num - 2, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num + this.nowPosition, 0), new System.Drawing.Point(num + this.nowPosition, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num + this.nowPosition + 1, 0), new System.Drawing.Point(num + this.nowPosition + 1, this.newBitmap.Height));
         graphics.DrawLine(pen, new System.Drawing.Point(num + this.nowPosition + 2, 0), new System.Drawing.Point(num + this.nowPosition + 2, this.newBitmap.Height));
         pen.Dispose();
         graphics.Dispose();
         this.nowPositionF -= this.step;
         if (this.nowPosition <= 0)
         {
             this.nowState = MarqueeDisplayState.Stay;
         }
         return(bitmap);
     }
     return(null);
 }
コード例 #16
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Rectangle rect = this.ClientRectangle;

            System.Drawing.Brush brush =
                new System.Drawing.SolidBrush(this.BackColor);
            e.Graphics.FillRectangle(brush, rect);
            brush.Dispose();

            System.Drawing.Brush brush2 =
                new System.Drawing.SolidBrush(
                    this.Enabled ? this.ForeColor : SystemColors.ControlDarkDark);
            for (int i = 0; i < _tiles.Length; i++)
            {
                if (_tiles[i])
                {
                    e.Graphics.FillRectangle(brush2,
                                             rect.X + i * (_tileSize + 1),
                                             rect.Y + rect.Height / 2 - _tileSize / 2,
                                             _tileSize, _tileSize);
                }
            }
            brush2.Dispose();
        }
コード例 #17
0
ファイル: BlackWallForm.cs プロジェクト: narlon/TOMClassic
 private void CardShopViewForm_Paint(object sender, PaintEventArgs e)
 {
     Color col = Color.FromArgb(180, Color.Black);
     SolidBrush brush = new SolidBrush(col);
     e.Graphics.FillRectangle(brush, 0, 0, formWidth, formHeight);
     brush.Dispose();
 }
コード例 #18
0
 private static void DrawCircle(PaintEventArgs e, int size, int x, int y, Color c)
 {
     System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(c);
     e.Graphics.FillEllipse(myBrush, new Rectangle(x + offsetX - size / 2, y + offsetY - size / 2, size, size));
     myBrush.Dispose();
     //  formGraphics.Dispose();
 }
コード例 #19
0
ファイル: UiHelper.cs プロジェクト: nickun/OCRonet
        public static Bitmap DrawSegmentTranscript(Bitmap bmp, Narray<Rect> bboxes, string trans)
        {
            if (String.IsNullOrEmpty(trans) || bboxes.Length() - 1 != trans.Length)
                return bmp;

            int numAreaHeight = 15;
            Bitmap newbitmap = new Bitmap(bmp.Width, bmp.Height + numAreaHeight, bmp.PixelFormat);
            int height = bmp.Height;
            using (Graphics g = Graphics.FromImage(newbitmap))
            {
                SolidBrush bgrnBrush = new SolidBrush(Color.White);
                SolidBrush txtBrush = new SolidBrush(Color.Black);
                Pen rectPen = new Pen(Color.DarkGray);
                g.FillRectangle(bgrnBrush, new Rectangle(Point.Empty, newbitmap.Size));
                g.DrawImage(bmp, Point.Empty);
                bgrnBrush.Dispose();
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                FontFamily fontFam;
                try { fontFam = new FontFamily("Tahoma"); }
                catch { fontFam = FontFamily.GenericSansSerif; }

                Font font = new Font(fontFam, 6f);
                for (int i = 1; i < bboxes.Length(); i++)
                {
                    Rect b = bboxes[i];
                    g.DrawString(trans[i-1].ToString(), font, txtBrush, b.x0, height + 1);
                }
                txtBrush.Dispose();
            }
            return newbitmap;
        }
コード例 #20
0
ファイル: GUI.cs プロジェクト: Redoxee/YACE
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            YACE.GameVue gameVue = this.gui.interop.GameVue;

            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            System.Drawing.Pen        pen     = new Pen(myBrush, 5);
            System.Drawing.Graphics   formGraphics;
            formGraphics = this.CreateGraphics();
            System.Drawing.Font font = new Font("Arial", 14);
            myBrush.Color = Color.Black;
            string currentPlayerLabel = string.Format("Current player {0}", gameVue.currentPlayer);

            formGraphics.DrawString(currentPlayerLabel, font, myBrush, 10, 10);

            Point point = new Point(10, 40);

            this.PaintCard(gameVue.Zones[0].Cards[0], point, formGraphics, font);

            myBrush.Dispose();
            formGraphics.Dispose();

            this.DrawButton(scoreButton);
            this.DrawButton(multiplyButton);
        }
コード例 #21
0
        public void uxDraw_Click(object sender, EventArgs e)
        {
            using (WindowGraphics wg = new WindowGraphics(this))
            {
                wg.Graphics.DrawLine(Pens.Blue, 0, 0, 100, 100);
                //.....

                // or if you have to call many drawing functions, here is the way to reduce
                // your typing. This is what I always do...
                Graphics g = wg.Graphics;
                g.DrawString("I am on the title bar!", new Font("Tahoma", 10, FontStyle.Bold), Brushes.Black, 0, 4);
                //g.FillEllipse(Brushes.Black, this.Width - 40, this.Height - 40, 80, 80);
                // g.DrawRectangle(new Pen(Color.Yellow, 10), this.DisplayRectangle);
                // .... other drawing commands...
            }


            //Draw a filled rectangle inside the form
            System.Drawing.SolidBrush myBrush      = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
            System.Drawing.Graphics   formGraphics = this.CreateGraphics();
            formGraphics.FillRectangle(myBrush, new Rectangle(50, 50, 200, 300));
            myBrush.Dispose();
            formGraphics.Dispose();

            //Draw rectangle inside the form
            System.Drawing.Graphics graphicsObj;
            graphicsObj = this.CreateGraphics();
            Pen       myPen       = new Pen(System.Drawing.Color.Red, 5);
            Rectangle myRectangle = new Rectangle(20, 20, 250, 200);

            graphicsObj.DrawRectangle(myPen, myRectangle);

            //Draw form border
            graphicsObj.DrawRectangle(new Pen(Color.Green, 10), this.DisplayRectangle);
        }
コード例 #22
0
        private void DrawRectangle(Graphics drawingTool, IPositionData positionData)
        {
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(Color.FromArgb(positionData.TransparencyRectangle, 255, 255, 255));

            drawingTool.FillRectangle(myBrush, new Rectangle(positionData.RectanglePosition.X, positionData.RectanglePosition.Y, positionData.SizeRectangle.Width, positionData.SizeRectangle.Height));
            myBrush.Dispose();
        }
コード例 #23
0
            protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
            {
                ToolStripMenuItem t = e.Item as ToolStripMenuItem;

                if (t != null)
                {
                    System.Drawing.SolidBrush b;
                    if (t.Pressed)
                    {
                        if (t.HasDropDownItems && t.OwnerItem == null)
                        {
                            b = new System.Drawing.SolidBrush(Color.FromArgb(31, 31, 31));
                            e.Graphics.FillRectangle(b, 0, 0, t.Width, t.Height);
                            b.Dispose();

                            System.Drawing.Pen p;
                            p = new System.Drawing.Pen(Color.FromArgb(127, 127, 127));
                            e.Graphics.DrawRectangle(p, 0, 0, t.Width - 1, t.Height);
                            p.Dispose();
                        }
                        else
                        {
                            b = new System.Drawing.SolidBrush(Color.FromArgb(127, 127, 127));
                            e.Graphics.FillRectangle(b, 3, 1, t.Width - 5, t.Height - 2);
                            b.Dispose();
                        }
                    }
                    else if (t.Selected)
                    {
                        b = new System.Drawing.SolidBrush(Color.FromArgb(127, 127, 127));
                        e.Graphics.FillRectangle(b, 3, 1, t.Width - 5, t.Height - 2);
                        b.Dispose();
                    }
                }
            }
コード例 #24
0
 public draw_point(Form2 f, System.Drawing.Graphics g, int zoom, int x, int y, System.Drawing.Color color, int thickness = 4)
 {
     System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(color);
     g.FillRectangle(myBrush, x - thickness / 2, y - thickness / 2, thickness, thickness);
     new draw_string("(" + x + "," + y + ")", g, x, y + 5, System.Drawing.Color.Blue);
     myBrush.Dispose();
 }
コード例 #25
0
ファイル: StatusIcon.cs プロジェクト: memorydoor/plugins4Mt4
        public static System.Drawing.Icon GetIcon(string text)
        {
            //Create bitmap, kind of canvas
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(32, 32);

            Icon icon = Resources.Status;

            System.Drawing.Font       drawFont  = new System.Drawing.Font("Calibri", 18, FontStyle.Regular);
            System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);

            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);

            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
            graphics.DrawIcon(icon, 0, 0);
            graphics.DrawString(text, drawFont, drawBrush, 0, 0);

            //To Save icon to disk
            bitmap.Save("icon.ico", System.Drawing.Imaging.ImageFormat.Icon);

            Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());

            drawFont.Dispose();
            drawBrush.Dispose();
            graphics.Dispose();
            bitmap.Dispose();

            return(createdIcon);
        }
コード例 #26
0
        private void inputTextBox_TextChanged(object sender, EventArgs e)
        {
            this.Refresh();
            if (inputTextBox.Text.Equals("") || inputTextBox.Text == null)
            {
                return;
            }
            startingPoint.X = 10;
            startingPoint.Y = this.Height - 10;
            int rectsAmount = int.Parse(inputTextBox.Text);

            rectWidth = (this.Width - rectSpace * (rectsAmount + 1)) / rectsAmount;
            for (int i = 0; i < rectsAmount; i++)
            {
                Color randomColor = Color.FromArgb(rnd.Next(10, 200), rnd.Next(10, 200), rnd.Next(30, 200));
                System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(randomColor);
                System.Drawing.Graphics   formGraphics;
                formGraphics = this.CreateGraphics();
                Rectangle rect       = new Rectangle();
                int       rectHeight = rnd.Next(35, maxHeight);
                rect.Location = new Point(startingPoint.X + i * (rectWidth + rectSpace), startingPoint.Y - rectHeight);
                rect.Size     = new Size(rectWidth, rectHeight);
                formGraphics.FillRectangle(myBrush, rect);
                myBrush.Dispose();
                formGraphics.Dispose();
            }
        }
コード例 #27
0
        public Subtitle(string content,
			Font font, Color fillColor, Color borderColor, float borderWidth,
			long startTime, long endTime)
        {
            StartTime = startTime;
            EndTime = endTime;

            IntPtr screenDc = ApiHelper.GetDC(IntPtr.Zero);
            Graphics g = Graphics.FromHdc(screenDc);
            SizeF gsize = g.MeasureString(content, font);
            g.Dispose();
            this.Size = Size.Ceiling(new SizeF(gsize.Width + borderWidth, gsize.Height + borderWidth));

            hMemDc = ApiHelper.CreateCompatibleDC(screenDc);
            hMemBitmap = ApiHelper.CreateCompatibleBitmap(screenDc, Size.Width, Size.Height);
            ApiHelper.ReleaseDC(IntPtr.Zero, screenDc);
            ApiHelper.SelectObject(hMemDc, hMemBitmap);
            g = Graphics.FromHdc(hMemDc);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            GraphicsPath path = new GraphicsPath();
            path.AddString(content, font.FontFamily, (int)font.Style, font.Size,
                new Rectangle(Point.Empty, Size), defaultFormat);

            Pen pen = new Pen(borderColor, borderWidth);
            pen.LineJoin = LineJoin.Round;
            pen.Alignment = PenAlignment.Outset;
            g.DrawPath(pen, path);
            pen.Dispose();
            Brush brush = new SolidBrush(fillColor);
            g.FillPath(brush, path);
            brush.Dispose();
            g.Dispose();
        }
コード例 #28
0
ファイル: IconGenerator.cs プロジェクト: rguerraalmeida/Moove
        public static System.Drawing.Icon CreateIcon(string text)
        {
            //Create bitmap, kind of canvas
            System.Drawing.Bitmap   bitmap   = new System.Drawing.Bitmap(16, 16);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);

            //System.Drawing.Icon icon = new System.Drawing.Icon(@"Icons/trayicon.ico");
            //System.Drawing.SolidBrush backgroundBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            //graphics.DrawRectangle( new System.Drawing.Pen(backgroundBrush,1), new System.Drawing.Rectangle(0,0,16,16));

            System.Drawing.Font       drawFont  = new System.Drawing.Font("Arial", 8, System.Drawing.FontStyle.Regular);
            System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.GreenYellow);


            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            //graphics.DrawIcon(icon, 0, 0);
            //graphics.DrawString(text, drawFont, drawBrush, 1, 2);
            graphics.DrawString(text, drawFont, drawBrush, 0, 0);

            //To Save icon to disk
            //bitmap.Save("icon.ico", System.Drawing.Imaging.ImageFormat.Icon);

            System.Drawing.Icon createdIcon = System.Drawing.Icon.FromHandle(bitmap.GetHicon());

            drawFont.Dispose();
            drawBrush.Dispose();
            graphics.Dispose();
            bitmap.Dispose();

            return(createdIcon);
        }
コード例 #29
0
        /// <summary>
        /// Renders the grid offset from its origin position by the given indices. If Draw() is called before the Graphics object has been 
        /// set, a null reference exception will be thrown
        /// </summary>
        public override void Draw()
        {
            // Iterate through all cells in grid
            for (int column = 0; column < Grid.Size; column++)
            {
                for (int row = 0; row < Grid.Size; row++)
                {
                    Cell currentCell = Grid[column, row];
                    int hex = Shader.HexValue(currentCell[GrayScottDiffusionReaction.CHEMICAL_B]);

                    // Convert colour hex to .NET Color and create brush to draw it with
                    Color colour = Color.FromArgb(hex);
                    Brush brush = new SolidBrush(colour);

                    // Calculate cell position and dimensions
                    float cellX = column * CellWidth;
                    float cellY = row * CellHeight;

                    // Draw cell
                    Graphics.FillRectangle(brush, cellX, cellY, CellWidth, CellHeight);

                    // Dispose of brush
                    brush.Dispose();
                }
            }
        }
コード例 #30
0
ファイル: ThingEditorCtrl.cs プロジェクト: 15831944/Test3-1
        private void drawGrid(Graphics gr)
        {
            switch (GridStyle)
            {
            case EGridStyle.GrdLine:
                System.Drawing.Pen drawPen = new System.Drawing.Pen(GridColor, 1);
                for (int i = this.ClientRectangle.Left; i < this.ClientRectangle.Right + scrollX; i += gridSize)
                {
                    gr.DrawLine(drawPen, i - scrollX, this.ClientRectangle.Top, i - scrollX, this.ClientRectangle.Bottom);
                }
                for (int i = this.ClientRectangle.Top; i < this.ClientRectangle.Bottom + scrollY; i += gridSize)
                {
                    gr.DrawLine(drawPen, this.ClientRectangle.Left, i - scrollY, this.ClientRectangle.Right, i - scrollY);
                }
                drawPen.Dispose();
                break;

            case EGridStyle.GrdDot:
                System.Drawing.SolidBrush solidBrush = new System.Drawing.SolidBrush(GridColor);
                for (int i = this.ClientRectangle.Left; i < this.ClientRectangle.Right + scrollX; i += gridSize)
                {
                    for (int j = this.ClientRectangle.Top; j < this.ClientRectangle.Bottom + scrollY; j += gridSize)
                    {
                        gr.FillEllipse(solidBrush, i - scrollX - 1, j - scrollY - 1, 2, 2);
                    }
                }
                solidBrush.Dispose();
                break;
            }
        }
コード例 #31
0
        private void storageinfotimer_Tick(object sender, EventArgs e)
        {
            //Die Zahlen zur aktuellen Partition erhalten
            ulong[] values = DriveFunctions.GetPartitionSizeData(driveletter);

            //Die Zahlen in die Felder eintragen
            lbsizefilledbyte.Text = ExtraFunctions.GetNumberWithPoints(Convert.ToDouble(values[2]));
            lbsizefreebyte.Text = ExtraFunctions.GetNumberWithPoints(Convert.ToDouble(values[1]));
            lbsizegesbyte.Text = ExtraFunctions.GetNumberWithPoints(Convert.ToDouble(values[0]));

            lbsizefilled.Text = ExtraFunctions.UnitChange(Convert.ToDouble(values[2]));
            lbsizefree.Text = ExtraFunctions.UnitChange(Convert.ToDouble(values[1]));
            lbsizeges.Text = ExtraFunctions.UnitChange(Convert.ToDouble(values[0]));

            //Jetzt muss der Balken gezeichnet werden. Die Farbe ist AquaMarine
            Graphics g = picstoragebar.CreateGraphics();
            g.Clear(Color.LightGray);
            Color fillcolor = Color.Aqua;
            Brush brush = new SolidBrush(fillcolor);

            //Die Werte müssen gezeichnet werden. Da die Größe des Balkens sich verändern kann, muss es
            //dynamisch berechnet werden können
            double percentfilled = values[2] * 100 / values[0];
            double lenbar = picstoragebar.Size.Width / 100 * percentfilled;

            //Die Bar wird jetzt gezeichnet
            g.FillRectangle(brush, 0, 0, Convert.ToSingle(lenbar), picstoragebar.Size.Height);

            //Die Objekte disposen (da die viel RAM verbrauchen)
            g.Dispose();
            brush.Dispose();

            //Das Textlabel mit den Speicher auch aktualisieren
            lbstorageinfo.Text = ExtraFunctions.UnitChange(Convert.ToDouble(values[1])) + " frei von " + ExtraFunctions.UnitChange(Convert.ToDouble(values[0]));
        }
コード例 #32
0
ファイル: Win10Tsr.cs プロジェクト: Stoom/KeePass
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem tsi = ((e != null) ? e.Item : null);

            if((tsi != null) && ((tsi.Owner is ContextMenuStrip) ||
                (tsi.OwnerItem != null)) && tsi.Selected && !tsi.Enabled)
            {
                Rectangle rect = tsi.ContentRectangle;
                rect.Offset(0, -1);
                rect.Height += 1;

                // In image area (228, 228, 228), in text area (230, 230, 230)
                Color clrBack = Color.FromArgb(229, 229, 229);
                Color clrBorder = Color.FromArgb(229, 229, 229);

                SolidBrush br = new SolidBrush(clrBack);
                Pen p = new Pen(clrBorder);

                Graphics g = e.Graphics;
                if(g != null)
                {
                    g.FillRectangle(br, rect);
                    g.DrawRectangle(p, rect);
                }
                else { Debug.Assert(false); }

                p.Dispose();
                br.Dispose();
            }
            else base.OnRenderMenuItemBackground(e);
        }
コード例 #33
0
ファイル: Form1.cs プロジェクト: Guille1257/pergelisol
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            Pen contour = new Pen(Brushes.Black);
            Font writing = new Font(FontFamily.GenericSansSerif, 10);
            StringFormat formatWriting = new StringFormat();
            formatWriting.Alignment = StringAlignment.Far;
            SolidBrush writingBrush = new SolidBrush(Color.Black);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new Bitmap(1, 1));
            int largeurTemp = (int)graphics.MeasureString(m_sTemp, writing).Width;

            if(m_temp < 0)
                pe.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 4,130,255)), new Rectangle(0, 0, this.Size.Width, this.Size.Height));
            else
                pe.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 224, 205, 14)), new Rectangle(0, 0, this.Size.Width, this.Size.Height));

            pe.Graphics.DrawLine(contour, 0, 0, this.Size.Width, 0);
            pe.Graphics.DrawLine(contour, 0, 0, 0, this.Size.Height);
            pe.Graphics.DrawLine(contour, this.Size.Width - 1, 0, this.Size.Width - 1, this.Size.Height);
            pe.Graphics.DrawLine(contour, 0, this.Size.Height - 1, this.Size.Width, this.Size.Height - 1);

            pe.Graphics.DrawString(m_sTemp, writing, writingBrush, new Rectangle(0, 1, largeurTemp + 2, 20), formatWriting);
            pe.Graphics.DrawString(m_sProfondeur, writing, writingBrush, new Rectangle(0, 20, largeurTemp, 20), formatWriting);

            pe.Graphics.DrawString(string.Format("{0: 0.00} °C", m_temp), writing, writingBrush, new Point(largeurTemp, 0));
            pe.Graphics.DrawString(string.Format("{0: 0.00} m", m_profondeur), writing, writingBrush, new Point(largeurTemp, 20));

            contour.Dispose();
            writing.Dispose();
            writingBrush.Dispose();
        }
コード例 #34
0
ファイル: CP_Barcode.ascx.cs プロジェクト: nehawadhwa/ccweb
    protected void Page_Load(object sender, EventArgs e)
    {
        string fName = ConfigurationManager.AppSettings["Code39Barcode.FontFamily"];

        PrivateFontCollection fCollection = new PrivateFontCollection();
        fCollection.AddFontFile(ConfigurationManager.AppSettings["Code39Barcode.FontFile"]);
        FontFamily fFamily = new FontFamily(fName, fCollection);
        Font f = new Font(fFamily, FontSize);

        Bitmap bmp = new Bitmap(Width, Height);
        Graphics g = Graphics.FromImage(bmp);
        g.Clear(Color.White);
        Brush b = new SolidBrush(Color.Black);
        g.DrawString("*" + strPortfolioID + "*", f, b, 0, 0);

        //PNG format has no visible compression artifacts like JPEG or GIF, so use this format, but it needs you to copy the bitmap into a new bitmap inorder to display the image properly.  Weird MS bug.
        Bitmap bm = new Bitmap(bmp);
        System.IO.MemoryStream ms = new System.IO.MemoryStream();

        Response.ContentType = "image/png";
        bm.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        ms.WriteTo(Response.OutputStream);

        b.Dispose();
        bm.Dispose();
        Response.End();
    }
コード例 #35
0
ファイル: Light.cs プロジェクト: pgalias/Psychomotor-tests
 private void btStop_Click(object sender, EventArgs e)
 {
     if (ckTest.Checked == false)
     {
         timer1.Stop();
         myBrush = new SolidBrush(Color.Red);
         Graphics formGraphics = this.CreateGraphics();
         formGraphics.FillEllipse(myBrush, new Rectangle(0, 0, 120, 130));
         myBrush.Dispose();
         formGraphics.Dispose();
         MessageBox.Show("Your result: " + sec.ToString() + " seconds");
         resultLight.Add(sec);
         sec = 0;
     }
     if (ckTest.Checked == true)
     {
         timer1.Stop();
         myBrush = new SolidBrush(Color.Red);
         Graphics formGraphics = this.CreateGraphics();
         formGraphics.FillEllipse(myBrush, new Rectangle(0, 0, 120, 130));
         myBrush.Dispose();
         formGraphics.Dispose();
         MessageBox.Show("Your result: " + sec.ToString() + " seconds");
         sec = 0;
     }
 }
コード例 #36
0
ファイル: RectButton.cs プロジェクト: imdmmp/kpgweigher
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            Graphics graphics = e.Graphics;
            SolidBrush myTopPen = new SolidBrush(colorTop);
            SolidBrush myBotPen = new SolidBrush(colorBottom);

            if (btnType == MyButtonType.round2Button || btnType == MyButtonType.roundButton)
            {
                graphics.FillEllipse(myBotPen, areaBottom);
                graphics.FillEllipse(myTopPen, areaTop);
                DrawText(e);
            }

            if (btnType == MyButtonType.round2RectButton || btnType == MyButtonType.roundGradientButton || btnType == MyButtonType.roundRectButton)
            {
                DrawRoundRect(graphics, myBotPen, areaBottom);
                DrawRoundRect(graphics, myTopPen, areaTop);
                DrawText(e);
            }
            if (btnType == MyButtonType.roundRect)
            {
                DrawRoundRect(graphics, myTopPen, areaTop);
            }
            myTopPen.Dispose();
            myBotPen.Dispose();
        }
コード例 #37
0
ファイル: UiHelper.cs プロジェクト: nickun/OCRonet
 public static Bitmap DrawSegmentNumbers(Bitmap bmp, Narray<Rect> bboxes)
 {
     int numAreaHeight = 10;
     Bitmap newbitmap = new Bitmap(bmp.Width, bmp.Height + numAreaHeight, bmp.PixelFormat);
     int height = bmp.Height;
     using (Graphics g = Graphics.FromImage(newbitmap))
     {
         SolidBrush bgrnBrush = new SolidBrush(Color.White);
         SolidBrush txtBrush = new SolidBrush(Color.Black);
         Pen rectPen = new Pen(Color.DarkGray);
         g.FillRectangle(bgrnBrush, new Rectangle(Point.Empty, newbitmap.Size));
         g.DrawImage(bmp, Point.Empty);
         bgrnBrush.Dispose();
         FontFamily fontFam;
         try { fontFam = new FontFamily("Tahoma"); }
         catch { fontFam = FontFamily.GenericSansSerif; }
         Font font = new Font(fontFam, 5f);
         for (int i = 1; i < bboxes.Length(); i++)
         {
             Rect b = bboxes[i];
             int bposY = (height - b.y1);
             // draw bounding rects
             g.DrawRectangle(rectPen, Math.Max(0, b.x0-1), Math.Max(0, bposY-1), b.W, b.H+1);
             // draw numbers
             g.DrawString(i.ToString(), font, txtBrush, b.x0, height + 1);
         }
         txtBrush.Dispose();
     }
     return newbitmap;
 }
コード例 #38
0
 private void _grid_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
 {
     if (e.Column.Name == "Progress")
     { 
         // Create a gradient brush
         Point pt1, pt2;
         pt1 = new Point(e.CellRect.X, e.CellRect.Y);
         pt2 = new Point(e.CellRect.Right, e.CellRect.Y);
         SolidBrush solidBrush = new SolidBrush(e.Row % 2 == 0 ? _grid.EvenRowStyle.BackColor : _grid.OddRowStyle.BackColor);
         LinearGradientBrush linGrBrush = new LinearGradientBrush(pt1, pt2, Color.Cyan, Color.DarkBlue);
         RectangleF rt = new RectangleF(e.CellRect.X, e.CellRect.Y, Convert.ToInt32(e.CellRect.Width * .7), e.CellRect.Height);
         // Fill solid brackground
         e.Graphics.FillRectangle(solidBrush, e.CellRect);
         // Fill the cell rectangle with the gradient. 
         e.Graphics.FillRectangle(linGrBrush, e.Row % 2 == 0 ? rt : e.CellRect);
         Brush whiteBR = new SolidBrush(Color.White);
         C1DisplayColumn dispCol = this._grid.Splits[0].DisplayColumns[e.Col];
         // Center the text horizontally. 
         StringFormat sfmt = new StringFormat();
         sfmt.Alignment = StringAlignment.Far;
         // Draw the text. 
         e.Graphics.DrawString(dispCol.DataColumn.CellText(e.Row), dispCol.Style.Font, whiteBR, rt, sfmt);
         whiteBR.Dispose();
         // Let the grid know the event was handled. 
         e.Handled = true;
     }
 }
コード例 #39
0
ファイル: SolidBrushTest.cs プロジェクト: nlhepler/mono
		public void Dispose_Color ()
		{
			SolidBrush sb = new SolidBrush (Color.Transparent);
			sb.Dispose ();
			Assert.AreEqual (Color.Transparent, sb.Color, "Color");
			// no exception - the call probably doesn't get to gdi+
		}
コード例 #40
0
        public static Image GeneratePBKDF2Image(string password, string salt, string interations, string iteration, byte[] hash)
        {
            Bitmap bm = new Bitmap(250, 250);
            Font arial = new Font("Monospace", 8);
            Graphics graphics = Graphics.FromImage(bm);
            SolidBrush background = new SolidBrush(Color.Black);
            graphics.FillRectangle(background, 0, 0, 250, 250);
            background.Dispose();
            SolidBrush foreground = new SolidBrush(Color.White);
            SolidBrush highlight = new SolidBrush(Color.Red);
            SolidBrush key = new SolidBrush(Color.Gold);

            graphics.DrawString("Password: "******"Salt: " + salt, arial, foreground, new PointF(3, 15f * (1) + 3));
            graphics.DrawString("Iterations: " + interations, arial, foreground, new PointF(3, 15f * (2) + 3));
            graphics.DrawString("Iteration: " + iteration, arial, foreground, new PointF(3, 15f * (3) + 3));
            graphics.DrawString("Hash: ", arial, foreground, new PointF(3, 15f * (13) + 3));
            for (int x = 0; x < 2; x++)
            {
                for (int y = 0; y < 16; y++)
                {
                    string val = Convert.ToString(hash[y + (16 * x)], 16);
                    if (val.Length == 1)
                        val = "0" + val;
                    graphics.DrawString(val.ToUpper(), arial, foreground, new PointF(15f * y + 3, 15f * (14 + x) + 3));
                }
            }
            return bm;
        }
コード例 #41
0
ファイル: Form1.cs プロジェクト: ali-atghaei/AI-project
        private void button1_Click(object sender, EventArgs e)
        {
            /*System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow);
             * System.Drawing.Graphics formGraphics;
             * formGraphics = this.CreateGraphics();
             * formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 400, 400));
             * myBrush.Dispose();
             * formGraphics.Dispose();
             */

            string s1 = textBox1.Text;

            int[] genome = s1.Split(',').Select(n => Convert.ToInt32(n)).ToArray();

            int i;
            int len   = genome.Length;
            int scale = Convert.ToInt32(400 / 80);

            for (i = 0; i <= len; i += 4)
            {
                int width = scale * (genome[i] - genome[i + 2]);
                int hight = scale * (genome[i + 1] - genome[i + 3]);
                int a     = scale * (genome[i] - width);
                int b     = scale * genome[i + 1];
                // int c = genome[i + 2] + width;
                // int d = genome[i + 3];

                System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);
                System.Drawing.Graphics   formGraphics;
                formGraphics = this.CreateGraphics();
                formGraphics.FillRectangle(myBrush, new Rectangle(a, b, width, hight));
                myBrush.Dispose();
                formGraphics.Dispose();
            }
        }
コード例 #42
0
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.SolidBrush pen = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            Graphics g = panel1.CreateGraphics();

            g.FillRectangle(pen, new Rectangle(panel1.Width / 5 - crane.width - 50, panel1.Height - crane.height, crane.width, crane.height));
            g.FillRectangle(pen, new Rectangle(panel1.Width / 5 - crane.width - 100, panel1.Height - crane.height + 50, crane.length, crane.width));
            g.FillRectangle(pen, new Rectangle(hook.x, hook.y, hook.width, hook.height));
            g.FillRectangle(pen, new Rectangle(hook.x + 4, panel1.Height - crane.height + 50 + winch.height, 2, hook.y - (panel1.Height - crane.height + 50 + winch.height)));
            pen = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);
            g.FillRectangle(pen, new Rectangle(winch.x, panel1.Height - crane.height + 50, winch.width, winch.height));

            pen = new System.Drawing.SolidBrush(System.Drawing.Color.Brown);
            for (int i = 0; i < blocks.Count; i++)
            {
                if (blocks[i].shape == 'r')
                {
                    g.FillRectangle(pen, new Rectangle(blocks[i].x, blocks[i].y, blocks[i].width, blocks[i].height));
                }
                else if (blocks[i].shape == 'c')
                {
                    g.FillEllipse(pen, new Rectangle(blocks[i].x, blocks[i].y, blocks[i].width, blocks[i].height));
                }
                else
                {
                    Point p1 = new Point(blocks[i].x, blocks[i].y + blocks[i].height);
                    Point p2 = new Point(blocks[i].x + blocks[i].width, blocks[i].y + blocks[i].height);
                    Point p3 = new Point(blocks[i].x + blocks[i].width / 2, blocks[i].y);

                    g.FillPolygon(pen, new Point[] { p1, p2, p3 });
                }
            }
            pen.Dispose();
            g.Dispose();
        }
コード例 #43
0
ファイル: Utils.cs プロジェクト: jbrambilla/boletonet
        internal static Image DrawText(string text, Font font, Color textColor, Color backColor)
        {
            //first, create a dummy bitmap just to get a graphics object
            Image img = new Bitmap(1, 1);
            Graphics drawing = Graphics.FromImage(img);

            //measure the string to see how big the image needs to be
            SizeF textSize = drawing.MeasureString(text, font);

            //free up the dummy image and old graphics object
            img.Dispose();
            drawing.Dispose();

            //create a new image of the right size
            img = new Bitmap((int)textSize.Width - Convert.ToInt32(font.Size * 1.5), (int)textSize.Height, PixelFormat.Format24bppRgb);

            drawing = Graphics.FromImage(img);

            //paint the background
            drawing.Clear(backColor);

            //create a brush for the text
            Brush textBrush = new SolidBrush(textColor);

            drawing.DrawString(text, font, textBrush, 0, 0);

            drawing.Save();

            textBrush.Dispose();
            drawing.Dispose();

            return img;
        }
コード例 #44
0
        /// <summary>
        /// Clear selecred bitmap
        /// </summary>
        /// <param name="bmp"></param>
        /// <returns></returns>
        public static Bitmap Clear_Selected_Area(Bitmap bmp)
        {
            Bitmap temp = (Bitmap)bmp.Clone();

            System.Drawing.Rectangle clear = new System.Drawing.Rectangle();
            clear.Width  = Images.Instance.SelectedBitmap.Width;
            clear.Height = Images.Instance.SelectedBitmap.Height;
            System.Drawing.SolidBrush myBrush      = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            System.Drawing.Graphics   formGraphics = Graphics.FromImage(temp);
            if (SelectedPoints.PointDown.X < SelectedPoints.PointUp.X && SelectedPoints.PointDown.Y < SelectedPoints.PointUp.Y)
            {
                formGraphics.FillRectangle(myBrush, (int)SelectedPoints.PointDown.X, (int)SelectedPoints.PointDown.Y, Images.Instance.SelectedBitmap.Width, Images.Instance.SelectedBitmap.Height);
            }
            else
            if (SelectedPoints.PointDown.X > SelectedPoints.PointUp.X && SelectedPoints.PointDown.Y > SelectedPoints.PointUp.Y)
            {
                formGraphics.FillRectangle(myBrush, (int)SelectedPoints.PointUp.X, (int)SelectedPoints.PointUp.Y, Images.Instance.SelectedBitmap.Width, Images.Instance.SelectedBitmap.Height);
            }
            else
            if (SelectedPoints.PointDown.X > SelectedPoints.PointUp.X && SelectedPoints.PointDown.Y < SelectedPoints.PointUp.Y)
            {
                formGraphics.FillRectangle(myBrush, (int)SelectedPoints.PointDown.X - clear.Width, (int)SelectedPoints.PointDown.Y, Images.Instance.SelectedBitmap.Width, Images.Instance.SelectedBitmap.Height);
            }
            else
            if (SelectedPoints.PointDown.X < SelectedPoints.PointUp.X && SelectedPoints.PointDown.Y > SelectedPoints.PointUp.Y)
            {
                formGraphics.FillRectangle(myBrush, (int)SelectedPoints.PointDown.X, (int)SelectedPoints.PointDown.Y - clear.Height, Images.Instance.SelectedBitmap.Width, Images.Instance.SelectedBitmap.Height);
            }
            myBrush.Dispose();
            formGraphics.Dispose();
            return(temp);
        }
コード例 #45
0
 private void drawBorder(PaintEventArgs e)
 {
     //Draws the black rectangle for the plot
     System.Drawing.SolidBrush boxDrawer = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
     e.Graphics.FillRectangle(boxDrawer, g_mar_x_left, g_mar_y_top, g_active_width, g_active_height);
     boxDrawer.Dispose();
 }
コード例 #46
0
        public Stream CreateImage()
        {
            int      iwidth  = this.Width;
            int      iheight = this.Height;
            Bitmap   image   = new Bitmap(iwidth, iheight);
            Graphics g       = Graphics.FromImage(image);
            Font     f       = new System.Drawing.Font("Arial", 24, System.Drawing.FontStyle.Bold);
            Brush    b       = new System.Drawing.SolidBrush(Color.FromArgb(102, 102, 102));

            g.Clear(Color.White);
            g.DrawString(this.Code, f, b, 5, 2);


            Random rand     = new Random();
            Pen    blackPen = new Pen(Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255)), 0);

            for (int i = 0; i < 3; i++)
            {
                int y = rand.Next(image.Height);
                g.DrawLine(blackPen, 0, y, image.Width, y);
            }

            MemoryStream ms = new MemoryStream();

            image.Save(ms, ImageFormat.Jpeg);
            ms.Position = 0;

            f.Dispose();
            b.Dispose();
            g.Dispose();
            image.Dispose();

            return(ms);
        }
コード例 #47
0
        //------ End Constructors -----//
        public override void Paint(Graphics g, System.Drawing.Drawing2D.GraphicsPath gp, bool isSelected)
        {
            if (isSelected)
            {
                SolidBrush br = new SolidBrush(selectedBack);
                Pen pen = new Pen(selectedLine);
                g.FillPath(br, gp);
                g.DrawPath(pen, gp);
                br.Dispose();
                pen.Dispose();
            }
            else  //is not selected
            {
                if (_PaintBack)
                {
                    SolidBrush br = new SolidBrush(_BackColor);
                    g.FillPath(br,gp);
                    br.Dispose();
                }

                if (_PaintLine)
                {
                    Pen pen = new Pen(_LineColor);
                    g.DrawPath(pen, gp);
                    pen.Dispose();
                }
            }
        }
コード例 #48
0
ファイル: Star.cs プロジェクト: AtanasK/VP
 public override void Draw(Graphics g)
 {
     Brush brush = new SolidBrush(Color.Yellow);
     Rectangle rect = new Rectangle(Position.X - WIDTH / 2, Position.Y - WIDTH / 2, WIDTH,WIDTH);
     g.FillPolygon(brush, StarPoints(5, rect));
     brush.Dispose();
 }
コード例 #49
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int Line1 = 40;
            int Line2 = 230;

            System.Drawing.Pen   DarkPen    = new System.Drawing.Pen(System.Drawing.Color.DarkGray);
            System.Drawing.Pen   WhitePen   = new System.Drawing.Pen(System.Drawing.Color.White);
            System.Drawing.Brush WhiteBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            System.Drawing.Brush BlackBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            System.Drawing.Font  Font       = new Font("Arial", 16);

            System.Drawing.Graphics formGraphics = this.CreateGraphics();

            formGraphics.FillRectangle(WhiteBrush, 0, 0, 500, Line1);

            formGraphics.DrawLine(DarkPen, 0, Line1, 500, Line1);
            formGraphics.DrawLine(WhitePen, 0, Line1 + 1, 500, Line1 + 1);
            formGraphics.DrawLine(DarkPen, 0, Line2, 500, Line2);
            formGraphics.DrawLine(WhitePen, 0, Line2 + 1, 500, Line2 + 1);

            formGraphics.DrawString("Welcome to OML Database Setup ", Font, BlackBrush, 10, 10);

            DarkPen.Dispose();
            WhitePen.Dispose();
            WhiteBrush.Dispose();
            BlackBrush.Dispose();
            WhitePen.Dispose();

            formGraphics.Dispose();
        }
コード例 #50
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Brush backBrush = new SolidBrush(this.BackColor);
            Brush foreBrush = new SolidBrush(this.ForeColor);

            // 背景を描画する
            e.Graphics.FillRectangle(backBrush, this.ClientRectangle);

            // バーの幅を計算する
            int chunksWidth = (int)(
                (double)this.ClientSize.Width *
                (double)(this.Value - this.Minimum) /
                (double)(this.Maximum - this.Minimum));
            Rectangle chunksRect = new Rectangle(0, 0,
                chunksWidth, this.ClientSize.Height);
            // バーを描画する
            e.Graphics.FillRectangle(foreBrush, chunksRect);

            // 残り時間を描画する
            var f = new Font("メイリオ", 8);
            var NwTime = (Value >= 10000 ? "99.99" : ((double)Value / 100).ToString("#0.00"));
            var MxTime = (Maximum >= 10000 ? "99.99" : ((double)Maximum / 100).ToString("#0.00"));

            e.Graphics.DrawString(String.Format("{0} / {1}", NwTime, MxTime),
                f, Brushes.White, new Point(ClientSize.Width - 80, 4));

            backBrush.Dispose();
            foreBrush.Dispose();
        }
コード例 #51
0
        private void DrawString(Graphics g, String str, Color colour, FPoint pt)
        {
            Font drawFont = new System.Drawing.Font("Arial", (int)(scale / textScalingFactor)); // 16);

            // break lines into single lines by recursively calling DrawString
            string[] lines = str.Split(new String[] { "\r\n" }, StringSplitOptions.None);
            if (lines.Length > 1)
            {
                for (int i = 0; i < lines.Length; i++)
                {
                    Size   textSize     = TextRenderer.MeasureText(lines[i], drawFont);
                    FPoint drawLocation = pt;

                    drawLocation.Y += ((textSize.Height + 3) * i);
                    DrawString(g, lines[i], colour, drawLocation);
                }
                drawFont.Dispose();
                return;
            }

            System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(colour);
            float x = pt.X;
            float y = pt.Y;

            g.DrawString(str, drawFont, drawBrush, x, y);
            drawBrush.Dispose();
            drawFont.Dispose();
        }
コード例 #52
0
ファイル: ImageConverter.cs プロジェクト: spncrgr/Embroidery
        public Bitmap CombineBitmap(Bitmap image)
        {
            Bitmap finalImage = new Bitmap(image.Width, image.Height);

            using (Graphics g = Graphics.FromImage(finalImage))
            {
                g.Clear(System.Drawing.Color.White);

                for (int x = 0; x < image.Width; x += GridItemSize)
                {
                    int _y = 0;

                    for (int y = 0; y < image.Height; y += GridItemSize)
                    {
                        System.Drawing.Color      color   = GetGeneralColor(image, x, y);
                        System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(color);
                        g.FillRectangle(myBrush, new System.Drawing.Rectangle(x, y, GridItemSize, GridItemSize));
                        //g.DrawLine(new System.Drawing.Pen(System.Drawing.Color.SlateGray), new System.Drawing.Point(x, y), new System.Drawing.Point(x, y + GridItemSize));
                        //g.DrawLine(new System.Drawing.Pen(System.Drawing.Color.SlateGray), new System.Drawing.Point(x, _y), new System.Drawing.Point(x + GridItemSize, _y));
                        myBrush.Dispose();
                        _y = y;
                    }
                }
            }

            return(finalImage);
        }
コード例 #53
0
        public void Render(Graphics g, Point graphStart)
        {
            int graphBaseWidth = 400;
            int graphRange     = (int)Math.Abs(MinRange - MaxRange);
            int graphHeight    = 80;
            Pen graphColor     = new Pen(Color.DeepPink, 3);

            g.DrawLine(graphColor, graphStart.X, graphStart.Y, graphStart.X, graphStart.Y + graphHeight);
            g.DrawLine(graphColor, graphStart.X, graphStart.Y + graphHeight, graphStart.X + graphBaseWidth, graphStart.Y + graphHeight);


            foreach (KeyValuePair <string, FuzzySet> f in MemberSets)
            {
                f.Value.Render(g, graphStart, graphBaseWidth, graphHeight, graphRange);
            }
            for (int i = 0; i < 11; i++)
            {
                g.DrawEllipse(new Pen(Color.Red), graphStart.X + (i * (graphBaseWidth / 10)) - 1, graphStart.Y + graphHeight - 1, 2, 2);
                g.DrawLine(new Pen(Color.Red), graphStart.X + (i * (graphBaseWidth / 10)), graphStart.Y + graphHeight, graphStart.X + (i * (graphBaseWidth / 10)), graphStart.Y);
                string drawString = ((graphRange / 10) * i).ToString();
                System.Drawing.Font       drawFont  = new System.Drawing.Font("Arial", 8);
                System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
                float x = graphStart.X + (i * (graphBaseWidth / 10));
                float y = graphStart.Y + graphHeight + 7;
                System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
                g.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
                drawFont.Dispose();
                drawBrush.Dispose();
            }
        }
コード例 #54
0
        // Make an icon from month number to show in tray bar
        static Image Generate(String text)
        {
            Image img = new Bitmap(1, 1);
            using (Graphics drawing = Graphics.FromImage(img))
            {

                Font font = new Font(SystemFonts.DefaultFont, FontStyle.Bold);
                SizeF textSize = drawing.MeasureString(text, font);
                Color textColor = Color.White;
                Color backColor = Color.Transparent;

                img.Dispose();
                drawing.Dispose();

                img = new Bitmap((int)textSize.Width, (int)textSize.Height);

                Graphics tmpDraw;
                tmpDraw = Graphics.FromImage(img);
                tmpDraw.Clear(backColor);

                Brush textBrush = new SolidBrush(textColor);
                tmpDraw.DrawString(text, font, textBrush, 0, 0);
                tmpDraw.Save();
                textBrush.Dispose();
            }

            return img;
        }
コード例 #55
0
ファイル: StyleStack.cs プロジェクト: gitter-badger/reko
 private SolidBrush CacheBrush(ref SolidBrush brInstance, SolidBrush brNew)
 {
     if (brInstance != null)
         brInstance.Dispose();
     brInstance = brNew;
     return brNew;
 }
コード例 #56
0
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     Color color = Color.FromArgb(0xcc, 0xd9, 0xea);
     Color color2 = Color.FromArgb(0xd9, 0xe3, 240);
     Color color3 = Color.FromArgb(0xe8, 0xee, 0xf7);
     Color color4 = Color.FromArgb(0xed, 0xf2, 0xf9);
     Color color5 = Color.FromArgb(240, 0xf4, 250);
     Color color6 = Color.FromArgb(0xf1, 0xf5, 0xfb);
     Rectangle rect = new Rectangle(0, 0, base.Width, 1);
     SolidBrush brush = new SolidBrush(color);
     e.Graphics.FillRectangle(brush, rect);
     rect = new Rectangle(0, 1, base.Width, 1);
     brush.Color = color2;
     e.Graphics.FillRectangle(brush, rect);
     rect = new Rectangle(0, 2, base.Width, 1);
     brush.Color = color3;
     e.Graphics.FillRectangle(brush, rect);
     rect = new Rectangle(0, 3, base.Width, 1);
     brush.Color = color3;
     e.Graphics.FillRectangle(brush, rect);
     rect = new Rectangle(0, 4, base.Width, 1);
     brush.Color = color4;
     e.Graphics.FillRectangle(brush, rect);
     rect = new Rectangle(0, 5, base.Width, 1);
     brush.Color = color5;
     e.Graphics.FillRectangle(brush, rect);
     rect = new Rectangle(0, 6, base.Width, base.Height - 5);
     brush.Color = color6;
     e.Graphics.FillRectangle(brush, rect);
     brush.Dispose();
 }
コード例 #57
0
ファイル: MediaPanel.cs プロジェクト: WesleyYep/ispyconnect
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);

            var g = pe.Graphics;
            if (Loading)
            {
                var txt = LocRm.GetString("Loading");
                var s = g.MeasureString(txt, MainForm.Drawfont);
                g.DrawString(txt, MainForm.Drawfont, MainForm.OverlayBrush, Convert.ToInt32(Width / 2) - s.Width / 2, Convert.ToInt32(Height / 2) - s.Height / 2);
            }

            if (SelectStart != Point.Empty && SelectEnd != Point.Empty)
            {
                var b = new SolidBrush(Color.White);
                var p = new Pen(b, 1) { DashStyle = DashStyle.Dash };
                g.DrawLine(p, SelectStart.X, SelectStart.Y, SelectStart.X, SelectEnd.Y);
                g.DrawLine(p, SelectStart.X, SelectEnd.Y, SelectEnd.X, SelectEnd.Y);
                g.DrawLine(p, SelectEnd.X, SelectEnd.Y, SelectEnd.X, SelectStart.Y);
                g.DrawLine(p, SelectEnd.X, SelectStart.Y, SelectStart.X, SelectStart.Y);

                b.Dispose();
                p.Dispose();
            }
        }
コード例 #58
0
        public void DrawString(PaintEventArgs e, string tenQuanBai, int size, int posX, int posY, Color MauChu)
        {
            System.Drawing.Graphics formGraphics = e.Graphics;
            string drawString = tenQuanBai;

            int fontResize = (int)(size * 0.5);

            System.Drawing.Font       drawFont  = new System.Drawing.Font("Arial", fontResize);
            System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(MauChu);

            System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();

            //Quan bai goc trai
            int rePosX1 = (int)(posX * 0.05);
            int rePosY1 = (int)(posY * 0.05);

            formGraphics.DrawString(drawString, drawFont, drawBrush, rePosX1, rePosY1, drawFormat);

            //Quan bai goc phai (1.33 la pt to pixel
            int rePosX2 = (int)(g_widthCard - rePosX1 - fontResize * 1.33);
            int rePosY2 = (int)(g_heightCard - rePosY1 - fontResize * 1.33);

            //Do so 10 2 kytu nen tru them ti xiu :<
            if (tenQuanBai == "10")
            {
                rePosX2 = (int)(g_widthCard - rePosX1 - fontResize * 2.2);
            }

            formGraphics.DrawString(drawString, drawFont, drawBrush, rePosX2, rePosY2, drawFormat);
            drawFont.Dispose();
            drawBrush.Dispose();
            formGraphics.Dispose();
        }
コード例 #59
0
ファイル: rc_input_control.cs プロジェクト: PlumpMath/UAV
        protected override void OnPaint(PaintEventArgs pe)
        {
            // Calling the base class OnPaint
            base.OnPaint(pe);

            // diplay mask
            System.Drawing.Font       drawFont       = new System.Drawing.Font(FontFamily.GenericMonospace, 8.0F);
            System.Drawing.SolidBrush drawBrush      = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            System.Drawing.SolidBrush drawBrushGreen = new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen);

            bmpBackground.MakeTransparent(Color.Yellow);
            pe.Graphics.DrawImageUnscaled(bmpBackground, 0, 0);

            for (int i = 0; i < RC_Channels; i++)
            {
                if (i < 12)     //do not draw above channel 12
                {
                    string strLabel = "";
                    if (i == 0)
                    {
                        strLabel = "Thr";
                    }
                    if (i == 1)
                    {
                        strLabel = "Pitch";
                    }
                    if (i == 2)
                    {
                        strLabel = "Roll";
                    }
                    if (i == 3)
                    {
                        strLabel = "Yaw";
                    }
                    if (i > 3)
                    {
                        strLabel = "Aux" + (i - 3);
                    }

                    pe.Graphics.DrawString(String.Format("{0:0}", strLabel), drawFont, drawBrush, 5, bar_pos[i] - 13);
                    pe.Graphics.DrawString(String.Format("{0:0}", RC_Values[i]), drawFont, drawBrush, 165, bar_pos[i] - 13);
                    int w = (int)((RC_Values[i] - 1000) / (double)(1000 / 120));
                    if (w < 0)
                    {
                        w = 0;
                    }
                    if (w > 120)
                    {
                        w = 120;
                    }

                    pe.Graphics.FillRectangle(drawBrushGreen, 40, bar_pos[i] - 10, w, 10);
                }
            }

            drawFont.Dispose();
            drawBrush.Dispose();
            drawBrushGreen.Dispose();
        }
コード例 #60
0
 public void Draw(ref Panel pnl)
 {
     System.Drawing.SolidBrush myBrush      = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
     System.Drawing.Graphics   formGraphics = pnl.CreateGraphics();
     formGraphics.FillRectangle(myBrush, new Rectangle(X, Y, 50, 50));
     myBrush.Dispose();
     formGraphics.Dispose();
 }