예제 #1
0
		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);
			}
		}
예제 #2
0
파일: Shape.cs 프로젝트: dtien147/MyPaint
 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);
 }
예제 #3
0
파일: Shape.cs 프로젝트: dtien147/MyPaint
 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);
     }
 }
예제 #5
0
        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);
        }
예제 #6
0
파일: Pen.cs 프로젝트: osmedile/TypeCobol
 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;
 }
예제 #7
0
파일: Shape.cs 프로젝트: dtien147/MyPaint
        public override bool ChangeOutlineType(System.Windows.Media.DashStyle newOutlineType)
        {
            if (newOutlineType != null && !newOutlineType.Equals(OutLineType))
            {
                OutLineType = newOutlineType;
                return(true);
            }

            return(false);
        }
예제 #8
0
 private void RadioBtn_DashtDotPenIcon_Checked(object sender, RoutedEventArgs e)
 {
     curDashStyle = Factory.GetDashStyle(MyPaint.DashStyle.DashDot);
     if (curGraphic != null)
     {
         if (curGraphic.ChangeOutlineType(curDashStyle))
         {
             DrawStuff();
         }
     }
 }
예제 #9
0
파일: Drawing.cs 프로젝트: dtien147/MyPaint
 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);
     }
 }
예제 #10
0
파일: Pen.cs 프로젝트: yk2012985/wpf
        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));
                }
            }
        }
예제 #11
0
        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
            };
        }
예제 #12
0
파일: Pen.cs 프로젝트: yk2012985/wpf
        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);
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
        /// <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;
        }
예제 #16
0
        /// <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;
        }
예제 #17
0
파일: Pen.cs 프로젝트: yk2012985/wpf
        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);
                }
            }
        }
예제 #18
0
        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);
            }
        }
예제 #19
0
 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;
 }
예제 #20
0
        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;
        }
예제 #21
0
 public void drawLine(Point from, Point to, Color color, int thickness, DashStyle dash, int time)
 {
     staticTactic.drawLine(from, to, color, thickness, dash, time);
 }
예제 #22
0
		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;
		}
예제 #23
0
 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;
 }
예제 #24
0
		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;
		}
예제 #25
0
파일: Ellipse.cs 프로젝트: dtien147/MyPaint
 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;
 }
예제 #26
0
 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;
 }
예제 #27
0
 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);
 }
예제 #28
0
 public StrokeStyle(Brush strokeColor, double thickness, DashStyle dashStyle, PenLineCap dashCap)
     : this()
 {
     StrokeColor = strokeColor;
     DashStyle = dashStyle;
     DashCap = dashCap;
     Thickness = thickness;
 }
예제 #29
0
 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;
 }
예제 #30
0
        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;
        }
예제 #31
0
 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();
 }
예제 #33
0
 public StrokeStyle(Brush strokeColor, DashStyle dashStyle, PenLineCap dashCap)
     : this()
 {
     StrokeColor = strokeColor;
     DashStyle = dashStyle;
     DashCap = dashCap;
 }
예제 #34
0
        /// <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;
 }
예제 #36
0
파일: Graphic.cs 프로젝트: dtien147/MyPaint
 public virtual bool ChangeOutlineType(System.Windows.Media.DashStyle newOutlineType)
 {
     return(false);
 }
예제 #37
0
 public StrokeStyle(Brush strokeColor, double thickness, DashStyle dashStyle)
     : this()
 {
     Thickness = thickness;
     StrokeColor = strokeColor;
     DashStyle = dashStyle;
 }
예제 #38
0
        //*************************************************************************
        //  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);
        }
예제 #39
0
 public StrokeStyle(Brush strokeColor, DashStyle dashStyle)
     : this()
 {
     StrokeColor = strokeColor;
     DashStyle = dashStyle;
 }
예제 #40
0
        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;
 }
예제 #42
0
 internal void SetDash(double offset, double[] pattern)
 {
     DashStyle ds = new DashStyle (pattern.Select (d => d / Pen.Thickness), offset);
     AllocatePen (colorBrush.Color, Pen.Thickness, ds);
 }
예제 #43
0
    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) );
    }
예제 #44
0
        /// <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;
        }
예제 #45
0
    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);
    }
예제 #46
0
 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)
 {
 }
예제 #47
0
        // 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;
            }
        }
예제 #48
0
    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);
    }
예제 #49
0
파일: Line.cs 프로젝트: dtien147/MyPaint
 public Line(Point start, Color outLineColor, int outlineWidth, System.Windows.Media.DashStyle outLineType)
     : base(outLineColor, outlineWidth, outLineType)
 {
     this.start = start;
     this.end   = start;
 }