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


C# Graphics.DrawRectangles方法代码示例

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


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

示例1: Debug

        /// <summary>
        /// Черае всички rayCast кутии + Всички collision кутии ако debugCollision е true
        /// </summary>
        /// <param name="g"></param>
        /// <param name="debugCollisions">Да чертае ли всички collision кутии</param>
        public void Debug(Graphics g, bool debugCollisions)
        {
            Pen debugColor = new Pen(Color.Red);

            if (debugCollisions)
            {
                allGameObjects.ForEach(obj => somethingToDebug.Add(obj.rectangle));

            if(somethingToDebug.Count > 0)
                g.DrawRectangles(debugColor, somethingToDebug.ToArray());

            }

            somethingToDebug.Clear();
        }
开发者ID:LyuboslavLyubenov,项目名称:C--Advanced-Team-Project,代码行数:20,代码来源:Collision.cs

示例2: DrawSegments

        void DrawSegments(Graphics grfx, RectangleF rectClip)
        {
            int penWidth = 3;

            if (LicenseManager.UsageMode == LicenseUsageMode.Runtime)
            {
                //рисование границ кубов
                if (PresentationController.Instance != null && PresentationController.Instance.CurrentSlideLayout != null)
                {
                    ISegmentationSupport disp = PresentationController.Instance.CurrentSlideLayout.Display as ISegmentationSupport;
                    if (disp != null)
                    {
                        float x = 0;
                        float y = 0;
                        List<RectangleF> rects = new List<RectangleF>();
                        for (int i = 0; i < disp.SegmentColumns; ++i)
                        {
                            for (int j = 0; j < disp.SegmentRows; j++)
                            {
                                RectangleF rect = new RectangleF(x, y, disp.SegmentWidth, disp.SegmentHeight);

                                if (rect.IntersectsWith(rectClip))
                                    rects.Add(rect);

                                y += disp.SegmentHeight + penWidth + 1;
                            }

                            x += disp.SegmentWidth + penWidth + 1;
                            y = 0;
                        }

                        if (rects.Count > 0)
                        {
                            Pen p = new Pen(new SolidBrush(Color.FromArgb(180, Color.Indigo)), penWidth);
                            p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                            grfx.DrawRectangles(p, rects.ToArray());
                        }
                    }
                }
            }
        }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:41,代码来源:SlideLayoutVeiw.cs

示例3: GenerateMap

 public void GenerateMap()
 {
     MapBox.CreateGraphics().Clear(AppWindow.DefaultBackColor);
     int w = 0, h = 0;
     try
     {
         w = Convert.ToInt32(TXTWidth.Text);
         h = Convert.ToInt32(TXTHeight.Text);
     }
     catch
     {
         Console.WriteLine("Input string is not a sequence of digits or Overflow");
         w = 20;
         h = 20;
     }
     paintMap = new Bitmap(MapBox.Size.Width, MapBox.Size.Height);
     g = Graphics.FromImage(paintMap);
     nodes = new MapNodes(w + 2, h + 2, MapBox.Size.Height); // + 2 is borders
     g.DrawRectangles(stdPen, nodes.nodeRect);
     FillBorderNodes();
     GenerateNoise();
     MapBox.Image = paintMap;
 }
开发者ID:imdigitaljim,项目名称:ProcGeneration,代码行数:23,代码来源:AppWindow.cs

