public static void DrawRectangles(Graphics graphics, List<RectangleF> rectangles, Color color) { if (rectangles.Count > 0) { var brush = new SolidBrush(color); graphics.FillRectangles(brush, rectangles.ToArray()); } }
public void DrawRectangles(Pen pen, RectD[] rects, bool fill = false) { if (pen == null) { throw new ArgumentNullException("pen"); } if (rects == null) { throw new ArgumentNullException("rects"); } lock (bitmapLock) { double maxX = 0.0d; double maxY = 0.0d; for (long i = 0L; i < rects.LongLength; i++) { if (rects[i].X + rects[i].Width > maxX) { maxX = rects[i].X + rects[i].Width; } if (rects[i].Y + rects[i].Height > maxY) { maxY = rects[i].Y + rects[i].Height; } } TryExpand(0.0d, 0.0d, maxX, maxY, pen.Width); using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) { g.SmoothingMode = (Antialiasing) ? SmoothingMode.AntiAlias : SmoothingMode.None; if (fill) { g.FillRectangles(pen.Brush, ToRectangleFArray(rects)); } else { g.DrawRectangles(pen, ToRectangleFArray(rects)); } } Texturize(); } }
/// <summary> /// Draws a drop shadow. /// </summary> /// <param name="g">The graphics. </param> /// <param name="viewPort"> The view port. </param> protected virtual void DrawDropShadow(Graphics g, Rectangle viewPort) { Rectangle rightEdge; Rectangle bottomEdge; rightEdge = new Rectangle(viewPort.Right + 1, viewPort.Top + this.DropShadowSize, this.DropShadowSize, viewPort.Height); bottomEdge = new Rectangle(viewPort.Left + this.DropShadowSize, viewPort.Bottom + 1, viewPort.Width + 1, this.DropShadowSize); using (Brush brush = new SolidBrush(this.ImageBorderColor)) { g.FillRectangles(brush, new[] { rightEdge, bottomEdge }); } }
private void drawNodeRect(Graphics g, XmlNode source, PointF margin) { Pen pen; PointF location = this.getLocationAttribute(source); location.X += margin.X; location.Y += margin.Y; SizeF size = this.getSizeAttribute(source); bool flag = true; if (source.Name != "rectangle") { string str = XmlFunc.getStringAttribute(source, "BorderStyle").Trim(); if (str.Length == 0) { str = this.defaultProerty(source.Name, "BorderStyle"); if (str == null) { str = BorderStyle.None.ToString(); } } flag = !(str == BorderStyle.None.ToString()); } if (source.Name == "rectangle") { pen = this.getPenAttribute(source); } else { pen = new Pen(Color.Black); } using (pen) { using (SolidBrush brush = this.getBrushAttribute(source)) { if (brush != null) { RectangleF ef2 = new RectangleF(location, size); RectangleF[] rects = new RectangleF[] { ef2 }; g.FillRectangles(brush, rects); } } if (flag) { g.DrawRectangle(pen, location.X, location.Y, size.Width, size.Height); } } }
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; } }
private void DrawBorder(Graphics gr, Image im) { TextureBrush br = new TextureBrush(im, System.Drawing.Drawing2D.WrapMode.Tile); gr.FillRectangles(br, borderRects); }
public void Draw(Graphics graphics) { graphics.FillRectangles(Brushes.Green, Body); }
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); } } }
protected void PaintDecoration(Graphics graphics) { // Paint the glass effect. Brush brush = null; Pen pen = null; try { var rectangles = new Rectangle[4]; brush = new SolidBrush(SystemColors.Control); pen = new Pen(new SolidBrush(Color.FromArgb(223, 223, 223))); // Gibt die höhe des/der linken und rechten Rechteckes/Linie an int sideHeight = ClientRectangle.Height - this.decorationMargin.Top - this.decorationMargin.Bottom; int bottomY = ClientRectangle.Height - this.decorationMargin.Bottom; int rightX = ClientRectangle.Width - this.decorationMargin.Right; // Top rectangles[0] = new Rectangle(0, 0, ClientRectangle.Width, this.decorationMargin.Top); // Bottom rectangles[1] = new Rectangle(0, bottomY, ClientRectangle.Width, this.decorationMargin.Bottom); // Left rectangles[2] = new Rectangle(0, this.decorationMargin.Top, this.decorationMargin.Left, sideHeight); // Right rectangles[3] = new Rectangle(rightX, this.decorationMargin.Top, this.decorationMargin.Right, sideHeight); graphics.FillRectangles(brush, rectangles); if (bottomY > this.decorationMargin.Top && rightX > this.decorationMargin.Left) { // Top-Left to Top-Right if (this.decorationMargin.Top > 0) { graphics.DrawLine(pen, new Point(this.decorationMargin.Left, this.decorationMargin.Top), new Point(rightX, this.decorationMargin.Top)); } // Top-Right To Bottom-Right if (this.decorationMargin.Right > 0) { graphics.DrawLine(pen, new Point(rightX, this.decorationMargin.Top), new Point(rightX, bottomY)); } // Bottom-Right To BottomLeft if (this.decorationMargin.Bottom > 0) { graphics.DrawLine(pen, new Point(rightX, bottomY), new Point(this.decorationMargin.Left, bottomY)); } // Bottom-Left To Top-Left if (this.decorationMargin.Left > 0) { graphics.DrawLine(pen, new Point(this.decorationMargin.Left, bottomY), new Point(this.decorationMargin.Left, this.decorationMargin.Top)); } } } finally { if (brush != null) { brush.Dispose(); } if (pen != null) { pen.Dispose(); } } }
/// <summary> /// Draws the grid to the graphics device /// </summary> /// <param name="graphics">The graphics for drawing</param> public void Draw(Graphics graphics) { // Clear the old set of states for(int s = 1; s < CellState.NUM_STATES; s++) cellRectangles[s].Clear(); // Concurrently determine which batch each cell should // be drawn in. GridLoopParallel((x, y) => { Cell currentCell = cells[x, y]; int stateId = currentCell.state; if (stateId == 0) return; lock (cellRectangles) { cellRectangles[stateId].Add(currentCell.visualRect); } }); // Concurrently convert each list to an array // Skip element 0 Rectangle[][] rectArray = new Rectangle[CellState.NUM_STATES][]; Parallel.For(1, CellState.NUM_STATES, s => { rectArray[s] = cellRectangles[s].ToArray(); }); // Linearly draw each rectangle brush with the // appropriate colour from the palette for(int s = 0; s < CellState.NUM_STATES; s++) { // If this is the lowest depth, fill the entire screen, // instead, fill the set of rectangles if (s == 0) graphics.Clear(palette.StateToColor(s)); else if (rectArray[s] != null && rectArray[s].Length > 0) graphics.FillRectangles(palette.StateToBrush(s), rectArray[s]); } }
private void ProcessPaint(Graphics gfx = null) { bool needDispose = gfx == null; if (gfx == null) gfx = Placeholder.CreateGraphics(); // draw background var backRect = new Rectangle(Placeholder.Location.X, Placeholder.Location.Y, Placeholder.Width, Placeholder.Height); gfx.FillRectangle(SystemBrushes.Control, backRect); // draw main image var imgRect = new Rectangle(); if (mainImage.Width > Placeholder.Width || mainImage.Height > Placeholder.Height) { imgRect.X = imgRect.X = 0; imgRect.Width = imgRect.Height = Placeholder.Width; } else { imgRect.X = (Placeholder.Width - mainImage.Width) / 2; imgRect.Y = (Placeholder.Height - mainImage.Height) / 2; imgRect.Width = mainImage.Width; imgRect.Height = mainImage.Height; } gfx.DrawImage(mainImage, imgRect); // draw crop rectangles if (!crop || Math.Abs(mainImage.Width - mainImage.Height) <= 1) return; using (var brush = new SolidBrush(Color.FromArgb(128, 0, 0, 0))) { var r = new Rectangle[2]; int unused = Math.Abs(mainImage.Width - mainImage.Height); if (mainImage.Width > mainImage.Height) { r[0] = new Rectangle(imgRect.Location.X, imgRect.Location.Y, unused / 2, mainImage.Height); r[1] = new Rectangle(imgRect.Location.X + imgRect.Size.Width - unused / 2, imgRect.Location.Y, unused / 2, mainImage.Height); } else { r[0] = new Rectangle(imgRect.Location.X, imgRect.Location.Y, mainImage.Width, unused / 2); r[1] = new Rectangle(imgRect.Location.X, imgRect.Location.Y + imgRect.Size.Height - unused / 2, mainImage.Width, unused / 2); } gfx.FillRectangles(brush, r); } if(needDispose) gfx.Dispose(); }
/// <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); } }
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); } }
/// <summary> /// Draws the HUD. /// </summary> /// <param name="src">The SRC.</param> /// <param name="dst">The DST.</param> public void DrawHUD(Bitmap src, Bitmap dst) { try { _transparentBrush.Color = _color; _pen1.Color = _color; _pen2.Color = _color; //_brush.Color = _color_brush; //Initialize Graphics _g = Graphics.FromImage(src); _g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; _g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear; _g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; //.ClearTypeGridFit; // Draw top and bottom black bands _rectangleTextBkg[0] = new Rectangle(0, 0, _videoWidth, 20); _rectangleTextBkg[1] = new Rectangle(0, _videoHeight - 20, _videoWidth, _videoHeight); _g.FillRectangles(_brush, _rectangleTextBkg); _s = DateTime.Now.ToString(); _s += " " + _message; _g.DrawString(_s, _fontOverlay, _transparentBrush, (RectangleF)_rectangleTextBkg[1], _format2); // Draw numeric boxes for: // 1. Heading _rectangleHUD[0] = new Rectangle((_videoWidth / 2) - 25, 30, 50, 15); // 2. Altitude _rectangleHUD[1] = new Rectangle(_videoWidth - 95, (_videoHeight / 2) - 8, 50, 15); // 3. Speed _rectangleHUD[2] = new Rectangle(45, (_videoHeight / 2) - 8, 50, 15); //_g.DrawRectangles(_pen1, _rectangleHUD); _g.FillRectangles(_brush, _rectangleHUD); //Draw numeric values inside each box: // 1. Heading _g.DrawString(_headingMagneticNorth.ToString(), _transparentFont, _transparentBrush, (RectangleF)_rectangleHUD[0], _format1); // 2. Altitude _g.DrawString(_altitude.ToString(), _transparentFont, _transparentBrush, (RectangleF)_rectangleHUD[1], _format1); //3. Speed _g.DrawString(_speed.ToString(), _transparentFont, _transparentBrush, (RectangleF)_rectangleHUD[2], _format1); //Draw aircraft indicator _pointsHUD3[0].X = _videoWidth / 2 - 20; _pointsHUD3[0].Y = _videoHeight / 2; _pointsHUD3[1].X = _videoWidth / 2 - 10; _pointsHUD3[1].Y = _videoHeight / 2; _pointsHUD3[2].X = _videoWidth / 2 - 5; _pointsHUD3[2].Y = _videoHeight / 2 + 10; _pointsHUD3[3].X = _videoWidth / 2; _pointsHUD3[3].Y = _videoHeight / 2 + 3; _pointsHUD3[4].X = _videoWidth / 2 + 5; _pointsHUD3[4].Y = _videoHeight / 2 + 10; _pointsHUD3[5].X = _videoWidth / 2 + 10; _pointsHUD3[5].Y = _videoHeight / 2; _pointsHUD3[6].X = _videoWidth / 2 + 20; _pointsHUD3[6].Y = _videoHeight / 2; _g.DrawLines(_pen1, _pointsHUD3); // Draw horizontal speed indicator Rectangle rectangleObj = new Rectangle(_videoWidth / 2 - _reticlesize / 2, _videoHeight / 2 - _reticlesize / 2, _reticlesize, _reticlesize); _g.DrawEllipse(_pen1, rectangleObj); // this line should represent the horizontal direction and speed up to X m/s _pointsHUD1[0].X = _videoWidth / 2 + 20; _pointsHUD1[0].Y = _videoHeight / 2 - 30; _pointsHUD1[1].X = _videoWidth / 2; _pointsHUD1[1].Y = _videoHeight / 2; _g.DrawLines(_pen1, _pointsHUD1); double pitch = _pitch; if (_pitch >= 90) pitch = 180 - _pitch; if (_pitch <= -90) pitch = -180 - _pitch; // save existing matrices _oldState = _g.Save(); //yaw _g.TranslateTransform((float)_yaw * _yaw_resolution, 0, MatrixOrder.Append); //pitch _g.TranslateTransform(0, (float)pitch * _pitch_resolution, MatrixOrder.Append); if (_pitch >= 90 || _pitch <= -90) _g.RotateTransform((float)180, MatrixOrder.Append); // make rotation point the origin _g.TranslateTransform(-_videoWidth / 2, -_videoHeight / 2); // roll _g.RotateTransform((float)-_roll, MatrixOrder.Append); // translate back _g.TranslateTransform(_videoWidth / 2, _videoHeight / 2, MatrixOrder.Append); //DrawHUD horizont line _pointsHUD1[0].X = _videoWidth / 2 - 150; _pointsHUD1[0].Y = _videoHeight / 2; _pointsHUD1[1].X = _videoWidth / 2 - 25; _pointsHUD1[1].Y = _videoHeight / 2; _g.DrawLines(_pen1, _pointsHUD1); _pointsHUD1[0].X = _videoWidth / 2 + 150; _pointsHUD1[0].Y = _videoHeight / 2; _pointsHUD1[1].X = _videoWidth / 2 + 25; _pointsHUD1[1].Y = _videoHeight / 2; _g.DrawLines(_pen1, _pointsHUD1); rectangleObj = new Rectangle(_videoWidth / 2 - _reticlesize1 / 2, _videoHeight / 2 - _reticlesize1 / 2, _reticlesize1, _reticlesize1); _g.DrawEllipse(_pen1, rectangleObj); for (int i = 1; i <= 36; i++) { _pointsHUD2[0].X = _videoWidth / 2 - 75; _pointsHUD2[0].Y = _videoHeight / 2 + _pitch_resolution * 10 * i - 10; _pointsHUD2[1].X = _videoWidth / 2 - 75; _pointsHUD2[1].Y = _videoHeight / 2 + _pitch_resolution * 10 * i; _pointsHUD2[2].X = _videoWidth / 2 - 25; _pointsHUD2[2].Y = _videoHeight / 2 + _pitch_resolution * 10 * i; _g.DrawLines(_pen2, _pointsHUD2); _pointsHUD2[0].X = _videoWidth / 2 + 75; _pointsHUD2[0].Y = _videoHeight / 2 + _pitch_resolution * 10 * i - 10; _pointsHUD2[1].X = _videoWidth / 2 + 75; _pointsHUD2[1].Y = _videoHeight / 2 + _pitch_resolution * 10 * i; _pointsHUD2[2].X = _videoWidth / 2 + 25; _pointsHUD2[2].Y = _videoHeight / 2 + _pitch_resolution * 10 * i; _g.DrawLines(_pen2, _pointsHUD2); _pointsHUD2[0].X = _videoWidth / 2 - 75; _pointsHUD2[0].Y = _videoHeight / 2 - _pitch_resolution * 10 * i + 10; _pointsHUD2[1].X = _videoWidth / 2 - 75; _pointsHUD2[1].Y = _videoHeight / 2 - _pitch_resolution * 10 * i; _pointsHUD2[2].X = _videoWidth / 2 - 25; _pointsHUD2[2].Y = _videoHeight / 2 - _pitch_resolution * 10 * i; _g.DrawLines(_pen1, _pointsHUD2); _pointsHUD2[0].X = _videoWidth / 2 + 75; _pointsHUD2[0].Y = _videoHeight / 2 - _pitch_resolution * 10 * i + 10; _pointsHUD2[1].X = _videoWidth / 2 + 75; _pointsHUD2[1].Y = _videoHeight / 2 - _pitch_resolution * 10 * i; _pointsHUD2[2].X = _videoWidth / 2 + 25; _pointsHUD2[2].Y = _videoHeight / 2 - _pitch_resolution * 10 * i; _g.DrawLines(_pen1, _pointsHUD2); // Draw numeric boxes _rectanglePitch[0] = new Rectangle(_videoWidth / 2 - 125, _videoHeight / 2 + _pitch_resolution * 10 * i - 15, 50, 15); _rectanglePitch[1] = new Rectangle(_videoWidth / 2 + 75, _videoHeight / 2 + _pitch_resolution * 10 * i - 15, 50, 15); _g.DrawString((-i * 10).ToString(), _fontOverlay, _transparentBrush, (RectangleF)_rectanglePitch[0], _format1); _g.DrawString((-i * 10).ToString(), _fontOverlay, _transparentBrush, (RectangleF)_rectanglePitch[1], _format1); _rectanglePitch[2] = new Rectangle(_videoWidth / 2 - 125, _videoHeight / 2 - _pitch_resolution * 10 * i, 50, 15); _rectanglePitch[3] = new Rectangle(_videoWidth / 2 + 75, _videoHeight / 2 - _pitch_resolution * 10 * i, 50, 15); _g.DrawString((i * 10).ToString(), _fontOverlay, _transparentBrush, (RectangleF)_rectanglePitch[2], _format1); _g.DrawString((i * 10).ToString(), _fontOverlay, _transparentBrush, (RectangleF)_rectanglePitch[3], _format1); } _g.Restore(_oldState); // restore old _oldState = _g.Save(); // save existing matrices // make rotation point the origin _g.TranslateTransform(-_videoWidth / 2, -_videoHeight + 100); // roll _g.RotateTransform((float)_roll, MatrixOrder.Append); // translate back _g.TranslateTransform(_videoWidth / 2, _videoHeight - 100, MatrixOrder.Append); src.RotateFlip(RotateFlipType.RotateNoneFlipY); _g.Dispose(); _g = Graphics.FromImage(dst); _g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // draw the overlay bitmap over the video's bitmap _g.DrawImage(src, 0, 0, src.Width, src.Height); _g.Dispose(); } catch (Exception e) { TraceException.WriteLine(e); } }
private void DrawMarks(Graphics g, MarkCollection marks, Color markColor) { Rectangle[] rectangles = marks.GetRectanglesForVisibleMarks(this); if (rectangles == null || rectangles.Length == 0) return; if (AddinSettings.Instance.FilledMarks) { List<Rectangle> rectsToFilling = new List<Rectangle>(); uint nativeBorderColor = (uint)markColor.R | (uint)markColor.G << 8 | (uint)markColor.B << 16; IntPtr hdc = g.GetHdc(); for (int i = 0; i < rectangles.Length; i++) { var rect = rectangles[i]; int score = 0; if (Gdi32.GetPixel(hdc, rect.Left, rect.Top) == nativeBorderColor) score++; if (Gdi32.GetPixel(hdc, rect.Left, rect.Bottom) == nativeBorderColor) score++; if (score < 2 && Gdi32.GetPixel(hdc, rect.Right, rect.Bottom) == nativeBorderColor) score++; if (score < 2 && Gdi32.GetPixel(hdc, rect.Right, rect.Top) == nativeBorderColor) score++; bool isBorderDrawn = score >= 2; if (!isBorderDrawn) rectsToFilling.Add(rect); } g.ReleaseHdc(); if (rectsToFilling.Count > 0) { using (var bodyBrush = new SolidBrush(Color.FromArgb(32, markColor))) g.FillRectangles(bodyBrush, rectsToFilling.ToArray()); //using (var borderPen = new Pen(markColor)) // g.DrawRectangles(borderPen, rectsToFilling.ToArray()); } } //Draw borders using (var borderPen = new Pen(markColor)) g.DrawRectangles(borderPen, rectangles); }
/// <summary> /// Renders the layer /// </summary> /// <param name="g">Graphics object reference</param> /// <param name="map">Map which is rendered</param> public override void Render(Graphics g, Map map) { if (Style.Enabled && Style.MaxVisible >= map.Zoom && Style.MinVisible < map.Zoom) { if (DataSource == null) throw (new ApplicationException("DataSource property not set on layer '" + LayerName + "'")); g.TextRenderingHint = TextRenderingHint; g.SmoothingMode = SmoothingMode; BoundingBox envelope = map.Envelope; //View to render var lineClipping = new CohenSutherlandLineClipping(envelope.Min.X, envelope.Min.Y, envelope.Max.X, envelope.Max.Y); if (CoordinateTransformation != null) { #if !DotSpatialProjections if (ReverseCoordinateTransformation != null) { envelope = GeometryTransform.TransformBox(envelope, ReverseCoordinateTransformation.MathTransform); } else { CoordinateTransformation.MathTransform.Invert(); envelope = GeometryTransform.TransformBox(envelope, CoordinateTransformation.MathTransform); CoordinateTransformation.MathTransform.Invert(); } #else envelope = GeometryTransform.TransformBox(envelope, CoordinateTransformation.Target, CoordinateTransformation.Source); #endif } FeatureDataSet ds = new FeatureDataSet(); DataSource.Open(); DataSource.ExecuteIntersectionQuery(envelope, ds); DataSource.Close(); if (ds.Tables.Count == 0) { base.Render(g, map); return; } FeatureDataTable features = ds.Tables[0]; //Initialize label collection List<BaseLabel> labels = new List<BaseLabel>(); //List<System.Drawing.Rectangle> LabelBoxes; //Used for collision detection //Render labels for (int i = 0; i < features.Count; i++) { FeatureDataRow feature = features[i]; if (CoordinateTransformation != null) #if !DotSpatialProjections features[i].Geometry = GeometryTransform.TransformGeometry(features[i].Geometry, CoordinateTransformation. MathTransform); #else features[i].Geometry = GeometryTransform.TransformGeometry(features[i].Geometry, CoordinateTransformation.Source, CoordinateTransformation.Target); #endif LabelStyle style; if (Theme != null) //If thematics is enabled, lets override the style style = Theme.GetStyle(feature) as LabelStyle; else style = Style; float rotationStyle = style != null ? style.Rotation : 0f; float rotationColumn = 0f; if (!String.IsNullOrEmpty(RotationColumn)) Single.TryParse(feature[RotationColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs, out rotationColumn); float rotation = rotationStyle + rotationColumn; int priority = Priority; if (_getPriorityMethod != null) priority = _getPriorityMethod(feature); else if (!String.IsNullOrEmpty(PriorityColumn)) Int32.TryParse(feature[PriorityColumn].ToString(), NumberStyles.Any, Map.NumberFormatEnUs, out priority); string text; if (_getLabelMethod != null) text = _getLabelMethod(feature); else text = feature[LabelColumn].ToString(); if (!String.IsNullOrEmpty(text)) { // for lineal geometries, try clipping to ensure proper labeling if (feature.Geometry is ILineal) { if (feature.Geometry is LineString) feature.Geometry = lineClipping.ClipLineString(feature.Geometry as LineString); else if (feature.Geometry is MultiLineString) feature.Geometry = lineClipping.ClipLineString(feature.Geometry as MultiLineString); } if (feature.Geometry is GeometryCollection) { if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.All) { foreach (Geometry geom in (feature.Geometry as GeometryCollection)) { BaseLabel lbl = CreateLabel(feature,geom, text, rotation, priority, style, map, g, _getLocationMethod); if (lbl != null) labels.Add(lbl); } } else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.CommonCenter) { BaseLabel lbl = CreateLabel(feature, feature.Geometry, text, rotation, priority, style, map, g, _getLocationMethod); if (lbl != null) labels.Add(lbl); } else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.First) { if ((feature.Geometry as GeometryCollection).Collection.Count > 0) { BaseLabel lbl = CreateLabel(feature, (feature.Geometry as GeometryCollection).Collection[0], text, rotation, style, map, g); if (lbl != null) labels.Add(lbl); } } else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.Largest) { GeometryCollection coll = (feature.Geometry as GeometryCollection); if (coll.NumGeometries > 0) { double largestVal = 0; int idxOfLargest = 0; for (int j = 0; j < coll.NumGeometries; j++) { Geometry geom = coll.Geometry(j); if (geom is LineString && ((LineString) geom).Length > largestVal) { largestVal = ((LineString) geom).Length; idxOfLargest = j; } if (geom is MultiLineString && ((MultiLineString) geom).Length > largestVal) { largestVal = ((MultiLineString)geom).Length; idxOfLargest = j; } if (geom is Polygon && ((Polygon) geom).Area > largestVal) { largestVal = ((Polygon) geom).Area; idxOfLargest = j; } if (geom is MultiPolygon && ((MultiPolygon) geom).Area > largestVal) { largestVal = ((MultiPolygon) geom).Area; idxOfLargest = j; } } BaseLabel lbl = CreateLabel(feature, coll.Geometry(idxOfLargest), text, rotation, priority, style, map, g, _getLocationMethod); if (lbl != null) labels.Add(lbl); } } } else { BaseLabel lbl = CreateLabel(feature, feature.Geometry, text, rotation, priority, style, map, g, _getLocationMethod); if (lbl != null) labels.Add(lbl); } } } if (labels.Count > 0) //We have labels to render... { if (Style.CollisionDetection && _labelFilter != null) _labelFilter(labels); for (int i = 0; i < labels.Count; i++) { // Don't show the label if not necessary if (!labels[i].Show) { continue; } if (labels[i] is Label) { var label = labels[i] as Label; if (label.Style.IsTextOnPath == false || label.TextOnPathLabel==null) { VectorRenderer.DrawLabel(g, label.Location, label.Style.Offset, label.Style.Font, label.Style.ForeColor, label.Style.BackColor, Style.Halo, label.Rotation, label.Text, map); } else { if (label.Style.BackColor != null && label.Style.BackColor != System.Drawing.Brushes.Transparent) { //draw background if (label.TextOnPathLabel.RegionList.Count > 0) { g.FillRectangles(labels[i].Style.BackColor, labels[i].TextOnPathLabel.RegionList.ToArray()); //g.FillPolygon(labels[i].Style.BackColor, labels[i].TextOnPathLabel.PointsText.ToArray()); } } label.TextOnPathLabel.DrawTextOnPath(); } } else if (labels[i] is PathLabel) { var plbl = labels[i] as PathLabel; var lblStyle = plbl.Style; g.DrawString(lblStyle.Halo, new SolidBrush(lblStyle.ForeColor), plbl.Text, lblStyle.Font.FontFamily, (int) lblStyle.Font.Style, lblStyle.Font.Size, lblStyle.GetStringFormat(), lblStyle.IgnoreLength, plbl.Location); } } } } base.Render(g, map); }
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); /* SliderSwitch的长条形主体 */ int x = 0; int y = SLIDER_EDGE_WIDTH; // int width = rect.Width; int height = rect.Height - 2 * y; Rectangle rect1 = new Rectangle(rect.X+x, rect.Y+y, width, height); if ((null == this.BackgroundImage) || (string.Empty == this.BackgroundImage)) { if (EFlatStyle.Stereo == this.FlatStyle) { /* 绘制立体效果,三色渐变 */ LinearGradientBrush brush = new LinearGradientBrush(rect1, 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, rect1, this.Radius, 1.0f); brush.Dispose(); } else if (EFlatStyle.Flat == this.FlatStyle) { SolidBrush brush = new SolidBrush(backColor); FillRoundRectangle(gp, brush, rect1, this.Radius, 1.0f); } } /* 左图标 */ x = PADDING; // 偏移为5 y = SLIDER_EDGE_WIDTH + PADDING; // height = rect.Height - 2 * y; // 计算出高度 width = height; // 计算出宽度 Image img = null; if (!string.IsNullOrEmpty(this.LeftImage)) { img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.LeftImage)); } if (null != img) { gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y); } /* 右图标 */ x = rect.Width - PADDING - width; img = null; if (!string.IsNullOrEmpty(this.RightImage)) { img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.RightImage)); } if (null != img) { gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y); } /* 中间滑块 */ width = SLIDER_WIDTH; x = rect.Width / 2 - width / 2; y = 0; height = rect.Height; Rectangle rect2 = new Rectangle(rect.X+x,rect.Y+y, width, height); Color sliderColor = ColorHelper.changeBrightnessOfColor(backColor, 70); LinearGradientBrush sliderBrush = new LinearGradientBrush(rect2, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical); Color[] sliderColors = new Color[3]; sliderColors[0] = ColorHelper.changeBrightnessOfColor(sliderColor, 100); sliderColors[1] = sliderColor; sliderColors[2] = ColorHelper.changeBrightnessOfColor(sliderColor, -30); ColorBlend sliderBlend = new ColorBlend(); sliderBlend.Positions = new float[] { 0.0f, 0.3f, 1.0f }; sliderBlend.Colors = sliderColors; sliderBrush.InterpolationColors = sliderBlend; FillRoundRectangle(gp, sliderBrush, rect2, this.Radius, .0f); sliderBrush.Dispose(); 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; } }
public void DrawMap(string p_FileName, Graphics g) { try { //*** Create New Graphics object for web version, For Desktop version Graphics Object of a control shall be passed System.Drawing.Bitmap _BitMap; if (p_FileName.Length > 0) { _BitMap = new System.Drawing.Bitmap((int)m_Width, (int)m_Height); g = Graphics.FromImage(_BitMap); } else { _BitMap = null; } // _BitMap is assigned some default values but has no relevance. //- Allow AntiAliasing for smooth Text Labels g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; //*** Set the background color of Graphics if (m_CanvasColor.ToArgb() != Color.Transparent.ToArgb()) g.Clear(m_CanvasColor); //*** Clearing with transparent color sets the backgolor to black in web //*** Set Transformation Variables SetTransVar(); Matrix mTransMatrix = GetTransMatrix(); RectangleF CurExt = GetCurrentExtent(); //*** Draw Themes (Base layer + Feature Layer) Theme _Theme; _Theme = m_Themes.GetActiveTheme(); //$$$ Assuming that at any point of time Only one Color Theme will be visible if ((_Theme == null)) { DrawBaseLayer(ref g, mTransMatrix, CurExt); //*** Base Layers '*** If no color theme then draw boundaries of map } foreach (Theme _TempTheme in Themes) { if (_TempTheme.Visible == true) { switch (_TempTheme.Type) { case ThemeType.Color: case ThemeType.Hatch: DrawColorTheme(ref g, _TempTheme, mTransMatrix, CurExt); //*** Color Theme + Hatch Theme break; case ThemeType.DotDensity: DrawDotDensity(ref g, _TempTheme, mTransMatrix, CurExt); //*** Dot Density break; case ThemeType.Chart: DrawChart(ref g, _TempTheme, mTransMatrix, CurExt); //*** Chart Theme break; case ThemeType.Symbol: DrawSymbolTheme(ref g, _TempTheme, mTransMatrix, CurExt); //*** Symbol Theme break; case ThemeType.Label: DrawLabelTheme(ref g, _TempTheme, mTransMatrix, CurExt); //*** Label Theme break; } } } //*** Draw Custom Feature Layers if (m_CFLCol.Count > 0) { DrawCustomFeatureLayers(ref g, mTransMatrix, CurExt); } //*** Draw North Symbol only for Main Map not for Insets g.SmoothingMode = SmoothingMode.AntiAlias; if (m_NorthSymbol == true) { Font _Font = new Font("Webdings", m_NorthSymbolSize); SolidBrush _Brush = new SolidBrush(m_NorthSymbolColor); //g.DrawString("l", _Font, _Brush, m_NorthSymbolPosition.X, m_NorthSymbolPosition.Y) g.DrawString("l", _Font, _Brush, m_Width - 60, m_Height - 60); _Font.Dispose(); _Brush.Dispose(); } g.SmoothingMode = SmoothingMode.None; //*** Display Map Scale Enhancement 11 May 2006 try { if (m_Scale == true) { int iScaleWidth = (int)(m_Width / 2.5); int iScaleHeight = 5; int iBlockCount = 5; int iBlockWidth = (int)iScaleWidth / iBlockCount; int iOrgX = 10; int iOrgY = (int)(m_Height - 20); double dMapWidth; double dBlockWidth; { dMapWidth = GetDistance(m_CurrentExtent.X, m_CurrentExtent.Y, m_CurrentExtent.X + m_CurrentExtent.Width, m_CurrentExtent.Y); } dBlockWidth = dMapWidth / m_Width * iBlockWidth; if (dBlockWidth > 2) { dBlockWidth = (int)dBlockWidth; } else { dBlockWidth = Math.Round(dBlockWidth, 1); } //*** Create array of rectagle to be filled with alternate colors Rectangle[] Rect1 = new Rectangle[3]; Rectangle[] Rect2 = new Rectangle[2]; Rect1[0] = new Rectangle(iOrgX, iOrgY, iBlockWidth, iScaleHeight); Rect2[0] = new Rectangle(iOrgX + iBlockWidth, iOrgY, iBlockWidth, iScaleHeight); Rect1[1] = new Rectangle(iOrgX + iBlockWidth * 2, iOrgY, iBlockWidth, iScaleHeight); Rect2[1] = new Rectangle(iOrgX + iBlockWidth * 3, iOrgY, iBlockWidth, iScaleHeight); Rect1[2] = new Rectangle(iOrgX + iBlockWidth * 4, iOrgY, iBlockWidth, iScaleHeight); //*** Fill alternate band of rectangles g.FillRectangles(Brushes.Red, Rect1); g.FillRectangles(Brushes.Blue, Rect2); //*** Draw Text for Scale measurements Font oFont = new Font("Arial", 7); StringFormat oStringFormat = new StringFormat(); oStringFormat.FormatFlags = StringFormatFlags.NoClip; oStringFormat.Alignment = StringAlignment.Center; g.DrawString(m_ScaleUnitText, oFont, Brushes.Black, iOrgX, iOrgY + iScaleHeight + 1, oStringFormat); g.DrawString(dBlockWidth.ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth, iOrgY + iScaleHeight + 1, oStringFormat); g.DrawString((dBlockWidth * 2).ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth * 2, iOrgY + iScaleHeight + 1, oStringFormat); g.DrawString((dBlockWidth * 3).ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth * 3, iOrgY + iScaleHeight + 1, oStringFormat); g.DrawString((dBlockWidth * 4).ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth * 4, iOrgY + iScaleHeight + 1, oStringFormat); g.DrawString((dBlockWidth * 5).ToString(), oFont, Brushes.Black, iOrgX + iBlockWidth * 5, iOrgY + iScaleHeight + 1, oStringFormat); oFont.Dispose(); } } catch (Exception ex) { } //*** Draw Label DrawLabel(ref g, mTransMatrix, CurExt); //*** For Web Version Save Image File to the specified path if (p_FileName.Length > 0) { //_BitMap.MakeTransparent(Color.Transparent) if (File.Exists(p_FileName)) File.Delete(p_FileName); FileStream _File = new FileStream(p_FileName, FileMode.Create); _BitMap.Save(_File, ImageFormat.Png); _File.Flush(); _File.Close(); //_BitMap.Save(p_FileName, Imaging.ImageFormat.Png) _BitMap.Dispose(); g.Dispose(); } } catch (Exception ex) { System.Diagnostics.Debug.Print(ex.Message); } }
public void draw(Graphics gfx) { createRectangles(); if (_container != null) gfx.DrawRectangle(resizeBoxPen, _container.bounds); else gfx.DrawRectangle(resizeBoxPen, _rectangle); if (_boxType == boxTypes.resize) gfx.FillRectangles(resizeBoxBrush,grabberRects); }
private void PaintGrid(Graphics graphics, Brush cellBrush, Pen gridPen) { isDrawing = true; if (state.State == null) { return; } int cellSize = PowerTwos.Get(tbZoom.Value); int padding = PowerTwos.Get(tbZoom.Value - 2); int totalSize = cellSize + padding; int width = state.State.GetLength(0) * totalSize; int xOffset = -(int)(scrollH.Value * width * 0.01f); int yOffset = -(int)(scrollV.Value * width * 0.01f); graphics.DrawRectangle(gridPen, xOffset, yOffset, width, width); Rectangle[] cells = new Rectangle[state.Population + 50]; int index = 0; for (int y = 0; y < state.State.GetLength(0); y++) { for (int x = 0; x < state.State.GetLength(1); x++) { if (state.State[y, x]) { cells[index++] = new Rectangle(x * totalSize + xOffset, y * totalSize + yOffset, cellSize, cellSize); } } } graphics.FillRectangles(cellBrush, cells); isDrawing = false; }
/// <summary> /// 绘图 /// </summary> public void Draw() { Console.WriteLine("FrameControl:" + "InitializeComponent:"); g = this.CreateGraphics(); SolidBrush brush = new SolidBrush(Color.Black); g.FillRegion(brush, Region); this.BringToFront(); Pen pen = new Pen(Color.LightGray, 0.8f); pen.DashStyle = DashStyle.Dot;//设置为虚线,用虚线画四边,模拟微软效果 g.DrawLine(pen, linePoints[0], linePoints[1]); g.DrawLine(pen, linePoints[2], linePoints[3]); g.DrawLine(pen, linePoints[4], linePoints[5]); g.DrawLine(pen, linePoints[6], linePoints[7]); g.DrawLine(pen, linePoints[8], linePoints[9]); g.DrawLine(pen, linePoints[10], linePoints[11]); g.DrawLine(pen, linePoints[12], linePoints[13]); g.DrawLine(pen, linePoints[14], linePoints[15]); g.FillRectangles(Brushes.White, smallRects); //填充8个小矩形的内部 pen.Width = 2.0f; pen.DashStyle = DashStyle.Solid; pen.Color = Color.Black; g.DrawRectangles(pen, smallRects); //绘制8个小矩形的黑色边线 }
private void DrawBoard(Graphics graphics) { int board_box_size = (int)(BoardPicBox.Width / size_); Brush white = Brushes.SandyBrown; Brush black = Brushes.Brown; for (int i = 0; i < size_; i++) { for (int j = 0; j < size_; j++) { Brush brush; if ((i + j) % 2 == 0) { brush = white; } else { brush = black; } Rectangle r = new Rectangle(i * board_box_size, j * board_box_size, board_box_size, board_box_size); graphics.FillRectangles(brush,new Rectangle[]{r}); } } }
/// <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; } } }
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); /* SliderSwitch的长条形主体 */ int x = 0; int y = 0; int width = 0; int height = 0; 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); } } /* 左图标 */ x = PADDING; // 偏移为5 y = PADDING; // height = rect.Height - 2 * y; // 计算出高度 width = rect.Height > SUBVIEW_WIDTH ? rect.Height : SUBVIEW_WIDTH; // 计算出宽度 width -= 2 * x; Image img = null; if (!string.IsNullOrEmpty(this.LeftImage)) { img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.LeftImage)); } if (null != img) { gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y); } /* 右图标 */ x = rect.Width - PADDING - width; /*Image*/ img = null; if (!string.IsNullOrEmpty(this.RightImage)) { img = Image.FromFile(Path.Combine(MyCache.ProjImagePath, this.RightImage)); } if (null != img) { gp.DrawImage(ImageHelper.Resize(img, new Size(width, height), false), rect.X+x, rect.Y+y); } /* 中间数字 */ string valueString = null; if (KNXDigitalAdjustment.EDigitalNumber.OneDigit == this.DigitalNumber) { valueString = "8"; } else if (KNXDigitalAdjustment.EDigitalNumber.TwoDigit == this.DigitalNumber) { valueString = "88"; } else if (KNXDigitalAdjustment.EDigitalNumber.ThreeDigit == this.DigitalNumber) { valueString = "888"; } if (null != valueString) { valueString += this.Unit.GetDescription(); Color fontColor = this.FontColor; Font font = new Font("宋体", this.FontSize); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; Size size = TextRenderer.MeasureText(valueString, font); x = PADDING; y = PADDING; width = rect.Width - 2 * x; height = rect.Height - 2 * y; Rectangle rectText = new Rectangle(rect.X+x, rect.Y+y, width, height); gp.DrawString(valueString, font, new SolidBrush(fontColor), rectText, format); } 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; } }
private void PaintGlass(Graphics graphics) { Brush brush = null; try { this.glassRectangles = new Rectangle[4]; if (this.windowMode == WindowMode.Aero) { // Wenn der TransparencyKey nicht an dieser Stelle auf einen einen anderen Wert // als auf dem beim Laden der Form gesetzt wird, erscheint für einen kurzen Augenblick // ein Balken in der Farbe mit der man das „Glas“ malt. // Alternativ kann der TransparencyKey unangetastet bleiben, dann muss man das „Glas“ // mit Color.Black malen. Diese Lösung hat den Nachteil, dass auch schwarze Schrift // transparent wird, wenn nicht UseCompatibleTextRendering auf true gesetzt wurde. TransparencyKey = this.glassColor; //glassColor = TransparencyKey = Color.Black; } brush = new SolidBrush(this.glassColor); if (this.fullWindow) { graphics.FillRectangle(brush, ClientRectangle); } else { // Gibt die höhe des/der linken und rechten Rechteckes/Linie an int sideHeight = ClientRectangle.Height - this.glassMargin.Top - this.glassMargin.Bottom; int bottomY = ClientRectangle.Height - this.glassMargin.Bottom; int rightX = ClientRectangle.Width - this.glassMargin.Right; // Top this.glassRectangles[0] = new Rectangle(0, 0, ClientRectangle.Width, this.glassMargin.Top); // Bottom this.glassRectangles[1] = new Rectangle(0, bottomY, ClientRectangle.Width, this.glassMargin.Bottom); // Left this.glassRectangles[2] = new Rectangle(0, this.glassMargin.Top, this.glassMargin.Left, sideHeight); // Right this.glassRectangles[3] = new Rectangle(rightX, this.glassMargin.Top, this.glassMargin.Right, sideHeight); graphics.FillRectangles(brush, this.glassRectangles); } } finally { if (brush != null) { brush.Dispose(); } } }
/// <summary> /// Paints the glass effect on the screen. /// </summary> /// <param name="g"></param> protected virtual void PaintGlass(Graphics g) { if (!GlassUtility.IsGlassEnabled) return; if (!this.DesignMode) { // Paint the glass effect. NativeMethods.MARGINS m = new NativeMethods.MARGINS(_margin); NativeMethods.DwmExtendFrameIntoClientArea(this.Handle, ref m); } // Paint the glass effect. using (Brush b = new SolidBrush(Color.Black)) { if (_fullWindow) { g.FillRectangle(b, this.ClientRectangle); } else { _rects[0] = new Rectangle(0, 0, this.Width, _margin.Top); _rects[1] = new Rectangle(this.ClientRectangle.Width - _margin.Right, 0, _margin.Right, this.Height); _rects[2] = new Rectangle(0, this.ClientRectangle.Height - _margin.Bottom, this.Width, _margin.Bottom); _rects[3] = new Rectangle(0, 0, _margin.Left, this.Height); g.FillRectangles(b, _rects); } } }
private void DisposerBonbons(Graphics g, int b) { Random rnd = new Random(); bonbonRects = new Rectangle[b]; bonbons = new Point[b]; int trouve = 0; while (trouve != b) { int index = rnd.Next(Largeur); int y = rnd.Next(Largeur); int x = rnd.Next(Largeur); // on ne place pas de bonbon sur la case en bas à gauche // car c'est d'ici que démarre le robot if (piece[y][x] == 0 && !(x == 0 && y == Largeur - 1) && piece[y][x] != 2) { Rectangle r = new Rectangle(x * pasX, y * pasY, pasX, pasY); bonbonRects[trouve] = r; Point point = new Point(x, y); bonbons[trouve] = point; piece[y][x] = 2; trouve++; string message = string.Format("({0},{1})", x, y); } } g.FillRectangles(Brushes.Pink, bonbonRects); }
public void Draw(Graphics g, PointF p, float scale) { PointF hip = new PointF(p.X + (float)P[0].X * scale, p.Y - (float)P[0].Y * scale); PointF kneel = new PointF(p.X + (float)P[2].X * scale, p.Y - (float)P[2].Y * scale); PointF kneer = new PointF(p.X + (float)P[1].X * scale, p.Y - (float)P[1].Y * scale); PointF anklel = new PointF(p.X + (float)P[4].X * scale, p.Y - (float)P[4].Y * scale); PointF ankler = new PointF(p.X + (float)P[3].X * scale, p.Y - (float)P[3].Y * scale); PointF centerofmass = new PointF(p.X + (float)CenterOfMass.X * scale, p.Y - (float)CenterOfMass.Y * scale); PointD h = PointD.FromPoint(P[0], Theta[0], 0.07); PointF head = new PointF(p.X + (float)h.X * scale, p.Y - (float)h.Y * scale); g.FillEllipse(Brushes.Blue, centerofmass.X - 3, centerofmass.Y - 3, 6, 6); g.DrawLine(PenGround, hip, head); g.DrawLine(PenLeft, hip, kneel); g.DrawLine(PenLeft, kneel, anklel); g.FillEllipse(BrushLeft, kneel.X - 5, kneel.Y - 5, 10, 10); g.FillEllipse(BrushRight, hip.X - 5, hip.Y - 5, 10, 10); g.DrawLine(PenRight, hip, kneer); g.DrawLine(PenRight, kneer, ankler); g.FillEllipse(BrushRight, kneer.X - 5, kneer.Y - 5, 10, 10); if (HipFix) g.DrawEllipse(PenRight, hip.X - 8, hip.Y - 8, 16, 16); if (LOnGround) LSteps.Add(new RectangleF(anklel.X, p.Y + 3, 1, 1)); if (ROnGround) RSteps.Add(new RectangleF(ankler.X, p.Y + 6, 1, 1)); RectangleF[] ls = new RectangleF[LSteps.Count]; LSteps.CopyTo(ls); if (ls.Length > 0) g.FillRectangles(BrushLeft, ls); RectangleF[] rs = new RectangleF[RSteps.Count]; RSteps.CopyTo(rs); if (rs.Length > 0) g.FillRectangles(BrushRight, rs); }
/// <summary> /// Implémente le cycle d'acions à réaliser à chaque itération /// </summary> /// <param name="nbIterations"></param> /// <param name="g"></param> /// <param name="t"></param> private void Passer(int nbIterations, Graphics g, int t) { double[] senseurs = CapturerSenseurs(robot); int action = reseau.Entrainer(senseurs, t, nbIterations); EffectuerAction(action); g.Clear(Color.White); DessinerMurs(g); g.FillRectangles(Brushes.Pink, bonbonRects); AfficherVisites(g, robot.Visites); DessinerRobot(g, robot); senseurs = CapturerSenseurs(robot); Liste.Text += string.Format("* Action: {0}", (Action)action) + Environment.NewLine; Liste.Text += string.Format("Senseur: {0}/{1}/{2}", senseurs[0].ToString("0.0000;-0.0000"), senseurs[1].ToString("0.0000;-0.0000"), senseurs[2].ToString("0.0000;-0.0000")) + Environment.NewLine; Liste.Text += "Robot: " + robot.Direction.ToString() + "; " + robot.X + ";" + robot.Y + Environment.NewLine; Sensor.Text = string.Format("Senseur: {0}/{1}/{2}", senseurs[0].ToString("0.0000;-0.0000"), senseurs[1].ToString("0.0000;-0.0000"), senseurs[2].ToString("0.0000;-0.0000")); Helper.AfficherVecteur(senseurs, "Senseurs"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Draw as much of this page as will fit in the clip rectangle. /// We must draw something in every part of the clip rectangle (unless fScreen is false), /// because (to avoid flicker drawing selections) we don't erase the window before /// drawing. We do this by stretching the element horizontally, and separately /// erasing the areas between elements (and before and after them). /// </summary> /// <param name="gr">graphics object to draw with</param> /// <param name="rectClip">rectangle to draw in (in target device pixels)</param> /// <param name="zoom">The zoom.</param> /// <param name="fScreen">true if drawing to screen, false for printers</param> /// ------------------------------------------------------------------------------------ internal void Draw(Graphics gr, Rectangle rectClip, float zoom, bool fScreen) { CheckDisposed(); Debug.Assert(!m_fBroken); float targetDpiX = gr.DpiX; float targetDpiY = gr.DpiY; int dpiXScreen = (int)(targetDpiX * zoom); int dpiYScreen = (int)(targetDpiY * zoom); Point unprintableAdjustment = new Point(0, 0); Point gutterAdjustment = new Point(0, 0); // for printing, calculate the amount of space to adjust each object placement by // to account for the unprintable area of a page. NOTE: this must be done before // getting the hDC because the Graphics object will then be locked. int autoscrollY = PubControl.AutoScrollPosition.Y; if (!fScreen) { unprintableAdjustment.X = -(rectClip.Width - (int)(gr.VisibleClipBounds.Width * targetDpiX) / 100) / 2; unprintableAdjustment.Y = -(rectClip.Height - (int)(gr.VisibleClipBounds.Height * (int)targetDpiY) / 100) / 2; // Make an adjustment for the gutter. if (PubControl.Publication.BindingEdge == BindingSide.Top) { if (PageNumber % 2 == 1 || PubControl.Publication.SheetLayout == MultiPageLayout.Simplex) { // Top gutter only comes into play if we're printing the page whose // top edge is the binding edge (i.e., normally the odd pages) gutterAdjustment.Y = (int)(PubControl.Publication.GutterMargin * targetDpiY / MiscUtils.kdzmpInch); } else if (PubControl.Publication.SheetLayout == MultiPageLayout.Duplex) { // This calculation attempts to deal with printing the "backside" page when // doing duplex. If the logical page size is smaller than the physical sheet size // onto which we're printing, we need to shift the printing origin so the backside // lines up with the frontside. // TODO: We're still off by a little. gutterAdjustment.Y = rectClip.Height - (int)((PubControl.Publication.PageHeight + PubControl.Publication.GutterMargin) * targetDpiY / MiscUtils.kdzmpInch); } } else { if ((PageNumber % 2 == 1 && PubControl.Publication.BindingEdge == BindingSide.Left) || (PageNumber % 2 == 0 && PubControl.Publication.BindingEdge == BindingSide.Right) || PubControl.Publication.SheetLayout == MultiPageLayout.Simplex || PubControl.Publication.PageWidth == 0) // 0 => full-page { // Side gutter only comes into play if we're printing the page whose // left edge is the binding edge (i.e., normally the odd pages) gutterAdjustment.X = (int)(PubControl.Publication.GutterMargin * targetDpiX / MiscUtils.kdzmpInch); } else if (PubControl.Publication.SheetLayout == MultiPageLayout.Duplex) { // This calculation attempts to deal with printing the "backside" page when // doing duplex. If the logical page size is smaller than the physical sheet size // onto which we're printing, we need to shift the printing origin so the backside // lines up with the frontside. // TODO: We're still off by a little, however not we're off by the same amount as // Microsoft Word when doing duplex, justified printing. We may need to provide // a printer-specific adjustment. gutterAdjustment.X = rectClip.Width - (int)((PubControl.Publication.PageWidth + PubControl.Publication.GutterMargin) * targetDpiX / MiscUtils.kdzmpInch); } } autoscrollY = 0; } int indexOfThisPage = PubControl.IndexOfPage(this); int bottomOfPage = PubControl.PageHeightPlusGapInScreenPixels * (indexOfThisPage + 1) - PubControl.Gap + autoscrollY; if (!fScreen) bottomOfPage = Int32.MaxValue; List<Rectangle> backgroundRects = new List<Rectangle>(); // This is the bottom of the area drawn or erased by the previous element. // to begin with, it can be the very top of the page. int bottomPrev = PubControl.PageHeightPlusGapInScreenPixels * (indexOfThisPage) + autoscrollY; if (!fScreen) bottomPrev = 0; IntPtr hdc = gr.GetHdc(); IVwGraphicsWin32 vg = VwGraphicsWin32Class.Create(); vg.Initialize(hdc); try { if (fScreen) { vg.XUnitsPerInch = dpiXScreen; vg.YUnitsPerInch = dpiYScreen; } IVwDrawRootBuffered vdrb = VwDrawRootBufferedClass.Create(); uint rgbBackColor = ColorUtil.ConvertColorToBGR(PubControl.BackColor); Debug.Assert(PageElements != null); foreach (PageElement element in PageElements) { IVwRootBox rootb = (IVwRootBox)element.m_stream; // Compute the part of this element that intersects the ClipRect. Rectangle rectElement = element.PositionInLayout(indexOfThisPage, PubControl, targetDpiX, targetDpiY, unprintableAdjustment, gutterAdjustment, fScreen); if (fScreen) { // If drawing on the screen expand this to the width of the clip rectangle Rectangle rectClipElt = GetElementClipBounds(element, rectElement); // If it doesn't intersect the clip rect skip this element. if (!rectClipElt.IntersectsWith(rectClip)) continue; rectClipElt.Intersect(rectClip); // We need to draw the space between the bottom of the previous element // and the top of the current element with the background color. if (bottomPrev < rectClipElt.Top) { Rectangle rectErase = new Rectangle(rectClip.X, bottomPrev, rectClip.Width, rectClipElt.Top - bottomPrev); if (rectErase.IntersectsWith(rectClip)) { rectErase.Intersect(rectClip); // Unfortunately we can't erase the background right away // because we obtained the HDC above. Need to do it later. backgroundRects.Add(rectErase); } } bottomPrev = rectClipElt.Bottom; // It just works! // The origin of this rectangle is the offset from the origin of this rootbox's // data to the origin of this element (in printer pixels). Rectangle rectSrc = new Rectangle(0, element.OffsetToTopPageBoundary - element.OverlapWithPreviousElement, (int)(PubControl.DpiXPrinter), (int)(PubControl.DpiYPrinter)); // The origin of this rectangle is the offset from the origin of this element // to the origin of the clip rectangle (the part of the rc that // actually pertains to this element) (in screen pixels) Rectangle rectDst = new Rectangle(rectElement.Left - rectClipElt.Left, rectElement.Top - rectClipElt.Top, dpiXScreen, dpiYScreen); // By "adding" the origins of the source and destination rectangles together // (each in its respective context, printer or screen), we get the overall // offset to the bit of data we actually want to draw in the clip rectangle. vdrb.DrawTheRootAt(rootb, hdc, rectClipElt, rgbBackColor, true, vg, rectSrc, rectDst, element.OffsetToTopPageBoundary, element.ColumnHeight); #if DEBUG #if _DEBUG_SHOW_BOX vg.ForeColor = (int)ColorUtil.ConvertColorToBGR(Color.Red); vg.DrawLine(rectElement.Left, rectElement.Top, rectElement.Left, rectElement.Bottom); vg.DrawLine(rectElement.Left, rectElement.Top, rectElement.Right, rectElement.Top); vg.DrawLine(rectElement.Right, rectElement.Top, rectElement.Right, rectElement.Bottom); vg.DrawLine(rectElement.Left, rectElement.Bottom, rectElement.Right, rectElement.Bottom); #endif #endif } else { // This version is for the printer. // (a) it uses a simpler interface for drawing, since it doesn't need to // fill in the background first, nor use double-buffering, nor do clipping. // (b) therefore it doesn't create a clip rectangle. // (c) but, it does need a dst rectangle at printer resolution. // (d) because we aren't drawing just in a clip rectangle, but the whole page, // the offset of each element is just the page element offsets. // As well as being much faster, this doesn't try to paint the page with the // window background color, and creates mdi files around 35 times smaller. // The origin of this rectangle is the offset from the origin of this rootbox's // data to the origin of this element (in printer pixels). Rectangle rectSrc = new Rectangle(0, element.OffsetToTopPageBoundary, (int)(PubControl.DpiXPrinter), (int)(PubControl.DpiYPrinter)); // The origin of this rectangle is the offset from the origin of this element // to the origin of the clip rectangle (the part of the rc that // actually pertains to this element) (in screen pixels) Rectangle rectDst = new Rectangle(rectElement.Left, rectElement.Top, (int)(PubControl.DpiXPrinter), (int)(PubControl.DpiYPrinter)); rootb.DrawRoot2(vg, rectSrc, rectDst, false, element.OffsetToTopPageBoundary, element.ColumnHeight); } try { rootb.DrawingErrors(); } catch /*(Exception ex)*/ { //TODO: GiveDrawErrMsg(ex, false); } } } finally { vg.ReleaseDC(); gr.ReleaseHdc(hdc); } if (fScreen) { // We also need to erase the background between the bottom of the last // element and the bottom of the page if (bottomPrev < bottomOfPage) { Rectangle rectErase = new Rectangle(rectClip.X, bottomPrev, rectClip.Width, bottomOfPage - bottomPrev); if (rectErase.IntersectsWith(rectClip)) { rectErase.Intersect(rectClip); backgroundRects.Add(rectErase); } } if (backgroundRects.Count > 0) gr.FillRectangles(new SolidBrush(PubControl.BackColor), backgroundRects.ToArray()); // Draw the gap to show page break. int bottomOfPageInDoc = PubControl.PageHeightPlusGapInScreenPixels * (indexOfThisPage + 1) - PubControl.Gap; Rectangle rectGap = new Rectangle(0, bottomOfPage, PubControl.PageWidth * dpiXScreen / MiscUtils.kdzmpInch, PubControl.Gap); gr.FillRectangle(new SolidBrush(Color.FromKnownColor(KnownColor.ControlDark)), rectGap); // Todo: draw the 3d effect around the page. } // Make a separator line above subordinate streams according to publication settings. foreach (PageElement element in PageElements) { if (!element.IsSubordinateStream || PubControl == null || PubControl.Publication.FootnoteSepWidth == 0) { continue; } // Compute the part of this element that intersects the ClipRect. Rectangle rectElement = element.PositionInLayout(indexOfThisPage, PubControl, targetDpiX, targetDpiY, unprintableAdjustment, gutterAdjustment, fScreen); int dpiX = fScreen ? dpiXScreen : (int)(PubControl.DpiXPrinter); int dpiY = fScreen ? dpiYScreen : (int)(PubControl.DpiYPrinter); Rectangle rectDst = new Rectangle(rectElement.Left, rectElement.Top + 1, dpiX, dpiY); AddSeparatorForDependentStream(gr, element, rectElement, rectDst); } // m_fReadyForDrawing = false; }
/// <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; } } } }