public override void Draw(System.Drawing.RectangleF dirtyRect) { var g = new Graphics(); // NSView does not have a background color so we just use Clear to white here g.Clear(Color.White); //RectangleF ClientRectangle = this.Bounds; RectangleF ClientRectangle = dirtyRect; // Calculate the location and size of the drawing area // within which we want to draw the graphics: Rectangle rect = new Rectangle((int)ClientRectangle.X, (int)ClientRectangle.Y, (int)ClientRectangle.Width, (int)ClientRectangle.Height); drawingRectangle = new Rectangle(rect.Location, rect.Size); drawingRectangle.Inflate(-offset, -offset); //Draw ClientRectangle and drawingRectangle using Pen: g.DrawRectangle(Pens.Red, rect); g.DrawRectangle(Pens.Black, drawingRectangle); // Draw a line from point (3,2) to Point (6, 7) // using the Pen with a width of 3 pixels: Pen aPen = new Pen(Color.Green, 3); g.DrawLine(aPen, Point2D(new PointF(3, 2)), Point2D(new PointF(6, 7))); g.PageUnit = GraphicsUnit.Inch; ClientRectangle = new RectangleF(0.5f,0.5f, 1.5f, 1.5f); aPen.Width = 1 / g.DpiX; g.DrawRectangle(aPen, ClientRectangle); aPen.Dispose(); g.Dispose(); }
public RectangleTransparent() { clearPen = new Pen(Color.FromArgb(1, 0, 0, 0)); borderDotPen = new Pen(Color.Black, 1); borderDotPen2 = new Pen(Color.White, 1); borderDotPen2.DashPattern = new float[] { 5, 5 }; penTimer = Stopwatch.StartNew(); ScreenRectangle = CaptureHelpers.GetScreenBounds(); surface = new Bitmap(ScreenRectangle.Width, ScreenRectangle.Height); gSurface = Graphics.FromImage(surface); gSurface.InterpolationMode = InterpolationMode.NearestNeighbor; gSurface.SmoothingMode = SmoothingMode.HighSpeed; gSurface.CompositingMode = CompositingMode.SourceCopy; gSurface.CompositingQuality = CompositingQuality.HighSpeed; gSurface.Clear(Color.FromArgb(1, 0, 0, 0)); StartPosition = FormStartPosition.Manual; Bounds = ScreenRectangle; Text = "ShareX - " + Resources.RectangleTransparent_RectangleTransparent_Rectangle_capture_transparent; Shown += RectangleLight_Shown; KeyUp += RectangleLight_KeyUp; MouseDown += RectangleLight_MouseDown; MouseUp += RectangleLight_MouseUp; using (MemoryStream cursorStream = new MemoryStream(Resources.Crosshair)) { Cursor = new Cursor(cursorStream); } timer = new Timer { Interval = 10 }; timer.Tick += timer_Tick; timer.Start(); }
private void EnsureTemporaryBitmap( int width, int height ) { if( bmp != null ) { if( bmp.Width >= width && bmp.Height >= height ) { g.Clear( Color.Black ); return; } width = Math.Max( width, bmp.Width ); height = Math.Max( height, bmp.Height ); } Helpers.DisposeAndClear( ref g ); Helpers.DisposeAndClear( ref bmp ); bmp = new Bitmap( width, height, PixelFormat.Format32bppRgb ); g = Graphics.FromImage( bmp ); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; g.Clear( Color.Black ); }
/// <summary></summary> /// <param name="box"></param> /// <param name="g"></param> protected override void PaintThisProgress(Rectangle box, Graphics g) { try { box.Width -= 1; box.Height -= 1; } catch {} if (box.Width <= 1) { return; } g.FillRectangle(brush, box); Rectangle innerBox = box; innerBox.Inflate(-1, -1); g.DrawRectangle(inner, innerBox); g.DrawLine(outer, box.X, box.Y, box.Right, box.Y); g.DrawLine(outer, box.X, box.Y, box.X, box.Bottom); g.DrawLine(edge, box.X, box.Bottom, box.Right, box.Bottom); if (gloss != null) { gloss.PaintGloss(box, g); } if (showEdge) { g.DrawLine(edge, box.Right, box.Y, box.Right, box.Bottom); } }
/// <summary> /// Constructor called that clears the field and also draws the board. /// </summary> /// <param name="g">The Graphics of the panel it draws on.</param> /// <param name="difficulty">The Difficulty of the Bot!</param> public Board(Graphics g, BotDifficulty difficulty) { _graphics = g; _botDifficulty = difficulty; ClearField(); DrawField(); }
public void DrawPaperSheet(Graphics graphic) { if (SingleOffset.Paper == null) { return; } var comp1 = (int)(SingleOffset.Paper.SizeH / printFormatWidth.Value) * (int)(SingleOffset.Paper.SizeW / printFormatHeight.Value); var comp2 = (int)(SingleOffset.Paper.SizeH / printFormatHeight.Value) * (int)(SingleOffset.Paper.SizeW / printFormatWidth.Value); if (comp1 > comp2) { var widthUse = (int)(SingleOffset.Paper.SizeW / printFormatHeight.Value); var heightUse = (int)(SingleOffset.Paper.SizeH / printFormatWidth.Value); var flipped = widthUse * printFormatHeight.Value > SingleOffset.Paper.SizeW || heightUse * printFormatWidth.Value > SingleOffset.Paper.SizeH; Drawing.Draw(graphic, SingleOffset.Paper.SizeW, SingleOffset.Paper.SizeH, (int)printFormatHeight.Value, (int)printFormatWidth.Value, heightUse, widthUse, false, false); usePerSheetLabel.Text = comp1 == usePerSheet.Value ? "" : string.Format("Anzahl Nutzen passt nicht.{0}Empfohlen wären {1} Nutzen.", Environment.NewLine, comp1); usePerSheetLabel.Update(); } else { var heightUse = (int)(SingleOffset.Paper.SizeH / printFormatHeight.Value); var widthUse = (int)(SingleOffset.Paper.SizeW / printFormatWidth.Value); var flipped = widthUse * printFormatWidth.Value > SingleOffset.Paper.SizeW || heightUse * printFormatHeight.Value > SingleOffset.Paper.SizeH; Drawing.Draw(graphic, SingleOffset.Paper.SizeW, SingleOffset.Paper.SizeH, (int)printFormatWidth.Value, (int)printFormatHeight.Value, widthUse, heightUse, false, false); usePerSheetLabel.Text = comp2 == usePerSheet.Value ? "" : string.Format("Anzahl Nutzen passt nicht.{0}Empfohlen wären {1} Nutzen.", Environment.NewLine, comp2); usePerSheetLabel.Update(); } }
protected internal override void Paint(Graphics gr) { var hf = CandleView.BAR_WIDTH / 2; if (m_View.Kind== ViewKind.SideBySide) { var hh = Host.Height / Host.Zoom; gr.FillRectangle(Brushes.Green, this.Left, hh - m_Lay_BuyHeight, hf, m_Lay_BuyHeight); gr.FillRectangle(Brushes.Red, this.Left+hf, hh - m_Lay_SellHeight, hf, m_Lay_SellHeight); } else if (m_View.Kind== ViewKind.Stacked) { var hh = Host.Height / Host.Zoom; gr.FillRectangle(Brushes.Green, this.Left, hh - m_Lay_BuyHeight, CandleView.BAR_WIDTH, m_Lay_BuyHeight); gr.FillRectangle(Brushes.Red, this.Left, hh - m_Lay_BuyHeight-m_Lay_SellHeight, CandleView.BAR_WIDTH, m_Lay_SellHeight); } else//centered { var mid = (Host.Height / 2) / Host.Zoom; gr.FillRectangle(Brushes.Green, this.Left, mid - m_Lay_BuyHeight, CandleView.BAR_WIDTH, m_Lay_BuyHeight); gr.FillRectangle(Brushes.Red, this.Left, mid, CandleView.BAR_WIDTH, m_Lay_SellHeight); } }
void PaintVoxel(Graphics graphics, int i, int j) { Brush brushVoxel_True = new SolidBrush(Color.FromArgb(181, 230, 29)); Brush brushVoxel_False = new SolidBrush(Color.FromArgb(240, 240, 240)); graphics.FillRectangle(VoxelsData[i, j] ? brushVoxel_True : brushVoxel_False, VoxelSize * i + 1, VoxelSize * j + 1, VoxelSize - 1, VoxelSize - 1); }
public override void DrawSelf(Graphics grfx) { grfx.Transform = this.TransformMatrix.GetMatrix(); grfx.FillRectangle(new SolidBrush(Color.FromArgb(Transparency, FillColor)), Rectangle); grfx.DrawRectangle(new Pen(LineColor, LineWidth), Rectangle.X, Rectangle.Y, Rectangle.Width, Rectangle.Height); grfx.Transform.Reset(); }
public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, Rectangle gripRect, bool enableShadows, bool useroundedCorners) { if (appointment == null) throw new ArgumentNullException("appointment"); if (g == null) throw new ArgumentNullException("g"); if (rect.Width != 0 && rect.Height != 0) using (StringFormat format = new StringFormat()) { format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Near; if ((appointment.Locked) && isSelected) { // Draw back using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color)) g.FillRectangle(m_Brush, rect); } else { // Draw back using (SolidBrush m_Brush = new SolidBrush(appointment.Color)) g.FillRectangle(m_Brush, rect); } if (isSelected) { using (Pen m_Pen = new Pen(appointment.BorderColor, 4)) g.DrawRectangle(m_Pen, rect); Rectangle m_BorderRectangle = rect; m_BorderRectangle.Inflate(2, 2); using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1)) g.DrawRectangle(m_Pen, m_BorderRectangle); m_BorderRectangle.Inflate(-4, -4); using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1)) g.DrawRectangle(m_Pen, m_BorderRectangle); } else { // Draw gripper gripRect.Width += 1; using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor)) g.FillRectangle(m_Brush, gripRect); using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1)) g.DrawRectangle(m_Pen, rect); } rect.X += gripRect.Width; g.DrawString(appointment.Subject, this.BaseFont, SystemBrushes.WindowText, rect, format); } }
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { var buttonRectangle = new Rectangle(cellBounds.X + 2, cellBounds.Y + 2, cellBounds.Width - 4, cellBounds.Height - 4); base.Paint(graphics, clipBounds, buttonRectangle, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); var imageRectangle = new Rectangle(cellBounds.X + 6, cellBounds.Y + 6, _detailImage.Width, _detailImage.Height); graphics.DrawImage(_detailImage, imageRectangle); }
public override void Paint(Graphics g) { if (g == null) throw new ArgumentNullException("The Graphics object is 'null'"); From.Paint(g); To.Paint(g); }
public virtual Size GetCharacterSize( Graphics g, Font font, CharacterCasing casing ) { const int MeasureCharCount = 10; Size charSize = new Size( 0, 0 ); for ( char c = '0'; c <= '9'; ++c ) { Size newSize = TextRenderer.MeasureText( g, new string( c, MeasureCharCount ), font, new Size( 0, 0 ), _textFormatFlags ); newSize.Width = (int)Math.Ceiling( (double)newSize.Width / (double)MeasureCharCount ); if ( newSize.Width > charSize.Width ) { charSize.Width = newSize.Width; } if ( newSize.Height > charSize.Height ) { charSize.Height = newSize.Height; } } return charSize; }
static protected void DrawBrick (Graphics graphics, Brush b1, Brush b2, Brush b3) { if (graphics == null) return; graphics.FillPolygon (b1, brickPoints1); graphics.FillPolygon (b2, brickPoints2); graphics.FillPolygon (b3, brickPoints3); }
private static SizeF CalcReciprocals(Graphics g) { switch(g.PageUnit) { case GraphicsUnit.World: case GraphicsUnit.Pixel: return new SizeF(1f,1f); case GraphicsUnit.Inch: return new SizeF(1f/g.DpiX,1f/g.DpiY); case GraphicsUnit.Millimeter: return new SizeF(25.4f/g.DpiX,25.4f/g.DpiY); case GraphicsUnit.Point: return new SizeF(72f/g.DpiX,72f/g.DpiY); case GraphicsUnit.Display: return new SizeF(75f/g.DpiX,75f/g.DpiY); case GraphicsUnit.Document: return new SizeF(300f/g.DpiX,300f/g.DpiY); } return new SizeF(10,10);//never gets here... }
public VisibleSurface(Graphics graphics, int wdth, int hght) : base(wdth, hght) { base.DC = graphics; base.Buffer = new Backbuffer(this); this.RedrawDirtyRectangleOnly = true; }
/// <summary> /// Paints the wrapped IOGraph onto the specified viewport. Does nothing if no /// IOGraph has been provided. /// </summary> public void Paint(Graphics g, Rectangle viewportArea, float zoomFactor) { if(null != _graph) { _layoutManager.Layout(_graph, viewportArea.Size); _graphPainter.PaintNetwork(_graph, g, viewportArea, zoomFactor); } }
public override SizeF Measure(Graphics graphics) { if (this.Image != null) { SizeF size = new Size(GraphConstants.MinimumItemWidth, GraphConstants.MinimumItemHeight); if (this.Width.HasValue) size.Width = Math.Max(size.Width, this.Width.Value); else size.Width = Math.Max(size.Width, this.Image.Width); if (this.Height.HasValue) size.Height = Math.Max(size.Height, this.Height.Value); else size.Height = Math.Max(size.Height, this.Image.Height); return size; } else { var size = new SizeF(GraphConstants.MinimumItemWidth, GraphConstants.MinimumItemHeight); if (this.Width.HasValue) size.Width = Math.Max(size.Width, this.Width.Value); if (this.Height.HasValue) size.Height = Math.Max(size.Height, this.Height.Value); return size; } }
// Methods public void Render(Graphics g, Character c) { int x, y; x = c.Location.X * m_blockSize; y = m_headerSize + c.Location.Y * m_blockSize; if (m_frame == 0) { RenderClosed(g, x, y); } else { if (c.Direction == Direction.Up) { RenderUp(g, x, y); } else if (c.Direction == Direction.Right) { RenderRight(g, x, y); } else if (c.Direction == Direction.Down) { RenderDown(g, x, y); } else { RenderLeft(g, x, y); } } m_frame = (m_frame + 1) % MaxFrames; }
public override void DoPaint(Graphics g) { using (Brush b = new SolidBrush(ZenParams.WindowColor)) { g.FillRectangle(b, 0, 0, Width, Height); } }
/* Draw the triangles */ public void DrawTriangles(Graphics canvas) { foreach (Triangle tri in triangles) { tri.Draw(canvas); } }
public void PaintJunk(Graphics g) { g.FillRectangle(Brushes.Transparent, 0, 0, 1000, 1000); using (Font font = new Font("Courier New", 20, FontStyle.Bold)) { if (bounceCounter == -1) return; const string str = "DEVELOPER BUILD"; float x = 0; int timefactor = bounceCounter; for (int i = 0; i < str.Length; i++) { string slice = str.Substring(i, 1); g.PageUnit = GraphicsUnit.Pixel; x += g.MeasureString(slice, font).Width - 1; int offset = -i * 3 + timefactor*3; int yofs = 0; if (offset < 0) { continue; } else if (offset < DigitTable.Length) yofs = DigitTable[offset]; g.DrawString(slice, font, Brushes.Black, 5 + x, 15 - yofs); } } }
public CMain() { InitializeComponent(); Application.Idle += Application_Idle; MouseClick += CMain_MouseClick; MouseDown += CMain_MouseDown; MouseUp += CMain_MouseUp; MouseMove += CMain_MouseMove; MouseDoubleClick += CMain_MouseDoubleClick; KeyPress += CMain_KeyPress; KeyDown += CMain_KeyDown; KeyUp += CMain_KeyUp; Deactivate += CMain_Deactivate; MouseWheel += CMain_MouseWheel; SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.Selectable, true); FormBorderStyle = Settings.FullScreen ? FormBorderStyle.None : FormBorderStyle.FixedDialog; Graphics = CreateGraphics(); Graphics.SmoothingMode = SmoothingMode.AntiAlias; Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; Graphics.CompositingQuality = CompositingQuality.HighQuality; Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; Graphics.TextContrast = 0; }
internal override void Draw(Graphics g) { IsInvalidated = false; Rectangle r = BaseElement.GetUnsignedRectangle(new Rectangle(location, size)); Point[] points = new Point[5]; points[0] = new Point(r.X + 0, r.Y + 0); points[1] = new Point(r.X + 0, r.Y + r.Height); points[2] = new Point(r.X + r.Width, r.Y + r.Height); //Fold points[3] = new Point(r.X + r.Width, r.Y + foldSize.Height); points[4] = new Point(r.X + r.Width - foldSize.Width, r.Y + 0); //foreach(Point p in points) p.Offset(location.X, location.Y); g.FillPolygon(GetBrush(r), points, FillMode.Alternate); g.DrawPolygon(new Pen(borderColor, borderWidth), points); g.DrawLine(new Pen(borderColor, borderWidth), new Point(r.X + r.Width - foldSize.Width, r.Y + foldSize.Height), new Point(r.X + r.Width, r.Y + foldSize.Height)); g.DrawLine(new Pen(borderColor, borderWidth), new Point(r.X + r.Width - foldSize.Width, r.Y + 0), new Point(r.X + r.Width - foldSize.Width, r.Y + 0 + foldSize.Height)); }
public void Setup() { Bitmap bmp = new Bitmap(200, 100); m_graphics = Graphics.FromImage(bmp); m_gm = new GraphicsManager(null, m_graphics); }
public void DrawPath(Graphics g, Pen p) { if (m_points != null) { g.DrawLines(p, m_points); } }
/// <summary> /// Initialize a new instance of the ViewContext class. /// </summary> /// <param name="control">Control associated with rendering.</param> /// <param name="alignControl">Control used for aligning elements.</param> /// <param name="graphics">Graphics instance for drawing.</param> /// <param name="renderer">Rendering provider.</param> public ViewContext(Control control, Control alignControl, Graphics graphics, IRenderer renderer) : this(null, control, alignControl, graphics, renderer) { }
public static void AddTag2(Graphics g, int x_pos, int y_pos, Size Canvas) { int x_scale = Canvas.Width / x_number_of_datapoints; int y_scale = Canvas.Height / y_number_of_datapoints; g.FillEllipse(tag2, (x_scale * x_pos) - diamater / 2, (y_pos * y_scale) - diamater / 2, diamater, diamater); }
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { // nothing to do return; } GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } ColorMatrix grayscaleMatrix = new ColorMatrix(new[] { new[] {.3f, .3f, .3f, 0, 0}, new[] {.59f, .59f, .59f, 0, 0}, new[] {.11f, .11f, .11f, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1} }); using (ImageAttributes ia = new ImageAttributes()) { ia.SetColorMatrix(grayscaleMatrix); graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia); } graphics.Restore(state); }
public PaintScrollBarTrackEventArgs( Graphics graphics, Rectangle trackRect, Orientation orientation) : this(graphics, trackRect, orientation, true) { }