protected override void OnRender(DrawingContext drawingContext) { double width = RenderSize.Width; double height = RenderSize.Height; MeshGeometry3D mesh = Mesh; if (mesh != null) { Pen pen = new Pen(Brushes.Black, 1.0); int numTriangles = mesh.TriangleIndices.Count/3; for(int i = 0; i < numTriangles; i++) { DrawTriangle(drawingContext, pen, mesh.TextureCoordinates[mesh.TriangleIndices[i * 3]], mesh.TextureCoordinates[mesh.TriangleIndices[i * 3 + 1]], mesh.TextureCoordinates[mesh.TriangleIndices[i * 3 + 2]], width, height); } } base.OnRender(drawingContext); }
/// <summary>Draws a snapped orthogonal line.</summary> internal static void DrawOrthogonal(DrawingContext dc, Orientation orientation, Pen pen, double q, double p0, double p1) { if (orientation == Orientation.Horizontal) { DrawHorizontal(dc, pen, q, p0, p1); } else { DrawVertical(dc, pen, q, p0, p1); } }
protected override void OnRender(DrawingContext drawingContext) { FoldingMargin margin = VisualParent as FoldingMargin; Pen activePen = new Pen(margin.SelectedFoldingMarkerBrush, 1); Pen inactivePen = new Pen(margin.FoldingMarkerBrush, 1); activePen.StartLineCap = inactivePen.StartLineCap = PenLineCap.Square; activePen.EndLineCap = inactivePen.EndLineCap = PenLineCap.Square; Size pixelSize = PixelSnapHelpers.GetPixelSize(this); Rect rect = new Rect(pixelSize.Width / 2, pixelSize.Height / 2, this.RenderSize.Width - pixelSize.Width, this.RenderSize.Height - pixelSize.Height); drawingContext.DrawRectangle( IsMouseDirectlyOver ? margin.SelectedFoldingMarkerBackgroundBrush : margin.FoldingMarkerBackgroundBrush, IsMouseDirectlyOver ? activePen : inactivePen, rect); double middleX = rect.Left + rect.Width / 2; double middleY = rect.Top + rect.Height / 2; double space = PixelSnapHelpers.Round(rect.Width / 8, pixelSize.Width) + pixelSize.Width; drawingContext.DrawLine(activePen, new Point(rect.Left + space, middleY), new Point(rect.Right - space, middleY)); if (!isExpanded) { drawingContext.DrawLine(activePen, new Point(middleX, rect.Top + space), new Point(middleX, rect.Bottom - space)); } }
//为图片画一个正方形边框 private void DrawLine(DrawingVisual visual) { DrawingVisual newvis = new DrawingVisual(); biankuang = newvis; var visualwidth = (visual.ContentBounds.TopRight - visual.ContentBounds.TopLeft).X; var visualheight = (visual.ContentBounds.BottomLeft - visual.ContentBounds.TopLeft).Y; var topleft = new System.Windows.Point(visual.Offset.X + visual.ContentBounds.TopLeft.X, visual.Offset.Y + visual.ContentBounds.TopLeft.Y); var topright = new System.Windows.Point(visual.Offset.X + visual.ContentBounds.TopLeft.X + visualwidth, visual.Offset.Y + visual.ContentBounds.TopLeft.Y); var bottomleft = new System.Windows.Point(visual.Offset.X + visual.ContentBounds.TopLeft.X, visual.Offset.Y + visualheight + visual.ContentBounds.TopLeft.Y); var bottomright = new System.Windows.Point(visual.Offset.X + visualwidth + visual.ContentBounds.TopLeft.X, visual.Offset.Y + visualheight + visual.ContentBounds.TopLeft.Y); using (var dc = newvis.RenderOpen()) { System.Windows.Media.Brush brush = System.Windows.Media.Brushes.Blue; System.Windows.Media.Pen pen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Blue, 2); dc.DrawLine(pen, topleft, topright); dc.DrawLine(pen, topleft, bottomleft); dc.DrawLine(pen, topright, bottomright); dc.DrawLine(pen, bottomleft, bottomright); pen.Freeze(); } this.AddVisual(newvis); }
//画箭头 protected Visual DrawArrow(System.Windows.Point startpoint, System.Windows.Point endpoint, System.Windows.Media.Brush brush, double thick) { var matx = new Matrix(); Vector vect = startPoint - endpoint; //获取单位向量 vect.Normalize(); vect *= 15; //旋转夹角的一半 matx.Rotate(60 / 2); //计算上半段箭头的点 System.Windows.Point point1 = endpoint + vect * matx; matx.Rotate(-60); //计算下半段箭头的点 System.Windows.Point point2 = endpoint + vect * matx; DrawingVisual visual = new DrawingVisual(); System.Windows.Media.Pen pen = new System.Windows.Media.Pen(brush, thick); using (var dc = visual.RenderOpen()) { dc.DrawLine(pen, startPoint, endpoint); dc.DrawLine(pen, endpoint, point1); dc.DrawLine(pen, endpoint, point2); pen.Freeze(); //冻结画笔,这样能加快绘图速度 } this.AddVisual(visual); return(visual); }
private void AsynDisplayImage() { ThreadPool.QueueUserWorkItem(o => { Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.SystemIdle, new Action(() => { //新开一个线程池执行draw BMDrawer bmd = new BMDrawer(); string teststrings = characterTextBox.Text; //放大比例 double rate = 1f; PresentationSource source = PresentationSource.FromVisual(this); double dpiX = 0f, dpiY = 0f; if (source != null) { dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11; dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22; } rate = dpiX / 96d; Bitmap bmp = bmd.test_draw(teststrings); BitmapImage cbmp = BitmapToBitmapImage(bmp); image.Height = cbmp.Height * rate; image.Width = cbmp.Width * rate; image.Source = cbmp; if (checkboxShowLine.IsChecked == true) { DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext drawingContext = drawingVisual.RenderOpen()) { // // ... draw on the drawingContext // System.Windows.Media.Pen pen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Red, (double)0.3f); drawingContext.DrawImage(image.Source, new Rect(0, 0, image.Source.Width * rate, image.Source.Height * rate)); int x_lines = (int)Math.Round((float)(int)image.Width / (float)GlobalSettings.iTileWidth); int y_lines = (int)Math.Round((float)(int)image.Height / (float)GlobalSettings.iTileHeight);; for (int i = 0; i < x_lines + 1; i++) { drawingContext.DrawLine(pen, new System.Windows.Point(i * GlobalSettings.iTileWidth, 0), new System.Windows.Point(i * GlobalSettings.iTileWidth, (float)(int)image.Height)); } for (int i = 0; i < y_lines + 1; i++) { drawingContext.DrawLine(pen, new System.Windows.Point(0, i * GlobalSettings.iTileHeight), new System.Windows.Point((float)(int)image.Width, i * GlobalSettings.iTileHeight)); } drawingContext.Close(); RenderTargetBitmap nbmp = new RenderTargetBitmap((int)(image.Width * rate), (int)(image.Height * rate), 96.0 * rate * rate, 96.0 * rate * rate, PixelFormats.Default); nbmp.Render(drawingVisual); image.Source = nbmp; } } }) ); }); }
public static System.Windows.Media.Pen ToWpf(this Altaxo.Graph.Gdi.PenX penx) { System.Windows.Media.Color c = ToWpf(penx.Color); var result = new System.Windows.Media.Pen(new System.Windows.Media.SolidColorBrush(c), penx.Width); return(result); }
public void Draw(PdfRenderer renderer, DrawingContext graphics) { if (renderer == null) { throw new ArgumentNullException(nameof(renderer)); } if (graphics == null) { throw new ArgumentNullException(nameof(graphics)); } Rect bounds = renderer.BoundsFromPdf(new PdfRectangle(Page, Bounds)); var brush = new SolidColorBrush(Color) { Opacity = .8 }; var pen = new Pen(new SolidColorBrush(BorderColor) { Opacity = .8 }, BorderWidth); graphics.DrawRectangle(brush, null, bounds); if (BorderWidth > 0) { graphics.DrawRectangle(null, pen, bounds); } }
/// <summary> /// DrawLine - /// Draws a line with the specified pen. /// Note that this API does not accept a Brush, as there is no area to fill. /// </summary> /// <param name="pen"> The Pen with which to stroke the line. </param> /// <param name="point0"> The start Point for the line. </param> /// <param name="point1"> The end Point for the line. </param> public override void DrawLine( Pen pen, Point point0, Point point1) { Debug.Assert(false); }
//https://gist.github.com/Phyxion/160a6f04e6083016d4b2a3aed3c4fe71 public static Image GetImage( PackIconKind iconKind, Brush brush, Pen pen) { var icon = new PackIcon { Kind = iconKind }; var geometryDrawing = new GeometryDrawing { Geometry = Geometry.Parse(icon.Data), Brush = brush, Pen = pen }; var drawingGroup = new DrawingGroup { Children = { geometryDrawing } }; var img = new DrawingImage { Drawing = drawingGroup }; var stream = DrawingImageToStream(img); return(Image.FromStream(stream)); }
private void RenderPolygon(DrawingContext drawingContext) { var fillBrush = Brushes.LawnGreen; var borderPen = new Pen(Brushes.Black,1.0); PathFigure myPathFigure = new PathFigure(); myPathFigure.StartPoint = maxPoints[0]; //PolyLineSegment seg = new PolyLineSegment( PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); for (int i = 1; i < maxPoints.Count; i++) { myPathSegmentCollection.Add(new LineSegment(maxPoints[i], true)); } for (int i = minPoints.Count - 1; i >= 0; i--) { myPathSegmentCollection.Add(new LineSegment(minPoints[i], true)); } myPathFigure.Segments = myPathSegmentCollection; PathGeometry myPathGeometry = new PathGeometry(); myPathGeometry.Figures.Add(myPathFigure); drawingContext.DrawGeometry(fillBrush, borderPen, myPathGeometry); }
public static System.Windows.Media.Geometry CreateGeometry(DrawingGroup drawingGroup, SvgImportOptions opts) { var geometry = new GeometryGroup { FillRule = opts.FillRule }; var defaultPen = new Pen(new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0)), 1); foreach (var drawing in drawingGroup.Children) { switch (drawing) { case GeometryDrawing gd: HandleGeometry(gd.Geometry, geometry, gd, opts, defaultPen); break; case GlyphRunDrawing grd: geometry.Children.Add(grd.GlyphRun.BuildGeometry()); break; case DrawingGroup dg: var c = new SvgImportOptions { FillRule = FillRule.EvenOdd, Smoothness = opts.Smoothness, UseOutlinedGeometry = opts.UseOutlinedGeometry, NeverWidenClosedPaths = opts.NeverWidenClosedPaths }; geometry.Children.Add(CreateGeometry(dg, c)); break; } } geometry.Transform = drawingGroup.Transform; return(geometry); }
private DrawingContext GetRectangles(DocumentPage page, DrawingContext backgroundContext, System.Windows.Media.Pen pen) { double boxLeft = page.ContentBox.Left; double boxTop = page.ContentBox.Top; double boxRight = page.ContentBox.Right; double boxBottom = page.ContentBox.Bottom; System.Windows.Media.Pen mainBoxPen = new System.Windows.Media.Pen(_borderBrush, _thickness * 2); //Big rectangle System.Windows.Point mainBoxTopLeft = new System.Windows.Point { X = boxLeft, Y = boxTop - _headerSize }; System.Windows.Point mainBoxBottomRight = new System.Windows.Point { X = boxRight, Y = boxBottom + _footerSize }; System.Windows.Rect mainRect = new Rect(mainBoxTopLeft, mainBoxBottomRight); backgroundContext.DrawRectangle(null, mainBoxPen, mainRect); //header drawPageline(boxLeft, boxRight, boxTop, pen, backgroundContext); //footer drawPageline(boxLeft, boxRight, boxBottom, pen, backgroundContext); return(backgroundContext); }
/// <summary> /// 从笔转化为系统笔; /// </summary> /// <param name="pen"></param> /// <returns></returns> public static SystemMedia.Pen ConverterToSystemPen(Pen pen) { if (pen == null) { throw new ArgumentNullException(nameof(pen)); } if (_frozenPenDict.TryGetValue(pen, out var sysPen)) { return(sysPen); } sysPen = new SystemMedia.Pen(BrushAdapter.ConvertToSystemBrush(pen.Brush), pen.Thickness); if (pen.DashStyle != null) { sysPen.DashStyle = DashStyleAdapter.ConvertToSystemDashStyle(pen.DashStyle); } if (pen.IsFrozen) { sysPen.Freeze(); _frozenPenDict.Add(pen, sysPen); } return(sysPen); }
/// <summary> /// Draw reference points on the image /// </summary> /// <param name="image">Image to draw</param> /// <param name="whiteAreas">White rectangles for white margin areas</param> /// <param name="refPoints">Black rectangles - actual reference points</param> /// <returns>Image with drawn reference points</returns> public static BitmapImage DrawReferencePoints(BitmapImage image, Rect[] whiteAreas, Rect[] refPoints) { // prepare resources SolidColorBrush whiteBrush = new SolidColorBrush(Colors.White); var blackBrush = new SolidColorBrush(Colors.Black); var whitePen = new System.Windows.Media.Pen(whiteBrush, 1); var blackPen = new System.Windows.Media.Pen(blackBrush, 1); whiteBrush.Freeze(); blackBrush.Freeze(); whitePen.Freeze(); blackPen.Freeze(); var target = new RenderTargetBitmap(image.PixelWidth, image.PixelHeight, image.DpiX, image.DpiY, PixelFormats.Pbgra32); var visual = new DrawingVisual(); using (DrawingContext r = visual.RenderOpen()) { r.DrawImage(image, new Rect(0, 0, image.Width, image.Height)); for (int i = 0; i < whiteAreas.Length; i++) { r.DrawRectangle(whiteBrush, whitePen, whiteAreas[i]); r.DrawRectangle(blackBrush, blackPen, refPoints[i]); } } // call render to render all changes on the image target.Render(visual); return(ConvertRenderTargetToBitmapImage(target)); }
System.Drawing.Size face_size = new System.Drawing.Size(7, 7); // units in pixels public FacialRecognition(dynamic mainWindow) { this.mainWindow = mainWindow; this.commHelper = this.mainWindow.communicationHelper; this.systemData = this.commHelper.systemData; classifier_path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/opencv/data/haarcascades/haarcascade_frontalface_default.xml"; database_path = "../../../../public/"; people_path = database_path + "people/"; activations_path = activations_path + "activations/"; recognized_threshold = 105; add_new_training_threshold = 75; num_trained = 0; input_height = 240; input_width = 426; face_outline_pen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.LightBlue, 3); face_label_brush = Brushes.Black; face_label_font = new Typeface("Georgia"); face_label_font_size = 10; label_to_int = new Dictionary <string, int>(); training_images = new List <Image <Gray, byte> >(); training_int_labels = new List <int>(); training_labels = new List <string>(); face_finder = new CascadeClassifier(classifier_path); face_recognizer = new LBPHFaceRecognizer(); load_database(); }
public PairedCharacterRenderer() { highlightBrush = new SolidColorBrush(Colors.LightBlue); highlightPen = new Pen(highlightBrush, 1.0); PairedCharacters = new TextSegmentCollection<TextSegment>(); }
public YearRegionFieldWindow(string parameterName, IParameter2DimensionalTypeless<double> parameterToDisplay) { InitializeComponent(); _parameter = parameterToDisplay; _parameterName = parameterName; plotterHeader.Content = parameterName; var data2 = from p in parameterToDisplay.GetEnumerator() where !Double.IsNaN(p.Value) && !Double.IsInfinity(p.Value) group p by p.Dimension2; foreach (var series in data2) { var data = from p in series select new Point(p.Dimension1.Index + 1950, p.Value); var dd = data.ToArray(); var d = dd.AsDataSource(); int remainder1 = series.Key.Index % 4; var color = remainder1 == 0 ? Brushes.Blue : remainder1 == 1 ? Brushes.Red : remainder1 == 2 ? Brushes.Green : Brushes.Gold; int tt = series.Key.Index / 4; var dashline = tt == 0 ? DashStyles.Solid : tt == 1 ? DashStyles.Dash : tt == 2 ? DashStyles.Dot : DashStyles.DashDot; var linedescr = tt == 0 ? "solid" : tt == 1 ? "dash" : tt == 2 ? "dot" : "dash-dot"; var pen = new Pen(color, 2); pen.DashStyle = dashline; plotter.AddLineGraph(d, pen, new PenDescription(String.Format("{0} ({1})", series.Key, linedescr))); } }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { base.OnRender(drawingContext); double height = element.ActualHeight; double width = element.ActualWidth; double linesHorizontal = height / LINEFACTOR; double linesVertical = width / LINEFACTOR; var pen = new Pen(Brushes.Blue, 0.1) { StartLineCap = PenLineCap.Triangle, EndLineCap = PenLineCap.Triangle }; int offset = 0; for (int i = 0; i <= linesVertical; ++i) { offset = offset + LINEFACTOR; drawingContext.DrawLine(pen, new Point(offset, 0), new Point(offset, height)); } offset = 0; for (int i = 0; i <= linesHorizontal; ++i) { offset = offset + LINEFACTOR; drawingContext.DrawLine(pen, new Point(0, offset), new Point(width, offset)); } }
public void Draw(TextView textView, DrawingContext drawingContext) { foreach (TextSegment current in this.SearchHitsSegments) { foreach (Rect current2 in BackgroundGeometryBuilder.GetRectsForSegment(textView, current)) { Point bottomLeft = current2.BottomLeft; Point bottomRight = current2.BottomRight; Pen pen = new Pen(new SolidColorBrush(Colors.OrangeRed), 1); pen.Freeze(); double num = 2.5; int count = System.Math.Max((int)((bottomRight.X - bottomLeft.X) / num) + 1, 4); StreamGeometry streamGeometry = new StreamGeometry(); using (StreamGeometryContext streamGeometryContext = streamGeometry.Open()) { streamGeometryContext.BeginFigure(bottomLeft, true, true); streamGeometryContext.LineTo(current2.TopLeft, true, false); streamGeometryContext.LineTo(current2.TopRight, true, false); streamGeometryContext.LineTo(current2.BottomRight, true, false); } streamGeometry.Freeze(); drawingContext.DrawGeometry(Brushes.Transparent, pen, streamGeometry); } } }
public static Pen CreateErrorPen(Color color) { var geometry = new StreamGeometry(); using (var context = geometry.Open()) { context.BeginFigure(new Point(-1, 0), false, false); context.PolyLineTo(new[] { new Point(-0.5, 0.4), new Point(0, 0), new Point(0.5, -0.4), new Point(1, 0), }, true, true); } var brushPattern = new GeometryDrawing { Pen = new Pen(new SolidColorBrush(color), 0.4), Geometry = geometry }; var brush = new DrawingBrush(brushPattern) { TileMode = TileMode.Tile, Viewport = new Rect(-1, -1, 2, 2), ViewportUnits = BrushMappingMode.Absolute, Viewbox = new Rect(-1, -1, 2, 2), ViewboxUnits = BrushMappingMode.Absolute, }; var pen = new Pen(brush, 3.0); pen.Freeze(); return pen; }
public bool DrawString( System.Windows.Media.DrawingContext graphics, System.Windows.Media.FontFamily fontFamily, System.Windows.FontStyle fontStyle, System.Windows.FontWeight fontWeight, double fontSize, string strText, System.Windows.Point ptDraw, System.Globalization.CultureInfo ci) { Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci); for (int i = 1; i <= m_nThickness; ++i) { SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline); Pen pen = new Pen(solidbrush, i); pen.LineJoin = PenLineJoin.Round; if (m_bClrText) { SolidColorBrush brush = new SolidColorBrush(m_clrText); graphics.DrawGeometry(brush, pen, path); } else graphics.DrawGeometry(m_brushText, pen, path); } return true; }
public TranslateAdorner(DesignerCanvas canvas) : base(canvas) { this.canvas = canvas; stroke = new Pen(new SolidColorBrush(Colors.DarkGray), 3); }
static PainterCache() { UseTransparentImage = true; try { TransparentBrush = new SolidColorBrush(Colors.Transparent); TransparentBrush.Freeze(); BlackBrush = new SolidColorBrush(Colors.Black); BlackBrush.Freeze(); WhiteBrush = new SolidColorBrush(Colors.White); WhiteBrush.Freeze(); ZonePen = new Pen(BlackBrush, 1); GridLineBrush = new SolidColorBrush(Colors.Orange); GridLineBrush.Freeze(); GridLinePen = new Pen(GridLineBrush, 1); GridLinePen.EndLineCap = PenLineCap.Square; GridLinePen.StartLineCap = PenLineCap.Square; GridLinePen.DashStyle = DashStyles.Dash; PointGeometry = new RectangleGeometry(new Rect(-15, -15, 30, 30)); _transparentBackgroundBrush = CreateTransparentBackgroundBrush(); } catch (Exception e) { Logger.Error(e, "PainterCache.PainterCache()"); } }
public AchievementAdornments(IWpfTextView view) { this.view = view; this.layer = view.GetAdornmentLayer("AchievementAdornments"); this.descriptionLayer = view.GetAdornmentLayer("AchievementAdornmentsDescription"); view.LayoutChanged += OnLayoutChanged; Brush brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff)); brush.Freeze(); Brush penBrush = new SolidColorBrush(Colors.Red); penBrush.Freeze(); Pen pen = new Pen(penBrush, 0.5); pen.Freeze(); this.brush = brush; this.pen = pen; AchievementUIContext.AchievementClicked += (sender, e) => { Reset(); var filePath = GetFilePath(view); if (e.AchievementDescriptor.CodeOrigin.FileName != filePath) return; codeOrigin = e.AchievementDescriptor.CodeOrigin; achievementUiElement = (UIElement)e.UIElement; CreateAdornment(); }; }
protected override void OnRender(DrawingContext drawingContext) { Pen blackPen = new Pen(Brushes.Black, 1); blackPen.StartLineCap = PenLineCap.Square; blackPen.EndLineCap = PenLineCap.Square; Size pixelSize = PixelSnapHelpers.GetPixelSize(this); Rect rect = new Rect(pixelSize.Width / 2, pixelSize.Height / 2, this.RenderSize.Width - pixelSize.Width, this.RenderSize.Height - pixelSize.Height); drawingContext.DrawRectangle(Brushes.White, IsMouseDirectlyOver ? blackPen : new Pen(Brushes.Gray, 1), rect); double middleX = rect.Left + rect.Width / 2; double middleY = rect.Top + rect.Height / 2; double space = PixelSnapHelpers.Round(rect.Width / 8, pixelSize.Width) + pixelSize.Width; drawingContext.DrawLine(blackPen, new Point(rect.Left + space, middleY), new Point(rect.Right - space, middleY)); if (!isExpanded) { drawingContext.DrawLine(blackPen, new Point(middleX, rect.Top + space), new Point(middleX, rect.Bottom - space)); } }
public override void Draw() { base.Draw(); if (Series != null && Series.Count >= 3) { Size boxSize = new Size(10, 10); double y = (this.Height - boxSize.Height) / 2; Pen border = new Pen(Brushes.Gray, 1); m_elementX.Text = Series[0].Label; m_elementX.BoxSize = boxSize; m_elementX.Offset = new Vector(this.Width - 186, y); m_elementX.Background = new SolidColorBrush(Series[0].Color); m_elementX.Border = border; m_elementX.Draw(); m_elementY.Text = Series[1].Label; m_elementY.BoxSize = boxSize; m_elementY.Offset = new Vector(this.Width - 120, y); m_elementY.Background = new SolidColorBrush(Series[1].Color); m_elementY.Border = border; m_elementY.Draw(); m_elementZ.Text = Series[2].Label; m_elementZ.BoxSize = boxSize; m_elementZ.Offset = new Vector(this.Width - 54, y); m_elementZ.Background = new SolidColorBrush(Series[2].Color); m_elementZ.Border = border; m_elementZ.Draw(); } }
// initializes the edge resources private void _initializeResources() { _foreground = Brushes.Black; Cursor = Cursors.Hand; ToolTipService.SetInitialShowDelay(this, 250); var sourceName = Source.Class.Name; var targetName = Target.Class.Name; var cardinality = ((Role & DiagramEdgeRole.ZeroToOne) != 0) ? "[0..1]" : "[0..n]"; var darkgray = (0x656565).ToBrush(); _lineStroke = new Pen(darkgray, 2); _arrowFilled = darkgray; if (Role.Has(DiagramEdgeRole.Inheritance)) { ToolTip = "'{0}' inherits '{1}'".Substitute(targetName, sourceName); } else if (Role.Has(DiagramEdgeRole.Containment)) { ToolTip = "'{0}.{1}' contains '{2}{3}'".Substitute(sourceName, Label, targetName, cardinality); } else if (Role.Has(DiagramEdgeRole.Association)) { ToolTip = "'{0}.{1}' references '{2}{3}'".Substitute(sourceName, Label, targetName, cardinality); } else if (Role.Has(DiagramEdgeRole.WeakAssociation)) { _lineStroke.DashStyle = new DashStyle(new[] { 2.0, 2.0 }, 0); ToolTip = "'{0}.{1}' references by Id '{2}{3}'".Substitute(sourceName, Label, targetName, cardinality); } _lineStroke.Freeze(); _arrowHollow = Brushes.White; _arrowStroke = new Pen(_lineStroke.Brush, _lineStroke.Thickness); _arrowStroke.Freeze(); }
// Create the pen and triangle in a static constructor and freeze them to improve performance. static InsertionAdorner() { pen = new Pen { Brush = Brushes.Gray, Thickness = 2 }; pen.Freeze(); LineSegment firstLine = new LineSegment(new Point(0, -5), false); firstLine.Freeze(); LineSegment secondLine = new LineSegment(new Point(0, 5), false); secondLine.Freeze(); PathFigure figure = new PathFigure { StartPoint = new Point(5, 0) }; figure.Segments.Add(firstLine); figure.Segments.Add(secondLine); figure.Freeze(); triangle = new PathGeometry(); triangle.Figures.Add(figure); triangle.Freeze(); }
private void DrawBone(Joint jointFrom, Joint jointTo, Pen aPen, DrawingContext aContext) { if (jointFrom.TrackingState == JointTrackingState.NotTracked || jointTo.TrackingState == JointTrackingState.NotTracked) { return; } if (jointFrom.TrackingState == JointTrackingState.Inferred || jointTo.TrackingState == JointTrackingState.Inferred) { ColorImagePoint p1 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointFrom.Position, ColorImageFormat.RgbResolution640x480Fps30); ColorImagePoint p2 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointTo.Position, ColorImageFormat.RgbResolution640x480Fps30); //Thin line aPen.DashStyle = DashStyles.Dash; aContext.DrawLine(aPen, new Point(p1.X, p1.Y), new Point(p2.X, p2.Y)); } if (jointFrom.TrackingState == JointTrackingState.Tracked || jointTo.TrackingState == JointTrackingState.Tracked) { ColorImagePoint p1 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointFrom.Position, ColorImageFormat.RgbResolution640x480Fps30); ColorImagePoint p2 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointTo.Position, ColorImageFormat.RgbResolution640x480Fps30); //Thick line aPen.DashStyle = DashStyles.Solid; aContext.DrawLine(aPen, new Point(p1.X, p1.Y), new Point(p2.X, p2.Y)); } }
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { if (drawingContext == null) { throw new ArgumentNullException("drawingContext"); } if (null == drawingAttributes) { throw new ArgumentNullException("drawingAttributes"); } Pen pen = new Pen { StartLineCap = PenLineCap.Round, EndLineCap = PenLineCap.Round, Brush = new SolidColorBrush(drawingAttributes.Color), Thickness = drawingAttributes.Width }; BrushConverter bc = new BrushConverter(); Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString()); drawingContext.DrawRectangle( BackGround, pen, new Rect(new Point(StylusPoints[0].X, StylusPoints[0].Y), new Point(StylusPoints[1].X, StylusPoints[1].Y))); }
public PathOutlineVisual(IPathOutline outline) { var brush = new SolidColorBrush(outline.LineColor); var pen = new Pen(brush, 1); var geometry = new StreamGeometry(); using (var gc = geometry.Open()) { gc.BeginFigure(outline.BottomLeft, false, false); gc.LineTo(outline.TopLeft, true, true); gc.ArcTo(outline.TopRight, new Size(outline.Radius + (outline.Width / 2), outline.Radius + (outline.Width / 2)), 1, false, outline.Direction == PathType.Convex ? SweepDirection.Clockwise : SweepDirection.Counterclockwise, true, true); gc.LineTo(outline.BottomRight, true, true); gc.ArcTo(outline.BottomLeft, new Size(outline.Radius - (outline.Width / 2), outline.Radius - (outline.Width / 2)), 1, false, outline.Direction == PathType.Convex ? SweepDirection.Counterclockwise : SweepDirection.Clockwise, true, true); } using (var context = RenderOpen()) { context.DrawGeometry(brush, pen, geometry); } }
// https://social.msdn.microsoft.com/Forums/vstudio/en-US/587e6164-65d7-4589-82e6-d1e5548e88a1/wpf-draw-graphics-to-imagesource?forum=wpf public static ImageSource DrawIcon(string path, string backgroundColor) { var source = new BitmapImage(new Uri(path.TrimStart('/'))); var group = new DrawingGroup(); // Draw the background. var color = GetColor(backgroundColor); var brush = new SolidColorBrush(color); var pen = new Pen(brush, 1); group.Children.Add(new GeometryDrawing(brush, pen, new RectangleGeometry(new Rect(0, 0, source.Width, source.Height)))); // Add the icon to the group. var imageDrawing = new ImageDrawing(source, new Rect(0, 0, source.Width, source.Height)); group.Children.Add(imageDrawing); var visual = new DrawingVisual(); using (var context = visual.RenderOpen()) { context.DrawDrawing(group); } var target = new RenderTargetBitmap((int)source.Width, (int)source.Height, 96, 96, PixelFormats.Pbgra32); target.Render(visual); return(target); }
public void end() { img.Opacity = 0; FormattedText fmtxt; System.Windows.Media.Pen blkPen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 1); System.Windows.Media.Brush bluBrush = System.Windows.Media.Brushes.AliceBlue; DrawingVisual vis = new DrawingVisual(); DrawingContext dc = vis.RenderOpen(); fmtxt = GetFormattedText("The Winner Is: " + turn, 40); dc.DrawText(fmtxt, new System.Windows.Point(0, 0)); dc.Close(); RenderTargetBitmap bmp = new RenderTargetBitmap(490, 260, 96, 96, PixelFormats.Pbgra32); bmp.Render(vis); WriteableBitmap wb = new WriteableBitmap(bmp); img.Source = wb; Storyboard sBrd = new Storyboard(); DoubleAnimation dblAni = new DoubleAnimation(); dblAni.From = 0.0; dblAni.To = 1.0; dblAni.Duration = new Duration(TimeSpan.FromSeconds(3)); dblAni.AutoReverse = true; //dblAni.RepeatBehavior = RepeatBehavior.Forever; sBrd.Children.Add(dblAni); Storyboard.SetTargetName(dblAni, img.Name); Storyboard.SetTargetProperty(dblAni, new PropertyPath(System.Windows.Controls.Image.OpacityProperty)); sBrd.Begin(this); }
/// <summary> /// DrawGeometry - /// Draw a Geometry with the provided Brush and/or Pen. /// If both the Brush and Pen are null this call is a no-op. /// </summary> /// <param name="brush"> /// The Brush with which to fill the Geometry. /// This is optional, and can be null, in which case no fill is performed. /// </param> /// <param name="pen"> /// The Pen with which to stroke the Geometry. /// This is optional, and can be null, in which case no stroke is performed. /// </param> /// <param name="geometry"> The Geometry to fill and/or stroke. </param> public override void DrawGeometry( Brush brush, Pen pen, Geometry geometry) { if (IsCurrentLayerNoOp ||(geometry == null) || geometry.IsEmpty()) { return; } if (brush != null) { _contains |= geometry.FillContains(_point); } // If we have a pen and we haven't yet hit, try the widened geometry. if ((pen != null) && !_contains) { _contains |= geometry.StrokeContains(pen, _point); } // If we've hit, stop walking. if (_contains) { StopWalking(); } }
public override BitmapBase Draw(Tank tank) { var outline = new Pen(new SolidColorBrush(Colors.Black), 1); var outlineInner = new Pen(new SolidColorBrush(Color.FromArgb(50, 255, 255, 255)), 1); var hsv = ColorHSV.FromColor(BackColor.GetColorWpf(tank)); var brush = new LinearGradientBrush { GradientStops = new GradientStopCollection { new GradientStop(hsv.ToColorWpf(), 0.1), new GradientStop(hsv.ScaleValue(0.56).ToColorWpf(), 0.49), new GradientStop(hsv.ScaleValue(0.39).ToColorWpf(), 0.51), new GradientStop(hsv.ScaleValue(0.56).ToColorWpf(), 0.9), }, StartPoint = new Point(0, 0), EndPoint = new Point(0, 1), }; return Ut.NewBitmapWpf(ParentStyle.IconWidth, ParentStyle.IconHeight, dc => { dc.DrawRectangle(brush, outline, new Rect(0.5, 1.5, ParentStyle.IconWidth - 1, ParentStyle.IconHeight - 3)); dc.DrawRectangle(null, outlineInner, new Rect(1.5, 2.5, ParentStyle.IconWidth - 3, ParentStyle.IconHeight - 5)); }).ToBitmapRam(); }
void DrawText(CardText T, ref DrawingGroup drawingGroup) { if (T.Text == "") { return; } using (DrawingContext drawingContext = drawingGroup.Append()) { // Build the geometry object that represents the text. Geometry textGeometry = CardText2Geometry(T); var converter = new System.Windows.Media.BrushConverter(); var inBrush = fonts[T.layer].BrushColor; if ((bool)elements[T.layer].textBorderCheckBox.IsChecked) { //var st = new ScaleTransform (1.2, 1.2); Geometry textShadowGeometry = textGeometry; var shadowBrush = elements[T.layer].textBorderColor.SelectedColor.Brush.Clone(); shadowBrush.Color = Media.Color.FromArgb(200, shadowBrush.Color.R, shadowBrush.Color.G, shadowBrush.Color.B); Media.Pen p = new Media.Pen(shadowBrush, elements[T.layer].textBorderSize.Value * 2); drawingContext.DrawGeometry(null, p, textShadowGeometry); drawingContext.DrawGeometry(inBrush, null, textGeometry); } else { drawingContext.DrawGeometry(inBrush, null, textGeometry); } } }
protected override void OnRender(DrawingContext drawingContext) { var dashPen = new Pen(Brushes.Red, 1) { DashStyle = new DashStyle(new double[] { 1, 6 }, 0) }; dashPen.Freeze(); if( _grid != null ) { if (_grid.ColumnDefinitions != null) { double xPos = 0; foreach (var column in _grid.ColumnDefinitions) { xPos += column.ActualWidth; drawingContext.DrawLine(dashPen, new Point(xPos, 0), new Point(xPos,ActualHeight)); } } if (_grid.RowDefinitions != null) { double yPos = 0; foreach (var column in _grid.RowDefinitions) { yPos += column.ActualHeight; drawingContext.DrawLine(dashPen, new Point(0, yPos), new Point(ActualWidth, yPos)); } } } base.OnRender(drawingContext); }
protected override void DrawVisualThumbnail(System.Windows.Media.DrawingContext drawingContext, out string title, ref BitmapSource icon) { var aeroColor = (Color)Application.Current.Resources["AeroColor"]; var aeroBrush = new SolidColorBrush(aeroColor); var aeroPen = new Pen(aeroBrush, 7); var grayBrush = new SolidColorBrush(Color.FromArgb(255, 0xaf, 0xaf, 0xaf)); var fontFamily = (FontFamily)Application.Current.Resources["CuprumFont"]; var typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Light, FontStretches.Normal); const int sourceTextOffset = VisualThumbnailMargin; var sourceText = new FormattedText(Name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 14, grayBrush); sourceText.MaxTextWidth = VisualThumbnailWidth - sourceTextOffset - VisualThumbnailMargin; sourceText.MaxTextHeight = 32; var imageRectangle = new Rect(VisualThumbnailWidth / 2 - 64 / 2, VisualThumbnailHeight / 2 - 64 / 2, 64, 64); drawingContext.DrawRectangle(Brushes.White, aeroPen, new Rect(-1, -1, VisualThumbnailWidth + 2, VisualThumbnailHeight + 2)); drawingContext.DrawImage(Icon, imageRectangle); drawingContext.DrawText(sourceText, new Point(sourceTextOffset, VisualThumbnailHeight - VisualThumbnailMargin - 16)); title = Name + " from " + Source.ApplicationName; }
public VmsViewportAdornment(IWpfTextView view, SVsServiceProvider serviceProvider) { var service = (DTE)serviceProvider.GetService(typeof(DTE)); var properties = service.Properties["Visual Method Separators", "Global"]; var colorProperty = properties.Item("Color"); var color = UIntToColor(colorProperty.Value); var dashStyleProperty = properties.Item("PenDashStyle"); var dashStyle = DashStyleFromInt(dashStyleProperty.Value); var thicknessProperty = properties.Item("Thickness"); var thickness = (double) thicknessProperty.Value; _view = view; _view.LayoutChanged += OnLayoutChanged; _layer = view.GetAdornmentLayer("VmsViewportAdornment"); _pen = new Pen(new SolidColorBrush(color), thickness) { DashStyle = dashStyle, DashCap = PenLineCap.Flat, }; _pen.Freeze(); }
private static GuidelineSet CreateGuidelineSet(Pen pen, Rect rect) { var halfPenWidth = pen.Thickness / 2; var guidelines = new GuidelineSet(new[] {rect.Left - halfPenWidth, rect.Right - halfPenWidth}, new [] {rect.Top - halfPenWidth, rect.Bottom - halfPenWidth}); return guidelines; }
static ResizeChrome() { TransparentBrush = Brushes.Transparent; TransparentBrush.Freeze(); var borderBrush = new LinearGradientBrush() { Opacity = 0.7, StartPoint = new Point(0, 0), EndPoint = new Point(1, 0.3), }; borderBrush.GradientStops.Add(new GradientStop(Colors.SlateBlue, 0)); borderBrush.GradientStops.Add(new GradientStop(Colors.LightBlue, 0.5)); borderBrush.GradientStops.Add(new GradientStop(Colors.SlateBlue, 1)); borderBrush.Freeze(); BorderBrush = borderBrush; var thumbBrush = new RadialGradientBrush() { Center = new Point(0.3, 0.3), GradientOrigin = new Point(0.3, 0.3), RadiusX = 0.7, RadiusY = 0.7, }; thumbBrush.GradientStops.Add(new GradientStop(Colors.White, 0)); thumbBrush.GradientStops.Add(new GradientStop(Colors.DarkSlateBlue, 0.9)); thumbBrush.Freeze(); ThumbBrush = thumbBrush; TransparentPen = new Pen(TransparentBrush, 3.5); BorderPen = new Pen(BorderBrush, 2); BorderPen.DashStyle = DashStyles.Dash; ThumbGeometry = new EllipseGeometry(); UpdateZoom(1); }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { Random r = new Random(); Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize); Point stPt = new Point(adornedElementRect.X, adornedElementRect.Y); for (int x = 0; x < Number; x++) { Ellipse e = new Ellipse(); e.Width = 4; Brush b = new SolidColorBrush(new Color() { R =(byte) r.Next(0,255), G =(byte) r.Next(0,255),B =(byte) r.Next(0,255) }); Pen p = new Pen(Brushes.Black,1); int Rad = 3 ; drawingContext.DrawEllipse(b, p, stPt, Rad, Rad); stPt.X += (Rad * 2) + 1; if (stPt.X > adornedElementRect.Width) { stPt.X = 3; stPt.Y += 3; } } // Some arbitrary drawing implements. }
//public void DrawDrawing(Drawing drawing); public void DrawEllipse(Brush brush, Pen pen, Point center, double radiusX, double radiusY) { Ellipse ellipse = new Ellipse(); SetupShape(ellipse, center.X - radiusX, center.Y - radiusY, radiusX * 2, radiusY * 2, brush, pen); ellipse.Fill = brush; _canvas.Children.Add(ellipse); }
Pen CreateWpfPen(TextStyleDecorator styleDecorator) { Pen myPen = new Pen(); myPen.Brush = ConvertBrush(styleDecorator.ForeColor); myPen.Thickness = 1.5; return(myPen); }
public void DrawPath(Point start, IList <IPathCommand> commands, double thickness, bool fill = false) { Pen newPen = new System.Windows.Media.Pen(Brushes.Black, thickness); newPen.StartLineCap = PenLineCap.Square; newPen.EndLineCap = PenLineCap.Square; Context.DrawGeometry((fill ? Brushes.Black : null), newPen, RenderHelper.GetGeometry(start, commands, fill)); }
public void DrawLine(Point start, Point end, double thickness) { Pen newPen = new System.Windows.Media.Pen(Brushes.Black, thickness); newPen.StartLineCap = PenLineCap.Square; newPen.EndLineCap = PenLineCap.Square; Context.DrawLine(newPen, start, end); }
internal WpfPen RealizeWpfPen() { #if !SILVERLIGHT if (_dirty || !_dirty) // TODOWPF: XPen is frozen by design, WPF Pen can change { //if (_wpfPen == null) _wpfPen = new WpfPen(new SolidColorBrush(_color.ToWpfColor()), _width); //else //{ // _wpfPen.Brush = new SolidColorBrush(_color.ToWpfColor()); // _wpfPen.Thickness = _width; //} PenLineCap lineCap = XConvert.ToPenLineCap(_lineCap); _wpfPen.StartLineCap = lineCap; _wpfPen.EndLineCap = lineCap; _wpfPen.LineJoin = XConvert.ToPenLineJoin(_lineJoin); if (_dashStyle == XDashStyle.Custom) { // TODOWPF: does not work in all cases _wpfPen.DashStyle = new System.Windows.Media.DashStyle(_dashPattern, _dashOffset); } else { switch (_dashStyle) { case XDashStyle.Solid: _wpfPen.DashStyle = DashStyles.Solid; break; case XDashStyle.Dash: //_wpfPen.DashStyle = DashStyles.Dash; _wpfPen.DashStyle = new System.Windows.Media.DashStyle(new double[] { 2, 2 }, 0); break; case XDashStyle.Dot: //_wpfPen.DashStyle = DashStyles.Dot; _wpfPen.DashStyle = new System.Windows.Media.DashStyle(new double[] { 0, 2 }, 1.5); break; case XDashStyle.DashDot: //_wpfPen.DashStyle = DashStyles.DashDot; _wpfPen.DashStyle = new System.Windows.Media.DashStyle(new double[] { 2, 2, 0, 2 }, 0); break; case XDashStyle.DashDotDot: //_wpfPen.DashStyle = DashStyles.DashDotDot; _wpfPen.DashStyle = new System.Windows.Media.DashStyle(new double[] { 2, 2, 0, 2, 0, 2 }, 0); break; } } } #else _wpfPen = new System.Windows.Media.Pen(); _wpfPen.Brush = new SolidColorBrush(_color.ToWpfColor()); _wpfPen.Thickness = _width; #endif return(_wpfPen); }
public static void UserDrawRoutesWPF(Route Route, DrawingContext dc, System.Windows.Media.Color color) { System.Windows.Point[] m_ScreenPnts = null; int PixelX = 0; int PixelY = 0; if (Route == null) { return; } if (Route.Points.Count() == 0) { return; } System.Windows.Media.SolidColorBrush curBrush = new System.Windows.Media.SolidColorBrush(); curBrush.Color = color;// System.Windows.Media.Colors.Gold; System.Windows.Media.Pen pen = new System.Windows.Media.Pen(curBrush, 3); // m_ScreenPnts = new System.Windows.Point[Route.arr_legs.Length + 1]; m_ScreenPnts = new System.Windows.Point[Route.Points.Count()]; //VMMainViewModel.Instance.ConvertCoordGroundToPixel(Route.arr_legs[0].FromLongn, Route.arr_legs[0].FromLatn, ref PixelX, ref PixelY); //m_ScreenPnts[0].X = PixelX; //m_ScreenPnts[0].Y = PixelY; for (int i = 0; i < Route.Points.Count(); i++) { //VMMainViewModel.Instance.ConvertCoordGroundToPixel(Route.arr_legs[i].ToLongn, Route.arr_legs[i].ToLatn, ref PixelX, ref PixelY); //m_ScreenPnts[i + 1].X = PixelX; //m_ScreenPnts[i + 1].Y = PixelY; VMMainViewModel.Instance.ConvertCoordGroundToPixel(Route.Points[i].X, Route.Points[i].Y, ref PixelX, ref PixelY); m_ScreenPnts[i].X = PixelX; m_ScreenPnts[i].Y = PixelY; } System.Windows.Media.PathGeometry PathGmtr = new System.Windows.Media.PathGeometry(); System.Windows.Media.PathFigure pathFigure = new System.Windows.Media.PathFigure(); System.Windows.Media.PolyLineSegment myPolyLineSegment = new System.Windows.Media.PolyLineSegment(); System.Windows.Media.PointCollection pc = new System.Windows.Media.PointCollection(m_ScreenPnts); myPolyLineSegment.Points = pc; pathFigure.StartPoint = m_ScreenPnts[0]; pathFigure.Segments.Add(myPolyLineSegment); PathGmtr.Figures.Add(pathFigure); dc.DrawGeometry(null, pen, PathGmtr); }
private void DrawCursor(DrawingContext g) { int adjustedY = CalculateFaderIndex(); //t_mousePoint.Y - 5; PathGeometry leftcur = new PathGeometry(); PathFigure lpf = new PathFigure(); lpf.StartPoint = new System.Windows.Point(0, adjustedY + 0); LineSegment lls1 = new LineSegment(new System.Windows.Point(5, adjustedY + 0), true); LineSegment lls2 = new LineSegment(new System.Windows.Point(8, adjustedY + 5), true); LineSegment lls3 = new LineSegment(new System.Windows.Point(5, adjustedY + 10), true); LineSegment lls4 = new LineSegment(new System.Windows.Point(0, adjustedY + 10), true); LineSegment lls5 = new LineSegment(new System.Windows.Point(0, adjustedY + 0), true); PathSegmentCollection lpsc = new PathSegmentCollection(5); lpsc.Add(lls1); lpsc.Add(lls2); lpsc.Add(lls3); lpsc.Add(lls4); lpsc.Add(lls5); lpf.Segments = lpsc; leftcur.Figures = new PathFigureCollection(1); leftcur.Figures.Add(lpf); PathGeometry rightcur = new PathGeometry(); PathFigure rpf = new PathFigure(); rpf.StartPoint = new System.Windows.Point(23, adjustedY + 0); LineSegment rls1 = new LineSegment(new System.Windows.Point(23, adjustedY + 10), true); LineSegment rls2 = new LineSegment(new System.Windows.Point(23, adjustedY + 10), true); LineSegment rls3 = new LineSegment(new System.Windows.Point(18, adjustedY + 10), true); LineSegment rls4 = new LineSegment(new System.Windows.Point(15, adjustedY + 5), true); LineSegment rls5 = new LineSegment(new System.Windows.Point(18, adjustedY + 0), true); PathSegmentCollection rpsc = new PathSegmentCollection(5); rpsc.Add(rls1); rpsc.Add(rls2); rpsc.Add(rls3); rpsc.Add(rls4); rpsc.Add(rls5); rpf.Segments = rpsc; rightcur.Figures = new PathFigureCollection(1); rightcur.Figures.Add(rpf); SolidColorBrush b = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 210, 210, 210)); System.Windows.Media.Pen p = new System.Windows.Media.Pen(new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 100, 100, 100)), 1d); g.DrawGeometry(b, p, leftcur); g.DrawGeometry(b, p, rightcur); }
public object Create(Color color, float thickness) { var brush = new swm.SolidColorBrush(color.ToWpf()); var pen = new swm.Pen(brush, thickness); pen.EndLineCap = pen.StartLineCap = pen.DashCap = swm.PenLineCap.Square; pen.MiterLimit = 10f; return(pen); }
public static System.Drawing.Pen AsGdiPen(this System.Windows.Media.Pen pen) { var brush = pen.Brush as SolidColorBrush; brush = brush ?? Brushes.Transparent; var color = brush.Color.AsGdiColor(); return(new System.Drawing.Pen(color, (float)pen.Thickness)); }
public object Create(Brush brush, float thickness) { var pen = new swm.Pen(brush.ToWpf(), thickness); pen.SetValue(brushProp, brush); pen.EndLineCap = pen.StartLineCap = pen.DashCap = swm.PenLineCap.Square; pen.MiterLimit = 10f; return(pen); }
void CreateUnderline(TextBlock textBlock, TextStyleDecorator styleDecorator) { TextDecoration underLine = new TextDecoration(); Pen p = CreateWpfPen(styleDecorator); underLine.Pen = p; underLine.PenThicknessUnit = TextDecorationUnit.FontRecommended; textBlock.TextDecorations.Add(underLine); }
private void GetHeaderFooter(DocumentPage page, DrawingVisual backGround) { System.Windows.Media.Pen pen = new System.Windows.Media.Pen(_borderBrush, _thickness); using (DrawingContext backgroundContext = backGround.RenderOpen()) { //header & footer dept. GetRectangles(page, backgroundContext, pen); backgroundContext.DrawRectangle(null, pen, page.ContentBox); } }
protected override void OnRender(DrawingContext drawingContext) { if (snip == null) { return; } var pen = new Pen(Brushes.Red, 2); var rectangle = snip.Rectangle(); drawingContext.DrawRectangle(Brushes.Transparent, pen, rectangle); }
protected void DrawImageHighlight(DrawingContext drawingContext, PDFImageExtract extract, Pen pen, Brush brush) { var deviceRec = PageToDeviceDoubleRect(extract.BoundingBox, extract.PageIndex); drawingContext.DrawRectangle(brush, pen, deviceRec); }
public MyMenuButton(string t, SolidColorBrush fC, SolidColorBrush c, System.Windows.Media.Pen bC, int x, int y, int w, int h) { text = t; fontColor = fC; color = c; borderColor = bC; this.x = x; this.y = y; height = h; width = w; this.rectangle = new Rect(x, y, w, h); }
void CreateStrikeout(TextBlock textBlock, TextStyleDecorator styleDecorator) { TextDecoration strikeOut = new TextDecoration(); strikeOut.Location = TextDecorationLocation.Strikethrough; Pen p = CreateWpfPen(styleDecorator); strikeOut.Pen = p; strikeOut.PenThicknessUnit = TextDecorationUnit.FontRecommended; textBlock.TextDecorations.Add(strikeOut); }
/// <summary> /// Draw the freeform selection shape. /// </summary> /// <param name="dc"></param> protected virtual void DrawSelectionShape(DrawingContext dc) { if (_mgr != null) { // Draw the freeform selection System.Windows.Media.Geometry shapeGeo = _mgr.GetCaptureShape(); System.Windows.Media.Brush brush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Yellow); System.Windows.Media.Pen pen = new System.Windows.Media.Pen(brush, 5.0); pen.DashStyle = System.Windows.Media.DashStyles.Dash; dc.DrawGeometry(brush, pen, shapeGeo); } }