public Plot2D(IPlotSurface2D plotSurface) { this.plotSurface2D = plotSurface; pen = new System.Drawing.Pen (System.Drawing.Color.Red, PenWidth); marker = new Marker (Marker.MarkerType.FilledCircle, MarkerSize, System.Drawing.Color.Blue); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { components = new System.ComponentModel.Container(); m_Pen = new System.Drawing.Pen( System.Drawing.Color.Black, 1.0f ); m_Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; }
public void Draw(System.Drawing.Graphics myGraphics) { System.Drawing.Pen myPen = new System.Drawing.Pen(color,width); if (direction.get_x()*direction.get_x() + direction.get_y()*direction.get_y() != 0) // Not null vector { myGraphics.DrawLine(myPen , position.get_x()-len/2*direction.get_x() /((float) System.Math.Sqrt( direction.get_x()*direction.get_x()+direction.get_y()*direction.get_y())) , position.get_y()-len/2*direction.get_y() /((float) System.Math.Sqrt( direction.get_x()*direction.get_x()+direction.get_y()*direction.get_y())) , position.get_x()+len/2*direction.get_x() /((float) System.Math.Sqrt( direction.get_x()*direction.get_x()+direction.get_y()*direction.get_y())) , position.get_y()+len/2*direction.get_y() /((float) System.Math.Sqrt( direction.get_x()*direction.get_x()+direction.get_y()*direction.get_y()))); } else { // dc.DrawPoint(self.x,self.y) } }
//------------------------------- internal MyGdiPlusCanvas( int horizontalPageNum, int verticalPageNum, int left, int top, int width, int height) { #if DEBUG debug_canvas_id = dbug_canvasCount + 1; dbug_canvasCount += 1; #endif this.pageNumFlags = (horizontalPageNum << 8) | verticalPageNum; //2. dimension this.left = left; this.top = top; this.right = left + width; this.bottom = top + height; currentClipRect = new System.Drawing.Rectangle(0, 0, width, height); CreateGraphicsFromNativeHdc(width, height); this.gx = System.Drawing.Graphics.FromHdc(win32MemDc.DC); //------------------------------------------------------- //managed object internalPen = new System.Drawing.Pen(System.Drawing.Color.Black); internalSolidBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); this.StrokeWidth = 1; }
// prekresli sa vrchol private void repaintNodes(KDNode n) { System.Drawing.Font font = new System.Drawing.Font("Verdana", 10); System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Black); if (n.highlight) { myBrush.Color = System.Drawing.Color.Green; myPen.Color = System.Drawing.Color.Green; } if (n.highlightRed) { myBrush.Color = System.Drawing.Color.Red; myPen.Color = System.Drawing.Color.Red; } if (n.highligthIn) { myBrush.Color = System.Drawing.Color.Red; myPen.Color = System.Drawing.Color.Red; g.DrawEllipse(myPen, n.getPoint().X - (RADIUS + 2), n.getPoint().Y - (RADIUS + 2), 2 * (RADIUS + 2), 2 * (RADIUS + 2)); myPen.Color = System.Drawing.Color.Black; } g.FillEllipse(myBrush, n.getPoint().X - RADIUS, n.getPoint().Y - RADIUS, 2*RADIUS, 2*RADIUS); string s = "(" + n.getPoint().X.ToString() + "," + n.getPoint().Y.ToString() + ")"; g.DrawString(s, font, myBrush, n.getPoint().X - 35, n.getPoint().Y); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { System.Drawing.Pen p = new System.Drawing.Pen(Dot_Color); e.Graphics.FillEllipse(p.Brush,15,15,10,10); base.OnPaint(e); }
protected override void Init() { base.Init (); float penWidth = rectSizing.Width / 32f; pen = new System.Drawing.Pen (System.Drawing.Color.Red, penWidth); }
public static void Draw3ColorBar(System.Drawing.Graphics dc, System.Drawing.RectangleF r, System.Windows.Forms.Orientation orientation, System.Drawing.Color c1, System.Drawing.Color c2, System.Drawing.Color c3) { // to draw a 3 color bar 2 gradient brushes are needed // one from c1 - c2 and c2 - c3 var lr1 = r; var lr2 = r; float angle = 0; if (orientation == System.Windows.Forms.Orientation.Vertical) { angle = 270; lr1.Height = lr1.Height/2; lr2.Height = r.Height - lr1.Height; lr2.Y += lr1.Height; } if (orientation == System.Windows.Forms.Orientation.Horizontal) { angle = 0; lr1.Width = lr1.Width/2; lr2.Width = r.Width - lr1.Width; lr1.X = lr2.Right; } if (lr1.Height > 0 && lr1.Width > 0) { using (System.Drawing.Drawing2D.LinearGradientBrush lb2 = new System.Drawing.Drawing2D.LinearGradientBrush(lr2, c1, c2, angle, false), lb1 = new System.Drawing.Drawing2D.LinearGradientBrush(lr1, c2, c3, angle, false) ) { dc.FillRectangle(lb1, lr1); dc.FillRectangle(lb2, lr2); } } // with some sizes the first pixel in the gradient rectangle shows the opposite color // this is a workaround for that problem if (orientation == System.Windows.Forms.Orientation.Vertical) { using (System.Drawing.Pen pc2 = new System.Drawing.Pen(c2, 1), pc3 = new System.Drawing.Pen(c3, 1)) { dc.DrawLine(pc3, lr1.Left, lr1.Top, lr1.Right - 1, lr1.Top); dc.DrawLine(pc2, lr2.Left, lr2.Top, lr2.Right - 1, lr2.Top); } } if (orientation == System.Windows.Forms.Orientation.Horizontal) { using (System.Drawing.Pen pc1 = new System.Drawing.Pen(c1, 1), pc2 = new System.Drawing.Pen(c2, 1), pc3 = new System.Drawing.Pen(c3, 1)) { dc.DrawLine(pc1, lr2.Left, lr2.Top, lr2.Left, lr2.Bottom - 1); dc.DrawLine(pc2, lr2.Right, lr2.Top, lr2.Right, lr2.Bottom - 1); dc.DrawLine(pc3, lr1.Right, lr1.Top, lr1.Right, lr1.Bottom - 1); } } }
public void Dispose() { if (mPen != null) { mPen.Dispose(); mPen = null; } }
public DrawContext(System.Drawing.Image image) { this.LastBitmap = image as System.Drawing.Bitmap; this.graphics = System.Drawing.Graphics.FromImage(image); this.pen = new System.Drawing.Pen(this.polygonColor); this.dashPen = new System.Drawing.Pen(this.polygonColor); this.dashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; }
/// <summary> /// Creates an instance of this class /// </summary> public StreetDirectionSymbolizer() { RepeatInterval = 500; ArrowLength = 100; ArrowPen = new System.Drawing.Pen(System.Drawing.Color.Black, 2) { EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor }; }
/// <summary> /// Gets the GDI pen. /// </summary> /// <param name="pen">The GDI pen.</param> /// <returns></returns> public System.Drawing.Pen GetPen(Styles.Pen pen) { System.Drawing.Pen gdiPen; if (!pens.TryGetValue(pen, out gdiPen)) { gdiPen = new System.Drawing.Pen(pen.Color.ToGdi(), (float)pen.Width); } return gdiPen; }
public LineCord(float x1, float y1, float x2, float y2, System.Drawing.Pen p) { X1 = x1; Y1 = y1; X2 = x2; Y2 = y2; pen = p; }
public CircleCord(float x, float y, float rpx, System.Drawing.Pen p, bool fill = false) { X = x; Y = y; Rpx = rpx; Fill = fill; pen = p; }
public ColorIcon() : base() { // // Required for Windows Form Designer support // InitializeComponent(); pen = new System.Drawing.Pen(System.Drawing.Color.Black); }
protected override void ProcessRecord() { using (var g = System.Drawing.Graphics.FromImage(this.Bitmap)) { var color = System.Drawing.Color.FromArgb(this.Color); using (var pen = new System.Drawing.Pen(color, this.Width)) { g.DrawRectangle(pen, this.X0, this.Y0, this.X1, this.Y1); } } }
public void Draw(System.Drawing.Graphics g, System.Drawing.PointF Where, double ScaleFactor = 1) { Size Size = this.Size; Size.Width *= ScaleFactor; Size.Height *= ScaleFactor; Where.X *= (float)ScaleFactor; Where.Y *= (float)ScaleFactor; System.Drawing.Pen penBlack = new System.Drawing.Pen(System.Drawing.Color.Black, 1); //Рисуем прямоугольник System.Drawing.Brush brushGradient = new System.Drawing.Drawing2D.LinearGradientBrush( new System.Drawing.PointF(Where.X, Where.Y), new System.Drawing.PointF(Where.X + (float)Size.Width - 1, Where.Y + (float)Size.Height - 1), Xwt.Ext.CanvasSystemDrawing.DrawingExtensions.ToWindowsColor(this.Color), Xwt.Ext.CanvasSystemDrawing.DrawingExtensions.ToWindowsColor(this.Color.BlendWith(Colors.White, 0.8)) ); g.FillRectangle(brushGradient, Where.X, Where.Y, (float)Size.Width - 1, (float)Size.Height - 1); float Factor = (this.DrawDescription) ? 3 : 2; if (!DrawImg || Img == null) { g.DrawString(this.Text, new System.Drawing.Font(Font.Family, (float)Font.Size), new System.Drawing.SolidBrush(System.Drawing.Color.Black), new System.Drawing.RectangleF(Where.X, Where.Y + ((float)Size.Height - 1) / Factor - (float)Font.Size / 2, (float)Size.Width - 1, (float)Size.Height - 1), new System.Drawing.StringFormat() { Alignment = System.Drawing.StringAlignment.Center } ); if (DrawDescription) g.DrawString(this.Description, new System.Drawing.Font(DescriptionFont.Family, (float)DescriptionFont.Size), new System.Drawing.SolidBrush(System.Drawing.Color.Black), new System.Drawing.RectangleF(Where.X, Where.Y + 2 * ((float)Size.Height - 1) / 3 - (float)Font.Size / 2, (float)Size.Width - 1, (float)Size.Height - 1), new System.Drawing.StringFormat() { Alignment = System.Drawing.StringAlignment.Center } ); } else { g.DrawImage(Img, new System.Drawing.Rectangle((int)(Where.X + 0 * Size.Width / 8f) + 1, (int)(Where.Y + 0 * Size.Height / 10f) + 1, (int)(8 * Size.Width / 8f) - 1, (int)(8 * Size.Height / 8f) - 1)); g.DrawAdaptiveString(this.Text, new System.Drawing.Font(Font.Family, (float)Font.Size), new System.Drawing.SolidBrush(System.Drawing.Color.Black), new System.Drawing.RectangleF(Where.X, Where.Y + ((float)Size.Height - 1) * 0.865f, (float)Size.Width - 1, (float)Size.Height * 0.13f), new System.Drawing.StringFormat() { Alignment = System.Drawing.StringAlignment.Center } ); } g.DrawRectangle(new System.Drawing.Pen(System.Drawing.Color.Gray), Where.X, Where.Y, (float)Size.Width - 1, (float)Size.Height - 1); }
public void dbug_HighlightMeNow(Rectangle rect) { using (System.Drawing.Pen mpen = new System.Drawing.Pen(System.Drawing.Brushes.White, 2)) using (System.Drawing.Graphics g = this.dbugCreateGraphics()) { System.Drawing.Rectangle r = rect.ToRect(); g.DrawRectangle(mpen, r); g.DrawLine(mpen, new System.Drawing.Point(r.X, r.Y), new System.Drawing.Point(r.Right, r.Bottom)); g.DrawLine(mpen, new System.Drawing.Point(r.X, r.Bottom), new System.Drawing.Point(r.Right, r.Y)); } }
public void Draw(System.Drawing.Graphics myGraphics) { if (m_visible) { System.Drawing.Pen myPen = new System.Drawing.Pen(m_color,m_width); foreach (Physic.Position pos in this.get_positions()) { myGraphics.DrawLine(myPen,pos.get_x(),pos.get_y()-m_marker_len/2,pos.get_x(),pos.get_y()+m_marker_len/2); myGraphics.DrawLine(myPen,pos.get_x()-m_marker_len/2,pos.get_y(),pos.get_x()+m_marker_len/2,pos.get_y()); } } }
public virtual void Init() { x1 = x2 = y1 = y2 = 0; needFilling = false; needOutline = true; filling = new System.Drawing.SolidBrush(System.Drawing.Color.White); outline = new System.Drawing.Pen(System.Drawing.Color.Black); outline.Width = 1; selectionPen = new System.Drawing.Pen(System.Drawing.Brushes.Blue,1); selectionPen.DashStyle=System.Drawing.Drawing2D.DashStyle.Dash; }
protected override void DrawPath(SeriesBase series, System.Drawing.Pen pen) { if (series is ColumnSeries) { var points = new PointCollection(); var pointCount = 0; var rects = new List<Rect>(); ColumnSeries columnSeries = series as ColumnSeries; points = columnSeries.ColumnPoints; pointCount = columnSeries.ColumnPoints.Count; rects = columnSeries.Rects; System.Drawing.Brush fill = columnSeries.Fill.AsDrawingBrush(); System.Drawing.Pen fillPen = new System.Drawing.Pen(fill); if (RenderingMode == RenderingMode.Default) { for (int i = 0; i < columnSeries.Parts.Count; i++) { System.Windows.Shapes.Rectangle element = (columnSeries.Parts[i] as ColumnPart).CreatePart() as System.Windows.Shapes.Rectangle; if (element != null && !PartsCanvas.Children.Contains(element)) PartsCanvas.Children.Add(element); } } else { for (int i = 0; i < rects.Count; i++) { Rect rect=rects[i]; switch (RenderingMode) { case RenderingMode.GDIRendering: GDIGraphics.DrawRectangle(pen, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); GDIGraphics.FillRectangle(fill, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); break; case RenderingMode.Default: break; case RenderingMode.WritableBitmap: this.WritableBitmap.Lock(); WritableBitmapGraphics.DrawRectangle(pen, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); WritableBitmapGraphics.FillRectangle(fill, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); this.WritableBitmap.Unlock(); break; default: break; } } this.Collection.InvalidateBitmap(); } } }
internal void Draw(PaintEventArgs pe, int nX, int nY, int nSide) { nX += 8; nY += 8; int nPenWidth = Math.Max (nSide / 15, 1); Color clr =Color.Blue; Brush brsh = brush == Selected.YES ? not_selected_color : selected_color; using (Pen aPen = new Pen(clr, nPenWidth)) { pe.Graphics.DrawEllipse (aPen, nX, nY, nSide, nSide); pe.Graphics.FillEllipse (brsh, nX, nY, nSide, nSide); } }
protected void CreateImage(string filename, byte[] data, System.Drawing.Color c) { int width = data.Length; int height = 256; System.Drawing.Pen pen = new System.Drawing.Pen(c); System.Drawing.Bitmap image = new System.Drawing.Bitmap(width, height); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image); g.Clear(System.Drawing.Color.White); for (int i = 0; i < width - 1; ++i) { g.DrawLine(pen, i, height - 1 - data[i], i + 1, height - 1 - data[i + 1]); } image.Save(filename); }
// prekresli sa bunka vrchola private void repaintBoxes(KDNode n) { if (n.isLeaf) { System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Black); if (n.highligthBox) { myBrush.Color = System.Drawing.Color.LightSteelBlue; g.FillRectangle(myBrush, n.from.X, n.from.Y, n.to.X - n.from.X, n.to.Y - n.from.Y); } //Console.WriteLine("vrchol: " + n.getPoint() + " from: " + n.from + " to: " + n.to); g.DrawRectangle(myPen, n.from.X, n.from.Y, n.to.X - n.from.X, n.to.Y - n.from.Y); } else { //Console.WriteLine("vrchol: (" + n.getSplit() + " from: " + n.from + " to: " + n.to); } }
public Renderer() { this.gd = Static.Device; var window = Static.Window; var control = Static.RenderTarget; window.Move += Renderer_Move; window.Shown += Renderer_Move; control.Move += Renderer_Move; control.SizeChanged += control_Resize; effect = Static.Effect; AdjustDevice(); volume = Static.Volume; Pen2D pen = new Pen2D(System.Drawing.Color.White, 3); var lineCross = new Bitmap2D(40, 40); Graphics2D glc = Graphics2D.FromImage(lineCross); glc.DrawLine(pen, 20, 0, 20, 16); glc.DrawLine(pen, 20, 24, 20, 40); glc.DrawLine(pen, 0, 20, 16, 20); glc.DrawLine(pen, 24, 20, 40, 20); layerLineCross = new Layer(GraphicsHelper.Convert(lineCross, gd), 1, 0.7f, LayerDock.Center, LayerDock.Center, () => true); layerLineCross.Push(new LayerCell { SourceTexture = new Rectangle(0, 0, 40, 40), DestinationScreen = new Rectangle(-18, -18, 36, 36) }); layerCurrentChatLine = new TextLayer("> ", 0.7f, LayerDock.Near, LayerDock.Near, () => Static.GameManager.chat); layerCurrentChatLine.Translation = () => new Vector2(10, 10 + layerCurrentChatLine.Height - 30); chatHistory = new Queue<Layer>(); debug1 = new TextLayer("", 0.7f, LayerDock.Near, LayerDock.Far, () => true); debug1.Translation = () => new Vector2(0, -30); debug2 = new TextLayer("", 0.7f, LayerDock.Near, LayerDock.Far, () => true); debug2.Translation = () => new Vector2(0, -60); debug3 = new TextLayer("", 0.7f, LayerDock.Near, LayerDock.Far, () => true); debug3.Translation = () => new Vector2(0, -90); currentMat = new TextLayer("", 0.7f, LayerDock.Near, LayerDock.Far, () => true); currentMat.Translation = () => new Vector2(0, -120); hoverBox = HelpfulStuff.getCube(0.51f, GraphicsHelper.TextureCoord(36)); }
public static void DrawFrame(System.Drawing.Graphics dc, System.Drawing.RectangleF r, float cornerRadius, System.Drawing.Color color) { var pen = new System.Drawing.Pen(color); if (cornerRadius <= 0) { dc.DrawRectangle(pen, ColorPickerUtil.Rect(r)); return; } cornerRadius = (float)System.Math.Min(cornerRadius, System.Math.Floor(r.Width) - 2); cornerRadius = (float)System.Math.Min(cornerRadius, System.Math.Floor(r.Height) - 2); var path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddArc(r.X, r.Y, cornerRadius, cornerRadius, 180, 90); path.AddArc(r.Right - cornerRadius, r.Y, cornerRadius, cornerRadius, 270, 90); path.AddArc(r.Right - cornerRadius, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 0, 90); path.AddArc(r.X, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 90, 90); path.CloseAllFigures(); dc.DrawPath(pen, path); }
public GdiPlusCanvasPainter(System.Drawing.Bitmap gfxBmp) { _width = 800;// gfxBmp.Width; _height = 600;// gfxBmp.Height; _gfxBmp = gfxBmp; _gfx = System.Drawing.Graphics.FromImage(_gfxBmp); //credit: //http://stackoverflow.com/questions/1485745/flip-coordinates-when-drawing-to-control _gfx.ScaleTransform(1.0F, -1.0F);// Flip the Y-Axis _gfx.TranslateTransform(0.0F, -(float)Height);// Translate the drawing area accordingly _currentFillBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); _currentPen = new System.Drawing.Pen(System.Drawing.Color.Black); // _bmpStore = new BufferBitmapStore(_width, _height); }
public override void ExecuteResult(ControllerContext context) { System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(100, 30); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp); g.Clear(System.Drawing.Color.Navy); string randomString = GetCaptchaString(6); context.HttpContext.Session["captchastring"] = randomString; #region //add noise , if dont want any noisy , then make it false. bool noisy = false; if (noisy) { var rand = new Random((int)DateTime.Now.Ticks); int i, r, x, y; var pen = new System.Drawing.Pen(System.Drawing.Color.Yellow); for (i = 1; i < 10; i++) { pen.Color = System.Drawing.Color.FromArgb( (rand.Next(0, 255)), (rand.Next(0, 255)), (rand.Next(0, 255))); r = rand.Next(0, (130 / 3)); x = rand.Next(0, 130); y = rand.Next(0, 30); int m = x - r; int n = y - r; g.DrawEllipse(pen, m, n, r, r); } } //end noise #endregion g.DrawString(randomString, new System.Drawing.Font("Courier", 16), new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke), 2, 2); System.Web.HttpResponseBase response = context.HttpContext.Response; response.ContentType = "image/jpeg"; bmp.Save(response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); bmp.Dispose(); }
public static System.Drawing.Bitmap create_hue_bitmap2(int width, int height) { var bitmap = new System.Drawing.Bitmap(width, height); using (var gfx = System.Drawing.Graphics.FromImage(bitmap)) { for (int x = 0; x < width; x++) { var h = x / (double)bitmap.Width; double _sat = 1.0; double _val = 1.0; var c0 = VisioAutomation.UI.ColorUtil.HSVToSystemDrawingColor(h, _sat, _val); uint rgb = (uint) (c0.R << 16 | c0.G << 8 | c0.B); uint mask = 0xff000000; var c2 = System.Drawing.Color.FromArgb((int)(mask | rgb)); using (var p = new System.Drawing.Pen(c2)) { gfx.DrawLine(p, x, 0, x, bitmap.Height); } } } return bitmap; }
private void btnSubmit_Click(object sender, EventArgs e) { try { test.IP = IPAddress.Parse(txtIP.Text); test.GetLocation(); lblCity.Text = "City: " + test.City; lblCountry.Text = "Country: " + test.Country; lblLatitude.Text = "Latitude: " + test.Latitude; lblLongitude.Text = "Longitude: " + test.Longitude; if (test.Longitude != 361) { float xplot = ((float)imgMap.Width / 360) * (180 + test.Longitude); float yplot = ((float)imgMap.Height / 180) * (90 - test.Latitude); System.Drawing.Pen myPen; myPen = new System.Drawing.Pen(System.Drawing.Color.White, 1); System.Drawing.Graphics formGraphics = imgMap.CreateGraphics(); imgMap.Refresh(); formGraphics.DrawLine(myPen, xplot, 0, xplot, imgMap.Height); formGraphics.DrawLine(myPen, 0, yplot, imgMap.Width, yplot); } } catch (Exception ex){ MessageBox.Show(ex.Message); }; }
//**************************************************************** // Serialization - Nodes conditionally serialize their parent. // This means that only the parents that were unconditionally // (using GetObjectData) serialized by someone else will be restored // when the node is deserialized. //**************************************************************** /// <summary> /// Read this this P3DRectangle and all its children from the given SerializationInfo. /// </summary> /// <param name="info">The SerializationInfo to read from.</param> /// <param name="context"> /// The StreamingContext of this serialization operation. /// </param> /// <remarks> /// This constructor is required for Deserialization. /// </remarks> protected P3DRectangle(SerializationInfo info, StreamingContext context) : base(info, context) { pen = PUtil.ReadPen(info); }
/// <summary> /// Constructs a new P3DRectangle with empty bounds. /// </summary> public P3DRectangle() { raised = true; pen = new System.Drawing.Pen(System.Drawing.Brushes.Black, 0); path = new XnaGraphicsPath(); }
/// <summary> /// Provides examples for rendering events /// </summary> private void BindMediaRenderingEvents() { if (System.Diagnostics.Debugger.IsAttached == false) { return; } #region Audio and Video Frame Rendering Variables // Setup GDI+ graphics System.Drawing.Bitmap overlayBitmap = null; System.Drawing.Graphics overlayGraphics = null; var overlayTextFont = new System.Drawing.Font("Arial", 14, System.Drawing.FontStyle.Bold); var overlayTextFontBrush = System.Drawing.Brushes.WhiteSmoke; var overlayTextOffset = new System.Drawing.PointF(12, 8); var overlayBackBuffer = IntPtr.Zero; var drawVuMeterLeftPen = new System.Drawing.Pen(System.Drawing.Color.OrangeRed, 12); var drawVuMeterRightPen = new System.Drawing.Pen(System.Drawing.Color.GreenYellow, 12); var drawVuMeterRmsLock = new object(); var drawVuMeterLeftRms = new SortedDictionary <TimeSpan, double>(); var drawVuMeterRightRms = new SortedDictionary <TimeSpan, double>(); var drawVuMeterLeftValue = 0d; var drawVuMeterRightValue = 0d; const float drawVuMeterLeftOffset = 16; const float drawVuMeterTopOffset = 50; const float drawVuMeterScaleFactor = 20; // RMS * pixel factor = the length of the VU meter lines #endregion #region Rendering Event Examples Media.RenderingVideo += (s, e) => { #region Create the overlay buffer to work with if (overlayBackBuffer != e.Bitmap.Scan0) { lock (drawVuMeterRmsLock) { drawVuMeterLeftRms.Clear(); drawVuMeterRightRms.Clear(); } if (overlayGraphics != null) { overlayGraphics.Dispose(); } if (overlayBitmap != null) { overlayBitmap.Dispose(); } overlayBitmap = e.Bitmap.CreateDrawingBitmap(); overlayBackBuffer = e.Bitmap.Scan0; overlayGraphics = System.Drawing.Graphics.FromImage(overlayBitmap); overlayGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; } #endregion #region Read the instantaneous RMS of the audio lock (drawVuMeterRmsLock) { var position = e.Clock; drawVuMeterLeftValue = drawVuMeterLeftRms.Where(kvp => kvp.Key > position).Select(kvp => kvp.Value).FirstOrDefault(); drawVuMeterRightValue = drawVuMeterRightRms.Where(kvp => kvp.Key > position).Select(kvp => kvp.Value).FirstOrDefault(); // do some cleanup so the dictionary does not grow too big. if (drawVuMeterLeftRms.Count > 256) { var keysToRemove = drawVuMeterLeftRms.Keys.Where(k => k < position).OrderBy(k => k).ToArray(); foreach (var k in keysToRemove) { drawVuMeterLeftRms.Remove(k); drawVuMeterRightRms.Remove(k); if (drawVuMeterLeftRms.Count < 256) { break; } } } } #endregion #region Draw the text and the VU meter var differenceMillis = TimeSpan.FromTicks(e.Clock.Ticks - e.StartTime.Ticks).TotalMilliseconds; overlayGraphics.DrawString($"Clock: {e.StartTime.TotalSeconds:00.000} | Skew: {differenceMillis:00.000} | PN: {e.PictureNumber}", overlayTextFont, overlayTextFontBrush, overlayTextOffset); // draw a simple VU meter overlayGraphics.DrawLine(drawVuMeterLeftPen, drawVuMeterLeftOffset, drawVuMeterTopOffset, drawVuMeterLeftOffset + 5 + (Convert.ToSingle(drawVuMeterLeftValue) * drawVuMeterScaleFactor), drawVuMeterTopOffset); overlayGraphics.DrawLine(drawVuMeterRightPen, drawVuMeterLeftOffset, drawVuMeterTopOffset + 20, drawVuMeterLeftOffset + 5 + (Convert.ToSingle(drawVuMeterRightValue) * drawVuMeterScaleFactor), drawVuMeterTopOffset + 20); #endregion }; Media.RenderingAudio += (s, e) => { // The buffer contains all the samples var buffer = new byte[e.BufferLength]; Marshal.Copy(e.Buffer, buffer, 0, e.BufferLength); // We need to split the samples into left and right samples var leftSamples = new double[e.SamplesPerChannel]; var rightSamples = new double[e.SamplesPerChannel]; // Iterate through the buffer var isLeftSample = true; var sampleIndex = 0; var samplePercent = default(double); for (var i = 0; i < e.BufferLength; i += e.BitsPerSample / 8) { samplePercent = 100d * buffer.GetAudioSampleLevel(i); if (isLeftSample) { leftSamples[sampleIndex] = samplePercent; } else { rightSamples[sampleIndex] = samplePercent; } sampleIndex += !isLeftSample ? 1 : 0; isLeftSample = !isLeftSample; } // Compute the RMS of the samples and save it for the given point in time. lock (drawVuMeterRmsLock) { // The VU meter should show the audio RMS, we compute it and save it in a dictionary. drawVuMeterLeftRms[e.StartTime] = Math.Sqrt((1d / leftSamples.Length) * leftSamples.Sum(n => n)); drawVuMeterRightRms[e.StartTime] = Math.Sqrt((1d / rightSamples.Length) * rightSamples.Sum(n => n)); } }; Media.RenderingSubtitles += (s, e) => { // a simple example of suffixing subtitles // if (e.Text != null && e.Text.Count > 0 && e.Text[e.Text.Count - 1] != "(subtitles)") // e.Text.Add("(subtitles)"); }; #endregion }
/// <summary> /// Provides examples for rendering events /// </summary> private void BindMediaRenderingEvents() { if (System.Diagnostics.Debugger.IsAttached == false) { return; } #region Audio and Video Frame Rendering Variables // Setup GDI+ graphics System.Drawing.Bitmap overlayBitmap = null; System.Drawing.Graphics overlayGraphics = null; var overlayTextFont = new System.Drawing.Font("Courier New", 14, System.Drawing.FontStyle.Bold); var overlayTextFontBrush = System.Drawing.Brushes.WhiteSmoke; var overlayTextOffset = new System.Drawing.PointF(12, 8); var overlayBackBuffer = IntPtr.Zero; var drawVuMeterLeftPen = new System.Drawing.Pen(System.Drawing.Color.OrangeRed, 12); var drawVuMeterRightPen = new System.Drawing.Pen(System.Drawing.Color.GreenYellow, 12); var drawVuMeterClock = TimeSpan.Zero; var drawVuMeterRmsLock = new object(); var drawVuMeterLeftValue = 0d; var drawVuMeterRightValue = 0d; double[] drawVuMeterLeftSamples = null; double[] rdrawVuMeterRightSamples = null; const float drawVuMeterLeftOffset = 36; const float drawVuMeterTopSpacing = 20; const float drawVuMeterTopOffset = 82; const float drawVuMeterMinWidth = 5; const float drawVuMeterScaleFactor = 20; // RMS * pixel factor = the length of the VU meter lines #endregion #region Rendering Event Examples Media.RenderingVideo += (s, e) => { #region Create the overlay buffer to work with if (overlayBackBuffer != e.Bitmap.Scan0) { lock (drawVuMeterRmsLock) { drawVuMeterLeftValue = 0; drawVuMeterRightValue = 0; } if (overlayGraphics != null) { overlayGraphics.Dispose(); } if (overlayBitmap != null) { overlayBitmap.Dispose(); } overlayBitmap = e.Bitmap.CreateDrawingBitmap(); overlayBackBuffer = e.Bitmap.Scan0; overlayGraphics = System.Drawing.Graphics.FromImage(overlayBitmap); overlayGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; } #endregion #region Draw the text and the VU meter double differenceMillis = 0d; float leftChannelWidth = 0; float rightChannelWidth = 0; if (e.EngineState.HasAudio) { lock (drawVuMeterRmsLock) { differenceMillis = Math.Round(TimeSpan.FromTicks(drawVuMeterClock.Ticks - e.StartTime.Ticks).TotalMilliseconds, 0); leftChannelWidth = drawVuMeterMinWidth + (Convert.ToSingle(drawVuMeterLeftValue) * drawVuMeterScaleFactor); rightChannelWidth = drawVuMeterMinWidth + (Convert.ToSingle(drawVuMeterRightValue) * drawVuMeterScaleFactor); } } overlayGraphics.DrawString($"Clock: {e.Clock.TotalSeconds:00.00}\r\nPN : {e.PictureNumber}\r\nA/V : {differenceMillis:+000;-000}\r\nL \r\nR", overlayTextFont, overlayTextFontBrush, overlayTextOffset); // draw a simple VU meter overlayGraphics.DrawLine(drawVuMeterLeftPen, drawVuMeterLeftOffset, drawVuMeterTopOffset, drawVuMeterLeftOffset + leftChannelWidth, drawVuMeterTopOffset); overlayGraphics.DrawLine(drawVuMeterRightPen, drawVuMeterLeftOffset, drawVuMeterTopOffset + drawVuMeterTopSpacing, drawVuMeterLeftOffset + rightChannelWidth, drawVuMeterTopOffset + drawVuMeterTopSpacing); #endregion }; Media.RenderingAudio += (s, e) => { // If we don't have video, we don't need to draw a thing. if (e.EngineState.HasVideo == false) { return; } // We need to split the samples into left and right sample channels if (drawVuMeterLeftSamples == null || drawVuMeterLeftSamples.Length != e.SamplesPerChannel) { drawVuMeterLeftSamples = new double[e.SamplesPerChannel]; } if (rdrawVuMeterRightSamples == null || rdrawVuMeterRightSamples.Length != e.SamplesPerChannel) { rdrawVuMeterRightSamples = new double[e.SamplesPerChannel]; } // Iterate through the buffer var isLeftSample = true; var sampleIndex = 0; var samplePercent = default(double); for (var i = 0; i < e.BufferLength; i += e.BitsPerSample / 8) { samplePercent = 100d * e.Buffer.GetAudioSampleLevel(i); if (isLeftSample) { drawVuMeterLeftSamples[sampleIndex] = samplePercent; } else { rdrawVuMeterRightSamples[sampleIndex] = samplePercent; } sampleIndex += !isLeftSample ? 1 : 0; isLeftSample = !isLeftSample; } // Compute the RMS of the samples and save it for the given point in time. lock (drawVuMeterRmsLock) { // The VU meter should show the audio RMS, we compute it and save it in a dictionary. drawVuMeterClock = TimeSpan.FromTicks(e.StartTime.Ticks + (e.Duration.Ticks / 2)); drawVuMeterLeftValue = Math.Sqrt((1d / drawVuMeterLeftSamples.Length) * drawVuMeterLeftSamples.Sum(n => n)); drawVuMeterRightValue = Math.Sqrt((1d / rdrawVuMeterRightSamples.Length) * rdrawVuMeterRightSamples.Sum(n => n)); } }; Media.RenderingSubtitles += (s, e) => { // a simple example of suffixing subtitles // if (e.Text != null && e.Text.Count > 0 && e.Text[e.Text.Count - 1] != "(subtitles)") // e.Text.Add("(subtitles)"); }; Media.AudioDeviceStopped += (s, e) => { // If we detect that the audio device has stopped, simply // call the changemedia command so the default audio device gets selected // and reopened. See issue #93 var task = Media.ChangeMedia(); }; #endregion }
public async Task <IActionResult> Edit(int id, [Bind("AmazonProductColorID,AmazonProductID,AmazonColorID,DesignURL,Name,Opacity,Top,Left,Right,Bot")] AmazonProductColor amazonProductColor, IFormFile DesignURL, string oldURL, string oldThumb) { if (id != amazonProductColor.AmazonProductColorID) { return(NotFound()); } if (ModelState.IsValid) { try { if (DesignURL != null) { var fullUploadPath = Path.Combine(_environment.WebRootPath, COLOR_DIR); var extension = DesignURL.FileName.Split('.').Last(); var filename = amazonProductColor.AmazonProductColorID + "." + extension; fullUploadPath = Path.Combine(fullUploadPath, filename); using (var fileStream = new FileStream(fullUploadPath, FileMode.Create)) { System.IO.File.Delete(Path.Combine(_environment.WebRootPath, oldURL)); await DesignURL.CopyToAsync(fileStream); amazonProductColor.DesignURL = Path.Combine(COLOR_DIR, filename); } } else { amazonProductColor.DesignURL = oldURL; } var thumbURL = Path.Combine(THUMB_DIR, amazonProductColor.AmazonProductColorID + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg"); var outputImage = Path.Combine(_environment.WebRootPath, thumbURL); var baseImage = Path.Combine(_environment.WebRootPath, amazonProductColor.DesignURL); System.IO.File.Delete(Path.Combine(_environment.WebRootPath, oldThumb)); System.Drawing.Image m_baseimage = System.Drawing.Image.FromFile(baseImage); System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Black); System.Drawing.Graphics.FromImage(m_baseimage).DrawLine(myPen, new System.Drawing.Point(amazonProductColor.Left, 0), new System.Drawing.Point(amazonProductColor.Left, m_baseimage.Height)); System.Drawing.Graphics.FromImage(m_baseimage).DrawLine(myPen, new System.Drawing.Point(amazonProductColor.Right, 0), new System.Drawing.Point(amazonProductColor.Right, m_baseimage.Height)); System.Drawing.Graphics.FromImage(m_baseimage).DrawLine(myPen, new System.Drawing.Point(0, amazonProductColor.Top), new System.Drawing.Point(m_baseimage.Width, amazonProductColor.Top)); System.Drawing.Graphics.FromImage(m_baseimage).DrawLine(myPen, new System.Drawing.Point(0, amazonProductColor.Bot), new System.Drawing.Point(m_baseimage.Width, amazonProductColor.Bot)); m_baseimage.Save(outputImage); m_baseimage.Dispose(); amazonProductColor.ThumbURL = thumbURL; _context.Update(amazonProductColor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AmazonProductColorExists(amazonProductColor.AmazonProductColorID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Edit", new { id = amazonProductColor.AmazonProductColorID })); } amazonProductColor = await _context.AmazonProductColors .Include(i => i.AmazonProduct) .Include(i => i.AmazonColor) .SingleOrDefaultAsync(m => m.AmazonProductColorID == id); ViewData["AmazonProductID"] = new SelectList(_context.AmazonProducts, "AmazonProductID", "Name", amazonProductColor.AmazonProductID); ViewData["AmazonColorID"] = new SelectList(_context.AmazonColors, "AmazonColorID", "Name", amazonProductColor.AmazonColorID); return(View(amazonProductColor)); }
public static void DebugDrawLine(Coordinates cord, double angle, double lenght, System.Drawing.Pen p, IGraphics graphicDevice) { DebugDrawLine(cord.X, cord.Y, angle, lenght, p, graphicDevice); }
protected override void RenderChart(System.Drawing.Graphics graphics, Palette palette, Bamboo.Css.StyleStack styleStack, System.Drawing.RectangleF rectangle, string title, Bamboo.DataStructures.Table table) { styleStack.PushTag("PieChart"); string backColor = (string)styleStack["BackColor"]; Bamboo.Css.Font font = (Bamboo.Css.Font)styleStack["Font"]; string foreColor = (string)styleStack["ForeColor"]; int padding = (int)styleStack["Padding"]; string[] colors = (string[])styleStack["Colors"]; //TODO put in stylesheet. System.Drawing.Font titleFont = palette.Font(font.Name, font.Size * 1.2f, System.Drawing.FontStyle.Bold); //TODO put in stylesheet. System.Drawing.Font labelFont = palette.Font(font.Name, font.Size, System.Drawing.FontStyle.Bold); System.Drawing.Pen backColorPen = palette.Pen(backColor); System.Drawing.Brush backColorBrush = palette.Brush(backColor); System.Drawing.Brush foreColorBrush = palette.Brush(foreColor); // Background graphics.DrawRectangle(backColorPen, rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height); graphics.FillRectangle(backColorBrush, rectangle); rectangle = new System.Drawing.RectangleF(rectangle.Left + padding, rectangle.Top + padding, rectangle.Width - padding - padding, rectangle.Height - padding - padding); // Title if (title != null) { rectangle = DrawTitle(title, titleFont, foreColorBrush, graphics, rectangle); } //TODO // Legend // rectangle = new System.Drawing.RectangleF(rectangle.Left, rectangle.Top, rectangle.Width - padding - padding, rectangle.Height); Slice[] slices = new Slice[table.Rows.Count]; float sum = 0; for (int i = 0; i < table.Rows.Count; i++) { Bamboo.DataStructures.Tuple row = table.Rows[i]; slices[i].Label = row[0].ToString(); float value = System.Convert.ToSingle(row[1]); slices[i].Value = value; sum += value; } sum /= 360; float startAngle = -90; for (int i = 0; i < slices.Length; i++) { slices[i].StartAngle = startAngle; float sweepAngle = slices[i].Value / sum; slices[i].SweepAngle = sweepAngle; double startPlusHalfSweepRadian = DegreeToRadian(startAngle + (sweepAngle / 2)); slices[i].LabelCos = (float)Math.Cos(startPlusHalfSweepRadian); slices[i].LabelSin = (float)Math.Sin(startPlusHalfSweepRadian); System.Drawing.SizeF sizef = MeasureString(graphics, slices[i].Label, labelFont); slices[i].LabelWidth = sizef.Width; slices[i].LabelHeight = sizef.Height; slices[i].Adjacent = slices[i].LabelCos * slices[i].LabelWidth; slices[i].Opposite = slices[i].LabelSin * slices[i].LabelHeight; slices[i].Hypotenuse = (float)Math.Sqrt((slices[i].Adjacent * slices[i].Adjacent) + (slices[i].Opposite * slices[i].Opposite)); slices[i].Brush = palette.Brush(colors[i % colors.Length]); startAngle += sweepAngle; } float x_min = 0; float x_max = 0; float y_min = 0; float y_max = 0; for (int i = 0; i < slices.Length; i++) { x_min = Math.Min(x_min, slices[i].Adjacent); x_max = Math.Max(x_max, slices[i].Adjacent); y_min = Math.Min(y_min, slices[i].Opposite); y_max = Math.Max(y_max, slices[i].Opposite); } float x_offset = Math.Max(Math.Abs(x_min), x_max); float y_offset = Math.Max(Math.Abs(y_min), y_max); rectangle = new System.Drawing.RectangleF(rectangle.Left + x_offset, rectangle.Top + y_offset, rectangle.Width - (x_offset * 2), rectangle.Height - (y_offset * 2)); float halfInnerWidth = rectangle.Width / 2; float halfInnerHeight = rectangle.Height / 2; float radius = Math.Min(halfInnerWidth, halfInnerHeight); float diameter = radius + radius; float x = rectangle.Left + halfInnerWidth - radius; float y = rectangle.Top + halfInnerHeight - radius; if (radius > 0) { graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; for (int i = 0; i < slices.Length; i++) { graphics.FillPie(slices[i].Brush, x, y, diameter, diameter, slices[i].StartAngle, slices[i].SweepAngle); float radiusPlusHalfHypotenuse = radius + slices[i].Hypotenuse / 2; float labelLeft = x + radius - (slices[i].LabelWidth / 2) + (slices[i].LabelCos * radiusPlusHalfHypotenuse); float labelTop = y + radius - (slices[i].LabelHeight / 2) + (slices[i].LabelSin * radiusPlusHalfHypotenuse); //TODO use a style for Brush DrawString(graphics, slices[i].Label, labelFont, foreColorBrush, labelLeft, labelTop); } graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; } styleStack.PopTag(); }
public static Pixie.Pen ToPixiePen(this System.Drawing.Pen self) => new Pixie.Pen(self.Color.ToPixieColor(), self.Width);
/// <summary> /// 根据验证码生成图片 /// </summary> /// <param name="validatecodes">验证码</param> /// <returns></returns> public System.IO.MemoryStream CreateValidateCodesImageStream(string validatecodes) { try { if (string.IsNullOrEmpty(validatecodes)) { throw new ArgumentException("验证码validatecodes不能为空"); } } catch { throw; } System.Drawing.Bitmap image = null; System.Drawing.Graphics grap = null; try { int imgWidth = validatecodes.Length * (FontSize + 2 * FontPadding); int imgHeight = FontSize + 2 * FontPadding; image = new System.Drawing.Bitmap(imgWidth, imgHeight); grap = System.Drawing.Graphics.FromImage(image); //设置高质量查值法 grap.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low; //设置高质量,低速度呈现平滑程度 grap.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; grap.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed; //清空画布并以透明背景色填充 grap.Clear(System.Drawing.Color.Transparent); Random rnd = new Random(); System.Drawing.Font font = null; System.Drawing.Brush brush = null; System.Drawing.Pen pen = null; int iFontFamilyIndex = 0; //字体序号 int iFontColorIndex = 0; //字体颜色 int codeLeft = 0; //字符左边距 int codeTop = FontPadding;; //字符上边距 int iStartX, iEndX, iStartY, iEndY; //干扰线起始点 //绘制干扰线 for (int i = 0; i < validatecodes.Length * 2; i++) { iStartX = rnd.Next(imgWidth); iEndX = rnd.Next(iStartX, iStartX + FontSize * 2 < imgWidth ? iStartX + FontSize * 2 : imgWidth); iStartY = rnd.Next(imgHeight); iEndY = rnd.Next(iStartY, iStartY + FontSize * 2 < imgHeight ? iStartY + FontSize * 2 : imgHeight); iFontColorIndex = rnd.Next(FontColors.Length); brush = new System.Drawing.SolidBrush(FontColors[iFontColorIndex]); pen = new System.Drawing.Pen(brush); grap.DrawLine(pen, new System.Drawing.Point(iStartX, iStartY), new System.Drawing.Point(iEndX, iEndY)); } //依次绘制字符 for (int i = 0; i < validatecodes.Length; i++) { iFontFamilyIndex = rnd.Next(FontFamilies.Length); iFontColorIndex = rnd.Next(FontColors.Length); font = new System.Drawing.Font(FontFamilies[iFontFamilyIndex], EMFontSize); brush = new System.Drawing.SolidBrush(FontColors[iFontColorIndex]); codeLeft = FontPadding + i * (FontPadding * 2 + FontSize); grap.DrawString(validatecodes[i].ToString(), font, brush, new System.Drawing.PointF(codeLeft, codeTop)); } System.IO.MemoryStream ms = new System.IO.MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); return(ms); } catch { throw; } finally { if (null != image) { image.Dispose(); } if (null != grap) { grap.Dispose(); } } }
/// <summary> /// 文字列をオフスクリーンに書き込みます。 /// </summary> /// <param name="text">書き込む文字列</param> /// <param name="font"><paramref name="text"/> のフォント</param> /// <param name="color"><paramref name="text"/> の色</param> /// <param name="outlineColor"><paramref name="text"/> の縁取り色</param> /// <param name="rectangle"><paramref name="text"/> の書き込み位置及び範囲</param> internal void DrawText(string text, System.Drawing.Font font, System.Drawing.Brush color, System.Drawing.Pen outlineColor, System.Drawing.RectangleF rectangle) { using (var g = System.Drawing.Graphics.FromImage(OffScreen)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; if (outlineColor == null) { g.FillRectangle(System.Drawing.Brushes.Transparent, rectangle); g.DrawString(text, font, color, rectangle); } else { using (var gp = new System.Drawing.Drawing2D.GraphicsPath()) { var sizeInPixels = font.SizeInPoints * g.DpiY / 72; gp.AddString(text, font.FontFamily, (int)font.Style, sizeInPixels, rectangle, null); g.DrawPath(outlineColor, gp); g.FillPath(color, gp); } } } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pevent) { base.OnPaint(pevent); base.OnPaintBackground(pevent); pevent.Graphics.FillRectangle(new System.Drawing.SolidBrush(BackColor), ClientRectangle); System.Windows.Forms.TextRenderer.DrawText( pevent.Graphics, Text, Font, new System.Drawing.Rectangle( 0, 0, Width - ScrollSize.Width - 2, Height), ForeColor, System.Windows.Forms.TextFormatFlags.VerticalCenter | System.Windows.Forms.TextFormatFlags.Left | System.Windows.Forms.TextFormatFlags.SingleLine | System.Windows.Forms.TextFormatFlags.WordEllipsis); var boxRect = new System.Drawing.Rectangle( new System.Drawing.Point(Width - ScrollSize.Width - 2, (Height - ScrollSize.Height) / 2), ScrollSize); pevent.Graphics.FillRectangle( new System.Drawing.SolidBrush(System.Drawing.Color.Silver), boxRect); System.Drawing.Rectangle sBoxRect; if (Checked) { sBoxRect = new System.Drawing.Rectangle( new System.Drawing.Point(boxRect.X + _offsetX, (Height - (ScrollSize.Height + 6)) / 2), new System.Drawing.Size(ScrollSize.Height, ScrollSize.Height + 6)); } else { sBoxRect = new System.Drawing.Rectangle( new System.Drawing.Point(boxRect.X + _offsetX, (Height - (ScrollSize.Height + 6)) / 2), new System.Drawing.Size(ScrollSize.Height, ScrollSize.Height + 6)); } if (IsShowBorder) { using (var pen = new System.Drawing.Pen(System.Drawing.Color.Black, 2)) { pevent.Graphics.DrawRectangle(pen, boxRect); pevent.Graphics.DrawRectangle(pen, sBoxRect); } } var boxBackColor = System.Drawing.Color.YellowGreen; pevent.Graphics.FillRectangle( new System.Drawing.SolidBrush(System.Drawing.Color.YellowGreen), new System.Drawing.Rectangle( sBoxRect.X + (IsShowBorder ? 1 : 0), sBoxRect.Y + (IsShowBorder ? 1 : 0), sBoxRect.Width - (IsShowBorder ? 2 : 0), sBoxRect.Height - (IsShowBorder ? 2 : 0))); var sub = IsShowBorder ? boxRect.Left + 2 : boxRect.Left; pevent.Graphics.FillRectangle( new System.Drawing.SolidBrush(boxBackColor), new System.Drawing.Rectangle( boxRect.X + (IsShowBorder ? 1 : 0), boxRect.Y + (IsShowBorder ? 1 : 0), sBoxRect.Left - sub, boxRect.Height - (IsShowBorder ? 2 : 0))); }
private SharpDX.Direct2D1.Bitmap DrawString(int width, int height, float fontSize15, float fontSize30) { //Dont know how to draw this on SharpDx so i'm using system drawing to draw and convet it to SharpDX Bitmap. System.Drawing.Graphics gr = System.Drawing.Graphics.FromHwnd(IntPtr.Zero); System.Drawing.Bitmap bm = new System.Drawing.Bitmap(width, height, gr); gr.Dispose(); gr = System.Drawing.Graphics.FromImage(bm); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); var strformat = new System.Drawing.StringFormat { Alignment = System.Drawing.StringAlignment.Center, LineAlignment = System.Drawing.StringAlignment.Center }; gr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; if (PlayerControl.Text_Intro == string.Empty || PlayerControl.Text_Intro == null) { string b = "BossDoy KaraokeNow"; var stringSize = MeasureString(b, fontSize15); path.AddString(b, fontFamily, (int)System.Drawing.FontStyle.Bold, fontSize15, new System.Drawing.Point((bm.Width / 2), (bm.Height / 2) - ((int)stringSize.Height) / 2), strformat); path.AddString("Select a song", fontFamily, (int)System.Drawing.FontStyle.Bold, fontSize30, new System.Drawing.Point(bm.Width / 2, (bm.Height / 2) + ((int)stringSize.Height) / 2), strformat); } else { string[] intro = PlayerControl.Text_Intro.Split(new char[] { '@' }, StringSplitOptions.None); var stringSize = MeasureString(intro[0], fontSize15); path.AddString(intro[0], fontFamily, (int)System.Drawing.FontStyle.Bold, fontSize15, new System.Drawing.Point((bm.Width / 2), (bm.Height / 2) - ((int)stringSize.Height) / 2), strformat); if (intro.Length > 1) { path.AddString(intro[1], fontFamily, (int)System.Drawing.FontStyle.Bold, fontSize30, new System.Drawing.Point(bm.Width / 2, (bm.Height / 2) + ((int)stringSize.Height) / 2), strformat); } else { path.AddString("Select a song", fontFamily, (int)System.Drawing.FontStyle.Bold, fontSize30, new System.Drawing.Point(bm.Width / 2, (bm.Height / 2) + ((int)stringSize.Height) / 2), strformat); } } System.Drawing.Pen penOut = new System.Drawing.Pen(System.Drawing.Color.FromArgb(32, 117, 81), (fontSize30 / 4)); penOut.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; gr.DrawPath(penOut, path); System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(234, 137, 6), (fontSize30 / 8)); pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; gr.DrawPath(pen, path); System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(128, 0, 255)); gr.FillPath(brush, path); path.Dispose(); penOut.Dispose(); pen.Dispose(); brush.Dispose(); gr.Dispose(); return(ConvertToSharpDXBitmap(m_D2DContext.d2dContext, bm)); }
public override void Draw(System.Drawing.Graphics g, System.Drawing.Pen p) { g.DrawLine(p, D1.X, D1.Y, D2.X, D2.Y); }
public byte[] CreateCheckCode(int nLen, ref string strKey) { int nBmpWidth = 13 * nLen + 15; // 图片宽度,能容纳完 int nBmpHeight = 25; // 定义一个 Bitmap System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(nBmpWidth, nBmpHeight); // 生成随机背景颜色 int nRed, nGreen, nBlue; // 生成三元色[128 - 255] System.Random rd = new Random((int)System.DateTime.Now.Ticks); nRed = rd.Next(255) % 128 + 128; nGreen = rd.Next(255) % 128 + 128; nBlue = rd.Next(255) % 128 + 128; // 创建 Bitmap 的画布 System.Drawing.Graphics graph = System.Drawing.Graphics.FromImage(bmp); graph.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.AliceBlue), 0, 0, nBmpWidth, nBmpHeight); // 绘制干扰线条,采用比背景略深一些的颜色 int nLines = 3; System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(nRed - 17, nGreen - 17, nBlue - 17), 2); for (int a = 0; a < nLines; a++) { // 随机位置、随机长度的直线 int x1 = rd.Next(nBmpWidth); int y1 = rd.Next(nBmpHeight); int x2 = rd.Next(nBmpWidth); int y2 = rd.Next(nBmpHeight); graph.DrawLine(pen, x1, y1, x2, y2); } //画图片的前景噪音点 for (int i = 0; i < 100; i++) { int x = rd.Next(bmp.Width); int y = rd.Next(bmp.Height); bmp.SetPixel(x, y, System.Drawing.Color.FromArgb(rd.Next())); // 像素点颜色 } // 确定字体 System.Drawing.Font font = new System.Drawing.Font("Courier New", 14 + rd.Next() % 4, System.Drawing.FontStyle.Bold); // 渐变画刷 System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush( new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Color.Blue, System.Drawing.Color.DarkRed, 1.2f, true); graph.DrawString(strKey, font, brush, 2, 2); // 输出字节流 System.IO.MemoryStream stream = new System.IO.MemoryStream(); bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); bmp.Dispose(); graph.Dispose(); byte[] byteReturn = stream.ToArray(); stream.Close(); return(byteReturn); }
public void Draw(System.Drawing.Graphics g, System.Drawing.Pen p) { g.DrawRectangle(p, X[0], Y[0], X[1] - X[0], Y[1] - Y[0]); }
public void SetBorder(System.Drawing.Color p_color, int p_width) { this.v_border = new System.Drawing.Pen(p_color, p_width); }
/// <summary> /// Draw rich text at specified area. /// </summary> /// <param name="g">Graphics context.</param> /// <param name="bounds">Target area to draw rich text.</param> internal void Draw(IGraphics g, Rectangle bounds) { RGFloat x = bounds.Left + 2; RGFloat y = bounds.Top + 2; if (!this.Overflow) { g.PushClip(bounds); } switch (this.VerticalAlignment) { default: case ReoGridVerAlign.General: case ReoGridVerAlign.Bottom: y += (bounds.Height - this.measuredSize.Height) - 6; break; case ReoGridVerAlign.Middle: y += (bounds.Height - this.measuredSize.Height) / 2 - 2; break; case ReoGridVerAlign.Top: y++; break; } Run lastRun = null; RGBrush lastBrush = null; SolidColor lastColor = SolidColor.Transparent; #if DEBUG1 g.DrawRectangle(System.Drawing.Pens.DarkRed, x, y, x + measuredSize.Width, y + measuredSize.Height); #endif // DEBUG foreach (var p in this.paragraphs) { foreach (var l in p.lines) { #if DEBUG //g.DrawRectangle(System.Drawing.Pens.Blue, x, y + l.leftTop.Y, l.Width, l.Height); #endif // DEBUG foreach (var b in l.boxes) { var r = b.Run; if (lastRun != r) { SolidColor textColor = r.TextColor; if (textColor.IsTransparent) { textColor = this.DefaultTextColor; } if (textColor != lastColor || lastBrush == null) { lastColor = textColor; #if WINFORM || ANDROID if (lastBrush != null) { lastBrush.Dispose(); } #endif // WINFORM lastBrush = new RGBrush(lastColor); } lastRun = r; } #if DEBUG //RGFloat baseLine = l.Top + l.Ascent; //g.DrawLine(System.Drawing.Pens.Blue, b.Left + 1, baseLine, b.Right - 1, baseLine); #endif // DEBUG if ((r.FontStyles & FontStyles.Underline) == FontStyles.Underline) { #if WINFORM using (var underlinePen = new RGPen(lastBrush.Color)) #elif WPF var underlinePen = new RGPen(new RGBrush(lastBrush.Color), 1); #endif // WPF { //RGFloat underlineTop = l.leftTop.Y + l.Ascent + y + 2; //g.PlatformGraphics.DrawLine(underlinePen, new Point(b.leftTop.X + x, underlineTop), new Point(b.rightBottom.X + x, underlineTop)); } } var tx = b.leftTop.X + x; var ty = b.leftTop.Y + y; #if WINFORM || ANDROID g.PlatformGraphics.DrawString(b.Str, b.FontInfo.Font, lastBrush, tx, ty, this.sf); #elif WPF var gr = new System.Windows.Media.GlyphRun(b.FontInfo.GlyphTypeface, 0, false, r.FontSize * 1.33d, new ushort[] { b.GlyphIndex }, new System.Windows.Point(tx, ty), new double[] { b.Width }, null, null, null, null, null, null); g.PlatformGraphics.DrawGlyphRun(lastBrush, gr); #endif // WPF } } //y += p.TextSize.Height + this.paragraphSpacing; } if (!this.Overflow) { g.PopClip(); } }
private void RenderImage(byte[] raw, TextExtractionResults lastOcrResults) { Contracts.entity.TextExtractionResults ocr = null; if (lastOcrResults == null) { ctlStatusPanel0.Text = $"Found {lastOcrResults.Blocks.Length} text objects"; //Create an empty object if none was specified ocr = new Contracts.entity.TextExtractionResults { Blocks = new Contracts.entity.TextBlock[] { } }; } else { ocr = lastOcrResults; } System.Drawing.Pen penBlock = new System.Drawing.Pen(System.Drawing.Color.Black); System.Drawing.Pen penSentence = new System.Drawing.Pen(System.Drawing.Color.Orange, 3); System.Drawing.Pen penPara = new System.Drawing.Pen(System.Drawing.Color.Blue, 3); System.Drawing.Brush b = new System.Drawing.SolidBrush( System.Drawing.Color.FromArgb(100, System.Drawing.Color.Yellow)); using (var memStm = new System.IO.MemoryStream(raw)) { var imge = System.Drawing.Image.FromStream(memStm); _picBox.Image = imge; using (var g = System.Drawing.Graphics.FromImage(imge)) { foreach (var box in ocr.Blocks) { //var pts = new System.Drawing.Point[] //{ // new System.Drawing.Point((int)box.X1,(int)box.Y1), // new System.Drawing.Point((int)box.X2,(int)box.Y1), // new System.Drawing.Point((int)box.X2,(int)box.Y2), // new System.Drawing.Point((int)box.X1,(int)box.Y2), // new System.Drawing.Point((int)box.X1,(int)box.Y1) //}; //g.DrawLines(pen,pts); int xUpperLeft = (int)Math.Min(box.X1, box.X2); int yUpperLeft = (int)Math.Min(box.Y1, box.Y2); float width = (float)Math.Abs(box.X1 - box.X2); float ht = (float)Math.Abs(box.Y1 - box.Y2); g.DrawRectangle(penBlock, xUpperLeft, yUpperLeft, width, ht); g.FillRectangle(b, xUpperLeft, yUpperLeft, width, ht); } foreach (var sentence in ocr.Sentences) { g.DrawLine( penSentence, sentence.Rectangle.X, sentence.Rectangle.Bottom, sentence.Rectangle.Right, sentence.Rectangle.Bottom); } foreach (var para in ocr.Paragraphs) { g.DrawRectangle( penPara, para.Rectangle.Left, para.Rectangle.Top, para.Rectangle.Width, para.Rectangle.Height); } } } }
public static void DebugDrawLine(double x, double y, double angle, double lenght, System.Drawing.Pen p, IGraphics graphicDevice) { double incX = lenght * Math.Sin(angle); double incY = lenght * Math.Cos(angle); graphicDevice.DrawLine(p, (float)x, (float)y, (float)(x + incX), (float)(y + incY)); }
override protected void DrawPath(SeriesBase series, System.Drawing.Pen pen) { if (series is LineSeries || series is HiLoSeries || series is HiLoOpenCloseSeries) { var points = new PointCollection(); var lowPoints = new PointCollection(); var pointCount = 0; PartsCollection partsCollection = new PartsCollection(); if (series is LineSeries) { LineSeries lineSeries = series as LineSeries; points = lineSeries.LinePoints; pointCount = lineSeries.LinePoints.Count; partsCollection = lineSeries.Parts; } else if (series is HiLoSeries) { HiLoSeries lineSeries = series as HiLoSeries; points = lineSeries.HighPoints; lowPoints = lineSeries.LowPoints; pointCount = lineSeries.HighPoints.Count; partsCollection = lineSeries.Parts; } else if (series is HiLoOpenCloseSeries) { HiLoOpenCloseSeries lineSeries = series as HiLoOpenCloseSeries; points = lineSeries.HighPoints; lowPoints = lineSeries.LowPoints; pointCount = lineSeries.HighPoints.Count; partsCollection = lineSeries.Parts; } if (RenderingMode == RenderingMode.Default) { for (int i = 0; i < partsCollection.Count; i++) { UIElement renderElement = partsCollection[i].CreatePart(); if (renderElement != null && !PartsCanvas.Children.Contains(renderElement)) { PartsCanvas.Children.Add(renderElement); } } } else { if (series is LineSeries) { for (int i = 0; i < pointCount - 1; i++) { switch (RenderingMode) { case RenderingMode.GDIRendering: GDIGraphics.DrawLine(pen, points[i].AsDrawingPointF(), points[i + 1].AsDrawingPointF()); break; case RenderingMode.Default: break; case RenderingMode.WritableBitmap: this.WritableBitmap.Lock(); WritableBitmapGraphics.DrawLine(pen, points[i].AsDrawingPointF(), points[i + 1].AsDrawingPointF()); this.WritableBitmap.Unlock(); break; default: break; } } } else { for (int i = 0; i < pointCount; i++) { switch (RenderingMode) { case RenderingMode.GDIRendering: GDIGraphics.DrawLine(pen, points[i].AsDrawingPointF(), lowPoints[i].AsDrawingPointF()); break; case RenderingMode.Default: break; case RenderingMode.WritableBitmap: this.WritableBitmap.Lock(); WritableBitmapGraphics.DrawLine(pen, points[i].AsDrawingPointF(), lowPoints[i].AsDrawingPointF()); this.WritableBitmap.Unlock(); break; default: break; } } } this.Collection.InvalidateBitmap(); } } }
/// <summary> /// Changes the cursor for this control to show the coordinates /// </summary> /// <param name="uiElement"></param> private void SetCoordinatesOnCursor(FrameworkElement uiElement) { Point coordinate = locked ? lockPoint : lastCoordinate; Cursor newCursor = null; SysSystem.Drawing.Font cursorFont = new SysSystem.Drawing.Font("Arial", 8f); try { // Lets get the string to be printed string coordinateText = coordinate.X.ToString(xFormat) + "," + coordinate.Y.ToString(yFormat); // Calculate the rectangle required to draw the string SysSystem.Drawing.SizeF textSize = GetTextSize(coordinateText, cursorFont); // ok, so here's the minimum 1/4 size of the bitmap we need, as the // Hotspot for the cursor will be in the centre of the bitmap. int minWidth = 8 + (int)SysSystem.Math.Ceiling(textSize.Width); int minHeight = 8 + (int)SysSystem.Math.Ceiling(textSize.Height); // If the bitmap needs to be resized, then resize it, else just clear it if (cursorBitmap.Width < minWidth * 2 || cursorBitmap.Height < minHeight * 2) { SysSystem.Drawing.Bitmap oldBitmap = cursorBitmap; cursorBitmap = new SysSystem.Drawing.Bitmap(SysSystem.Math.Max(cursorBitmap.Width, minWidth * 2), SysSystem.Math.Max(cursorBitmap.Height, minHeight * 2)); oldBitmap.Dispose(); } // Get the centre of the bitmap which will be the Hotspot SysSystem.Drawing.Point centre = new SysSystem.Drawing.Point(cursorBitmap.Width / 2, cursorBitmap.Height / 2); /// Calculate the text rectangle SysSystem.Drawing.Rectangle textRectangle = new SysSystem.Drawing.Rectangle(centre.X + 8, centre.Y + 8, minWidth - 8, minHeight - 8); int diff = (int)cursorPosition.X + textRectangle.Right / 2 - 3 - (int)uiElement.ActualWidth; if (diff > 0) { textRectangle.Location = new SysSystem.Drawing.Point(textRectangle.Left - diff, textRectangle.Top); } // Draw the target symbol, and the coordinate text on the bitmap using (SysSystem.Drawing.Graphics g = SysSystem.Drawing.Graphics.FromImage(cursorBitmap)) { g.SmoothingMode = SysSystem.Drawing.Drawing2D.SmoothingMode.AntiAlias; // This line causes a crash on laptops when you render a string // g.CompositingMode = CompositingMode.SourceCopy; g.Clear(SysSystem.Drawing.Color.Transparent); float targetX = centre.X; float targetY = centre.Y; float radius = 30; if (!locked) { SysSystem.Drawing.Pen blackPen = new SysSystem.Drawing.Pen(SysSystem.Drawing.Color.FromArgb(255, 0, 0, 0), 1.4f); g.DrawEllipse(blackPen, targetX - radius * .5f, targetY - radius * .5f, radius, radius); g.DrawLine(blackPen, targetX - radius * .8f, targetY, targetX - 2f, targetY); g.DrawLine(blackPen, targetX + 2f, targetY, targetX + radius * .8f, targetY); g.DrawLine(blackPen, targetX, targetY - radius * .8f, targetX, targetY - 2f); g.DrawLine(blackPen, targetX, targetY + 2f, targetX, targetY + radius * .8f); } else { SysSystem.Drawing.Pen blackPen = new SysSystem.Drawing.Pen(SysSystem.Drawing.Color.FromArgb(255, 0, 0, 0), 3f); SysSystem.Drawing.Pen yellowPen = new SysSystem.Drawing.Pen(SysSystem.Drawing.Color.FromArgb(255, 255, 255, 0), 2f); g.DrawEllipse(blackPen, targetX - radius * .5f, targetY - radius * .5f, radius, radius); g.DrawEllipse(yellowPen, targetX - radius * .5f, targetY - radius * .5f, radius, radius); } if (!locked) { g.FillRectangle(new SysSystem.Drawing.SolidBrush(SysSystem.Drawing.Color.FromArgb(127, 255, 255, 255)), textRectangle); } else { g.FillRectangle(new SysSystem.Drawing.SolidBrush(SysSystem.Drawing.Color.FromArgb(170, 255, 255, 0)), textRectangle); } // Setup the text format for drawing the subnotes using (SysSystem.Drawing.StringFormat stringFormat = new SysSystem.Drawing.StringFormat()) { stringFormat.Trimming = SysSystem.Drawing.StringTrimming.None; stringFormat.FormatFlags = SysSystem.Drawing.StringFormatFlags.NoClip | SysSystem.Drawing.StringFormatFlags.NoWrap; stringFormat.Alignment = SysSystem.Drawing.StringAlignment.Near; // Draw the string left aligned g.DrawString( coordinateText, cursorFont, new SysSystem.Drawing.SolidBrush(SysSystem.Drawing.Color.Black), textRectangle, stringFormat); } } // Now copy the bitmap to the cursor newCursor = WPFCursorFromBitmap.CreateCursor(cursorBitmap); } catch (SysSystem.Exception) { } finally { // After the new cursor has been set, the unmanaged resources can be // cleaned up that were being used by the old cursor if (newCursor != null) { uiElement.Cursor = newCursor; } if (lastCursor != null) { lastCursor.Dispose(); } lastCursor = newCursor; // Save the new values for cleaning up on the next pass } }
public static string getExpertImage() { if (SessionClass.Flow.Count > 0) { System.Drawing.Bitmap bm = new System.Drawing.Bitmap(400, SessionClass.Flow.Count * 90); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bm); g.Clear(System.Drawing.Color.White); int x = 100; int y = 10; System.Drawing.StringFormat f = new System.Drawing.StringFormat(); f.Alignment = System.Drawing.StringAlignment.Center; f.LineAlignment = System.Drawing.StringAlignment.Center; System.Drawing.Font font; System.Drawing.Drawing2D.LinearGradientBrush b = new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Point(0, 40), new System.Drawing.Point(30, 130), System.Drawing.Color.GreenYellow, System.Drawing.Color.LemonChiffon); for (int i = 0; i < SessionClass.Flow.Count; i++) { if (((Node)SessionClass.Flow[i]).type == 1) { font = new System.Drawing.Font("Arial Unicode MS", 9, System.Drawing.FontStyle.Regular); g.DrawImageUnscaled(System.Drawing.Image.FromFile(HttpContext.Current.Request.MapPath("tskRect.png")), x - 3, y); g.DrawString(((Node)SessionClass.Flow[i]).fromTitle.Substring(0, ((Node)SessionClass.Flow[i]).fromTitle.Length > 56 ? 56 : ((Node)SessionClass.Flow[i]).fromTitle.Length), font, System.Drawing.Brushes.Black, new System.Drawing.Rectangle(x + 35, y + 8, 170, 40), f); y += 85; } else { font = new System.Drawing.Font("Arial Unicode MS", 10, System.Drawing.FontStyle.Regular); g.DrawImageUnscaled(System.Drawing.Image.FromFile(HttpContext.Current.Request.MapPath("tskOval.png")), x, y); g.DrawString(((Node)SessionClass.Flow[i]).fromTitle.Substring(0, ((Node)SessionClass.Flow[i]).fromTitle.Length > 52 ? 52 : ((Node)SessionClass.Flow[i]).fromTitle.Length), font, System.Drawing.Brushes.Black, new System.Drawing.Rectangle(x + 30, y + 6, 172, 40), f); y += 85; } if (((Node)SessionClass.Flow[i]).from == -1) { break; } } if (SessionClass.Flow.Count > 0) { x = 100; y = 10; int y1, y2; for (int i = 1; i < SessionClass.Flow.Count; i++) { System.Drawing.Pen p = new System.Drawing.Pen(System.Drawing.Color.Black); p.Width = 1.5F; y1 = (((i) * 50) + y + ((i - 1) * 35)); y2 = (((i) * 50) + y + ((i) * 35)); g.DrawLine(p, 200, y1 + 2, 200, y2); System.Drawing.Point[] pns = new System.Drawing.Point[4]; pns[0] = new System.Drawing.Point(195, y2 - 5); pns[1] = new System.Drawing.Point(200, y2); pns[2] = new System.Drawing.Point(205, y2 - 5); pns[3] = new System.Drawing.Point(195, y2 - 5); g.FillPolygon(System.Drawing.Brushes.Black, pns); g.DrawString(((Node)SessionClass.Flow[i - 1]).decision.Equals("True")?"Yes":"No", new System.Drawing.Font("Arial Unicode MS", 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, new System.Drawing.Point(205, y1 + 6)); if (((Node)SessionClass.Flow[i]).from == -1) { break; } } } string res = HttpContext.Current.Server.MapPath("Results") + "\\User" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".png"; bm.Save(res, System.Drawing.Imaging.ImageFormat.Png); return("Results/" + res.Replace(HttpContext.Current.Server.MapPath("Results") + "\\", "")); } return(""); }
public override void childPaint(System.Drawing.Graphics g, Model.DataModel data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font FontText, System.Drawing.Font FontData) { }
private void DrawSkeleton(Skeleton skeleton) { System.Windows.Point joint1 = this.ScalePosition(skeleton.Joints[JointType.ElbowRight].Position); System.Windows.Point joint2 = this.ScalePosition(skeleton.Joints[JointType.HipCenter].Position); System.Windows.Point joint3 = this.ScalePosition(skeleton.Joints[JointType.Spine].Position); System.Windows.Point joint4 = this.ScalePosition(skeleton.Joints[JointType.ShoulderRight].Position); Point P1 = new Point(); //elbow Point P2 = new Point(); // hip Point P3 = new Point(); //spine Point P4 = new Point(); // shoulder P1.X = joint1.X; P1.Y = joint1.Y; P2.X = joint2.X; P2.Y = joint2.Y; P3.X = joint3.X; P3.Y = joint3.Y; P4.X = joint4.X; P4.Y = joint4.Y; Size size_val = new Size(5, 5); System.Drawing.Pen blackPen = new System.Drawing.Pen(System.Drawing.Color.Black, 3); AddCircularArcGraph(P2, P1, size_val); /* * * * double P12 = Math.Sqrt( Math.Pow(P1.X - P2.X, 2) + Math.Pow(P1.Y - P2.Y, 2)); * double P13 = Math.Sqrt( Math.Pow(P1.X - P3.X, 2) + Math.Pow(P1.Y - P3.Y, 2)); * double P23 = Math.Sqrt( Math.Pow(P2.X - P3.X, 2) + Math.Pow(P2.Y - P3.Y, 2)); * * double angle = Math.Acos((Math.Pow(P13, 2) + Math.Pow(P23, 2) - Math.Pow(P12, 2))/(2*P13*P23)); * angle = angle * 180 / Math.PI; * Console.WriteLine("P13"); * Console.WriteLine(P13); */ double a = P1.X - P4.X; double b = P1.Y - P4.Y; double c = P2.X - P3.X; double d = P2.Y - P3.Y;; double atanA = Math.Atan2(a, b); double atanB = Math.Atan2(c, d); //double angle = (atanA - atanB) * (-180 / Math.PI); //double angle = (atanB) * (-180 / Math.PI); double angle1 = (atanA) * (-180 / Math.PI); double angle2 = (atanB) * (-180 / Math.PI); double angle = -(angle1 - angle2); TextBox txt = new TextBox(); txt.Text = angle.ToString(); Canvas.SetLeft(txt, P1.X + 0.1); Canvas.SetTop(txt, P1.Y + 0.1); canvas1.Children.Add(txt); drawBone(skeleton.Joints[JointType.Head], skeleton.Joints[JointType.ShoulderCenter]); drawBone(skeleton.Joints[JointType.ShoulderCenter], skeleton.Joints[JointType.Spine]); drawBone(skeleton.Joints[JointType.ShoulderCenter], skeleton.Joints[JointType.ShoulderLeft]); drawBone(skeleton.Joints[JointType.ShoulderLeft], skeleton.Joints[JointType.ElbowLeft]); drawBone(skeleton.Joints[JointType.ElbowLeft], skeleton.Joints[JointType.WristLeft]); drawBone(skeleton.Joints[JointType.WristLeft], skeleton.Joints[JointType.HandLeft]); drawBone(skeleton.Joints[JointType.ShoulderCenter], skeleton.Joints[JointType.ShoulderRight]); drawBone(skeleton.Joints[JointType.ShoulderRight], skeleton.Joints[JointType.ElbowRight]); drawBone(skeleton.Joints[JointType.ElbowRight], skeleton.Joints[JointType.WristRight]); drawBone(skeleton.Joints[JointType.WristRight], skeleton.Joints[JointType.HandRight]); drawBone(skeleton.Joints[JointType.Spine], skeleton.Joints[JointType.HipCenter]); drawBone(skeleton.Joints[JointType.HipCenter], skeleton.Joints[JointType.HipLeft]); drawBone(skeleton.Joints[JointType.HipLeft], skeleton.Joints[JointType.KneeLeft]); drawBone(skeleton.Joints[JointType.KneeLeft], skeleton.Joints[JointType.AnkleLeft]); drawBone(skeleton.Joints[JointType.AnkleLeft], skeleton.Joints[JointType.FootLeft]); drawBone(skeleton.Joints[JointType.HipCenter], skeleton.Joints[JointType.HipRight]); drawBone(skeleton.Joints[JointType.HipRight], skeleton.Joints[JointType.KneeRight]); drawBone(skeleton.Joints[JointType.KneeRight], skeleton.Joints[JointType.AnkleRight]); drawBone(skeleton.Joints[JointType.AnkleRight], skeleton.Joints[JointType.FootRight]); }
public void RemoveBorder() { this.v_border = null; }
/// <summary> /// Draw border at specified position. /// </summary> /// <param name="g">Instance for graphics object.</param> /// <param name="x">X coordinate of start point.</param> /// <param name="y">Y coordinate of start point.</param> /// <param name="x2">X coordinate of end point.</param> /// <param name="y2">Y coordinate of end point.</param> /// <param name="style">Style flag of border.</param> /// <param name="color">Color of border.</param> /// <param name="bgPen">Fill pen used when drawing double outline.</param> public void DrawLine(PlatformGraphics g, RGFloat x, RGFloat y, RGFloat x2, RGFloat y2, BorderLineStyle style, SolidColor color, RGPen bgPen = null) { if (style == BorderLineStyle.None) { return; } #if WINFORM || WPF || ANDROID #if WINFORM RGPen p = pens[(byte)style]; lock (p) { p.Color = color; p.StartCap = System.Drawing.Drawing2D.LineCap.Square; p.EndCap = System.Drawing.Drawing2D.LineCap.Square; g.DrawLine(p, new RGPointF(x, y), new RGPointF(x2, y2)); } #elif WPF // get template pen from cache list var tp = pens[(byte)style]; // create new WPF pen var p = new RGPen(new RGSolidBrush(color), tp.Thickness); // copy the pen style from template p.DashStyle = tp.DashStyle; p.StartLineCap = System.Windows.Media.PenLineCap.Square; p.EndLineCap = System.Windows.Media.PenLineCap.Square; System.Windows.Media.GuidelineSet gs = new System.Windows.Media.GuidelineSet(); double halfPenWidth = p.Thickness / 2; gs.GuidelinesX.Add(x + halfPenWidth); gs.GuidelinesY.Add(y + halfPenWidth); gs.GuidelinesX.Add(x2 + halfPenWidth); gs.GuidelinesY.Add(y2 + halfPenWidth); g.PushGuidelineSet(gs); g.DrawLine(p, new RGPointF(x, y), new RGPointF(x2, y2)); #elif ANDROID g.DrawLine(x, y, x2, y2, p); #endif if (style == BorderLineStyle.DoubleLine && bgPen != null) { lock (bgPen) { #if WINFORM || WPF g.DrawLine(bgPen, new RGPointF(x, y), new RGPointF(x2, y2)); #elif ANDROID g.DrawLine(x, y, x2, y2, bgPen); #endif // WPF } } #if WPF g.Pop(); #endif // WPF //#endif // WINFORM || WPF || ANDROID #elif iOS using (var path = new CGPath()) { path.AddLines(new CGPoint[] { new CGPoint(x, y), new CGPoint(x2, y2) }); switch (style) { default: case BorderLineStyle.Solid: g.AddPath(path); g.SetStrokeColor(color); g.DrawPath(CGPathDrawingMode.Stroke); break; } } #endif // iOS }
public override void Draw(System.Drawing.Rectangle renderingRect, System.Drawing.Graphics g, ICoordinateMapper coordinateMapper) { if (g == null) { throw new System.ArgumentNullException("g"); } if (coordinateMapper == null) { throw new System.ArgumentNullException("coordinateMapper"); } // FillPath doesn't support specifying FillMode, it always uses FillMode.Alternate, // so we have to use Graphics.FillPolygon method in other cases. if (!_closePath || base.Brush == null || _fillMode == System.Drawing.Drawing2D.FillMode.Alternate) { base.Draw(renderingRect, g, coordinateMapper); } else { System.Drawing.PointF[] transformedPoints = VObjectsUtils.TransformPoints(base.Transform, _points); for (int i = 0; i < transformedPoints.Length; i++) { transformedPoints[i] = coordinateMapper.WorkspaceToControl(transformedPoints[i], Aurigma.GraphicsMill.Unit.Point); } System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode; System.Drawing.Pen pen = base.CreateViewportPen(coordinateMapper); try { switch (base.DrawMode) { case VObjectDrawMode.Draft: g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; break; case VObjectDrawMode.Normal: g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; break; default: throw new Aurigma.GraphicsMill.UnexpectedException(StringResources.GetString("ExStrUnexpectedDrawMode")); } if (base.Brush != null) { AdaptBrushToViewport(coordinateMapper); try { g.FillPolygon(base.Brush, transformedPoints, _fillMode); } finally { RestoreBrush(); } } if (pen != null) { g.DrawPolygon(pen, transformedPoints); } } finally { pen.Dispose(); g.SmoothingMode = oldSmoothingMode; } } }
private BorderPainter() { RGPen p; // Solid #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 1); #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.Solid] = p; // Dahsed #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 1); p.DashStyle = RGDashStyles.Dash; #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.Dashed] = p; // Dotted #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 1); p.DashStyle = RGDashStyles.Dot; #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.Dotted] = p; // DoubleLine #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 3); #if WINFORM p.CompoundArray = new float[] { 0f, 0.2f, 0.8f, 1f }; #endif #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.DoubleLine] = p; // Dashed2 #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 1); #if WINFORM p.DashPattern = new float[] { 2f, 2f }; #endif #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.Dashed2] = p; // DashDot #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 1); #if WINFORM p.DashPattern = new float[] { 10f, 3f, 3f, 3f }; #elif WPF p.DashStyle = RGDashStyles.DashDot; #endif #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.DashDot] = p; // DashDotDot #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 1); #if WINFORM p.DashPattern = new float[] { 10f, 3f, 3f, 3f, 3f, 3f }; #elif WPF p.DashStyle = RGDashStyles.DashDotDot; #endif #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.DashDotDot] = p; // BoldDashDot #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 2); p.DashStyle = RGDashStyles.DashDot; #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.BoldDashDot] = p; // BoldDashDotDot #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 2); p.DashStyle = RGDashStyles.DashDotDot; #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.BoldDashDotDot] = p; // BoldDotted #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 2); p.DashStyle = RGDashStyles.Dot; #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.BoldDotted] = p; // BoldDashed #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 2); p.DashStyle = RGDashStyles.Dash; #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.BoldDashed] = p; // BoldSolid #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 2); #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.BoldSolid] = p; // BoldSolidStrong #if WINFORM || WPF p = new RGPen(RGPenColor.Black, 3); #elif ANDROID p = new RGPen(); p.Color = Android.Graphics.Color.Black; p.SetPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1)); #endif // ANDROID pens[(byte)BorderLineStyle.BoldSolidStrong] = p; }
protected override void RenderChart(System.Drawing.Graphics graphics, Palette palette, Bamboo.Css.StyleStack styleStack, System.Drawing.RectangleF rectangle, string title, Bamboo.DataStructures.Table table) { styleStack.PushTag("ScatterGraph"); string axisForeColor = (string)styleStack["AxisForeColor"]; string axisLineColor = (string)styleStack["AxisLineColor"]; string backColor = (string)styleStack["BackColor"]; Bamboo.Css.Font font = (Bamboo.Css.Font)styleStack["Font"]; string foreColor = (string)styleStack["ForeColor"]; string gridLineColor = (string)styleStack["GridLineColor"]; int padding = (int)styleStack["Padding"]; float pointRadius = System.Convert.ToSingle(styleStack["PointRadius"]); float tickSize = System.Convert.ToSingle(styleStack["TickSize"]); string[] colors = (string[])styleStack["Colors"]; //TODO put in stylesheet System.Drawing.Font titleFont = palette.Font(font.Name, font.Size * 1.2f, System.Drawing.FontStyle.Bold); //TODO put in stylesheet System.Drawing.Font axisTickFont = palette.Font(font.Name, font.Size * .66f); //TODO put in stylesheet. System.Drawing.Font axisTitleFont = palette.Font(font.Name, font.Size, System.Drawing.FontStyle.Bold); System.Drawing.Brush axisForeColorBrush = palette.Brush(axisForeColor); System.Drawing.Pen axisLineColorPen = palette.Pen(axisLineColor); System.Drawing.Pen backColorPen = palette.Pen(backColor); System.Drawing.Brush backColorBrush = palette.Brush(backColor); System.Drawing.Brush foreColorBrush = palette.Brush(foreColor); System.Drawing.Pen gridLineColorPen = palette.Pen(gridLineColor); // Background graphics.DrawRectangle(backColorPen, rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height); graphics.FillRectangle(backColorBrush, rectangle); rectangle = new System.Drawing.RectangleF(rectangle.Left + padding, rectangle.Top + padding, rectangle.Width - padding - padding, rectangle.Height - padding - padding); // Title if (title != null) { rectangle = DrawTitle(title, titleFont, foreColorBrush, graphics, rectangle); } //TODO // Legend rectangle = new System.Drawing.RectangleF(rectangle.Left, rectangle.Top, rectangle.Width - padding - padding, rectangle.Height); string xAxisTitle = table.Columns[0].ToString(); decimal x0 = System.Convert.ToDecimal(table.Rows[0][0]); decimal x_min = x0; decimal x_max = x0; for (int i = 1; i < table.Rows.Count; i++) { decimal x = System.Convert.ToDecimal(table.Rows[i][0]); if (x > x_max) { x_max = x; } else if (x < x_min) { x_min = x; } } Range xRange = new Range(x_min, x_max); bool isXRangeNumeric = true; int xAxisScale = CalculateScale(xRange); int xAxisPrecision = Math.Max(0, 0 - xAxisScale); string yAxisTitle = table.Columns[1].ToString(); decimal y0 = System.Convert.ToDecimal(table.Rows[0][1]); decimal y_min = y0; decimal y_max = y0; for (int j = 1; j < table.Rows.Count; j++) { for (int i = 1; i < table.Columns.Count; i++) { decimal y = System.Convert.ToDecimal(table.Rows[j][i]); if (y > y_max) { y_max = y; } else if (y < y_min) { y_min = y; } } } Range yRange = new Range(y_min, y_max); bool isYRangeNumeric = true; int yAxisScale = CalculateScale(yRange); int yAxisPrecision = Math.Max(0, 0 - yAxisScale); float maxYTickLabelWidth = Math.Max( MeasureString(graphics, y_min.ToString("N" + yAxisPrecision), axisTickFont).Width, MeasureString(graphics, y_max.ToString("N" + yAxisPrecision), axisTickFont).Width); System.Drawing.SizeF yAxisTitleSize = MeasureString(graphics, yAxisTitle, axisTitleFont); System.Drawing.SizeF xAxisTitleSize = MeasureString(graphics, xAxisTitle, axisTitleFont); float maxXTickLabelHeight = MeasureString(graphics, "A", axisTickFont).Height; // Y-Axis Title rectangle = DrawYAxisTitle(graphics, rectangle, yAxisTitle, axisTitleFont, yAxisTitleSize, xAxisTitleSize.Height + maxXTickLabelHeight + tickSize, axisForeColorBrush); // X-Axis Title rectangle = DrawXAxisTitle(graphics, rectangle, xAxisTitle, axisTitleFont, xAxisTitleSize, yAxisTitleSize.Height + maxYTickLabelWidth + tickSize, axisForeColorBrush); rectangle = new System.Drawing.RectangleF(rectangle.Left + maxYTickLabelWidth + tickSize, rectangle.Top, rectangle.Width - (maxYTickLabelWidth + tickSize), rectangle.Height - (maxXTickLabelHeight + tickSize)); DrawYAxis(graphics, rectangle, YAxisTicks(rectangle, graphics, axisTickFont, yRange, isYRangeNumeric, yAxisScale, yAxisPrecision, table), tickSize, axisTickFont, gridLineColorPen, axisLineColorPen, axisForeColorBrush, true); DrawXAxis(graphics, rectangle, XAxisTicks(rectangle, graphics, axisTickFont, xRange, isXRangeNumeric, xAxisScale, xAxisPrecision, table), tickSize, axisTickFont, gridLineColorPen, axisLineColorPen, axisForeColorBrush, true); rectangle = new System.Drawing.RectangleF(rectangle.Left + 1, rectangle.Top, rectangle.Width - 1, rectangle.Height - 1); // Plot // graphics.FillRectangle(B.WhiteSmoke, canvasX, canvasY - canvasHeight, canvasWidth, canvasHeight); System.Drawing.PointF[] points = new System.Drawing.PointF[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { Bamboo.DataStructures.Tuple row = table.Rows[i]; points[i] = Coordinate(System.Convert.ToSingle(row[0]), System.Convert.ToSingle(xRange.Min), System.Convert.ToSingle(xRange.Max), rectangle.Left, rectangle.Width, System.Convert.ToSingle(row[1]), System.Convert.ToSingle(yRange.Min), System.Convert.ToSingle(yRange.Max), rectangle.Top, rectangle.Height); } DrawPoints(graphics, palette.Brush(colors[0]), points, pointRadius); styleStack.PopTag(); }
/// <summary> /// Draws a Red polygon if all values 0, a DarkMagenta polygon if all values the same non-zero value, or else themes Red/DarkOrange/Gold/YellowGreen/LawnGreen/LimeGreen/ForestGreen/DarkGreen. /// </summary> /// <param name="operation"></param> /// <param name="workingDataKey"></param> public void ThemeMap(string workingDataKey) { using (var graphics = _spatialViewer.CreateGraphics()) { graphics.Clear(System.Drawing.Color.White); _drawingUtil = new DrawingUtil(_spatialViewer.Width, _spatialViewer.Height, graphics); List <Point> projectedPoints = new List <Point>(); List <double> doubleValues = null; foreach (SpatialRecord record in _spatialRecords) { Point point = record.Geometry as Point; projectedPoints.Add(point.ToUtm()); if (_workingDataDictionary.ContainsKey(workingDataKey)) { WorkingData workingData = _workingDataDictionary[workingDataKey]; RepresentationValue repValue = record.GetMeterValue(workingData); if (repValue is NumericRepresentationValue) { NumericRepresentationValue numericValue = repValue as NumericRepresentationValue; if (doubleValues == null) { doubleValues = new List <double>(); } doubleValues.Add(numericValue.Value.Value); } else if (repValue is EnumeratedValue) { EnumeratedValue enumValue = repValue as EnumeratedValue; if (enumValue.Representation.Code == "dtRecordingStatus") { if (doubleValues == null) { doubleValues = new List <double>(); } doubleValues.Add(enumValue.Value.Value == "On" ? 1d : -1d); } } } } if (!projectedPoints.Any()) { return; } _drawingUtil.SetMinMax(projectedPoints); var screenPolygon = projectedPoints.Select(point => point.ToXy(_drawingUtil.MinX, _drawingUtil.MinY, _drawingUtil.GetDelta())).ToArray(); if (screenPolygon.All(p => !double.IsNaN(p.X) && !double.IsNaN(p.Y))) { if (doubleValues == null) { //WorkingData is not numeric graphics.DrawPolygon(DrawingUtil.B_Black, screenPolygon); } else { if (doubleValues.Max() == doubleValues.Min()) { //All values are the same if (doubleValues.Max() <= 0d) { //Zero values graphics.DrawPolygon(DrawingUtil.E_Red, screenPolygon); } else { //Non-zero values graphics.DrawPolygon(DrawingUtil.L_DarkGreen, screenPolygon); } } else { double max = doubleValues.Max(); double min = doubleValues.Min(); double average = doubleValues.Average(); List <double> removedZeroValues = doubleValues.Where(dv => dv != 0).ToList(); double avarageWithoutZeroes = removedZeroValues.Average(); if (average != avarageWithoutZeroes) { min = removedZeroValues.Min(); } int i = 0; double range = (max - min) / 7.0; double e7th = min; double f7th = e7th + range; double g7th = f7th + range; double h7th = g7th + range; double i7th = h7th + range; double j7th = i7th + range; double k7th = j7th + range; double l7th = max; foreach (System.Drawing.PointF f in screenPolygon) { double dbl = i < doubleValues.Count ? doubleValues[i] : 0d; //Values will be in same order as points System.Drawing.Pen pen = DrawingUtil.B_Black; if (dbl <= e7th) { pen = DrawingUtil.E_Red; } else if (dbl <= f7th) { pen = DrawingUtil.F_DarkOrange; } else if (dbl <= g7th) { pen = DrawingUtil.G_Gold; } else if (dbl <= h7th) { pen = DrawingUtil.H_YellowGreen; } else if (dbl <= i7th) { pen = DrawingUtil.I_LawnGreen; } else if (dbl <= j7th) { pen = DrawingUtil.J_LimeGreen; } else if (dbl <= k7th) { pen = DrawingUtil.K_ForestGreen; } else if (dbl <= l7th) { pen = DrawingUtil.L_DarkGreen; } graphics.DrawEllipse(pen, new System.Drawing.RectangleF(f.X, f.Y, 2, 2)); i++; } } } } } }