/// <summary> /// Determine is mouse on the element or not. /// </summary> /// <param name="point"></param> /// <returns></returns> internal override bool IsMouseOnTheElement(PointF point) { PointF[] tmpPoints = convertDataPointToPointFArrayWithTranslate(points, YAxis.HeightRate, XAxis.WidthRate, YAxis.Center, XAxis.Center); float tmpYAxesCenterWidth = XAxis.Center; if (tmpPoints.Length > 1) { if (AutoShift) { if (points.GetLast().XValue > XAxis.Maximum) { tmpYAxesCenterWidth = -((float)points.GetLast().XValue - XAxis.Maximum) * XAxis.WidthRate + YAxis.Center; } else { tmpYAxesCenterWidth = -tmpPoints[0].X + YAxis.Center; } } } System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); if (tmpPoints.Length > 2) { gp.AddLines(tmpPoints); } //if (XAxis.Labels.Count > 0) // point = new PointF(point.X - XAxis.WidthRate / 2, point.Y); point = new PointF(point.X - transLate.X, point.Y); return(gp.IsOutlineVisible(point, new Pen(Color.Red, mouseHitRay))); }
public void Plot(PlotPoint[] plotValues, float pointSize, Color clr, GraphPlotType plotType = GraphPlotType.Points) { using (Graphics g = Graphics.FromImage(graphBase)) { //draw points/lines if (plotType == GraphPlotType.Points) { for (int i = 0; i < plotValues.Length; i++) { float xpos = (plotValues[i].X * xScale) - xOffset; float ypos = (float)graphBase.Height - ((plotValues[i].Y * yScale) - yOffset); float half = pointSize / 2; g.FillEllipse(new SolidBrush(clr), xpos - half, ypos - half, pointSize, pointSize); } } else { List <PointF> points = new List <PointF>(); for (int i = 0; i < plotValues.Length; i++) { float xpos = (plotValues[i].X * xScale) - xOffset; float ypos = (float)graphBase.Height - ((plotValues[i].Y * yScale) - yOffset); points.Add(new PointF(xpos, ypos)); } System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddLines(points.ToArray()); g.DrawPath(new Pen(clr, pointSize), gp); } } }
public void DrawPolygon(PointF[] ps, Color strokeColor, float weight, Color fillColor) { using (var path = new System.Drawing.Drawing2D.GraphicsPath()) { PointF[] pt = new PointF[ps.Length]; for (int i = 0; i < ps.Length; i++) { pt[i] = ps[i]; } path.AddLines(pt); if (fillColor.A > 0) { using (var b = new SolidBrush(fillColor)) { g.FillPath(b, path); } } if (strokeColor.A > 0 && weight > 0) { using (var p = new Pen(strokeColor, weight)) { g.DrawPath(p, path); } } } }
/// <summary> /// Draw curves on graphics with transform and given pen /// </summary> static void DrawCurves( Graphics graphics, List<PointF[]> curves, System.Drawing.Drawing2D.Matrix transform, Pen pen) { foreach( PointF[] curve in curves ) { System.Drawing.Drawing2D.GraphicsPath gPath = new System.Drawing.Drawing2D.GraphicsPath(); if( curve.Length == 0 ) { break; } if( curve.Length == 1 ) { gPath.AddArc( new RectangleF( curve[0], new SizeF( 0.5f, 0.5f ) ), 0.0f, (float) Math.PI ); } else { gPath.AddLines( curve ); } if( transform != null ) gPath.Transform( transform ); graphics.DrawPath( pen, gPath ); } }
protected void UpdatePath() { // After deserialization _points array will be null. if (_points == null) { return; } if (_path != null) { _path.Dispose(); } System.Drawing.RectangleF bounds = VObjectsUtils.GetBoundingRectangle(_points); if (bounds.Width < VObject.Eps) { _points[0].X += 0.05f; } if (bounds.Height < VObject.Eps) { _points[0].Y += 0.05f; } _path = new System.Drawing.Drawing2D.GraphicsPath(); _path.AddLines(_points); if (_closePath) { _path.CloseFigure(); } }
/// <summary> /// creates the region for the control. The region will have curved edges. /// This prevents any drawing outside of the region. /// </summary> private void CreateRegion(int nContract) { Point[] points = border_Get(0, 0, this.Width, this.Height); border_Contract(nContract, ref points); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddLines(points); this.Region = new Region(path); }
private void FirstForm_Load(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddLines(new[] { new Point(0, Height / 2), new Point(Width / 2, 0), new Point(Width, Height / 2), new Point(Width / 2, Height) }); Region myRegion = new Region(myPath); this.Region = myRegion; }
private void SecondForm_Load(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddLines(new Point[] { new Point(100, 0), new Point(200, 100), new Point(100, 200), new Point(0, 100) }); Region myRegion = new Region(myPath); this.Region = myRegion; }
void DefaultPaintCell(GB_GridView.CellPaintEventArgs e) { if (m_cellPaint != null) { m_cellPaint(this, e); if (e.Handled) { return; } } GDI.Brush brush = m_background; if (e.ColumnIndex == m_mouseColumn) { brush = m_hoverbackground; } e.Graphics.FillRectangle(brush, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1); //e.Graphics.DrawRectangle(System.Drawing.Pens.Black, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1); // 判断下有没有SortGraph System.Windows.Forms.SortOrder so = GetColumnSortGraph(e.ColumnIndex); if (so != System.Windows.Forms.SortOrder.None) { GDI.Drawing2D.GraphicsPath path = new GDI.Drawing2D.GraphicsPath(); // 创建一个5*9的三角形 GDI.Point[] ptList = null; if (so == System.Windows.Forms.SortOrder.Ascending) // 箭头朝上 { ptList = new GDI.Point[] { new GDI.Point(5, 0), new GDI.Point(0, 5), new GDI.Point(9, 5) }; } else { ptList = new GDI.Point[] { new GDI.Point(4, 5), new GDI.Point(0, 0), new GDI.Point(9, 0) }; } GDI.Size offset = new GDI.Size(e.Bounds.Right - e.Bounds.Width / 2 - 5, e.Bounds.Top); path.AddLines(new GDI.Point[] { GDI.Point.Add(ptList[0], offset), GDI.Point.Add(ptList[1], offset), GDI.Point.Add(ptList[2], offset) }); e.Graphics.FillPath(m_foreground, path); path.Dispose(); } if (e.Value != null) { GDI.StringFormat sf = new System.Drawing.StringFormat(); sf.Alignment = System.Drawing.StringAlignment.Center; sf.FormatFlags = System.Drawing.StringFormatFlags.NoWrap; sf.LineAlignment = System.Drawing.StringAlignment.Center; sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter; System.Drawing.Text.TextRenderingHint hint = e.Graphics.TextRenderingHint; e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; e.Graphics.DrawString(e.Value.ToString(), Font, m_foreground, e.Bounds, sf); e.Graphics.TextRenderingHint = hint; } }
/// <summary> /// Renders a LineString to the map. /// </summary> /// <param name="g">Graphics reference</param> /// <param name="line">LineString to render</param> /// <param name="pen">Pen style used for rendering</param> /// <param name="map">Map reference</param> public static void DrawLineString(System.Drawing.Graphics g, Geometries.LineString line, System.Drawing.Pen pen, SharpMap.Map map) { if (line.Vertices.Count > 1) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddLines(line.TransformToImage(map)); g.DrawPath(pen, gp); } }
/// <summary> /// Renders a LineString to the map. /// </summary> /// <param name="g">Graphics reference</param> /// <param name="line">LineString to render</param> /// <param name="pen">Pen style used for rendering</param> /// <param name="map">Map reference</param> public static void DrawLineString(System.Drawing.Graphics g, Geometries.LineString line, System.Drawing.Pen pen, SharpMap.Map map) { if (line.Vertices.Count > 1) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddLines(line.TransformToImage(map)); g.DrawPath(pen, gp); } }
/// <summary> /// Get is mouse on the annotation polygon or not. /// </summary> /// <param name="point"></param> /// <returns></returns> internal override bool IsMouseOnTheElement(PointF point) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); if (DrawPoints.Length > 5) { gp.AddLines(DrawPoints); } return(gp.IsVisible(point)); }
private void DrawBorder(Graphics graphics) { var rectangleCloseButton = new Rectangle(Width - titleBarThickness - 1, 0, titleBarThickness, titleBarThickness); var rectangleMinimizeButton = new Rectangle(Width - titleBarThickness * 2, 0, titleBarThickness, titleBarThickness); var pLeftUp1 = new Point(0, 0); var pLeftUp2 = new Point(thickness, thickness); var pRightUp1 = new Point(Width, 0); var pRightUp2 = new Point(Width - thickness, thickness); var pLeftDown1 = new Point(0, Height); var pLeftDown2 = new Point(thickness, Height - thickness); var pRightDown1 = new Point(Width, Height); var pRightDown2 = new Point(Width - thickness, Height - thickness); //UP var pathUp = new System.Drawing.Drawing2D.GraphicsPath(); pathUp.AddLines(new[] { pLeftUp1, new Point(0, titleBarThickness), new Point(Width, titleBarThickness), pRightUp1 }); //Left var pathLeft = new System.Drawing.Drawing2D.GraphicsPath(); pathLeft.AddLines(new[] { pLeftUp1, pLeftUp2, pLeftDown2, pLeftDown1 }); //Bottom var pathBottom = new System.Drawing.Drawing2D.GraphicsPath(); pathBottom.AddLines(new[] { pLeftDown1, pLeftDown2, pRightDown2, pRightDown1 }); //Right var pathRight = new System.Drawing.Drawing2D.GraphicsPath(); pathRight.AddLines(new[] { pRightDown1, pRightDown2, pRightUp2, pRightUp1 }); //External Up graphics.SetClip(pathUp); graphics.DrawLine(PenBorder, pLeftUp1, pRightUp1); //External Left graphics.SetClip(pathLeft); graphics.DrawLine(PenBorder, pLeftUp1, pLeftDown1); //External Bottom graphics.SetClip(pathBottom); graphics.DrawLine(PenBorder, pLeftDown1, pRightDown1); //External Right graphics.SetClip(pathRight); graphics.DrawLine(PenBorder, pRightUp1, pRightDown1); graphics.ResetClip(); }
protected override void FillPath(System.Drawing.Drawing2D.GraphicsPath pPath) { Point lPoint1 = EndPos; Point lPoint2 = StartPos; int lMargin = (int)Pen.Width; lPoint1.Offset(lMargin, lMargin); lPoint2.Offset(lMargin, lMargin); pPath.AddLines(new Point[] { StartPos, EndPos, lPoint1, lPoint2 }); }
public AndControl() { ComentsInput.Size = new Size(100, 50); ComentsInput.Location = new Point(15, 35); PropabilityOutput = new Label(); PropabilityOutput.Size = new Size(33, 20); PropabilityOutput.Location = new Point(75, 90); PropabilityOutput.AutoSize = true; PropabilityOutput.Parent = this; PropabilityLabel.Location = new Point(15, 90); PropabilityLabel.Size = new Size(58, 13); Size = new Size(140, 130); ElementPanel.Size = Size; System.Drawing.Drawing2D.GraphicsPath Path = new System.Drawing.Drawing2D.GraphicsPath(); Path.AddArc(0, 0, ElementPanel.Width - 10, ElementPanel.Height - 30, 180, 180); Point[] Lines = new Point[4]; Lines[0].X = 0; Lines[0].Y = 50; Lines[1].X = 0; Lines[1].Y = ElementPanel.Height; Lines[2].X = ElementPanel.Width - 10; Lines[2].Y = ElementPanel.Height; Lines[3].X = ElementPanel.Width - 10; Lines[3].Y = 50; Path.AddLines(Lines); Region myRegion = new Region(Path); this.Region = myRegion; ElementPanel.Controls.Add(ComentsInput); ElementPanel.Controls.Add(PropabilityOutput); ElementPanel.Controls.Add(PropabilityLabel); ElementPanel.MouseEnter += (object obj, EventArgs args) => { GetInfoEvent(this, String.Format("Element:And Value:{0}", propability)); }; ElementPanel.MouseClick += ((object sender, MouseEventArgs e) => { if (e.Button == MouseButtons.Right) { if (DeleteVariable != null) { DeleteVariable((IVariable)this); } if (DeleteControl != null) { DeleteControl((ICalculate)this); } CallRemoveControl(); } }); }
public void Render(LittleSharpRenderEngine engine, Graphics graphics, ILineString line, ILineStyle style) { if (line == null || style == null) return; System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); //TODO: Does not seems to add a single long line, but multiple line segments gp.AddLines(RenderUtil.CoordToPoint(line.Coordinates)); if (style.Outlines != null) foreach(IOutline linestyle in style.Outlines) RenderUtil.RenderOutline(engine, graphics, gp, linestyle); }
private void FrmPolygonShape2_Paint(object sender, PaintEventArgs e) { /// zoom and shift the output Form f = (Form)sender; double d = f.ClientSize.Width / (double)f.ClientSize.Height; _shiftX = pt.Min(a => a.X); _shiftY = pt.Min(a => a.Y); float distX = Math.Abs(pt.Max(a => a.X) - _shiftX); float distY = Math.Abs(pt.Max(a => a.Y) - _shiftY); double factor = distX / distY; _zoom = 1.0f; _zoom = factor >= d ? (float)(f.ClientSize.Width / distX) : (float)(f.ClientSize.Height / distY); e.Graphics.ScaleTransform(_zoom, _zoom); e.Graphics.TranslateTransform(-_shiftX * _zoom, -_shiftY * _zoom, System.Drawing.Drawing2D.MatrixOrder.Append); /// make nicer look e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; /// setup the path and test for being inside using (System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath()) { myPath.AddLines(pt); myPath.CloseFigure(); using (Pen pen = new Pen(Color.Blue, 4)) e.Graphics.DrawPath(pen, myPath); using (Pen pen = new Pen(Color.Blue)) { /// IsoutlineVisible is not needed normally if (myPath.IsVisible(ptCheck) || myPath.IsOutlineVisible(ptCheck, pen)) { this.Text = "inside - Origin at " + new PointF(_shiftX, _shiftY).ToString() + "; ZoomFacotr: ";// + _zoom.ToString(); } else { this.Text = "outside - Origin at " + new PointF(_shiftX, _shiftY).ToString() + "; ZoomFacotr: ";// + _zoom.ToString(); } } } /// draw the testpoint as a small cross using (Pen pen = new Pen(Color.Red, 4)) { e.Graphics.DrawLine(pen, ptCheck.X - 5 / _zoom, ptCheck.Y, ptCheck.X + 5 / _zoom, ptCheck.Y); e.Graphics.DrawLine(pen, ptCheck.X, ptCheck.Y - 5 / _zoom, ptCheck.X, ptCheck.Y + 5 / _zoom); } }
private void DrawBorder(Graphics graphics) { var rectangleCloseButton = new Rectangle(Width - titleBarThickness - 1, 0, titleBarThickness, titleBarThickness); var rectangleMinimizeButton = new Rectangle(Width - titleBarThickness * 2, 0, titleBarThickness, titleBarThickness); var pLeftUp1 = new Point(0, 0); var pLeftUp2 = new Point(thickness, thickness); var pRightUp1 = new Point(Width, 0); var pRightUp2 = new Point(Width - thickness, thickness); var pLeftDown1 = new Point(0, Height); var pLeftDown2 = new Point(thickness, Height - thickness); var pRightDown1 = new Point(Width, Height); var pRightDown2 = new Point(Width - thickness, Height - thickness); //UP var pathUp = new System.Drawing.Drawing2D.GraphicsPath(); pathUp.AddLines(new[] { pLeftUp1, new Point(0, titleBarThickness), new Point(Width, titleBarThickness), pRightUp1 }); //Left var pathLeft = new System.Drawing.Drawing2D.GraphicsPath(); pathLeft.AddLines(new[] { pLeftUp1, pLeftUp2, pLeftDown2, pLeftDown1 }); //Bottom var pathBottom = new System.Drawing.Drawing2D.GraphicsPath(); pathBottom.AddLines(new[] { pLeftDown1, pLeftDown2, pRightDown2, pRightDown1 }); //Right var pathRight = new System.Drawing.Drawing2D.GraphicsPath(); pathRight.AddLines(new[] { pRightDown1, pRightDown2, pRightUp2, pRightUp1 }); //External Up graphics.SetClip(pathUp); graphics.DrawLine(PenBorder, pLeftUp1, pRightUp1); //External Left graphics.SetClip(pathLeft); graphics.DrawLine(PenBorder, pLeftUp1, pLeftDown1); //External Bottom graphics.SetClip(pathBottom); graphics.DrawLine(PenBorder, pLeftDown1, pRightDown1); //External Right graphics.SetClip(pathRight); graphics.DrawLine(PenBorder, pRightUp1, pRightDown1); graphics.ResetClip(); }
/// <summary> /// Erase the trail of the gesture and stop drawing /// </summary> public void RefreshAndStopDrawing() { // the drawing of gestures was finished m_gestureDrawing = false; // drawing in thread timer tick should not continue m_drawingEnded = true; // stop the thread timer m_threadTimerDraw.Change(-1, -1); if (!m_threadDrawing) { int lastIndex = m_curvePoints.Count; PointF[] points = m_curvePoints.GetRange(m_lastIndex, lastIndex - m_lastIndex).ToArray(); m_lastIndex = lastIndex - 1; if (points.Length > 1) { m_gp.DrawLines(m_pen, points); } } List <PointF> allPoints = new List <PointF>(m_curvePoints.ToArray()); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddLines(allPoints.ToArray()); RectangleF rect = path.GetBounds(); int rectShift = m_penWidth * 6; rect.X -= rectShift; rect.Y -= rectShift; rect.Width += rectShift * 2; rect.Height += rectShift * 2; //Win32.RECT r = new Win32.RECT(rect); m_drawnRegion = new Win32.RECT(rect); //Rectangle r = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height); if (!m_threadDrawing) { Debug.WriteLine(String.Format("##### InvalidateRect in MOUSE UP left: {0}, top: {1}, right: {2}, bottom: {3} ######", m_drawnRegion.left, m_drawnRegion.top, m_drawnRegion.right, m_drawnRegion.bottom)); //Win32.InvalidateRect(m_hwndForm, ref m_drawnRegion, true); Win32.RedrawWindow(m_hwndForm, ref m_drawnRegion, IntPtr.Zero, Win32.RDW_ERASE | Win32.RDW_INVALIDATE | Win32.RDW_UPDATENOW); MakeNonTopMost(); } else { m_redrawInTick = true; } //this.Invalidate(r); //Win32.RedrawWindow(m_hwndForm, ref r, IntPtr.Zero, 0x2); }
public override bool HitTest(System.Drawing.Point p) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); Pen pn = new Pen(Color.Black, 10); gp.AddLines(myPts); gp.Widen(pn); gp.IsVisible(p); pn.Dispose(); return(gp.IsVisible(p)); }
protected override void OnSizeChanged(EventArgs e) { System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.StartFigure(); path.AddLines(new Point[] { new Point(this.Width, 0), new Point(this.Width - this.Height, this.Height), new Point(this.Width, this.Height) }); path.CloseFigure(); Region reReg = new Region(path); reReg.Complement(m_Path); this.Invalidate(reReg); base.OnSizeChanged(e); this.m_Path = path; //ControlPaint.DrawSizeGrip(this.CreateGraphics(), System.Drawing.Color.FromArgb(0, 30, 88), this.Width - this.Height, 0, this.Height, this.Height); }
public void Render(LittleSharpRenderEngine engine, Graphics graphics, ILineString line, ILineStyle style) { if (line == null || style == null) { return; } System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); //TODO: Does not seems to add a single long line, but multiple line segments gp.AddLines(RenderUtil.CoordToPoint(line.Coordinates)); if (style.Outlines != null) { foreach (IOutline linestyle in style.Outlines) { RenderUtil.RenderOutline(engine, graphics, gp, linestyle); } } }
public override void Draw(Graphics g,string str) { PointF A; PointF B; System.Drawing.Drawing2D.GraphicsPath graphPath = new System.Drawing.Drawing2D.GraphicsPath(); switch(str) { case "XY": A = new PointF(_v1.X+3, g.VisibleClipBounds.Height - _v1.Y); B = new PointF(_v2.X+3, g.VisibleClipBounds.Height - _v2.Y); break; case "XZ": A = new PointF(_v1.X + 3, g.VisibleClipBounds.Height - _v1.Z); B = new PointF(_v2.X + 3, g.VisibleClipBounds.Height - _v2.Z); break; case "YZ": A = new PointF(_v1.Y + 3, g.VisibleClipBounds.Height - _v1.Z); B = new PointF(_v2.Y + 3, g.VisibleClipBounds.Height - _v2.Z); break; default: A = new PointF(); B = new PointF(); break; } PointF[] arrayOfPoint = { A, B }; graphPath.AddLines(arrayOfPoint); g.DrawPath(new Pen(Color.Black),graphPath); }
/// <summary> /// Renders a LineString to the map. /// </summary> /// <param name="g">Graphics reference</param> /// <param name="line">LineString to render</param> /// <param name="pen">Pen style used for rendering</param> /// <param name="map">Map reference</param> public static void DrawLineString(System.Drawing.Graphics g, Geometries.LineString line, System.Drawing.Pen pen, SharpMap.Map map) { if (line.Vertices.Count > 1) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddLines(line.TransformToImage(map)); if (line.UseColor) { pen.Color = line.Color; } if (line.UseCustomWidth) { g.DrawPath(new Pen(pen.Color, line.Width_), gp); } else { g.DrawPath(pen, gp); } } }
private void Form1_Load(object sender, EventArgs e) { BackColor = Color.Green; System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddLines(new[] { new Point(0, Height / 2), new Point(Width / 2, 0), new Point(Width, Height / 2), new Point(Width / 2, Height) }); Region myRegion = new Region(myPath); this.Region = myRegion; GREENPEACE.Left = (this.ClientSize.Width - GREENPEACE.Width) / 2; GREENPEACE.Top = (this.ClientSize.Height - GREENPEACE.Height) / 2; }
public static int drawer(OptsType opts, ArgsType args) { string[] commands = Regex.Split(Console.In.ReadToEnd(), @"\r?\n"); System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); List <PointF> pts = new List <PointF>(); foreach (var line in commands) { var items = Regex.Split(line, @"\s+"); if (items.Length != 2) { if (pts.Count > 0) { if (pts.Count == 1) { gp.AddLine(pts.First(), pts.First()); } else { gp.AddLines(pts.ToArray()); } pts.Clear(); } continue; } float x, y; if (float.TryParse(items[0], out x) && float.TryParse(items[1], out y)) { pts.Add(new PointF(x, y)); } } Color bgcolor = Color.Black; if (opts.ContainsKey("bgcolor")) { bgcolor = Color.FromName(opts["bgcolor"]); } Color fgcolor = Color.White; if (opts.ContainsKey("fgcolor")) { fgcolor = Color.FromName(opts["fgcolor"]); } float pensize = 1.0f; if (opts.ContainsKey("pensize")) { float val; if (float.TryParse(opts["pensize"], out val)) { pensize = val; } } string title = "fwfw drawer"; if (opts.ContainsKey("title")) { title = opts["title"]; } int width = 512; if (opts.ContainsKey("width")) { int val; if (int.TryParse(opts["width"], out val)) { width = val; } } int height = 512; if (opts.ContainsKey("height")) { int val; if (int.TryParse(opts["height"], out val)) { height = val; } } Form f = new Form(); f.Text = title; f.StartPosition = FormStartPosition.CenterScreen; f.Size = new Size(width, height); f.Resize += (s, e) => { Bitmap bitmap = new Bitmap(f.ClientRectangle.Width, f.ClientRectangle.Height); Graphics g = Graphics.FromImage(bitmap); g.FillRectangle(new SolidBrush(bgcolor), f.ClientRectangle); g.DrawPath(new Pen(fgcolor, pensize), gp); g.Dispose(); f.BackgroundImage = bitmap; }; f.MouseClick += (s, e) => { // var loc = f.PointToClient(e.Location); Console.Out.WriteLine("{e.Location.X}\t{e.Location.Y}"); }; f.Shown += (s, e) => { Bitmap bitmap = new Bitmap(f.ClientRectangle.Width, f.ClientRectangle.Height); Graphics g = Graphics.FromImage(bitmap); g.FillRectangle(new SolidBrush(bgcolor), f.ClientRectangle); g.DrawPath(new Pen(fgcolor, pensize), gp); g.Dispose(); f.BackgroundImage = bitmap; }; f.ShowDialog(); return(0); }
private void doRender(object sender, DoWorkEventArgs e) { var polygons = this.Polygons; if (!(polygons?.Any() ?? false)) { _image.Source = null; return; } _width = _layer.Map.Size.Width; _height = _layer.Map.Size.Height; initialize(); if (this.IsDirty || _paths == null) { var paths = new Dictionary <PolygonObject, IEnumerable <System.Drawing.Drawing2D.GraphicsPath> >(); foreach (var item in polygons) { var polygonPaths = new List <System.Drawing.Drawing2D.GraphicsPath>(); foreach (var pixelPoints in item.Value.PixelPoints) { var path = new System.Drawing.Drawing2D.GraphicsPath() { FillMode = System.Drawing.Drawing2D.FillMode.Alternate }; var points = pixelPoints.Select(p => p.AsGdiPointF()).ToArray(); if (_layer.UseCurvedLines) { path.AddCurve(points); } else { path.AddLines(points); } polygonPaths.Add(path); } paths[item.Value] = polygonPaths; } _paths = paths; this.IsDirty = false; } var pen = _layer.StrokeColor != null && _layer.StrokeColor != Colors.Transparent && _layer.StrokeThickness > 0 ? new System.Drawing.Pen(_layer.StrokeColor.AsGdiBrush(), (float)_layer.StrokeThickness) : null; foreach (var item in _paths) { foreach (var path in item.Value) { try { var fill = item.Key.Fill != null && item.Key.Fill != Colors.Transparent ? item.Key.Fill.AsGdiBrush() : null; if (fill != null) { _gdiGraphics.FillPath(fill, path); } if (pen != null) { _gdiGraphics.DrawPath(pen, path); } } catch { } } } _interopBitmap.Invalidate(); _interopBitmap.Freeze(); e.Result = _interopBitmap; }
/// <summary> /// creates the region for the control. The region will have curved edges. /// This prevents any drawing outside of the region. /// </summary> private void CreateRegion(int nContract) { Point[] points = border_Get(0,0,this.Width,this.Height); border_Contract(nContract,ref points); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddLines(points); this.Region = new Region(path); }
/// <summary> /// Repaints the form with cool background and stuff /// </summary> /// <param name="graph">The graphics object to paint to, the element will be drawn to 0,0</param> public virtual void Paint(Graphics graph) { //Sets up the colors to use Pen outlinePen = new Pen(MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.6 * Highlight), 1.75F); Color gradientTop = MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.7 * Highlight); Color gradientBottom = MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 1.0 * Highlight); //The path used for drop shadows System.Drawing.Drawing2D.GraphicsPath shadowPath = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Drawing2D.ColorBlend colorBlend = new System.Drawing.Drawing2D.ColorBlend(3); colorBlend.Colors = new Color[] { Color.Transparent, Color.FromArgb(180, Color.DarkGray), Color.FromArgb(180, Color.DimGray) }; colorBlend.Positions = new float[] { 0f, 0.125f,1f}; //Draws Rectangular Shapes if (Shape == ModelShapes.Rectangle) { //Draws the shadow shadowPath.AddPath(GetRoundedRect(new Rectangle(5, 5, this.Width, this.Height), 10), true); System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath); shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; shadowBrush.InterpolationColors = colorBlend; graph.FillPath(shadowBrush, shadowPath); //Draws the basic shape System.Drawing.Rectangle fillRectange = new Rectangle(0, 0, this.Width - 5, this.Height - 5); System.Drawing.Drawing2D.GraphicsPath fillArea = GetRoundedRect(fillRectange, 5); System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillRectange, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical); graph.FillPath(myBrush, fillArea); graph.DrawPath(outlinePen, fillArea); //Draws the status light drawStatusLight(graph); //Draws the text SizeF textSize = graph.MeasureString(Name, Font, this.Width); RectangleF textRect; if ((textSize.Width < this.Width) || (textSize.Height < this.Height)) textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height); else textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height); graph.DrawString(Name, Font, new SolidBrush(Color.FromArgb(50, Color.Black)), textRect); textRect.X = textRect.X - 1; textRect.Y = textRect.Y - 1; graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect); //Garbage collection fillArea.Dispose(); myBrush.Dispose(); } //Draws Ellipse Shapes if (_shape == ModelShapes.Ellipse) { //Draws the shadow shadowPath.AddEllipse(0, 5, this.Width+5, this.Height); System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath); shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; shadowBrush.InterpolationColors = colorBlend; graph.FillPath(shadowBrush, shadowPath); //Draws the Ellipse System.Drawing.Rectangle fillArea = new Rectangle(0, 0, this.Width, this.Height); System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillArea, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical); graph.FillEllipse(myBrush, 1, 1, this.Width - 5, this.Height - 5); graph.DrawEllipse(outlinePen, 1, 1, this.Width - 5, this.Height - 5); //Draws the text SizeF textSize = graph.MeasureString(_name, _font, this.Width); RectangleF textRect; if ((textSize.Width < this.Width) || (textSize.Height < this.Height)) textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height); else textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height); graph.DrawString(Name, Font, new SolidBrush(Color.FromArgb(50, Color.Black)), textRect); textRect.X = textRect.X - 1; textRect.Y = textRect.Y - 1; graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect); //Garbage collection myBrush.Dispose(); } //Draws Triangular Shapes if (_shape == ModelShapes.Triangle) { //Draws the shadow Point[] ptShadow = new Point[4]; ptShadow[0] = new Point(5, 5); ptShadow[1] = new Point(this.Width + 5, ((this.Height - 5) / 2) + 5); ptShadow[2] = new Point(5, this.Height+2); ptShadow[3] = new Point(5, 5); shadowPath.AddLines(ptShadow); System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath); shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; shadowBrush.InterpolationColors = colorBlend; graph.FillPath(shadowBrush, shadowPath); //Draws the shape Point[] pt = new Point[4]; pt[0] = new Point(0, 0); pt[1] = new Point(this.Width - 5, (this.Height-5) / 2); pt[2] = new Point(0, this.Height-5); pt[3] = new Point(0, 0); System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddLines(pt); System.Drawing.Rectangle fillArea = new Rectangle(1, 1, this.Width - 5, this.Height - 5); System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillArea, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical); graph.FillPath(myBrush, myPath); graph.DrawPath(outlinePen, myPath); //Draws the text SizeF textSize = graph.MeasureString(Name, Font, this.Width); RectangleF textRect; if ((textSize.Width < this.Width) || (textSize.Height < this.Height)) textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height); else textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height); graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect); //Garbage collection myBrush.Dispose(); } //Garbage collection shadowPath.Dispose(); outlinePen.Dispose(); }
/// <summary> /// Erase the trail of the gesture and stop drawing /// </summary> public void RefreshAndStopDrawing() { // the drawing of gestures was finished m_gestureDrawing = false; // drawing in thread timer tick should not continue m_drawingEnded = true; // stop the thread timer m_threadTimerDraw.Change(-1, -1); if (!m_threadDrawing) { int lastIndex = m_curvePoints.Count; PointF[] points = m_curvePoints.GetRange(m_lastIndex, lastIndex - m_lastIndex).ToArray(); m_lastIndex = lastIndex - 1; if (points.Length > 1) m_gp.DrawLines(m_pen, points); } List<PointF> allPoints = new List<PointF>(m_curvePoints.ToArray()); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddLines(allPoints.ToArray()); RectangleF rect = path.GetBounds(); int rectShift = m_penWidth * 6; rect.X -= rectShift; rect.Y -= rectShift; rect.Width += rectShift * 2; rect.Height += rectShift * 2; //Win32.RECT r = new Win32.RECT(rect); m_drawnRegion = new Win32.RECT(rect); //Rectangle r = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height); if (!m_threadDrawing) { Debug.WriteLine(String.Format("##### InvalidateRect in MOUSE UP left: {0}, top: {1}, right: {2}, bottom: {3} ######", m_drawnRegion.left, m_drawnRegion.top, m_drawnRegion.right, m_drawnRegion.bottom)); //Win32.InvalidateRect(m_hwndForm, ref m_drawnRegion, true); Win32.RedrawWindow(m_hwndForm, ref m_drawnRegion, IntPtr.Zero, Win32.RDW_ERASE | Win32.RDW_INVALIDATE | Win32.RDW_UPDATENOW); MakeNonTopMost(); } else m_redrawInTick = true; //this.Invalidate(r); //Win32.RedrawWindow(m_hwndForm, ref r, IntPtr.Zero, 0x2); }
public override void Draw3D(Graphics g) { float x0 = g.VisibleClipBounds.Width / 4; float y0 = g.VisibleClipBounds.Height / 4; float resultX1 = _v1.X + x0; float resultY1 = _v1.Y+y0; //float resultZ1 = _v1.Z + y0; float resultX2 = _v2.X +x0; float resultY2 = _v2.Y+y0; //float resultZ2 = _v2.Z + y0; PointF A; PointF B; System.Drawing.Drawing2D.GraphicsPath graphPath = new System.Drawing.Drawing2D.GraphicsPath(); A = new PointF(resultX1+3, resultY1); B = new PointF(resultX2+3, resultY2); PointF[] arrayOfPoint = { A, B }; graphPath.AddLines(arrayOfPoint); g.DrawPath(new Pen(Color.Black), graphPath); }
public static int drawer(OptsType opts, ArgsType args) { string[] commands = Regex.Split(Console.In.ReadToEnd(), @"\r?\n"); System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); List<PointF> pts = new List<PointF>(); foreach (var line in commands) { var items = Regex.Split(line, @"\s+"); if (items.Length != 2) { if (pts.Count > 0) { if (pts.Count == 1) { gp.AddLine(pts.First(), pts.First()); } else { gp.AddLines(pts.ToArray()); } pts.Clear(); } continue; } float x, y; if (float.TryParse(items[0], out x) && float.TryParse(items[1], out y)) { pts.Add(new PointF(x, y)); } } Color bgcolor = Color.Black; if (opts.ContainsKey("bgcolor")) { bgcolor = Color.FromName(opts["bgcolor"]); } Color fgcolor = Color.White; if (opts.ContainsKey("fgcolor")) { fgcolor = Color.FromName(opts["fgcolor"]); } float pensize = 1.0f; if (opts.ContainsKey("pensize")) { float val; if (float.TryParse(opts["pensize"], out val)) { pensize = val; } } string title = "fwfw drawer"; if (opts.ContainsKey("title")) { title = opts["title"]; } int width = 512; if (opts.ContainsKey("width")) { int val; if (int.TryParse(opts["width"], out val)) { width = val; } } int height = 512; if (opts.ContainsKey("height")) { int val; if (int.TryParse(opts["height"], out val)) { height = val; } } Form f = new Form(); f.Text = title; f.StartPosition = FormStartPosition.CenterScreen; f.Size = new Size(width, height); f.Resize += (s, e) => { Bitmap bitmap = new Bitmap(f.ClientRectangle.Width, f.ClientRectangle.Height); Graphics g = Graphics.FromImage(bitmap); g.FillRectangle(new SolidBrush(bgcolor), f.ClientRectangle); g.DrawPath(new Pen(fgcolor, pensize), gp); g.Dispose(); f.BackgroundImage = bitmap; }; f.MouseClick += (s, e) => { // var loc = f.PointToClient(e.Location); Console.Out.WriteLine("{e.Location.X}\t{e.Location.Y}"); }; f.Shown += (s, e) => { Bitmap bitmap = new Bitmap(f.ClientRectangle.Width, f.ClientRectangle.Height); Graphics g = Graphics.FromImage(bitmap); g.FillRectangle(new SolidBrush(bgcolor), f.ClientRectangle); g.DrawPath(new Pen(fgcolor, pensize), gp); g.Dispose(); f.BackgroundImage = bitmap; }; f.ShowDialog(); return 0; }
public void AddSample(float progress, float value) { if (graph == null) { graph = new Bitmap(this.Width - 2 * borderSize, this.Height - 2 * borderSize); marker = new Bitmap(graph.Width, (int)(this.Font.GetHeight(graph.VerticalResolution) + 0.5f)); drawIndex = -1; maxIndex = (int)((graph.Width - 1) * 1f / PIXELS_PER_INDEX); } int width = graph.Width; int index = (int)((graph.Width - 1) * progress / PIXELS_PER_INDEX); int count; float valueAvg; bool redrawBounds = false; if (currentIndex == index) { currentAvg += value; currentAvgCount++; return; } else if (currentAvgCount > 0) { valueAvg = (float)(currentAvg / currentAvgCount); count = samples.Count; if (count == 0 && currentIndex != 0) { samples.Add(new PointF(0, valueAvg)); count++; } samples.Add(new PointF(currentIndex, valueAvg)); count++; if (valueAvg >= maxValue) { maxValue = valueAvg * 1.01f; drawIndex = -1; redrawBounds = true; } if (valueAvg < minValue) { minValue = valueAvg * 0.99f; drawIndex = -1; redrawBounds = true; } currentIndex = index; currentAvg = value; currentAvgCount = 1; } else { currentIndex = index; currentAvg = value; currentAvgCount = 1; return; } using (var g = Graphics.FromImage(graph)) { int height = graph.Height; float range = maxValue - minValue; int i = 0; Point[] lines; Point startpoint, endpoint; if (drawIndex < 0) { drawIndex = 0; } drawIndex = 0; redrawBounds = true; lines = new Point[count - drawIndex + 1]; //previous lines within the area that needs to be updated for (int j = drawIndex; j < count; j++) { PointF s = samples[j]; lines[i++] = new Point( (int)(s.X * PIXELS_PER_INDEX), (int)(height * (1 - (s.Y - minValue) / range))); } //adding on the current point using the previous average value, unless it's the last point, then use the current average and move it to the end of the graph float currentValue; if (index == maxIndex) { currentValue = (float)(currentAvg / currentAvgCount); lines[i++] = new Point( width, (int)(height * (1 - (currentValue - minValue) / range))); } else { currentValue = valueAvg; lines[i++] = new Point( (int)(index * PIXELS_PER_INDEX), (int)(height * (1 - (currentValue - minValue) / range))); } startpoint = lines[0]; endpoint = lines[count - drawIndex]; pathGraph.Reset(); //lines path with added beginning and end pathGraph.AddLine(new Point(startpoint.X, height), startpoint); pathGraph.AddLines(lines); pathGraph.AddLine(endpoint, new Point(endpoint.X + 1, height)); //clipping the area to prevent aliased paths from overlapping Rectangle clip; if (redrawBounds) { clip = new Rectangle(0, 0, width, height); g.SetClip(clip); g.Clear(this.BackColor); textUpper = string.Format(textFormat, range * 0.75 + minValue); textLower = string.Format(textFormat, range * 0.25 + minValue); SizeF size; int w, h; size = g.MeasureString(textLower, this.Font); w = (int)(size.Width + 0.5f); h = (int)(size.Height + 0.5f); textBoundsLower = new Rectangle(width - 2 - w, (int)(height * 0.75f) - h / 2, w, h); size = g.MeasureString(textUpper, this.Font); w = (int)(size.Width + 0.5f); h = (int)(size.Height + 0.5f); textBoundsUpper = new Rectangle(width - 2 - w, (int)(height * 0.25f) - h / 2, w, h); } else { clip = new Rectangle(startpoint.X, 0, endpoint.X - startpoint.X + 1, height); g.SetClip(clip); g.Clear(this.BackColor); } #region draw clip background int x2 = clip.Right; if (x2 >= textBoundsLower.X && clip.X < textBoundsLower.Right) { g.DrawString(textLower, this.Font, brushText, textBoundsLower.X, textBoundsLower.Y); } if (x2 >= textBoundsUpper.X && clip.X < textBoundsUpper.Right) { g.DrawString(textUpper, this.Font, brushText, textBoundsUpper.X, textBoundsUpper.Y); } if (clip.X < textBoundsLower.X - 5) { int y1 = textBoundsLower.Y + textBoundsLower.Height / 2; g.DrawLine(penLine, 0, y1, textBoundsLower.X - 5, y1); //if (x2 >= textBoundsLower.X - 5) // g.DrawLine(penLine, clip.X, y1, textBoundsLower.X - 5, y1); //else // g.DrawLine(penLine, clip.X, y1, x2, y1); } if (clip.X < textBoundsUpper.X - 5) { int y1 = textBoundsUpper.Y + textBoundsUpper.Height / 2; g.DrawLine(penLine, 0, y1, textBoundsUpper.X - 5, y1); //if (x2 >= textBoundsUpper.X - 5) // g.DrawLine(penLine, clip.X, y1, textBoundsUpper.X - 5, y1); //else // g.DrawLine(penLine, clip.X, y1, x2, y1); } #endregion g.FillPath(brushGraph, pathGraph); g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; pathGraph.Reset(); if (drawIndex > 0) { //add the previous point to create an accurate line //this point is outside the clip and will not be drawn PointF s = samples[drawIndex - 1]; var previous = new Point( (int)(s.X * PIXELS_PER_INDEX), (int)(height * (1 - (s.Y - minValue) / range))); pathGraph.AddLine(previous, startpoint); } pathGraph.AddLines(lines); g.DrawPath(penGraph, pathGraph); //the next draw includes the previous point to overwrite the current value drawIndex = count - 1; this.Invalidate(new Rectangle(clip.X + borderSize, clip.Y + borderSize, clip.Width, clip.Height)); //this.Invalidate(new Rectangle(lineLocation, new Size(width, 1))); //this.Invalidate(textBounds); //lineLocation = new Point(borderSize + 1, endpoint.Y); //text = string.Format("{0:0} MB/s", currentValue); //SizeF size1 = g.MeasureString(text, this.Font); //textBounds = new Rectangle(borderSize + width - (int)(size1.Width + 0.5f) - 1, endpoint.Y - (int)(size1.Height + 0.5f) / 2, (int)(size1.Width + 0.5f), (int)(size1.Height + 0.5f)); //if (textBounds.Y < 1 + borderSize) // textBounds.Y = 1 + borderSize; //else if (textBounds.Bottom > height + borderSize - 1) // textBounds.Y = height - borderSize - 1 - textBounds.Height; //if (pathText == null) // pathText = new System.Drawing.Drawing2D.GraphicsPath(); //else // pathText.Reset(); //int st = (int)this.Font.Style; //float emSize = g.DpiY * this.Font.SizeInPoints / 72; //pathText.AddString(text, this.Font.FontFamily, st, emSize, textBounds.Location, StringFormat.GenericDefault); //this.Invalidate(new Rectangle(lineLocation, new Size(width, 1))); //this.Invalidate(textBounds); } }
private void ListView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { var item = listView.SelectedItem as Record; if (!listView.HasItems || item.EventMouse == null) { return; } try { if (g != null) { RedrawWindow(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW); g.Dispose(); //ReleaseDC(desktop); } } catch (Exception ex) { Console.WriteLine(ex); } int id = item.Id; System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red, 3); if (item.EventMouse.Action == MouseHook.MouseEvents.MouseMove) { Record last = recordList.FindLast(r => { if (r.EventMouse == null) { return(false); } return(r.Id < id && r.EventMouse.Action != MouseHook.MouseEvents.MouseMove); }); if (last == null) { last = recordList[0]; } List <Record> list = recordList.FindAll(r => r.Id <= id && r.Id > last.Id); desktop = GetDC(IntPtr.Zero); g = System.Drawing.Graphics.FromHdc(desktop); System.Drawing.Point[] points = list.ConvertAll(new Converter <Record, System.Drawing.Point>(RecordToPoint)).ToArray(); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddLines(points); g.DrawPath(pen, path); //g.Clear(System.Drawing.Color.Transparent); } else if (item.Type == Constants.MOUSE) { int lengthLine = 40; desktop = GetDC(IntPtr.Zero); g = System.Drawing.Graphics.FromHdc(desktop); System.Drawing.Point point1 = new System.Drawing.Point( (int)item.EventMouse.Location.X, (int)item.EventMouse.Location.Y - lengthLine); System.Drawing.Point point2 = new System.Drawing.Point( (int)item.EventMouse.Location.X, (int)item.EventMouse.Location.Y + lengthLine); g.DrawLine(pen, point1, point2); System.Drawing.Point point3 = new System.Drawing.Point( (int)item.EventMouse.Location.X - lengthLine, (int)item.EventMouse.Location.Y); System.Drawing.Point point4 = new System.Drawing.Point( (int)item.EventMouse.Location.X + lengthLine, (int)item.EventMouse.Location.Y); g.DrawLine(pen, point3, point4); } }
public override void AddToGraphicsPath(System.Drawing.Drawing2D.GraphicsPath path) { path.AddLines(Points); }