public override void Draw(System.Drawing.Graphics g) { #if DEBUG Console.WriteLine("Zone"); #endif GraphicsState gState = g.Save(); //Matrix scaleM = new Matrix(); //scaleM.Scale(1, 1); //scaleM.TransformPoints(arrPoints); base.translationMatrix.Reset(); base.translationMatrix.Translate(this.Position.X, this.Position.Y); g.MultiplyTransform(base.translationMatrix, MatrixOrder.Prepend); g.FillRectangle(Brushes.Blue, 0, 0, 500, 250); //g.FillRectangle(Brushes.Blue, 0, 0, 500, 250); foreach (IDrawable e in cards) { if (e.Visible) { e.Draw(g); } } g.Restore(gState); }
public void Draw(System.Drawing.Graphics g) { GraphicsState gs = g.Save(); g.FillRectangle(new SolidBrush(Color.FromArgb(127, Color.LightBlue)), HighlightRectangle); g.Restore(gs); }
public override void Draw(System.Drawing.Graphics g) { GraphicsState gs = g.Save(); PointF[] screenBounds = this.getScreenBoundsInWorldCoordinates(g); float left = screenBounds[0].X; float top = screenBounds[0].Y; float right = screenBounds[1].X; float bottom = screenBounds[1].Y; DrawVerticalLines(g, left, top, right, bottom); DrawHorizontalLines(g, left, top, right, bottom); g.Restore(gs); }
public override void DrawArrowForces(System.Drawing.Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods) { if (m_visibleThickPath != null) { GraphicsState o = gc.Save(); gc.SetClip(m_visibleThickPath); if ((m_traceLines != null) && (m_traceLines.Length > 0) && (m_traceLines[0].Count > 1)) { for (int k = 0; k < m_traceLines.Length; k++) { gc.DrawLines(r.RegionGuides, m_traceLines[k].ToArray()); } } gc.Restore(o); } }
public override void Draw(System.Drawing.Graphics g) { GraphicsState gs = g.Save(); PointF[] transformedPoints = this.getScreenBoundsInWorldCoordinates(g); g.DrawLine(axisPen, new PointF(base.Position.X, transformedPoints[0].Y), new PointF(base.Position.X, transformedPoints[1].Y)); g.DrawLine(axisPen, new PointF(transformedPoints[0].X, base.Position.Y), new PointF(transformedPoints[1].X, base.Position.Y)); #if DEBUG g.FillEllipse(Brushes.Maroon, base.Position.X, transformedPoints[0].Y, 10, 10); g.FillEllipse(Brushes.Maroon, base.Position.X, transformedPoints[1].Y, -10, -10); g.FillEllipse(Brushes.Maroon, transformedPoints[0].X, base.Position.Y, 10, 10); g.FillEllipse(Brushes.Maroon, transformedPoints[1].X, base.Position.Y, -10, -10); #endif g.Restore(gs); }
public override void Draw(System.Drawing.Graphics g) { //g.DrawRectangle(Pens.Green, 10, 10, 50, 80); GraphicsState gState = g.Save(); //Matrix scaleM = new Matrix(); //scaleM.Scale(1, 1); //scaleM.TransformPoints(arrPoints); base.translationMatrix.Reset(); base.translationMatrix.Translate(this.Position.X, this.Position.Y); g.MultiplyTransform(base.translationMatrix, MatrixOrder.Prepend); g.DrawRectangle(Pens.Green, 0, 0, 50, 100); //g.FillRectangle(Brushes.Blue, 0, 0, 500, 250); g.Restore(gState); #if CONSOLE Console.WriteLine(Name); #endif }
public void DrawEan13Barcode(System.Drawing.Graphics g, System.Drawing.Point pt) { float width = this.Width * this.Scale; float height = this.Height * this.Scale; // EAN13 Barcode should be a total of 113 modules wide. float lineWidth = width / 113f; // Save the GraphicsState. System.Drawing.Drawing2D.GraphicsState gs = g.Save(); // Set the PageUnit to Inch because all of our measurements are in inches. g.PageUnit = System.Drawing.GraphicsUnit.Millimeter; // Set the PageScale to 1, so a millimeter will represent a true millimeter. g.PageScale = 1; System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); ///调整条码左边距 float xPosition = 3;//0 System.Text.StringBuilder strbEAN13 = new System.Text.StringBuilder(); System.Text.StringBuilder sbTemp = new System.Text.StringBuilder(); float xStart = pt.X; float yStart = pt.Y; float xEnd = 0; System.Drawing.Font font = new System.Drawing.Font("Arial", this._fFontSize * this.Scale); // Calculate the Check Digit. //20121112注释,根据客户需求,不需要验证13码,直接打印即可 //this.CalculateChecksumDigit(); sbTemp.AppendFormat("{0}{1}{2}{3}", this.CountryCode, this.ManufacturerCode, this.ProductCode, this.ChecksumDigit); string sTemp = sbTemp.ToString(); string sLeftPattern = ""; // Convert the left hand numbers. sLeftPattern = ConvertLeftPattern(sTemp.Substring(0, 7)); // Build the UPC Code. strbEAN13.AppendFormat("{0}{1}{2}{3}{4}{1}{0}", this._sQuiteZone, this._sLeadTail, sLeftPattern, this._sSeparator, ConvertToDigitPatterns(sTemp.Substring(7), this._aRight)); string sTempUPC = strbEAN13.ToString(); float fTextHeight = g.MeasureString(sTempUPC, font).Height; // Draw the barcode lines. for (int i = 0; i < strbEAN13.Length; i++) { if (sTempUPC.Substring(i, 1) == "1") { if (xStart == pt.X) xStart = xPosition; // Save room for the UPC number below the bar code. if ((i > 12 && i < 55) || (i > 57 && i < 101)) // Draw space for the number g.FillRectangle(brush, xPosition, yStart, lineWidth, height - fTextHeight); else // Draw a full line. g.FillRectangle(brush, xPosition, yStart, lineWidth, height - fTextHeight / 2);//20121127修改,减短长线 } xPosition += lineWidth; xEnd = xPosition; } /**/ // Draw the upc numbers below the line. xPosition = xStart - g.MeasureString(this.CountryCode.Substring(0, 1), font).Width; float yPosition = yStart + (height - fTextHeight); // Draw 1st digit of the country code. g.DrawString(sTemp.Substring(0, 1), font, brush, new System.Drawing.PointF(xPosition, yPosition)); xPosition += (g.MeasureString(sTemp.Substring(0, 1), font).Width + 43 * lineWidth) - (g.MeasureString(sTemp.Substring(1, 6), font).Width); // Draw MFG Number. g.DrawString(sTemp.Substring(1, 6), font, brush, new System.Drawing.PointF(xPosition, yPosition)); xPosition += g.MeasureString(sTemp.Substring(1, 6), font).Width + (11 * lineWidth); // Draw Product ID. g.DrawString(sTemp.Substring(7), font, brush, new System.Drawing.PointF(xPosition, yPosition)); // Restore the GraphicsState. g.Restore(gs); }
public RectangleF PaintSymbol(System.Drawing.Graphics g, System.Drawing.RectangleF bounds) { if (!LineConnectionStyles.NoConnection.Instance.Equals(_connectionStyle)) { GraphicsState gs = g.Save(); g.TranslateTransform(bounds.X + 0.5f * bounds.Width, bounds.Y + 0.5f * bounds.Height); float halfwidth = bounds.Width / 2; float symsize = (float)(_symbolSize); if (this.UseSymbolGap == true) { // plot a line with the length of symbolsize from PaintLine(g, new PointF(-halfwidth, 0), new PointF(-symsize, 0)); PaintLine(g, new PointF(symsize, 0), new PointF(halfwidth, 0)); } else // no gap { PaintLine(g, new PointF(-halfwidth, 0), new PointF(halfwidth, 0)); } g.Restore(gs); } return bounds; }
protected override void DrawHandles(System.Drawing.Graphics grfx, Syncfusion.Windows.Forms.Diagram.NodeCollection nodesSelected) { if (NeedDrawHandles) { if ((nodesSelected != null) && (nodesSelected.Count > 0)) { foreach (Node node in nodesSelected) { PathNode node2; if (!node.Visible) { continue; } HandleEditMode defaultHandleEditMode = node.EditStyle.DefaultHandleEditMode; Matrix parentsTransform = this.GetParentsTransform(node); GraphicsState gstate = grfx.Save(); grfx.MultiplyTransform(parentsTransform); if (this.CustomHandleRenderer != null) { this.CustomHandleRenderer.Render(grfx, defaultHandleEditMode, node); } else { switch (defaultHandleEditMode) { case HandleEditMode.Resize: if (!node.ShowResizeHandles()) { HandleRenderer.OutlineBoundingRectangle(grfx, node); if (node is IEndPointContainer) { HandleRenderer.DrawEndPoints(grfx, node); } } else { HandleRenderer.OutlineBoundingRectangle(grfx, node); //HandleRenderer.DrawRotationHandles(grfx, node); HandleRenderer.DrawSelectionHandles(grfx, node); } break; case HandleEditMode.Vertex: node2 = node as PathNode; if (!(node is IEndPointContainer)) { if ((node2 != null) && (node2.CanChangePath || node2.IsVertexEditable)) { HandleRenderer.OutlineBoundingRectangle(grfx, node2); if (node2.CanDrawControlPoints()) { node2.DrawControlPoints(grfx); } else { HandleRenderer.DrawVertexHandles(grfx, node2); } } } else { HandleRenderer.DrawEndPoints(grfx, node); HandleRenderer.OutlineBoundingRectangle(grfx, node); if (node2.CanDrawControlPoints()) { node2.DrawControlPoints(grfx); } } break; } } grfx.Restore(gstate); } } } }
public RectangleF PaintSymbol(System.Drawing.Graphics g, System.Drawing.RectangleF bounds) { if (Shape != XYPlotScatterStyles.Shape.NoSymbol) { GraphicsState gs = g.Save(); g.TranslateTransform(bounds.X + 0.5f * bounds.Width, bounds.Y + 0.5f * bounds.Height); Paint(g); g.Restore(gs); if (this.SymbolSize > bounds.Height) bounds.Inflate(0, this.SymbolSize - bounds.Height); } return bounds; }
public RectangleF PaintSymbol(System.Drawing.Graphics g, System.Drawing.RectangleF bounds) { if (_scatterSymbol is NoSymbol) return bounds; var cachedPathData = new CachedPathData(); var cachedBrushData = new CachedBrushData(); var scatterSymbol = CalculateOverriddenScatterSymbol(); CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); GraphicsState gs = g.Save(); g.TranslateTransform(bounds.X + 0.5f * bounds.Width, bounds.Y + 0.5f * bounds.Height); if (null != cachedPathData.InsetPath) g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); if (null != cachedPathData.FillPath) g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); if (null != cachedPathData.FramePath) g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); cachedBrushData.Clear(); cachedPathData.Clear(); g.Restore(gs); if (this.SymbolSize > bounds.Height) bounds.Inflate(0, (float)(this.SymbolSize - bounds.Height)); return bounds; }
// TODO: Correctly Draw the Slide Annotation private void DrawSlide( DeckTraversalModel traversal, int index, System.Drawing.Rectangle rect, System.Drawing.Graphics buffer ) { // Save the old state System.Drawing.Drawing2D.GraphicsState oldState; using( Synchronizer.Lock( traversal.SyncRoot ) ) { using( Synchronizer.Lock( traversal.Deck.SyncRoot ) ) { using( Synchronizer.Lock( traversal.Deck.TableOfContents.SyncRoot ) ) { TableOfContentsModel.Entry entry = traversal.Deck.TableOfContents.Entries[index]; using( Synchronizer.Lock( entry.Slide.SyncRoot ) ) { //Draw the background color //First see if there is a Slide BG, if not, try the Deck. Otherwise, use transparent. if( entry.Slide.BackgroundColor != Color.Empty ) { buffer.FillRectangle( new System.Drawing.SolidBrush( entry.Slide.BackgroundColor ), rect ); } else if( traversal.Deck.DeckBackgroundColor != Color.Empty ) { buffer.FillRectangle( new System.Drawing.SolidBrush( traversal.Deck.DeckBackgroundColor ), rect ); } else { buffer.FillRectangle( new System.Drawing.SolidBrush( Color.Transparent ), rect ); } //Get the Slide content and draw it oldState = buffer.Save(); Model.Presentation.SlideModel.SheetCollection sheets = entry.Slide.ContentSheets; for( int i = 0; i < sheets.Count; i++ ) { SlideDisplayModel display = new SlideDisplayModel( buffer, null ); Rectangle slide = rect; float zoom = 1f; if( entry.Slide != null ) { slide = entry.Slide.Bounds; zoom = entry.Slide.Zoom; } System.Drawing.Drawing2D.Matrix pixel, ink; display.FitSlideToBounds(System.Windows.Forms.DockStyle.Fill, rect, zoom, ref slide, out pixel, out ink); using(Synchronizer.Lock(display.SyncRoot)) { display.Bounds = slide; display.PixelTransform = pixel; display.InkTransform = ink; } Viewer.Slides.SheetRenderer r = Viewer.Slides.SheetRenderer.ForStaticSheet( display, sheets[i] ); r.Paint( new System.Windows.Forms.PaintEventArgs(buffer, rect) ); r.Dispose(); } //Restore the Old State buffer.Restore( oldState ); oldState = buffer.Save(); //Get the Annotation content and draw it sheets = entry.Slide.AnnotationSheets; for( int i = 0; i < sheets.Count; i++ ) { SlideDisplayModel display = new SlideDisplayModel( buffer, null ); Rectangle slide = rect; float zoom = 1f; if( entry.Slide != null ) { slide = entry.Slide.Bounds; zoom = entry.Slide.Zoom; } System.Drawing.Drawing2D.Matrix pixel, ink; display.FitSlideToBounds(System.Windows.Forms.DockStyle.Fill, rect, zoom, ref slide, out pixel, out ink); using(Synchronizer.Lock(display.SyncRoot)) { display.Bounds = slide; display.PixelTransform = pixel; display.InkTransform = ink; } Viewer.Slides.SheetRenderer r = Viewer.Slides.SheetRenderer.ForStaticSheet( display, sheets[i] ); if( r is Viewer.Slides.InkSheetRenderer ) { ((Viewer.Slides.InkSheetRenderer)r).Paint( buffer, rect ); } else r.Paint( new System.Windows.Forms.PaintEventArgs(buffer, rect) ); r.Dispose(); } //Restore the Old State buffer.Restore( oldState ); /* Microsoft.Ink.Renderer renderer = new Microsoft.Ink.Renderer(); for( int i = 0; i < sheets.Count; i++ ) { SheetModel sm = sheets[i]; if( sm is InkSheetModel ) { InkSheetModel ism = sm as InkSheetModel; using( Synchronizer.Lock( ism.SyncRoot ) ) { foreach( Microsoft.Ink.Stroke stroke in ism.Ink.Strokes ) { renderer.Draw( buffer, stroke ); } } } else if( sm is TextSheetModel ) { TextSheetModel tsm = sm as TextSheetModel; using( Synchronizer.Lock( tsm.SyncRoot ) ) { buffer.DrawString( tsm.Text, tsm.Font, new SolidBrush( tsm.Color ), tsm.Bounds ); } } else if( sm is ImageSheetModel ) { //add any images in the AnnotationSheets ImageSheetModel image_sheet_model = (ImageSheetModel)sm; using( Synchronizer.Lock( image_sheet_model.SyncRoot ) ) { buffer.DrawImage( image_sheet_model.Image, image_sheet_model.Bounds ); } } else { //Unknown, skip it continue; } } */ } } } } }
public void Draw(System.Drawing.Graphics g, float scale, float x, float y, DrawMode mode, Image image) { if (!Visible) return; GraphicsState old_state = g.Save(); g.ScaleTransform(scale, scale); g.TranslateTransform(x, y); Rectangle frect = rect;// GetRect(x, y, scale); g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; int pen_width = mode == DrawMode.Hovered ? 2 : 1; if (mode == DrawMode.Selected) { g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; g.FillRectangle(new SolidBrush(Color.FromArgb(60, Color.Red)), frect); g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; g.DrawRectangle(new Pen(Color.Red, pen_width), frect); } else { Color color = Color.RoyalBlue; g.DrawRectangle(new Pen(color, pen_width), frect); } g.Restore(old_state); //GraphicsState old_state = g.Save(); }
/// <summary> /// Draw tiled cells. /// </summary> private void DrawGrid(System.Drawing.Graphics gfx) { // Save state. GraphicsState state = gfx.Save(); // Create pen. Pen pen = new Pen(Color.Red); // Get rendering rectangle. Rectangle rect = new Rectangle(0, 0, _backBuffer.Width, _backBuffer.Height); // Create a new graphics path for inverted lines. GraphicsPath path = new GraphicsPath(FillMode.Alternate); // Calculate row and column amounts. int cols = (int)Math.Floor((double)(_image.Width - _offsetX) / (double)(_tileSize.Width + _seperationX)); int rows = (int)Math.Floor((double)(_image.Height - _offsetY) / (double)(_tileSize.Height + _seperationY)); // Iterate through vertical tiles. for (int row = 0; row < rows; row++) { // Iterate through horizontal tiles. for (int col = 0; col < cols; col++) { // Get position coordinates. int x = (int)(double)(col * _tileSize.Width + col * _seperationX) + _offsetX; int y = (int)(double)(row * _tileSize.Height + row * _seperationY) + _offsetY; // Add rectangle path. path.AddRectangle(new Rectangle(x, y, _tileSize.Width - 1, _tileSize.Height - 1)); } } // Path widen. path.Widen(pen); // Create new region from path. Region region = new Region(path); // Set the clip region. gfx.Clip = region; // Draw the backbuffer image. gfx.DrawImage(_backBuffer, rect, 0, 0, rect.Width, rect.Height, GraphicsUnit.Pixel, _atts); // Restore the graphics state to non-inverted. gfx.Restore(state); // Dispose of all temp objects. region.Dispose(); pen.Dispose(); }
public override void Paint(System.Drawing.Graphics g, IPaintContext paintContext) { if (null == _cachedArea) return; bool orientationIsVertical = IsOrientationVertical; bool scaleIsReversed = IsScaleReversed; int pixelH = orientationIsVertical ? _bitmapPixelsAcross : _bitmapPixelsAlong; int pixelV = orientationIsVertical ? _bitmapPixelsAlong : _bitmapPixelsAcross; if (null == _bitmap || _bitmap.Width != pixelH || _bitmap.Height != pixelV) { if (null != _bitmap) _bitmap.Dispose(); _bitmap = new Bitmap(pixelH, pixelV, System.Drawing.Imaging.PixelFormat.Format32bppArgb); } Data.AltaxoVariant porg; Data.AltaxoVariant pend; NumericalScale originalZScale; Plot.IColorProvider colorProvider; if (null != PlotItem) { porg = PlotItem.Style.Scale.OrgAsVariant; pend = PlotItem.Style.Scale.EndAsVariant; originalZScale = PlotItem.Style.Scale; colorProvider = PlotItem.Style.ColorProvider; } else { porg = 0; pend = 1; originalZScale = new LinearScale(); colorProvider = new Plot.ColorProvider.ColorProviderBGRY(); } var legendScale = (NumericalScale)ScaleWithTicks; var legendTickSpacing = ScaleWithTicks.TickSpacing; // Fill the bitmap for (int i = 0; i < _bitmapPixelsAlong; i++) { double r = (scaleIsReversed ^ orientationIsVertical) ? 1 - i / (double)(_bitmapPixelsAlong - 1) : i / (double)(_bitmapPixelsAlong - 1); double l = originalZScale.PhysicalToNormal(legendScale.NormalToPhysical(r)); var color = colorProvider.GetColor(l); if (orientationIsVertical) { for (int j = 0; j < _bitmapPixelsAcross; j++) _bitmap.SetPixel(j, i, color); } else { for (int j = 0; j < _bitmapPixelsAcross; j++) _bitmap.SetPixel(i, j, color); } } var graphicsState = g.Save(); TransformGraphics(g); { // Three tricks are neccessary to get the color legend (which is the bitmap) drawn smooth and uniformly: // Everything other than this will result in distorted image, or soft (unsharp) edges var graphicsState2 = g.Save(); // Of course, save the graphics state so we can make our tricks undone afterwards g.InterpolationMode = InterpolationMode.Default; // Trick1: Set the interpolation mode, whatever it was before, back to default g.PixelOffsetMode = PixelOffsetMode.Default; // Trick2: Set the PixelOffsetMode, whatever it was before, back to default g.DrawImage(_bitmap, new RectangleF(0, 0, (float)Size.X, (float)Size.Y), new Rectangle(0, 0, pixelH - 1, pixelV - 1), GraphicsUnit.Pixel); // Trick3: Paint both in X and Y direction one pixel less than the source bitmap acually has, this prevents soft edges g.Restore(graphicsState2); // make our tricks undone here } _axisStyles.Paint(g, paintContext, _cachedArea); g.Restore(graphicsState); }