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


C# IGraphics.DrawRectangle方法代码示例

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


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

示例1: OnPaint

        public override void OnPaint(IGraphics g)
        {
            // Draw a line from our robot to the scanned robot
            g.DrawLine(new Pen(Color.Red),  targetX, targetY, (int)X, (int)Y);

            // Draw a filled square on top of the scanned robot that covers it
            g.DrawRectangle(new Pen(Color.Red), targetX - 20, targetY - 20, 40, 40);
        }
开发者ID:stdcallua,项目名称:Robots,代码行数:8,代码来源:Dog.cs

示例2: DoPaintBackground

 public static void DoPaintBackground(IGraphics g, Control control)
 {
     if (g is CGraphics && (!control.BackColor.IsEmpty && control.BackColor != Color.Transparent)){
         g.FillRectangle(new Brush2(GraphUtils.ToColor2(control.BackColor)), control.Location.X, control.Location.Y, control.Width,
             control.Height);
     }
     (control as BasicControl)?.view.Print(g, control.Width, control.Height);
     if (control is Panel && ((Panel) control).BorderStyle == BorderStyle.FixedSingle){
         g.DrawRectangle(new Pen2(GraphUtils.ToColor2(control.ForeColor)), control.Location.X, control.Location.Y, control.Width, control.Height);
     }
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:11,代码来源:ExportGraphics.cs

示例3: Draw

 public void Draw(IGraphics graphics)
 {
     switch (status)
     {
         case GameManagerStatus.Title:
             title.Draw(graphics);
             break;
         case GameManagerStatus.Game:
             game.Draw(graphics);
             break;
         case GameManagerStatus.BossEnd:
             graphics.SetColor(255, 255, 255, 255);
             graphics.DrawRectangle(0, 0, Game.FieldWidth, Game.FieldHeight);
             break;
         case GameManagerStatus.GameOver:
             game.Draw(graphics);
             gameOver.Draw(graphics);
             break;
         case GameManagerStatus.Ranking:
             ranking.Draw(graphics);
             break;
     }
 }
开发者ID:sinshu,项目名称:dtf,代码行数:23,代码来源:GameManager.cs

示例4: DrawBackground

 public override void DrawBackground(IGraphics graphics)
 {
     graphics.SetColor(255, 0, 0, 0);
     graphics.DrawRectangle(0, 0, Game.FieldWidth, Game.FieldHeight);
     graphics.EnableAddBlend();
     graphics.SetColor(255, 255, 255, 255);
     /*
     for (int i = 0; i < NUM_STARS / 4; i++)
     {
         graphics.DrawBackground(Image.Star, starX[i] - 4, starY[i] - 4, 8, 8, 0, 0, BackgroundStretch);
     }
     */
     for (int i = NUM_STARS / 4; i < NUM_STARS / 2; i++)
     {
         graphics.DrawBackground(Image.Star, starX[i] - 4, starY[i] - 4, 8, 8, 0, 1, BackgroundStretch);
     }
     graphics.SetColor(255, 128, 128, 128);
     for (int i = NUM_STARS / 2; i < NUM_STARS; i++)
     {
         graphics.DrawBackground(Image.Star, starX[i] - 4, starY[i] - 4, 8, 8, 0, 1, BackgroundStretch);
     }
     graphics.DisableAddBlend();
 }
开发者ID:sinshu,项目名称:dtf,代码行数:23,代码来源:StarBackgroundGame.cs

示例5: DrawGroupBox

 private void DrawGroupBox(IGraphics g)
 {
     // Get windows to draw the GroupBox
     Rectangle bounds = new Rectangle(ClientRectangle.X + Margin.Left, ClientRectangle.Y + Margin.Top + Padding.Top,
         ClientRectangle.Width - Margin.Left - Margin.Right,
         ClientRectangle.Height - Margin.Top - Margin.Bottom - Padding.Top);
     g.DrawRectangle(BackColor != SystemColors.Control ? SystemPens.Control : new Pen(Color.Black), bounds.X, bounds.Y,
         bounds.Width, bounds.Height, 5, RectangleCorners.All);
     // Text Formating positioning & Size
     int iTextPos = (bounds.X + 8) + mToggleRect.Width + 2;
     int iTextSize = (int) g.MeasureString(Text, Font).Width;
     iTextSize = iTextSize < 1 ? 1 : iTextSize;
     int iEndPos = iTextPos + iTextSize + 1;
     // Draw a line to cover the GroupBox border where the text will sit
     if (g is CGraphics){
         g.DrawLine(SystemPens.Control, iTextPos, bounds.Y, iEndPos, bounds.Y);
     }
     // Draw the GroupBox text
     using (SolidBrush drawBrush = new SolidBrush(Color.FromArgb(0, 70, 213))){
         g.DrawString(Text, Font, drawBrush, iTextPos, bounds.Y - (Font.Height*0.5f));
     }
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:22,代码来源:CollapsibleGroupBox.cs

示例6: Draw

        void Draw(IGraphics g, DrawingMode mode)
        {
            g.SmoothingMode = checkBoxAntialiasing.Checked ? SmoothingMode.HighQuality : SmoothingMode.None;
            g.Clear(Color.White);

            DrawMillimeterGridInPixels(g, tabControl1.SelectedTab.Controls[0].ClientRectangle);

            g.PageUnit = GraphicsUnit.Millimeter;

            var points = _noisePoints;

            DrawLines(g, points, mode);

            g.ResetTransform();

            var path = CreateRoundedRectanglePath(new RectangleF(10, 10, 100, 40), 10);

            g.FillPath(new SolidBrush(Color.FromArgb(120, Color.LightSlateGray)), path);
            g.DrawPath(new Pen(Color.LightSlateGray, 0.0f), path);

            g.FillPie(new SolidBrush(Color.FromArgb(120, Color.CadetBlue)), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f);
            g.DrawPie(new Pen(Color.CadetBlue, 0.0f), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f);

            //GLGraphics gl = g as GLGraphics;
            //if (gl != null)
            //    gl.FillTextBackground = gl.FillTextBackground_glReadPixels;

            g.PageUnit = GraphicsUnit.Pixel;
            RectangleF rect = new RectangleF(30.0f, 15.0f, _testImage.Width, _testImage.Height);
            g.DrawImage(_testImage, rect);
            g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);

            g.PageUnit = GraphicsUnit.Millimeter;

            g.HintTextBackgroundAction((gdi, textLocation, textRect) =>
            {
                _millimeterGridBrush.ResetTransform();
                _millimeterGridBrush.TranslateTransform(-textLocation.X, -textLocation.Y);
                gdi.FillRectangle(_millimeterGridBrush, textRect);
            });

            g.DrawString("Testovací řetězec pro odzkoušení správné implementace IGraphics - metody DrawString.",
                new Font("Arial", 12.0f), Brushes.Black, new PointF(100.0f, 58.0f));
        }
开发者ID:filipkunc,项目名称:GLGraphics,代码行数:44,代码来源:Form1.cs

示例7: RenderCellColor

 private static void RenderCellColor(IGraphics g, bool selected, object o, int x1, int y1)
 {
     Color c = (Color) o;
     Brush b = new SolidBrush(c);
     Pen p = selected ? Pens.White : Pens.Black;
     const int w = 14;
     g.FillRectangle(b, x1 + 3, y1 + 4, w, w);
     g.DrawRectangle(p, x1 + 3, y1 + 4, w, w);
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:9,代码来源:TableView.cs

示例8: DrawStatus

 public void DrawStatus(IGraphics graphics)
 {
     graphics.SetColor(255, 128, 192, 255);
     graphics.DrawRectangle(480, 0, 160, 480);
     graphics.SetColor(255, 255, 255, 255);
     graphics.DrawImage(Image.Hud, FIELD_WIDTH + 16 + 2, 32 + 8 + 4, 128, 64, 2, 0);
     graphics.DrawImage(Image.Hud, FIELD_WIDTH + 16 - 2, 32 + 8 - 4, 128, 64, 1, 0);
     graphics.SetColor(255, 255, 255, 255);
     graphics.DrawString("TOP SCORE", (640 - FIELD_WIDTH - 9 * 16) / 2 + FIELD_WIDTH, 128 + 8);
     {
         string s = highScore.ToString();
         graphics.DrawString(s, (640 - FIELD_WIDTH - s.Length * 16) / 2 + FIELD_WIDTH, 160 + 8);
     }
     graphics.DrawString("SCORE", (640 - FIELD_WIDTH - 5 * 16) / 2 + FIELD_WIDTH, 208 + 8);
     {
         string s = score.ToString();
         graphics.DrawString(s, (640 - FIELD_WIDTH - s.Length * 16) / 2 + FIELD_WIDTH, 240 + 8);
     }
     graphics.DrawString("LEVEL", (640 - FIELD_WIDTH - 5 * 16) / 2 + FIELD_WIDTH, 288 + 8);
     {
         string s = Level.ToString();
         graphics.DrawString(s, (640 - FIELD_WIDTH - s.Length * 16) / 2 + FIELD_WIDTH, 320 + 8);
     }
     graphics.DrawString("LEFT", (640 - FIELD_WIDTH - 4 * 16) / 2 + FIELD_WIDTH, 368 + 8);
     {
         int drawX = (640 - FIELD_WIDTH - (left * 40 - 8)) / 2 + FIELD_WIDTH;
         for (int i = 0; i < left; i++)
         {
             graphics.DrawImage(Image.Player, drawX + i * 40, 400 + 8, 32, 32, 0, 0);
         }
     }
 }
开发者ID:sinshu,项目名称:dtf,代码行数:32,代码来源:Game.cs

示例9: Draw

        public virtual void Draw(IGraphics graphics)
        {
            DrawBackground(graphics);
            foreach (Enemy enemy in enemyList)
            {
                enemy.Draw(graphics);
            }
            foreach (Bullet bullet in playerBulletList)
            {
                bullet.Draw(graphics);
            }
            foreach (Effect effect in effectList)
            {
                effect.Draw(graphics);
            }
            foreach (Bullet bullet in enemyBulletList)
            {
                bullet.Draw(graphics);
            }
            player.Draw(graphics);
            if (ticks < 8)
            {
                int alpha = (8 - ticks) * 32;
                if (alpha > 255)
                {
                    alpha = 255;
                }
                graphics.SetColor(alpha, 255, 255, 255);
                graphics.DrawRectangle(0, 0, FIELD_WIDTH, FIELD_HEIGHT);
            }
            if (left > 0)
            {
                if (playerDeadTicks > 30 - 8)
                {
                    int alpha = (playerDeadTicks - (30 - 8)) * 32;
                    if (alpha > 255)
                    {
                        alpha = 255;
                    }
                    graphics.SetColor(alpha, 255, 255, 255);
                    graphics.DrawRectangle(0, 0, FIELD_WIDTH, FIELD_HEIGHT);
                }
            }
            if (!player.IsDead)
            {
                if (warpTicks > 60 - 32)
                {
                    graphics.EnableAddBlend();
                    for (int i = 0; i < (warpTicks - (60 - 32)) * 8; i++)
                    {
                        int drawLen = (warpTicks - 32) * 16;
                        int drawX = drawRandom.Next(FIELD_WIDTH);
                        int drawY = drawRandom.Next(FIELD_HEIGHT + drawLen * 2) - drawLen;
                        switch (i % 3)
                        {
                            case 0:
                                graphics.SetColor(255, 255, 0, 0);
                                break;
                            case 1:
                                graphics.SetColor(255, 0, 255, 0);
                                break;
                            case 2:
                                graphics.SetColor(255, 0, 0, 255);
                                break;
                        }
                        graphics.DrawRectangle(drawX, drawY, 1, drawLen);
                    }
                    graphics.DisableAddBlend();

                    int alpha = (warpTicks - (60 - 32)) * 8;
                    if (alpha > 255)
                    {
                        alpha = 255;
                    }
                    graphics.SetColor(alpha, 255, 255, 255);
                    graphics.DrawRectangle(0, 0, FIELD_WIDTH, FIELD_HEIGHT);
                }
            }
            if (player.IsDead && !gameOver)
            {
                graphics.SetColor(255, 255, 0, 0);
                DrawStringCenter(graphics, "MISS");
            }
            else if (warping)
            {
                DrawClear(graphics);
            }
            else if (ticks < 60)
            {
                DrawLevel(graphics);
            }
            DrawStatus(graphics);
        }
开发者ID:sinshu,项目名称:dtf,代码行数:93,代码来源:Game.cs

示例10: RenderRectangle

 private static void RenderRectangle(IGraphics g, int x, int y, int width, int height, Pen pen, Brush brush)
 {
     if (brush != null)
         g.FillRectangle(brush, x, y, width, height);
     g.DrawRectangle(pen, x, y, width, height);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:6,代码来源:ScaleBar.cs

示例11: DrawZoomBox

        private void DrawZoomBox(IGraphics g, WorldTransform transform, Coordinates start, Coordinates end)
        {
            float x, y;
            float width, height;

            if (start.X < end.X) {
                x = (float)start.X;
                width = (float)(end.X - start.X);
            }
            else {
                x = (float)end.X;
                width = (float)(start.X - end.X);
            }

            if (start.Y < end.Y) {
                y = (float)start.Y;
                height = (float)(end.Y - start.Y);
            }
            else {
                y = (float)end.Y;
                height = (float)(start.Y - end.Y);
            }

            // create the rectangle
            RectangleF rect = new RectangleF(x, y, width, height);

            // draw the transparent background
            g.FillRectangle(Color.FromArgb(50, Color.Purple), rect);

            IPen pen = g.CreatePen();
            pen.Width = 1.0f/transform.Scale;
            pen.Color = Color.Purple;

            g.DrawRectangle(pen, rect);

            pen.Dispose();
        }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:37,代码来源:ZoomTool.cs

示例12: PaintOverview

        public static void PaintOverview(IGraphics g, SizeI2 totalSize, RectangleI2 visibleWin,
			Func<int, int, Bitmap2> getOverviewBitmap, float zoomFactorX, float zoomFactorY)
        {
            Size2 overview = CalcOverviewSize(visibleWin.Width, visibleWin.Height, totalSize.Width, totalSize.Height);
            Rectangle2 win = CalcWin(overview, totalSize, visibleWin, zoomFactorX, zoomFactorY);
            g.FillRectangle(Brushes2.White, 0, visibleWin.Height - overview.Height, overview.Width, overview.Height);
            g.DrawImageUnscaled(getOverviewBitmap((int) overview.Width, (int) overview.Height), 0,
                visibleWin.Height - overview.Height);
            Brush2 b = new Brush2(Color2.FromArgb(30, 0, 0, 255));
            if (win.X > 0){
                g.FillRectangle(b, 0, visibleWin.Height - overview.Height, win.X, overview.Height);
            }
            if (overview.Width - win.X - win.Width > 0){
                g.FillRectangle(b, win.X + win.Width, visibleWin.Height - overview.Height, overview.Width - win.X - win.Width,
                    overview.Height);
            }
            if (win.Y > 0){
                g.FillRectangle(b, win.X, visibleWin.Height - overview.Height, win.Width, win.Y);
            }
            if (overview.Height - win.Y - win.Height > 0){
                g.FillRectangle(b, win.X, visibleWin.Height - overview.Height + win.Y + win.Height - 1, win.Width,
                    overview.Height - win.Y - win.Height);
            }
            g.DrawRectangle(Pens2.Black, 0, visibleWin.Height - overview.Height - 1, overview.Width, overview.Height);
            g.DrawRectangle(Pens2.Blue, win.X, visibleWin.Height - overview.Height - 1 + win.Y, win.Width, win.Height);
        }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:26,代码来源:GraphUtil.cs

示例13: DoPaint

 internal static void DoPaint(IGraphics g, Panel control, int addx, int addy)
 {
     g.FillRectangle(new Brush2(GraphUtils.ToColor2(control.BackColor) ), 0, 0, control.Width, control.Height);
     if (control.BorderStyle == BorderStyle.FixedSingle){
         g.DrawRectangle(new Pen2(GraphUtils.ToColor2(control.ForeColor)), 0, 0, control.Width, control.Height);
     }
     if (control is TableLayoutPanel){
         DoPaint(g, (Control) control, addx, addy);
     } else{
         foreach (Control c in control.Controls){
             if (c is BasicControl){
                 Debug.WriteLine("- BasicControl");
                 g.SetClippingMask(c.Width, c.Height, control.Location.X + c.Location.X + addx,
                     control.Location.Y + c.Location.Y + addy);
                 ((BasicControl) c).view.Print(g, c.Width, c.Height);
             } else{
                 DoPaint(g, c);
             }
         }
     }
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:21,代码来源:ExportGraphics.cs

示例14: PaintImp

        /// <summary>
        /// Paints the fragment
        /// </summary>
        /// <param name="g">the device to draw to</param>
        protected override void PaintImp(IGraphics g)
        {
            // load image iff it is in visible rectangle
            if (_imageLoadHandler == null)
            {
                _imageLoadHandler = new ImageLoadHandler(OnLoadImageComplete);
                _imageLoadHandler.LoadImage(HtmlContainer, GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
            }

            var rect = CommonUtils.GetFirstValueOrDefault(Rectangles);
            PointF offset = HtmlContainer.ScrollOffset;
            rect.Offset(offset);

            var prevClip = RenderUtils.ClipGraphicsByOverflow(g, this);

            PaintBackground(g, rect, true, true);
            BordersDrawHandler.DrawBoxBorders(g, this, rect, true, true);

            RectangleF r = _imageWord.Rectangle;
            r.Offset(offset);
            r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom;
            r.Y += ActualBorderTopWidth + ActualPaddingTop;

            if (_imageWord.Image != null)
            {
                if (_imageWord.ImageRectangle == Rectangle.Empty)
                    g.DrawImage(_imageWord.Image, Rectangle.Round(r));
                else
                    g.DrawImage(_imageWord.Image, Rectangle.Round(r), _imageWord.ImageRectangle);

                if (_imageWord.Selected)
                {
                    g.FillRectangle(GetSelectionBackBrush(true), _imageWord.Left + offset.X, _imageWord.Top + offset.Y, _imageWord.Width+2, DomUtils.GetCssLineBoxByWord(_imageWord).LineHeight);
                }
            }
            else if (_imageLoadingComplete)
            {
                if (_imageLoadingComplete && r.Width > 19 && r.Height > 19)
                {
                    RenderUtils.DrawImageErrorIcon(g, r);
                }
            }
            else
            {
                RenderUtils.DrawImageLoadingIcon(g, r);
                if (r.Width > 19 && r.Height > 19)
                {
                    g.DrawRectangle(Pens.LightGray, r.X, r.Y, r.Width, r.Height);
                }
            }

            RenderUtils.ReturnClip(g, prevClip);
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:57,代码来源:CssBoxImage.cs

示例15: DrawRect

            private static void DrawRect(IGraphics canvas, string id, Rectangle rect, StringAlignment horizontalAlignment, StringAlignment verticalAlignment)
            {
                var format = new StringFormat();
                format.Alignment = horizontalAlignment;
                format.LineAlignment = verticalAlignment;
                format.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.NoClip;

                var pen = new Pen(new SolidBrush(Color.Black), 1);
                canvas.DrawRectangle(pen, rect);

                var aFont = System.Windows.Forms.Control.DefaultFont;
                var font = new Font(aFont.Name, RectFontSize, aFont.Style, aFont.Unit);

                {
                    // Draw label
                    var labelFormat = new StringFormat();
                    labelFormat.Alignment = StringAlignment.Near;
                    labelFormat.LineAlignment = StringAlignment.Center;
                    labelFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.NoClip;
                    var labelRect = new Rectangle(rect.X, rect.Y - RectGap, RectGap, RectGap);
                    var labelFont = new Font(aFont.Name, RectFontSize * 0.8f, aFont.Style, aFont.Unit);
                    canvas.DrawString(id, labelFont, new SolidBrush(Color.Black), labelRect, labelFormat);
                }

                canvas.DrawString("Helloy", font, new SolidBrush(Color.Blue), rect, format);
            }
开发者ID:hnafar,项目名称:SvgNet,代码行数:26,代码来源:Form1.cs


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