示例4: histogramPanel_Paint

 private void histogramPanel_Paint(object sender, PaintEventArgs e)
 {
     Rectangle[] rectArr = new Rectangle[6]; 
     histogramGraphics = histogramPanel.CreateGraphics();
     for(int i = 0; i < quantityArray.Length; i++)
     {
         if(i==0)
         {
             Rectangle rect = new Rectangle(5, 388-quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 1)
         {
             Rectangle rect = new Rectangle(105, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 2)
         {
             Rectangle rect = new Rectangle(205, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 3)
         {
             Rectangle rect = new Rectangle(305, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 4)
         {
             Rectangle rect = new Rectangle(405, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
         if (i == 5)
         {
             Rectangle rect = new Rectangle(505, 388 - quantityArray[i], 100, quantityArray[i]);
             rectArr[i] = rect;
         }
     }
     histogramGraphics.DrawRectangles(myPen, rectArr);
 }
开发者ID:JakubOciepa,项目名称:UMK_2016,代码行数:39,代码来源:Form1.cs

示例5: Draw

        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            PointF pix1 = this.Location.TransformTopLeft(pane);
            PointF pix2 = this.Location.TransformBottomRight(pane);

            //RectangleF pixRect = this.Location.TransformRect(pane);
            RectangleF pixRect = new RectangleF(Math.Min(pix1.X, pix2.X), Math.Min(pix1.Y, pix2.Y),
                            Math.Abs(pix2.X - pix1.X), Math.Abs(pix2.Y - pix1.Y));

            //System.Diagnostics.Debug.WriteLine(string.Format("box {0} {1}", pix1, pix2));

            // Clip the rect to just outside the PaneRect so we don't end up with wild coordinates.
            RectangleF tmpRect = pane.Rect;
            tmpRect.Inflate(20, 20);
            pixRect.Intersect(tmpRect);

            if (Math.Abs(pixRect.Left) < 100000 &&
                Math.Abs(pixRect.Top) < 100000 &&
                Math.Abs(pixRect.Right) < 100000 &&
                Math.Abs(pixRect.Bottom) < 100000)
            {
                // If the box is to be filled, fill it
                _fill.Draw(g, pixRect);

                // Draw the border around the box if required
                //_border.Draw( g, pane, scaleFactor, pixRect );

                if (_border.IsVisible)
                {
                    var smode = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    RectangleF tRect = pixRect;

                    float scaledInflate = (float)(_border.InflateFactor * scaleFactor);
                    tRect.Inflate(scaledInflate, scaledInflate);

                    using (Pen pen = _border.GetPen(pane, scaleFactor))
                    {
                        if (IsMoving)
                        {
                            // Set the DashCap to round.
                            pen.DashCap = DashCap.Round;

                            // Create a custom dash pattern.
                            pen.DashPattern = new float[] { 4.0F, 4.0F };
                        }

                        g.DrawRectangle(pen, tRect.X, tRect.Y, tRect.Width, tRect.Height);

                        if (IsSelected)
                        {
                            Brush brush = new SolidBrush(Color.White);

                            g.FillRectangles(brush, EdgeRects(pane));

                            pen.DashStyle = DashStyle.Solid;

                            g.DrawRectangles(pen, EdgeRects(pane));
                        }
                    }

                    g.SmoothingMode = smode;
                }
            }
        }
开发者ID:sntree,项目名称:ZedGraph,代码行数:89,代码来源:BoxObj.cs

示例6: DrawAt

        public override void DrawAt(Point basePoint, Graphics g)
        {
            base.DrawAt(basePoint, g);

            Rectangle rect = new Rectangle(Point.Empty, this.RectInPage.Size);
            Bitmap bm = new Bitmap(this.RectInPage.Width, this.RectInPage.Height);
            Graphics gp = Graphics.FromImage(bm);

            Color backColor = Color.FromArgb((int)(this.Alpha * 255), this.BackgroundColor);

            if ((null == this.BackgroundImage) || (string.Empty == this.BackgroundImage))
            {
                if (EFlatStyle.Flat == this.FlatStyle)
                {
                    SolidBrush brush = new SolidBrush(backColor);
                    FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f);
                }
            }

            if (EBool.Yes == this.DisplayBorder)
            {
                Color borderColor = this.BorderColor;
                DrawRoundRectangle(gp, new Pen(borderColor, 1), rect, this.Radius, 1.0f);
            }

            g.DrawImage(bm,
                this.VisibleRectInPage,
                new Rectangle(new Point(this.VisibleRectInPage.X - this.RectInPage.X, this.VisibleRectInPage.Y - this.RectInPage.Y), this.VisibleRectInPage.Size),
                GraphicsUnit.Pixel);

            foreach (ViewNode node in this.Nodes)
            {
                if (MyConst.Controls.KnxGroupBoxType != node.Name)
                {
                    node.DrawAt(LocationInPage, g);
                }
            }

            foreach (ViewNode node in this.Nodes)
            {
                if (MyConst.Controls.KnxGroupBoxType == node.Name)
                {
                    node.DrawAt(LocationInPage, g);
                }
            }

            this.FrameIsVisible = false;
            if (ControlState.Move == this.State)
            {
                Pen pen = new Pen(Color.Navy, 2.0f);
                DrawRoundRectangle(g, pen, this.RectInPage, this.Radius, 1.0f);
            }
            else if (this.IsSelected)
            {
                this.SetFrame();
                Pen pen = new Pen(Color.LightGray, 1.0f);
                pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果
                g.DrawLine(pen, this.LinePoints[0], this.LinePoints[1]);
                g.DrawLine(pen, this.LinePoints[2], this.LinePoints[3]);
                g.DrawLine(pen, this.LinePoints[4], this.LinePoints[5]);
                g.DrawLine(pen, this.LinePoints[6], this.LinePoints[7]);
                g.DrawLine(pen, this.LinePoints[8], this.LinePoints[9]);
                g.DrawLine(pen, this.LinePoints[10], this.LinePoints[11]);
                g.DrawLine(pen, this.LinePoints[12], this.LinePoints[13]);
                g.DrawLine(pen, this.LinePoints[14], this.LinePoints[15]);

                g.FillRectangles(Brushes.White, this.SmallRects); //填充8个小矩形的内部
                g.DrawRectangles(Pens.Black, this.SmallRects);  //绘制8个小矩形的黑色边线

                this.FrameIsVisible = true;

                int centerX;
                int centerY;
                int SideMobile = 16;
                if ((this.LinePoints[1].X - this.LinePoints[0].X) > SideMobile)
                {
                    centerX = this.LinePoints[0].X + (this.LinePoints[1].X - this.LinePoints[0].X) / 2;
                    centerY = this.LinePoints[0].Y;
                }
                else
                {
                    centerX = this.SmallRects[0].X + this.SmallRects[0].Width / 2;
                    centerY = this.SmallRects[0].Y + this.SmallRects[0].Height / 2;
                }

                int lX = centerX - SideMobile / 2;
                int lY = centerY - SideMobile / 2;

                this.MobileRect = new Rectangle(new Point(lX, lY), new Size(SideMobile, SideMobile));

                g.DrawRectangle(Pens.Black, this.MobileRect);
                g.FillRectangle(Brushes.White, this.MobileRect);
                GraphicsPath path = new GraphicsPath();
                int x1 = this.MobileRect.X + this.MobileRect.Width / 2;
                int y1 = this.MobileRect.Y;

                int xr1 = x1 + 3;
                int yr1 = y1 + 3;

                int xl1 = x1 - 3;
//.........这里部分代码省略.........
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:101,代码来源:GroupBoxNode.cs

示例7: DrawHelper

        void DrawHelper(AnimationTrack track, Graphics g)
        {
            PointF[] helperPoints = GetHelperPoints(track);

            // helper bounds.
            PointF[] helperBound = new PointF[] {
                helperPoints[0],
                helperPoints[1],
                helperPoints[2],
                helperPoints[3],
                helperPoints[0]};

            // helper corner bounds.
            RectangleF[] helperRects = new RectangleF[]{
                new RectangleF( // top-left
                    helperPoints[0].X - HelperKitWidth * 0.5f, helperPoints[0].Y - HelperKitWidth * 0.5f,
                    HelperKitWidth, HelperKitWidth),
                new RectangleF( // top-right
                    helperPoints[1].X - HelperKitWidth * 0.5f, helperPoints[1].Y - HelperKitWidth * 0.5f,
                    HelperKitWidth, HelperKitWidth),
                new RectangleF( // bottom-left
                    helperPoints[2].X - HelperKitWidth * 0.5f, helperPoints[2].Y - HelperKitWidth * 0.5f,
                    HelperKitWidth, HelperKitWidth),
                new RectangleF( // bottom-right
                    helperPoints[3].X - HelperKitWidth * 0.5f, helperPoints[3].Y - HelperKitWidth * 0.5f,
                    HelperKitWidth, HelperKitWidth)};

            // helper center.
            PointF[] helperCenter = new PointF[] {
                helperPoints[4] - new SizeF(-HelperKitWidth, 0),
                helperPoints[4] - new SizeF(0, +HelperKitWidth),
                helperPoints[4] - new SizeF(+HelperKitWidth, 0),
                helperPoints[4] - new SizeF(0, -HelperKitWidth),
                helperPoints[4] - new SizeF(-HelperKitWidth, 0),
                helperPoints[4] - new SizeF(+HelperKitWidth, 0),
                helperPoints[4] - new SizeF(0, +HelperKitWidth),
                helperPoints[4] - new SizeF(0, -HelperKitWidth)};

            // draw the image.
            g.Transform = new Matrix();
            g.DrawLines(mHelperPen, helperBound);
            g.DrawRectangles(mHelperPen, helperRects);
            g.DrawLines(mHelperPen, helperCenter);
        }
开发者ID:gigiwotou,项目名称:GameEdit2,代码行数:44,代码来源:AnimationPreviewPanel.cs

示例8: DrawAt

        public override void DrawAt(Point basePoint, Graphics g)
        {
            base.DrawAt(basePoint, g);

            Rectangle rect = new Rectangle(Point.Empty, this.RectInPage.Size);
            Bitmap bm = new Bitmap(this.RectInPage.Width, this.RectInPage.Height);
            Graphics gp = Graphics.FromImage(bm);

            Color backColor = Color.FromArgb((int)(this.Alpha * 255), this.BackgroundColor);
            
            if ((null == this.BackgroundImage) || (string.Empty == this.BackgroundImage))
            {
                if (EFlatStyle.Stereo == this.FlatStyle)
                {
                    /* 绘制立体效果,三色渐变 */
                    LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical);
                    Color[] colors = new Color[3];
                    colors[0] = ColorHelper.changeBrightnessOfColor(backColor, 100);
                    colors[1] = backColor;
                    colors[2] = ColorHelper.changeBrightnessOfColor(backColor, -50);
                    ColorBlend blend = new ColorBlend();
                    blend.Positions = new float[] { 0.0f, 0.3f, 1.0f };
                    blend.Colors = colors;
                    brush.InterpolationColors = blend;
                    FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f);
                    brush.Dispose();
                }
                else if (EFlatStyle.Flat == this.FlatStyle)
                {
                    SolidBrush brush = new SolidBrush(backColor);
                    FillRoundRectangle(gp, brush, rect, this.Radius, 1.0f);
                    brush.Dispose();
                }
            }

            /* 文本 */
            if (null != this.Text)
            {
                int x = 5;
                int y = 5;
                int width = rect.Width - 2 * x;
                int height = rect.Height - 2 * y;

                Rectangle stateRect = new Rectangle(rect.X + x, rect.Y + y, width, height);
                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                Color fontColor = this.FontColor;
                gp.DrawString(this.Text, new Font("宋体", this.FontSize), new SolidBrush(fontColor), stateRect, sf);
            }

            if (EBool.Yes == this.DisplayBorder)
            {
                Color borderColor = this.BorderColor;
                DrawRoundRectangle(gp, new Pen(borderColor, 1), rect, this.Radius, 1.0f);
            }

            g.DrawImage(bm, 
                this.VisibleRectInPage,
                new Rectangle(new Point(this.VisibleRectInPage.X-this.RectInPage.X, this.VisibleRectInPage.Y-this.RectInPage.Y), this.VisibleRectInPage.Size),
                GraphicsUnit.Pixel);

            this.FrameIsVisible = false;
            if (ControlState.Move == this.State)
            {
                Pen pen = new Pen(Color.Navy, 2.0f);
                DrawRoundRectangle(g, pen, this.RectInPage, this.Radius, 1.0f);
            }
            else if (this.IsSelected)
            {
                this.SetFrame();
                Pen pen = new Pen(Color.LightGray, 1.0f);
                pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果
                g.DrawLine(pen, this.LinePoints[0], this.LinePoints[1]);
                g.DrawLine(pen, this.LinePoints[2], this.LinePoints[3]);
                g.DrawLine(pen, this.LinePoints[4], this.LinePoints[5]);
                g.DrawLine(pen, this.LinePoints[6], this.LinePoints[7]);
                g.DrawLine(pen, this.LinePoints[8], this.LinePoints[9]);
                g.DrawLine(pen, this.LinePoints[10], this.LinePoints[11]);
                g.DrawLine(pen, this.LinePoints[12], this.LinePoints[13]);
                g.DrawLine(pen, this.LinePoints[14], this.LinePoints[15]);

                g.FillRectangles(Brushes.White, this.SmallRects); //填充8个小矩形的内部
                g.DrawRectangles(Pens.Black, this.SmallRects);  //绘制8个小矩形的黑色边线

                this.FrameIsVisible = true;
            }
        }
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:88,代码来源:LabelNode.cs

示例9: drawNodes

        private void drawNodes(IEnumerable<ICoordinate> nodes, Graphics g, MapToClientDelegate MapToClient, Color color, int offsetX, int offsetY)
        {
            if (nodes.Count() <= 0)
                return;

            using (Pen p = new Pen(color))
            {
                Point[] points = new Point[nodes.Count()];

                int i = 0;
                foreach (ICoordinate c in nodes)
                {
                    points[i] = MapToClient(c);
                    points[i].X += offsetX;
                    points[i].Y += offsetY;
                    i++;
                }

                Rectangle[] rectangles = new Rectangle[points.Length];

                int ns = this.NodeSize;
                for (i = 0; i < points.Length; i++)
                    rectangles[i] = new Rectangle((int)points[i].X - ns,
                        (int)points[i].Y - ns, ns * 2, ns * 2);

                using (Brush b = new SolidBrush(color))
                {
                    g.FillRectangles(b, rectangles);
                }
                g.DrawRectangles(p, rectangles);
            }
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:32,代码来源:GeometryEditor.cs

示例10: Draw

        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            RectangleF pixRect = this.Location.TransformRect(pane);

            //GraphPane gPane = pane as GraphPane;

            //System.Diagnostics.Trace.WriteLine("XScale " + gPane.XAxis.Scale);
            //System.Diagnostics.Trace.WriteLine("YScale " + gPane.YAxis.Scale);

            //System.Diagnostics.Trace.WriteLine(pixRect.X);

            if (Math.Abs(pixRect.Left) < 100000 &&
                    Math.Abs(pixRect.Top) < 100000 &&
                    Math.Abs(pixRect.Right) < 100000 &&
                    Math.Abs(pixRect.Bottom) < 100000)
            {
                GraphicsState state = g.Save();

                g.SmoothingMode = SmoothingMode.AntiAlias;

                Matrix matrix = g.Transform;

                matrix.RotateAt(Angle, Center(pixRect));
                //matrix.Rotate(Angle);

                g.Transform = matrix;
                if (_fill.IsVisible)
                    using (Brush brush = _fill.MakeBrush(pixRect))
                        g.FillEllipse(brush, pixRect);

                if (_border.IsVisible)
                    using (Pen pen = _border.GetPen(pane, scaleFactor))
                    {
                        if (IsMoving)
                        {
                            // Set the DashCap to round.
                            pen.DashCap = DashCap.Round;

                            // Create a custom dash pattern.
                            pen.DashPattern = new float[] { 4.0F, 4.0F };
                        }

                        g.DrawEllipse(pen, pixRect);

                        if (IsSelected)
                        {
                            Brush brush = new SolidBrush(Color.White);

                            g.FillRectangles(brush, EdgeRects(pane));

                            pen.DashStyle = DashStyle.Solid;

                            g.DrawRectangles(pen, EdgeRects(pane));
                        }
                    }

                g.Restore(state);
            }
        }
开发者ID:sntree,项目名称:ZedGraph,代码行数:82,代码来源:EllipseObj.cs

示例11: Draw

        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw( Graphics g, PaneBase pane, float scaleFactor )
        {
            if ( _points != null && _points.Count > 1 )
            {
                using ( GraphicsPath path = MakePath( pane ) )
                {
                    // Fill or draw the symbol as required
                    if ( _fill.IsVisible )
                    {
                        using ( Brush brush = this.Fill.MakeBrush( path.GetBounds() ) )
                            g.FillPath( brush, path );
                    }

                    if ( _border.IsVisible )
                    {
                        var sm = g.SmoothingMode;

                        g.SmoothingMode = SmoothingMode.AntiAlias;

                        using (Pen pen = _border.GetPen(pane, scaleFactor))
                        {
                            if (IsMoving)
                            {
                                // Set the DashCap to round.
                                pen.DashCap = DashCap.Round;

                                // Create a custom dash pattern.
                                pen.DashPattern = new float[] { 4.0F, 4.0F };
                            }

                            g.DrawPath(pen, path);

                            if (!_isClosedFigure)
                            {
                                PointF lastPt = path.GetLastPoint();
                                PointF firstPt = path.PathPoints[0];

                                // Set the DashCap to round.
                                pen.DashCap = DashCap.Round;

                                // Create a custom dash pattern.
                                pen.DashPattern = new float[] { 4.0F, 4.0F };

                                g.DrawLine(pen, firstPt.X, firstPt.Y, lastPt.X, lastPt.Y);
                            }

                            if (IsSelected)
                            {
                                Brush brush = new SolidBrush(Color.White);

                                g.FillRectangles(brush, EdgeRects(pane));

                                pen.DashStyle = DashStyle.Solid;

                                g.DrawRectangles(pen, EdgeRects(pane));
                            }
                        }

                        g.SmoothingMode = sm;
                    }
                }
            }
        }
开发者ID:sntree,项目名称:ZedGraph,代码行数:84,代码来源:PolyObj.cs

示例12: DrawSelection

        public void DrawSelection(Control ctrl, Graphics formGraphics)
        {
            int size = 6;
            Brush horBorderBrush = new TextureBrush(new Bitmap(WixFiles.GetResourceStream("hcontrolborder.bmp")));
            Brush verBorderBrush = new TextureBrush(new Bitmap(WixFiles.GetResourceStream("vcontrolborder.bmp")));

            Rectangle topBorder = new Rectangle(ctrl.Left, ctrl.Top - size - 1, ctrl.Width, size + 1);
            Rectangle bottomBorder = new Rectangle(ctrl.Left, ctrl.Bottom, ctrl.Width, size + 1);

            formGraphics.FillRectangles(horBorderBrush, new Rectangle[] {topBorder, bottomBorder});

            Rectangle rightBorder = new Rectangle(ctrl.Right, ctrl.Top, size + 1, ctrl.Height);
            Rectangle leftBorder = new Rectangle(ctrl.Left - size - 1, ctrl.Top, size + 1, ctrl.Height);

            formGraphics.FillRectangles(verBorderBrush, new Rectangle[] {rightBorder, leftBorder});

            Rectangle leftTop = new Rectangle(ctrl.Left - size - 1, ctrl.Top - size - 1, size, size);
            Rectangle rightTop = new Rectangle(ctrl.Right, ctrl.Top - size - 1, size, size);

            Rectangle leftBottom = new Rectangle(ctrl.Left - size - 1, ctrl.Bottom, size, size);
            Rectangle rightBottom = new Rectangle(ctrl.Right, ctrl.Bottom, size, size);

            Rectangle leftMid = new Rectangle(ctrl.Left - size - 1, ctrl.Top + (ctrl.Height-size)/2, size, size);
            Rectangle rightMid = new Rectangle(ctrl.Right, ctrl.Top + (ctrl.Height-size)/2, size, size);

            Rectangle midBottom = new Rectangle(ctrl.Left + (ctrl.Width-size)/2, ctrl.Bottom, size, size);
            Rectangle midTop = new Rectangle(ctrl.Left + (ctrl.Width-size)/2, ctrl.Top - size - 1, size, size);

            formGraphics.FillRectangles(Brushes.White, new Rectangle[] {leftTop, rightTop, leftBottom, rightBottom, leftMid, rightMid, midBottom, midTop});
            formGraphics.DrawRectangles(Pens.Black, new Rectangle[] {leftTop, rightTop, leftBottom, rightBottom, leftMid, rightMid, midBottom, midTop});
        }
开发者ID:xwiz,项目名称:WixEdit,代码行数:31,代码来源:SelectionOverlay.cs

示例13: DrawPartition


//.........这里部分代码省略.........
            //}

            //모두보기에서는 현재 에러남
            //int visit = 0;
            //bool visit_flag = false;
            //for (int i = 0; i < pTotal_data[index].event_data.Count; i++)
            //{
            //    if (pTotal_data[index].scenario_name.CompareTo(scenario) == 0 && pTotal_data[index].event_data[i].img.CompareTo(selected) == 0 && pTotal_data[index].event_data[i].test_num == Convert.ToInt16(test))
            //    {
            //        if(pTotal_data[index].event_data[i].timeEntire - pTotal_data[index].event_data[i].timeImg != pTotal_data[index].event_data[i - 1].timeImg)
            //        {
            //            //if (visit_flag == false)
            //            //{
            //                visit++;
            //            //}
            //            //visit_flag = true;
            //        }
            //    }
            //    else
            //    {
            //        //visit_flag = false;
            //    }
            //}

            //if (click == 0)
            //{
            //    label_time.Text = "체류 시간 : 0z초";
            //    label_longest.Text = "최장 체류 시간 : 0초";
            //    label_shortest.Text = "최단 체류 시간 : 0초";
            //    //label_visit.Text = "방문 횟수 : 0회";
            //}
            //else
            //{
            //    label_time.Text = "체류 시간 : " + entireTime + "초";
            //    label_longest.Text = "최장 체류 시간 : " + longestTime + "초";
            //    label_shortest.Text = "최단 체류 시간 : " + shortestTime + "초";
            //    //label_visit.Text = "방문 횟수 : " + visit + "회";
            //}

            RectangleF[] rects = { new RectangleF(0,0, each_width, each_height) };
            
            int count_index = 0;
            for (int j = 0; j < h_count; j++)
            {
                for (int i = 0; i < w_count; i++)
                {
                    rects[0].Location = new PointF((float)(i * each_width), (float)(j * each_height));
                    gr.DrawRectangles(new Pen(Color.Red, 1), rects);
                    if (count[count_index] > 0)
                    {
                        if (count[count_index] < (pTotal_data[index].event_data.Count / 9))
                        {
                            br = new SolidBrush(SetColor(180, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 8))
                        {
                            br = new SolidBrush(SetColor(160, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 7))
                        {
                            br = new SolidBrush(SetColor(140, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 6))
                        {
                            br = new SolidBrush(SetColor(120, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 5))
                        {
                            br = new SolidBrush(SetColor(100, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 4))
                        {
                            br = new SolidBrush(SetColor(80, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 3))
                        {
                            br = new SolidBrush(SetColor(60, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 2))
                        {
                            br = new SolidBrush(SetColor(40, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                        else if (count[count_index] < (pTotal_data[index].event_data.Count / 1))
                        {
                            br = new SolidBrush(SetColor(20, Color.Red));
                            gr.FillRectangle(br, new RectangleF(new PointF((float)(i * each_width), (float)(j * each_height)), new Size((int)each_width, (int)each_height)));
                        }
                    }
                    count_index++;
                }
            }
        }
开发者ID:lewis810,项目名称:HueApp,代码行数:101,代码来源:Partition.cs

示例14: PaintBlackBands

        protected virtual void PaintBlackBands(Graphics g)
        {
            if (this.videoRenderer != null)
            {
                Trace.WriteLineIf(trace.TraceInfo, "PaintBlackBands()");

                Rectangle[] alRectangles = GetBlackBands();
                if (alRectangles.Length > 0)
                {
                    g.FillRectangles(new SolidBrush(Settings.VideoBackgroundColor), alRectangles);
                    g.DrawRectangles(new System.Drawing.Pen(Settings.VideoBackgroundColor), alRectangles);
                }
            }
        }
开发者ID:dgis,项目名称:CodeTV,代码行数:14,代码来源:GraphBuilderBase.cs

示例15: DrawGridQuad

        private static void DrawGridQuad(Graphics g, TmxMap tmxMap)
        {
            HashSet<Point> points = new HashSet<Point>();
            for (int x = 0; x < GetMaxTilesWide(tmxMap); ++x)
            {
                for (int y = 0; y < GetMaxTilesHigh(tmxMap); ++y)
                {
                    // Add the "top-left" corner of a tile
                    points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y));

                    // Add all other corners of the tile to our list of grid points
                    // This is complicated by different map types (espcially staggered isometric)
                    if (tmxMap.Orientation == TmxMap.MapOrientation.Orthogonal || tmxMap.Orientation == TmxMap.MapOrientation.Isometric)
                    {
                        points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y));
                        points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y + 1));
                        points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                    }
                    else if (tmxMap.Orientation == TmxMap.MapOrientation.Staggered)
                    {
                        bool sx = TmxMath.DoStaggerX(tmxMap, x);
                        bool sy = TmxMath.DoStaggerY(tmxMap, y);

                        if (sx)
                        {
                            // top-right, bottom-right, and bottom-left
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x - 1, y + 1));
                        }
                        else if (sy)
                        {
                            // top-right, bottom-right, and bottom-left
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 2));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                        }
                        else if (tmxMap.StaggerAxis == TmxMap.MapStaggerAxis.X)
                        {
                            // top-right, bottom-right, and bottom-left
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x + 1, y));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x - 1, y));
                        }
                        else if (tmxMap.StaggerAxis == TmxMap.MapStaggerAxis.Y)
                        {
                            // top-right, bottom-right, and bottom-left
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 1));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x, y + 2));
                            points.Add(TmxMath.TileCornerInGridCoordinates(tmxMap, x - 1, y + 1));
                        }
                    }
                }
            }

            // Can take for granted that background is always white
            List<RectangleF> rectangles = new List<RectangleF>(points.Count);
            foreach (var p in points)
            {
                RectangleF rc = new RectangleF(p.X, p.Y, PreviewImage.GridSize, PreviewImage.GridSize);
                rc.Offset(-PreviewImage.GridSize * 0.5f, -PreviewImage.GridSize * 0.5f);
                rectangles.Add(rc);
            }

            g.DrawRectangles(Pens.Black, rectangles.ToArray());
        }
开发者ID:GaelicGamer,项目名称:Tiled2Unity,代码行数:66,代码来源:PreviewImage.cs


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