public void SetDashStyle (Pen widget, DashStyle dashStyle) { var swmpen = (swm.Pen)widget.ControlObject; if (dashStyle == null || dashStyle.IsSolid) swmpen.DashStyle = swm.DashStyles.Solid; else { var dashes = dashStyle.Dashes; double[] wpfdashes; if (swmpen.DashCap == swm.PenLineCap.Flat) wpfdashes = Array.ConvertAll (dashStyle.Dashes, x => (double)x); else { wpfdashes = new double[dashes.Length]; for (int i = 0; i < wpfdashes.Length; i++) { var dash = (double)dashes[i]; if ((i % 2) == 1) { // gap must include square/round thickness dash += 1; } else { // dash must exclude square/round thickness dash -= 1; } wpfdashes[i] = dash; } } swmpen.DashStyle = new swm.DashStyle (wpfdashes, dashStyle.Offset); } }
protected Shape(Color outLineColor, int outlineWidth, System.Windows.Media.DashStyle outLineType) { this.OutLineColor = outLineColor; this.OutlineWidth = outlineWidth; this.OutLineType = outLineType; Degree = 0; Trans = new RotateTransform(Degree); }
protected Shape() { OutLineColor = Colors.Black; OutlineWidth = 1; OutLineType = DashStyles.Solid; Degree = 0; Trans = new RotateTransform(Degree); }
public void drawArrow(Point from, Point to, Color color, int thickness, DashStyle dash, int time) { if (adapter.isServer() || adapter.isClient() && adapter.canDraw()) { LinesPacket data = new LinesPacket(from, to, color, thickness, dash, time); NetPackage pack = new NetPackage(NetPackageTypes.DrawArrow, nick, data); adapter.send(pack); } }
public void drawLine(Point from, Point to, Color color, int thickness, DashStyle dash, int time) { prepareDraw(time); removeSamples(); Pen pen = new Pen(new SolidColorBrush(color), thickness); pen.DashStyle = dash; pen.Freeze(); staticTactics[time].map.drawLine(from, to, pen, color); }
public static Pen CreateRainbowPen(DashStyle style = null) { var pen = new Pen(); pen.Brush = new LinearGradientBrush(Colors.Yellow, Colors.Red, new Point(0, 0.5), new Point(1, 0.5)); pen.Brush.Opacity = 0.5; pen.Thickness = 1.5; pen.DashStyle = (style != null ? style : DashStyles.Dash); pen.Freeze(); return pen; }
public override bool ChangeOutlineType(System.Windows.Media.DashStyle newOutlineType) { if (newOutlineType != null && !newOutlineType.Equals(OutLineType)) { OutLineType = newOutlineType; return(true); } return(false); }
private void RadioBtn_DashtDotPenIcon_Checked(object sender, RoutedEventArgs e) { curDashStyle = Factory.GetDashStyle(MyPaint.DashStyle.DashDot); if (curGraphic != null) { if (curGraphic.ChangeOutlineType(curDashStyle)) { DrawStuff(); } } }
public Drawing(Layer.Layer layer, ShapeType shapeType, Brush backgroundType, Color outlineColor, int outlineWidth, System.Windows.Media.DashStyle outlineType, Point mousePosition) : base(layer) { if (shapeType != ShapeType.None) { Graphic = Factory.GetGraphic(shapeType, new Point(mousePosition.X, mousePosition.Y), backgroundType, outlineColor, outlineWidth, outlineType); layer.AddGraphic(Graphic); } }
internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck) { // If we're told we can skip the channel check, then we must be on channel Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel)); if (skipOnChannelCheck || _duceResource.IsOnChannel(channel)) { base.UpdateResource(channel, skipOnChannelCheck); // Read values of properties into local variables Brush vBrush = Brush; DashStyle vDashStyle = DashStyle; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hBrush = vBrush != null ? ((DUCE.IResource)vBrush).GetHandle(channel) : DUCE.ResourceHandle.Null; DUCE.ResourceHandle hDashStyle = vDashStyle != null ? ((DUCE.IResource)vDashStyle).GetHandle(channel) : DUCE.ResourceHandle.Null; // Obtain handles for animated properties DUCE.ResourceHandle hThicknessAnimations = GetAnimationResourceHandle(ThicknessProperty, channel); // Pack & send command packet DUCE.MILCMD_PEN data; unsafe { data.Type = MILCMD.MilCmdPen; data.Handle = _duceResource.GetHandle(channel); data.hBrush = hBrush; if (hThicknessAnimations.IsNull) { data.Thickness = Thickness; } data.hThicknessAnimations = hThicknessAnimations; data.StartLineCap = StartLineCap; data.EndLineCap = EndLineCap; data.DashCap = DashCap; data.LineJoin = LineJoin; data.MiterLimit = MiterLimit; data.hDashStyle = hDashStyle; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_PEN)); } } }
public Linea(Point point1, Point point2, Color color, DashStyle style, float width) { P1 = point1; P2 = point2; LineColor = color; DashStyle = style; GrosorLinea = width; MyBrush = new SolidColorBrush(LineColor); pen = new Pen() { Brush = MyBrush, Thickness = GrosorLinea, DashStyle = this.DashStyle }; }
private static void DashStylePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { // The first change to the default value of a mutable collection property (e.g. GeometryGroup.Children) // will promote the property value from a default value to a local value. This is technically a sub-property // change because the collection was changed and not a new collection set (GeometryGroup.Children. // Add versus GeometryGroup.Children = myNewChildrenCollection). However, we never marshalled // the default value to the compositor. If the property changes from a default value, the new local value // needs to be marshalled to the compositor. We detect this scenario with the second condition // e.OldValueSource != e.NewValueSource. Specifically in this scenario the OldValueSource will be // Default and the NewValueSource will be Local. if (e.IsASubPropertyChange && (e.OldValueSource == e.NewValueSource)) { return; } Pen target = ((Pen)d); DashStyle oldV = (DashStyle)e.OldValue; DashStyle newV = (DashStyle)e.NewValue; System.Windows.Threading.Dispatcher dispatcher = target.Dispatcher; if (dispatcher != null) { DUCE.IResource targetResource = (DUCE.IResource)target; using (CompositionEngineLock.Acquire()) { int channelCount = targetResource.GetChannelCount(); for (int channelIndex = 0; channelIndex < channelCount; channelIndex++) { DUCE.Channel channel = targetResource.GetChannel(channelIndex); Debug.Assert(!channel.IsOutOfBandChannel); Debug.Assert(!targetResource.GetHandle(channel).IsNull); target.ReleaseResource(oldV, channel); target.AddRefResource(newV, channel); } } } target.PropertyChanged(DashStyleProperty); }
/// <summary> /// Draw graphics object /// </summary> public override void Draw(DrawingContext drawingContext) { drawingContext.DrawRectangle( null, new Pen(Brushes.White, ActualLineWidth), Rectangle); DashStyle dashStyle = new DashStyle(); dashStyle.Dashes.Add(4); Pen dashedPen = new Pen(Brushes.Black, ActualLineWidth); dashedPen.DashStyle = dashStyle; drawingContext.DrawRectangle( null, dashedPen, Rectangle); }
internal unsafe void GetBasicPenData(MIL_PEN_DATA *pData, out double[] dashArray) { dashArray = null; Invariant.Assert(pData != null); unsafe { pData->Thickness = Thickness; pData->StartLineCap = GetInternalCapType(StartLineCap); pData->EndLineCap = GetInternalCapType(EndLineCap); pData->DashCap = GetInternalCapType(DashCap); pData->LineJoin = GetInternalJoinType(LineJoin); pData->MiterLimit = MiterLimit; } if (DashStyle != null) { DashStyle.GetDashData(pData, out dashArray); } }
/// <summary> /// Pen - Initializes the brush from the parameters. /// </summary> /// <param name="brush"> The Pen's Brush. </param> /// <param name="thickness"> The Pen's thickness. </param> /// <param name="startLineCap"> The PenLineCap which applies to the start of the stroke. </param> /// <param name="endLineCap"> The PenLineCap which applies to the end of the stroke. </param> /// <param name="dashCap"> The PenDashCap which applies to the ends of each dash. </param> /// <param name="lineJoin"> The PenLineJoin. </param> /// <param name="miterLimit"> The miter limit. </param> /// <param name="dashStyle"> The dash style. </param> internal Pen( Brush brush, double thickness, PenLineCap startLineCap, PenLineCap endLineCap, PenLineCap dashCap, PenLineJoin lineJoin, double miterLimit, DashStyle dashStyle) { Thickness = thickness; StartLineCap = startLineCap; EndLineCap = endLineCap; DashCap = dashCap; LineJoin = lineJoin; MiterLimit = miterLimit; Brush = brush; DashStyle = dashStyle; }
void DUCE.IResource.ReleaseOnChannel(DUCE.Channel channel) { using (CompositionEngineLock.Acquire()) { Debug.Assert(_duceResource.IsOnChannel(channel)); if (_duceResource.ReleaseOnChannel(channel)) { Brush vBrush = Brush; if (vBrush != null) { ((DUCE.IResource)vBrush).ReleaseOnChannel(channel); } DashStyle vDashStyle = DashStyle; if (vDashStyle != null) { ((DUCE.IResource)vDashStyle).ReleaseOnChannel(channel); } ReleaseOnChannelAnimations(channel); } } }
public static Shape GetGraphic(ShapeType shapeType, Point start, Brush backgroundType, Color outlineColor, int outlineWidth, System.Windows.Media.DashStyle outlineType) { switch (shapeType) { case ShapeType.Line: return(new Line(start, outlineColor, outlineWidth, outlineType)); case ShapeType.Ellipse: return(new Ellipse(start, backgroundType, outlineColor, outlineWidth, outlineType)); case ShapeType.Rectangle: return(new Rectangle(start, backgroundType, outlineColor, outlineWidth, outlineType)); case ShapeType.Star: return(new Star(start, backgroundType, outlineColor, outlineWidth, outlineType)); case ShapeType.Triangle: return(new Triangle(start, backgroundType, outlineColor, outlineWidth, outlineType)); default: return(null); } }
private ArrowLineBuilder CreateDefaultArrowLineBilder() { ArrowLineBuilder builder = new ArrowLineBuilder(); builder.ShapeBrush = Brushes.Red; DashStyle dash = new DashStyle(new double[] {3,3}, 0); builder.DrawPen = new Pen() { Brush = Brushes.Gray, Thickness = 2, DashStyle = dash }; builder.ArrowHeadWidth = 10; builder.ArrowHeadLength = 10; return builder; }
private GeometryDrawing NewDrawingItem(Shape shape, Geometry geometry) { GeometryDrawing item = new GeometryDrawing(); Stroke stroke = shape.Stroke; if (stroke != null) { item.Pen = new Pen(stroke.StrokeBrush(this.SVG), stroke.Width); if (stroke.StrokeArray != null) { item.Pen.DashCap = PenLineCap.Flat; DashStyle ds = new DashStyle(); double scale = 1 / stroke.Width; foreach (int dash in stroke.StrokeArray) ds.Dashes.Add(dash * scale); item.Pen.DashStyle = ds; } switch (stroke.LineCap) { case Stroke.eLineCap.butt: item.Pen.StartLineCap = PenLineCap.Flat; item.Pen.EndLineCap = PenLineCap.Flat; break; case Stroke.eLineCap.round: item.Pen.StartLineCap = PenLineCap.Round; item.Pen.EndLineCap = PenLineCap.Round; break; case Stroke.eLineCap.square: item.Pen.StartLineCap = PenLineCap.Square; item.Pen.EndLineCap = PenLineCap.Square; break; } switch (stroke.LineJoin) { case Stroke.eLineJoin.round: item.Pen.LineJoin = PenLineJoin.Round; break; case Stroke.eLineJoin.miter: item.Pen.LineJoin = PenLineJoin.Miter; break; case Stroke.eLineJoin.bevel: item.Pen.LineJoin = PenLineJoin.Bevel; break; } } if (shape.Fill != null) { item.Brush = shape.Fill.FillBrush(this.SVG); GeometryGroup g = new GeometryGroup(); g.FillRule = FillRule.Nonzero; if (shape.Fill.FillRule == Fill.eFillRule.evenodd) g.FillRule = FillRule.EvenOdd; g.Children.Add(geometry); geometry = g; } if (shape.Transform != null) geometry.Transform = shape.Transform; // for debugging, if neither stroke or fill is set then set default pen //if (shape.Fill == null && shape.Stroke == null) // item.Pen = new Pen(Brushes.Blue, 1); item.Geometry = geometry; return item; }
public void drawLine(Point from, Point to, Color color, int thickness, DashStyle dash, int time) { staticTactic.drawLine(from, to, color, thickness, dash, time); }
public static ImageSource GetImage(DashStyleEx val) { const double height = 1; const double width = 2; const double lineWidth = height / 5; DashStyle dashStyle = DashStyles.Solid; if (val.IsKnownStyle) { if (val == DashStyleEx.Solid) dashStyle = DashStyles.Solid; else if (val == DashStyleEx.Dash) dashStyle = DashStyles.Dash; else if (val == DashStyleEx.Dot) dashStyle = DashStyles.Dot; else if (val == DashStyleEx.DashDot) dashStyle = DashStyles.DashDot; else if (val == DashStyleEx.DashDotDot) dashStyle = DashStyles.DashDotDot; else if (val == DashStyleEx.LongDash) dashStyle = new DashStyle(new double[] { 5, 2 }, 0); } else if (val.IsCustomStyle) { var list = new List<double>(); foreach (var e in val.CustomStyle) list.Add(e); dashStyle = new DashStyle(list, 0); } // draws a transparent outline to fix the borders var drawingGroup = new DrawingGroup(); var geometryDrawing = new GeometryDrawing(); geometryDrawing.Geometry = new RectangleGeometry(new Rect(0, 0, width, height)); geometryDrawing.Pen = new Pen(Brushes.Transparent, 0); drawingGroup.Children.Add(geometryDrawing); geometryDrawing = new GeometryDrawing() { Geometry = new LineGeometry(new Point(0, height / 2), new Point(width, height / 2)) }; geometryDrawing.Pen = new Pen(Brushes.Black, lineWidth) { DashStyle = dashStyle }; drawingGroup.Children.Add(geometryDrawing); var geometryImage = new DrawingImage(drawingGroup); // Freeze the DrawingImage for performance benefits. geometryImage.Freeze(); return geometryImage; }
public Rectangle(Point start, Brush backgroundType, Color outLineColor, int outlineWidth, System.Windows.Media.DashStyle outLineType) : base(outLineColor, outlineWidth, outLineType) { this.start = start; this.end = start; Background = backgroundType; }
public static ImageSource GetImage(IDashPattern val) { const double height = 1; const double width = 2; const double lineWidth = height / 5; DashStyle dashStyle; if (val is Solid) dashStyle = DashStyles.Solid; else if (val is Dash) dashStyle = DashStyles.Dash; else if (val is Dot) dashStyle = DashStyles.Dot; else if (val is DashDot) dashStyle = DashStyles.DashDot; else if (val is DashDotDot) dashStyle = DashStyles.DashDotDot; else dashStyle = new DashStyle(val, 0); // draws a transparent outline to fix the borders var drawingGroup = new DrawingGroup(); var geometryDrawing = new GeometryDrawing(); geometryDrawing.Geometry = new RectangleGeometry(new Rect(0, 0, width, height)); geometryDrawing.Pen = new Pen(Brushes.Transparent, 0); drawingGroup.Children.Add(geometryDrawing); geometryDrawing = new GeometryDrawing() { Geometry = new LineGeometry(new Point(0, height / 2), new Point(width, height / 2)) }; geometryDrawing.Pen = new Pen(Brushes.Black, lineWidth) { DashStyle = dashStyle }; drawingGroup.Children.Add(geometryDrawing); var geometryImage = new DrawingImage(drawingGroup); // Freeze the DrawingImage for performance benefits. geometryImage.Freeze(); return geometryImage; }
public Ellipse(Point center, Brush backgroundType, Color outLineColor, int outlineWidth, System.Windows.Media.DashStyle outLineType) : base(outLineColor, outlineWidth, outLineType) { this.m_center = center; this.radiusX = 0; this.radiusY = 0; this.Background = backgroundType; }
void AllocatePen(Color color, double thickness, DashStyle dashStyle) { if (colorBrush != null && color == colorBrush.Color) { if (Pen.Thickness != thickness || !dashStyle.Equals (Pen.DashStyle)) Pen = new SWM.Pen (colorBrush, thickness) { DashStyle = dashStyle }; } else { colorBrush = new SolidColorBrush (color); Pen = new SWM.Pen (colorBrush, thickness) { DashStyle = dashStyle }; } Pen.DashCap = PenLineCap.Flat; }
public void SetThickness(double t) { var ds = Pen.DashStyle; if (ds != DashStyles.Solid) { var dashes = Pen.DashStyle.Dashes.Clone (); for (int n = 0; n < dashes.Count; n++) dashes[n] = (dashes[n] * Pen.Thickness) / t; var offset = (Pen.DashStyle.Offset * Pen.Thickness) / t; ds = new DashStyle (dashes, offset); } AllocatePen (colorBrush.Color, t, ds); }
public StrokeStyle(Brush strokeColor, double thickness, DashStyle dashStyle, PenLineCap dashCap) : this() { StrokeColor = strokeColor; DashStyle = dashStyle; DashCap = dashCap; Thickness = thickness; }
public StrokeStyle(Brush strokeColor, double thickness, PenLineCap startLineCap, PenLineCap endLineCap, PenLineJoin lineJoin, DashStyle dashStyle, PenLineCap dashCap) : this() { StrokeColor = strokeColor; Thickness = thickness; StartLineCap = startLineCap; EndLineCap = endLineCap; LineJoin = lineJoin; DashStyle = dashStyle; DashCap = dashCap; }
public Pen GetPen(Geometry geometry) { double strokeWidth = GetStrokeWidth(); if (strokeWidth == 0) return null; WpfSvgPaint stroke; if (PaintType == SvgPaintType.None) { return null; } else if (PaintType == SvgPaintType.CurrentColor) { stroke = new WpfSvgPaint(_context, _element, "color"); } else { stroke = this; } Pen pen = new Pen(stroke.GetBrush(geometry, "stroke", true), strokeWidth); pen.StartLineCap = pen.EndLineCap = GetLineCap(); pen.LineJoin = GetLineJoin(); double miterLimit = GetMiterLimit(strokeWidth); if (miterLimit > 0) { pen.MiterLimit = miterLimit; } //pen.MiterLimit = 1.0f; DoubleCollection dashArray = GetDashArray(strokeWidth); if (dashArray != null && dashArray.Count != 0) { bool isValidDashes = true; //Do not draw if dash array had a zero value in it for (int i = 0; i < dashArray.Count; i++) { if (dashArray[i] == 0) { isValidDashes = false; } } if (isValidDashes) { DashStyle dashStyle = new DashStyle(dashArray, GetDashOffset(strokeWidth)); pen.DashStyle = dashStyle; // This is the one that works well for the XAML, the default is not Flat as // stated in the documentations... pen.DashCap = PenLineCap.Flat; } } return pen; }
protected ShapeWithBackground(Color outLineColor, int outlineWidth, System.Windows.Media.DashStyle outLineType) : base(outLineColor, outlineWidth, outLineType) { }
public void drawArrow(Point from, Point to, Color color, int thickness, DashStyle dash, int time) { tactic.drawArrow(from, to, color, thickness, dash, time); mainwindow.refreshMap(); }
public StrokeStyle(Brush strokeColor, DashStyle dashStyle, PenLineCap dashCap) : this() { StrokeColor = strokeColor; DashStyle = dashStyle; DashCap = dashCap; }
/// <summary> /// Initializes a new instance of the <see cref="RectangleAdorner"/> class. /// </summary> /// <param name="adornedElement"> /// The adorned element. /// </param> /// <param name="rectangle"> /// The rectangle. /// </param> /// <param name="color1"> /// The color1. /// </param> /// <param name="color2"> /// The color2. /// </param> /// <param name="thickness1"> /// The thickness1. /// </param> /// <param name="thickness2"> /// The thickness2. /// </param> /// <param name="crossHairSize"> /// Size of the cross hair. /// </param> /// <param name="dashStyle2"> /// The dash style2. /// </param> public RectangleAdorner( UIElement adornedElement, Rect rectangle, Color color1, Color color2, double thickness1, double thickness2, double crossHairSize, DashStyle dashStyle2) : base(adornedElement) { if (adornedElement == null) { throw new ArgumentNullException("adornedElement"); } this.Rectangle = rectangle; // http://www.wpftutorial.net/DrawOnPhysicalDevicePixels.html var ps = PresentationSource.FromVisual(adornedElement); if (ps == null) { return; } var ct = ps.CompositionTarget; if (ct == null) { return; } var m = ct.TransformToDevice; double dpiFactor = 1 / m.M11; this.pen = new Pen(new SolidColorBrush(color1), thickness1 * dpiFactor); this.pen2 = new Pen(new SolidColorBrush(color2), thickness2 * dpiFactor); this.pen2.DashStyle = dashStyle2; this.crossHairSize = crossHairSize; }
public PenData() { this.DashStyle = DashStyles.Solid; }
public virtual bool ChangeOutlineType(System.Windows.Media.DashStyle newOutlineType) { return(false); }
public StrokeStyle(Brush strokeColor, double thickness, DashStyle dashStyle) : this() { Thickness = thickness; StrokeColor = strokeColor; DashStyle = dashStyle; }
//************************************************************************* // Method: CreateFrozenPen() // /// <summary> /// Creates a Pen and freezes it. /// </summary> /// /// <param name="oBrush"> /// The brush to use. /// </param> /// /// <param name="dThickness"> /// The pen thickness. /// </param> /// /// <param name="oDashStyle"> /// The pen's dash style. /// </param> /// /// <returns> /// A new frozen Pen. /// </returns> //************************************************************************* protected Pen CreateFrozenPen( Brush oBrush, Double dThickness, DashStyle oDashStyle ) { Debug.Assert(oBrush != null); Debug.Assert(dThickness > 0); Debug.Assert(oDashStyle != null); // AssertValid(); Pen oPen = new Pen(oBrush, dThickness); oPen.DashStyle = oDashStyle; oPen.DashCap = PenLineCap.Flat; WpfGraphicsUtil.FreezeIfFreezable(oPen); return (oPen); }
public StrokeStyle(Brush strokeColor, DashStyle dashStyle) : this() { StrokeColor = strokeColor; DashStyle = dashStyle; }
public void drawSampleArrow(Point from, Point to, Color color, int thickness, DashStyle dash, int time) { prepareDraw(time); removeSamples(); samplePen = new Pen(new SolidColorBrush(color), thickness); samplePen.DashStyle = dash; samplePen.Freeze(); sample = new KeyValuePair<Point, Point>(from, to); hasSampleArrow = true; }
public LinesPacket(Point from, Point to, Color color, int thickness, DashStyle dash, int time) { this.from = from; this.to = to; a = color.A; r = color.R; g = color.G; b = color.B; this.thickness = thickness; if (dash == DashStyles.Solid) { this.dash = 1; } else if (dash == DashStyles.Dot) { this.dash = 2; } else { // Dash this.dash = 3; } this.time = time; }
internal void SetDash(double offset, double[] pattern) { DashStyle ds = new DashStyle (pattern.Select (d => d / Pen.Thickness), offset); AllocatePen (colorBrush.Color, Pen.Thickness, ds); }
CreateFrozenPen ( Brush oBrush, Double dThickness, DashStyle oDashStyle ) { Debug.Assert(oBrush != null); Debug.Assert(dThickness > 0); Debug.Assert(oDashStyle != null); // AssertValid(); return ( CreateFrozenPen(oBrush, dThickness, oDashStyle, PenLineCap.Flat) ); }
/// <summary> /// Initializes a new instance of the <see cref="RectangleAdorner"/> class. /// </summary> /// <param name="adornedElement"> /// The adorned element. /// </param> /// <param name="rectangle"> /// The rectangle. /// </param> /// <param name="color1"> /// The color1. /// </param> /// <param name="color2"> /// The color2. /// </param> /// <param name="thickness1"> /// The thickness1. /// </param> /// <param name="thickness2"> /// The thickness2. /// </param> /// <param name="crossHairSize"> /// Size of the cross hair. /// </param> /// <param name="dashStyle2"> /// The dash style2. /// </param> public RectangleAdorner( UIElement adornedElement, Rect rectangle, Color color1, Color color2, double thickness1, double thickness2, double crossHairSize, DashStyle dashStyle2) : base(adornedElement) { this.Rectangle = rectangle; // http://www.wpftutorial.net/DrawOnPhysicalDevicePixels.html var m = PresentationSource.FromVisual(adornedElement).CompositionTarget.TransformToDevice; double dpiFactor = 1 / m.M11; this.pen = new Pen(new SolidColorBrush(color1), thickness1 * dpiFactor); this.pen2 = new Pen(new SolidColorBrush(color2), thickness2 * dpiFactor); this.pen2.DashStyle = dashStyle2; this.crossHairSize = crossHairSize; }
CreateFrozenPen ( Brush oBrush, Double dThickness, DashStyle oDashStyle, PenLineCap eLineCap ) { Debug.Assert(oBrush != null); Debug.Assert(dThickness > 0); Debug.Assert(oDashStyle != null); // AssertValid(); Pen oPen = new Pen(oBrush, dThickness); oPen.DashStyle = oDashStyle; oPen.StartLineCap = eLineCap; oPen.EndLineCap = eLineCap; WpfGraphicsUtil.FreezeIfFreezable(oPen); return (oPen); }
public Ellipse(int x1, int y1, int x2, int y2, Brush contourColor, Color fillColor, int thickness, DashStyle dashStyle, Brush hatchStyle) : base(x1, y1, x2, y2, contourColor, fillColor, thickness, dashStyle, hatchStyle) { }
// this checks the dragged node type and creates the right custom node for it... // this checks the dragged node type and creates the right custom node for it... #region Node created private void DiagramNodeCreated(ShapeNode node) { // check if the node is a connector if (node.Shape.Id == "InheritanceLink") { // replace the dummy connector node with a DiagramLink var bounds = node.Bounds; diagram.Items.Remove(node); var link = diagram.Factory.CreateDiagramLink( bounds.TopLeft, bounds.BottomRight); link.SegmentCount = 2; link.Shape = LinkShape.Cascading; link.HeadShape = ArrowHeads.Triangle; ConnectToNearbyNode(link); } else if (node.Shape.Id == "InterfaceLink") { var bounds = node.Bounds; diagram.Items.Remove(node); var link = diagram.Factory.CreateDiagramLink( bounds.TopLeft, bounds.BottomRight); link.SegmentCount = 1; link.Shape = LinkShape.Cascading; System.Windows.Media.DashStyle dash = new System.Windows.Media.DashStyle(); dash.Dashes = new DoubleCollection(new double[] { 1, 7 }); Pen pen = new Pen(Brushes.Black, 1); pen.DashStyle = dash; link.Pen = pen; link.HeadShape = ArrowHeads.Triangle; ConnectToNearbyNode(link); } else if (node.Shape.Id == "RelationshipLink") { // replace the dummy connector node with a DiagramLink var bounds = node.Bounds; diagram.Items.Remove(node); var link = diagram.Factory.CreateDiagramLink( bounds.TopLeft, bounds.BottomRight); link.SegmentCount = 1; link.Shape = LinkShape.Cascading; link.HeadShape = ArrowHeads.DefaultFlow; // might need a custom arrowhead here, supposed to be a straight line with 2 link.BaseShape = ArrowHeads.RevWithLine; // vertical || across (see visio) ConnectToNearbyNode(link); } else { //node.AnchorPattern = AnchorPattern.Decision2In2Out; ConnectToNearbyLink(node); } // no other actions needed if diagram type is basic flowchart if (node.Name.Equals("processNode") || node.Name.Equals("startEndNode") || node.Name.Equals("decisionNode") || node.Name.Equals("dataNode") || node.Name.Equals("subprocessNode") || node.Name.Equals("documentNode")) { return; } diagram.Items.Remove(node); // dont add the default shape // UML Nodes if (node.Name.Equals("classNode")) { var node1 = new UMLClassNode { Bounds = new Rect(node.Bounds.Left, node.Bounds.Top, 300, 160), }; diagram.Nodes.Add(node1); } else if (node.Name.Equals("interfaceNode")) { var node1 = new UMLInterfaceNode { Bounds = new Rect(node.Bounds.Left, node.Bounds.Top, 300, 160), }; diagram.Nodes.Add(node1); } else if (node.Name.Equals("memberNode")) { var node1 = new UMLMember { Bounds = new Rect(node.Bounds.Left, node.Bounds.Top, 300, 25), }; diagram.Nodes.Add(node1); } else if (node.Name.Equals("separatorNode")) { var node1 = new UMLSeparatorNode { Bounds = new Rect(node.Bounds.Left, node.Bounds.Top, 300, 5), }; diagram.Nodes.Add(node1); } else if (node.Name.Equals("packageNode")) { var node1 = new UMLPackageNode { Bounds = new Rect(node.Bounds.Left, node.Bounds.Top, 300, 160), }; diagram.Nodes.Add(node1); } // // Crow's foot nodes else if (node.Name.Equals("entityNode")) { var node1 = new CrowsFootEntity { Bounds = new Rect(node.Bounds.Left, node.Bounds.Top, 300, 160), }; diagram.Nodes.Add(node1); } else if (node.Name.Equals("primaryKeyNode")) { var node1 = new CFPrimaryKeyNode { Bounds = new Rect(node.Bounds.Left, node.Bounds.Top, 300, 25), }; diagram.Nodes.Add(node1); } else if (node.Name.Equals("attributeNode")) { var node1 = new CFAttributeNode { Bounds = new Rect(node.Bounds.Left, node.Bounds.Top, 300, 25), }; diagram.Nodes.Add(node1); } else if (node.Name.Equals("primaryKeySeparatorNode")) { var node1 = new CFPrimaryKeySeparatorNode { Bounds = new Rect(node.Bounds.Left, node.Bounds.Top, 300, 5), }; diagram.Nodes.Add(node1); } else { return; } }
GetDashStyle ( IEdge oEdge, Double dWidth, Boolean bDrawAsSelected ) { Debug.Assert(oEdge != null); Debug.Assert(dWidth >= 0); AssertValid(); // Note: // // An early implementation used the predefined DashStyle objects // provided by the DashStyles class, but those did not look good at // smaller edge widths. This implementation builds the DashStyle's // Dashes collection from scratch. Double [] adDashes = null; if (!bDrawAsSelected) { Object oPerEdgeStyleAsObject; // Check for a per-edge style. if ( oEdge.TryGetValue(ReservedMetadataKeys.PerEdgeStyle, typeof(EdgeStyle), out oPerEdgeStyleAsObject) ) { switch ( (EdgeStyle)oPerEdgeStyleAsObject ) { case EdgeStyle.Solid: break; case EdgeStyle.Dash: adDashes = new Double[] {4.0, 2.0}; break; case EdgeStyle.Dot: adDashes = new Double[] {1.0, 2.0}; break; case EdgeStyle.DashDot: adDashes = new Double[] {4.0, 2.0, 1.0, 2.0}; break; case EdgeStyle.DashDotDot: adDashes = new Double[] {4.0, 2.0, 1.0, 2.0, 1.0, 2.0}; break; default: throw new FormatException( String.Format( "{0}: The edge with the ID {1} has an invalid {2}" + " value." , this.ClassName, oEdge.ID, "ReservedMetadataKeys.PerEdgeStyle" ) ); } } } if (adDashes == null) { return (DashStyles.Solid); } DashStyle oDashStyle = new DashStyle(); oDashStyle.Dashes = new DoubleCollection(adDashes); WpfGraphicsUtil.FreezeIfFreezable(oDashStyle); return (oDashStyle); }
public Line(Point start, Color outLineColor, int outlineWidth, System.Windows.Media.DashStyle outLineType) : base(outLineColor, outlineWidth, outLineType) { this.start = start; this.end = start; }