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


C# IGraphics.FillRectangle方法代码示例

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


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

示例1: PaintImp

        /// <summary>
        /// Paints the fragment
        /// </summary>
        /// <param name="g">the device to draw to</param>
        protected override void PaintImp(IGraphics g)
        {
            var offset = HtmlContainer != null ? HtmlContainer.ScrollOffset : PointF.Empty;
            var rect = new RectangleF(Bounds.X + offset.X, Bounds.Y + offset.Y, Bounds.Width, Bounds.Height);

            if (rect.Height > 2 && RenderUtils.IsColorVisible(ActualBackgroundColor))
            {
                g.FillRectangle(RenderUtils.GetSolidBrush(ActualBackgroundColor), rect.X, rect.Y, rect.Width, rect.Height);
            }

            var b1 = RenderUtils.GetSolidBrush(ActualBorderTopColor);
            BordersDrawHandler.DrawBorder(Border.Top, g, this, b1, rect);

            if (rect.Height > 1)
            {
                var b2 = RenderUtils.GetSolidBrush(ActualBorderLeftColor);
                BordersDrawHandler.DrawBorder(Border.Left, g, this, b2, rect);

                var b3 = RenderUtils.GetSolidBrush(ActualBorderRightColor);
                BordersDrawHandler.DrawBorder(Border.Right, g, this, b3, rect);

                var b4 = RenderUtils.GetSolidBrush(ActualBorderBottomColor);
                BordersDrawHandler.DrawBorder(Border.Bottom, g, this, b4, rect);
            }
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:29,代码来源:CssBoxHr.cs

示例2: OnRender

 protected override void OnRender(IGraphics g, Map map)
 {
     Brush brush = new SolidBrush(OpacityColor(Color.Red));
     RectangleF rect = g.Clip;
     g.FillRectangle(brush, 
         (int) rect.X, (int) rect.Y, 
         (int) rect.Width, (int) rect.Height);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:8,代码来源:MapDecorationTest.cs

示例3: DrawBulletTarget

 /// <summary>
 /// Method to draw half-transparent bullet-line & targeting-box (the size of a robot) on the battlefield. 
 /// The idea is to use this for visual debugging: Set start point to own robot's position, and end point 
 /// to where you mean the bullet to go. Then see if this really is where the bullet is heading: 
 /// 1) If the targeting-box is off the spot you wanted it, you got a bug in your target prediction code.
 /// 2) If the targeting-box is on the spot, but the bullet is off the line (and center of the box), you 
 ///    got a bug in your "gun turning and firing" code.
 /// </summary>
 public static void DrawBulletTarget(IGraphics graphics, Color drawColor, Point2D start, Point2D end)
 {
     // Set color to a semi-transparent one.
     Color halfTransparent = Color.FromArgb(128, drawColor);
     // Draw line and rectangle.
     graphics.DrawLine(new Pen(halfTransparent), (int)start.X, (int)start.Y, (int)end.X, (int)end.Y);
     graphics.FillRectangle(new SolidBrush(halfTransparent), (int)end.X - 18, (int)end.Y - 18, 36, 36);
 }
开发者ID:OleVedeler,项目名称:RoboCode,代码行数:16,代码来源:RoboHelpers.cs

示例4: OnPaintBackground

 protected internal override void OnPaintBackground(IGraphics g, int width, int height)
 {
     Brush b = new SolidBrush(Color.FromArgb(236, 233, 216));
     g.FillRectangle(b, 0, 0, width, height);
     Pen p = new Pen(Color.FromArgb(172, 168, 153));
     g.DrawLine(p, 0, height - 1, width, height - 1);
     g.DrawLine(p, width - 1, 0, width - 1, height);
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:8,代码来源:ScrollableControlSmallCornerView.cs

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

示例6: OnPaintBackground

 protected internal override sealed void OnPaintBackground(IGraphics g, int width, int height)
 {
     if (main == null){
         return;
     }
     if (main.BackColor.IsEmpty || main.BackColor == Color.Transparent){
         return;
     }
     Brush b = new SolidBrush(main.BackColor);
     g.FillRectangle(b, 0, 0, width, height);
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:11,代码来源:ScrollComponentView.cs

示例7: DrawMillimeterGridInPixels

        public static void DrawMillimeterGridInPixels(IGraphics g, Rectangle rectPx)
        {
            Dpi dpi = new Dpi(g.DpiX, g.DpiY);

            if (_millimeterGridBitmap == null)
                CreateMillimiterGridBrush(dpi);

            g.CompositingMode = CompositingMode.SourceCopy;

            _millimeterGridBrush.ResetTransform();
            _millimeterGridBrush.TranslateTransform(rectPx.Left, rectPx.Top);
            g.FillRectangle(_millimeterGridBrush, rectPx);

            g.CompositingMode = CompositingMode.SourceOver;
        }
开发者ID:filipkunc,项目名称:GLGraphics,代码行数:15,代码来源:Form1.cs

示例8: DoPaint

 private static void DoPaint(IGraphics g, Label label)
 {
     Rectangle2 rect = new Rectangle2(GraphUtils.ToPointF2(label.Location) , GraphUtils.ToSizeF2(label.Size) );
     g.FillRectangle(new Brush2(GraphUtils.ToColor2(label.BackColor)), rect.X, rect.Y, label.Width - label.Margin.Left - label.Margin.Right,
         label.Height - label.Margin.Top - label.Margin.Bottom);
     StringFormat2 format = new StringFormat2{Alignment = StringAlignment2.Near, LineAlignment = StringAlignment2.Near};
     g.DrawString(label.Text, GraphUtils.ToFont2(label.Font), new Brush2(GraphUtils.ToColor2(label.ForeColor)), rect, format);
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:8,代码来源:ExportGraphics.cs

示例9: Draw

        void Draw(IGraphics g)
        {
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            g.SmoothingMode = SmoothingMode.HighQuality;

            //g.SetClip(new Rectangle(50, 50, 200, 400));

            if (gridBrush == null)
            {
                gridBrush = new TextureBrush(Images.Grid_37px);
            }

            //gridBrush.ResetTransform();
            //gridBrush.TranslateTransform(100, 100);

            g.CompositingMode = CompositingMode.SourceCopy;
            gridBrush.ResetTransform();
            g.FillRectangle(gridBrush, glView1.ClientRectangle);
            g.CompositingMode = CompositingMode.SourceOver;

            g.HintTextBackgroundAction(HintBackground);

            //g.PageUnit = GraphicsUnit.Millimeter;
            //g.SmoothingMode = SmoothingMode.AntiAlias;
            string text = "12.5% 2/5 (1) + ms test...";

            g.DrawString(g.DpiX.ToString(), font1, Brushes.Black, new PointF(2, 2));

            StringFormat sf = new StringFormat();
            Rectangle rect = new Rectangle(100, 50, 400, 150);

            g.DrawRectangle(Pens.Black, rect);

            g.DrawString(text, font2, Brushes.Red, rect, sf);

            sf.Alignment = StringAlignment.Center;

            g.FillRectangle(Brushes.Black, new Rectangle(230, 50, 140, 40));
            g.DrawString(text, font1, Brushes.Yellow, rect, sf);

            sf.Alignment = StringAlignment.Far;

            g.DrawString(text, font2, Brushes.Green, rect, sf);

            sf.Alignment = StringAlignment.Near;
            sf.LineAlignment = StringAlignment.Center;

            g.DrawString(text, font1, Brushes.Blue, rect, sf);

            sf = new StringFormat();
            sf.Alignment = StringAlignment.Far;
            sf.LineAlignment = StringAlignment.Far;

            g.DrawString("Far, Far, PointF", font2, Brushes.Green, new PointF(100.0f, 150.0f), sf);

            sf = new StringFormat();
            sf.LineAlignment = StringAlignment.Far;

            g.DrawString(text, font1, Brushes.DarkCyan, rect, sf);

            List<PointF> points = new List<PointF>();

            for (float x = 0.0f; x < (float)Math.PI * 6.0f; x += 0.01f)
            {
                points.Add(new PointF(x * (float)Math.Cos(x), x * (float)Math.Sin(x)));
            }

            Matrix m = new Matrix();

            for (int y = 0; y < 5; y++)
            {
                for (int x = 0; x < 5; x++)
                {
                    m.Reset();
                    m.Translate(x * 50.0f + 200.0f, y * 50.0f + 300.0f);
                    g.Transform = m;
                    g.DrawLines(new Pen(Color.Blue, 0.0f), points.ToArray());
                }
            }

            g.ResetTransform();

            g.DrawRectangle(new Pen(Color.Red, 0), new Rectangle(50, 150, 24, 24));
            g.DrawImage(Images.NavigateDown_48px, new Rectangle(50, 150, 24, 24));

            if (transparentBitmap == null)
            {
                ColorMatrix matrix = new ColorMatrix();
                matrix.Matrix33 = 0.4f; //opacity 0 = completely transparent, 1 = completely opaque
                transparentBitmap = GraphicsHelpers.BitmapFromImageAndColorMatrix(Images.NavigateDown_48px, matrix);
            }

            g.DrawRectangle(new Pen(Color.Red, 0), new Rectangle(100, 150, 24, 24));
            g.DrawImage(transparentBitmap, new Rectangle(100, 150, 24, 24));

            using (HatchBrush hatchBrush = new HatchBrush(HatchStyle.LightUpwardDiagonal, Color.Black, Color.Transparent))
            {
                g.FillRectangle(hatchBrush, new Rectangle(10, 10, 100, 20));
            }

//.........这里部分代码省略.........
开发者ID:filipkunc,项目名称:GLGraphics,代码行数:101,代码来源:Form1.cs

示例10: OnPaintRowHeaderView

 protected internal virtual void OnPaintRowHeaderView(IGraphics g, int y, int height)
 {
     g.FillRectangle(Brushes.White, 0, 0, RowHeaderWidth, VisibleHeight);
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:4,代码来源:CompoundScrollableControl.cs

示例11: OnPaintMainView

 protected internal virtual void OnPaintMainView(IGraphics g, int x, int y, int width, int height)
 {
     g.FillRectangle(Brushes.White, 0, 0, VisibleWidth, VisibleHeight);
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:4,代码来源:CompoundScrollableControl.cs

示例12: RenderTextBox

        protected void RenderTextBox(IGraphics g, float x, float y, float textHeight, string teamName, string score)
        {
            var size = this.MeasureTextBox(g, textHeight, teamName, score);

            g.FillRectangle(
                UserboxBrush,
                new RectangleF(
                    new PointF(x, y),
                    new SizeF(size.Width, size.Height)));

            if (!string.IsNullOrEmpty(teamName))
            {
                float minWidth = TextXOffset * 2;
                if (!string.IsNullOrEmpty(score))
                {
                    minWidth += g.MeasureString(score, UserboxFont).Width + TextXOffset;
                }

                int nameLength = teamName.Length;
                string shortName = teamName;
                if (!string.IsNullOrEmpty(teamName))
                {
                    while (nameLength > 1 && g.MeasureString(shortName, UserboxFont).Width + minWidth > MinBracketWidth)
                    {
                        nameLength--;
                        shortName = teamName.Substring(0, nameLength) + "...";
                    }

                    minWidth += g.MeasureString(shortName, UserboxFont).Width;
                }

                g.DrawString(
                    shortName,
                    UserboxFont,
                    UserboxFontBrush,
                    new PointF(
                        x + TextXOffset,
                        y + TextYOffset));
            }

            if (!string.IsNullOrEmpty(score))
            {
                var scoreWidth = g.MeasureString(score, UserboxFont).Width;

                g.DrawString(
                    score,
                    UserboxFont,
                    UserboxFontBrush,
                    new PointF(
                        x + size.Width - scoreWidth - TextXOffset,
                        y + TextYOffset));
            }
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:53,代码来源:EliminationDecider.cs

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

示例14: PaintOnGraphicsVector

 protected void PaintOnGraphicsVector(IGraphics g, int width, int height)
 {
     if (scatterPlot == null) {
         return;
     }
     if (!area.IsEmpty){
         g.FillRectangle(Brushes.LightGray, 0, 0, width, height);
         g.FillRectangle(Brushes.White, area.X, area.Y, area.Width, area.Height);
     } else{
         g.FillRectangle(new SolidBrush(BackColor), 0, 0, width, height);
     }
     PaintGridVector(g, width, height);
     SymbolProperties[] gg = ArrayUtils.GetKeys(values);
     int[] counts = new int[gg.Length];
     for (int i = 0; i < counts.Length; i++){
         counts[i] = values[gg[i]].Count;
     }
     int[] o = ArrayUtils.Order(counts);
     Array.Reverse(o);
     gg = ArrayUtils.SubArray(gg, o);
     foreach (SymbolProperties g1 in gg){
         bool[,] vals = values[g1].Data;
         double[,] zvals = null;
         if (zValues != null){
             zvals = zValues[g1];
         }
         for (int i = 0; i < width; i++){
             for (int j = 0; j < height; j++){
                 if (vals[i, j]){
                     Color color;
                     if (zvals != null && !double.IsNaN(zvals[i, j]) && colorScale != null){
                         color = colorScale.GetColor(zvals[i, j]);
                     } else{
                         color = g1.Color;
                     }
                     Pen p = new Pen(color);
                     Brush b = new SolidBrush(color);
                     SymbolType symbolType = SymbolType.allSymbols[g1.Type];
                     int symbolSize = g1.Size;
                     if (symbolSize == 0){
                         continue;
                     }
                     int[] pathX;
                     int[] pathY;
                     symbolType.GetPath(symbolSize, out pathX, out pathY);
                     symbolType.Draw(symbolSize, i, j, g, p, b);
                 }
             }
         }
     }
     // selected data points
     Brush selectionBrush = new SolidBrush(SelectionColor);
     Pen selectionPen = new Pen(SelectionColor);
     foreach (int s in scatterPlot.Selection){
         double[] w = scatterPlot.GetDataAt(s);
         if (w.Length > 0){
             double x = w[0];
             double y = w[1];
             SymbolProperties gx = GetPointProperties != null ? GetPointProperties(s) : defaultSymbol;
             SymbolType symbolType = SymbolType.allSymbols[gx.Type];
             int symbolSize = gx.Size;
             if (symbolSize > 0){
                 symbolType.Draw(symbolSize, ModelToViewX(x, width), ModelToViewY(y, height), g, selectionPen, selectionBrush);
             }
         }
     }
     // labels
     ScatterPlotLabelMode labelMode = scatterPlot.GetLabelMode();
     bool cutLabels = scatterPlot.CutLabels;
     if (labelMode == ScatterPlotLabelMode.All && scatterPlot.HasLabels) {
         Font font = new Font("Arial", scatterPlot.FontSize, scatterPlot.FontStyle);
         for (;;){
             double[] x;
             double[] y;
             double[] z;
             string[] labels;
             int index;
             scatterPlot.GetData(out x, out y, out z, out labels, out index);
             if (x == null){
                 break;
             }
             SymbolProperties gx = GetPointProperties != null ? GetPointProperties(index) : defaultSymbol;
             for (int i = 0; i < x.Length; i++){
                 if (labelMode == ScatterPlotLabelMode.All || scatterPlot.IsSelected(i)) {
                     int ix = ModelToViewX(x[i], width);
                     int iy = ModelToViewY(y[i], height);
                     Color c;
                     if (z != null && colorScale != null){
                         c = colorScale.GetColor(z[i]);
                     } else{
                         c = gx.Color;
                     }
                     Brush b = new SolidBrush(c);
                     if (ix >= 0 && iy >= 0 && ix < width && iy < height){
                         if (labels[i] != null){
                             string s = labels[i];
                             if (cutLabels){
                                 if (s.Contains(";")){
                                     s = s.Substring(0, s.IndexOf(';'));
                                 }
//.........这里部分代码省略.........
开发者ID:neuhauser,项目名称:compbio-base,代码行数:101,代码来源:ScatterPlotPlaneView.cs

示例15: PaintIndicator

 private void PaintIndicator(IGraphics g, int width, int height)
 {
     Brush2 indicatorBrush = new Brush2(IndicatorColor);
     Pen2 indicatorPen = new Pen2(ForeColor);
     float len = GetDeltaIndicator(GetLength(width, height));
     if (IsHorizontal()){
         if (len >= 1){
             g.FillRectangle(indicatorBrush, GetMinIndicator(GetLength(width, height)), 0, len, height - 1);
             g.DrawRectangle(indicatorPen, GetMinIndicator(GetLength(width, height)), 0, len, height - 1);
         } else{
             g.DrawLine(indicatorPen, GetMinIndicator(GetLength(width, height)), 0, GetMinIndicator(GetLength(width, height)),
                 height - 1);
         }
     } else{
         if (len >= 1){
             g.FillRectangle(indicatorBrush, 0, GetMinIndicator(GetLength(width, height)), width - 1, len);
             g.DrawRectangle(indicatorPen, 0, GetMinIndicator(GetLength(width, height)), width - 1, len);
         } else{
             g.DrawLine(indicatorPen, 0, GetMinIndicator(GetLength(width, height)), width - 1,
                 GetMinIndicator(GetLength(width, height)));
         }
     }
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:23,代码来源:NumericAxisView.cs


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