Exemple #1
0
        public PenDialog(int p, LineCap lineCap)
        {
            InitializeComponent();
            
            penSizeNumericUpDown.Value = p;

            //switch (lineCap)
            //{
            //    case LineCap.AnchorMask:
            //        {
            //            penStyleNumericUpDown.Value = 1;
            //        }
            //        break;
            //    case LineCap.ArrowAnchor:
            //        {
            //            penStyleNumericUpDown.Value = 2;
            //        }
            //        break;
            //    case LineCap.Custom:
            //        {
            //            penStyleNumericUpDown.Value = 3;
            //        }
            //        break;
            //    case LineCap.DiamondAnchor:
            //        {
            //            penStyleNumericUpDown.Value = 4;
            //        }
            //        break;
            //    case LineCap.Flat:
            //        {
            //            penStyleNumericUpDown.Value = 5;
            //        }
            //        break;
            //    case LineCap.NoAnchor:
            //        {
            //            penStyleNumericUpDown.Value = 6;
            //        }
            //        break;
            //    case LineCap.Round:
            //        {
            //            penStyleNumericUpDown.Value = 7;
            //        }
            //        break;
            //    case LineCap.Square:
            //        {
            //            penStyleNumericUpDown.Value = 8;
            //        }
            //        break;
            //    case LineCap.SquareAnchor:
            //        {
            //            penStyleNumericUpDown.Value = 9;
            //        }
            //        break;
            //    case LineCap.Triangle:
            //        {
            //            penStyleNumericUpDown.Value = 10;
            //        }
            //        break;
            //}
        }
		public LineFunction ()
		{
			Width = 1;
			Color = "#FFFFFF";
			Opacity = 1.0m;
			LineCap = LineCap.Butt;
		}
 private void Configure()
 {
     _joinType = LineJoinType.Round;
     _startCap = LineCap.Round;
     _endCap = LineCap.Round;
     _decorations = new CopyList<ILineDecoration>();
 }
Exemple #4
0
        // Set/get line caps: start, end, and dash

        // Line cap and join APIs by using LineCap and LineJoin enums.

        public GpStatus SetLineCap(LineCap startCap,
                          LineCap endCap,
                          DashCap dashCap)
        {
            return SetStatus(NativeMethods.GdipSetPenLineCap197819(nativePen,
                                       startCap, endCap, dashCap));
        }
 private void _SetBaseCap(LineCap baseCap)
 {
     int status = SafeNativeMethods.Gdip.GdipSetCustomLineCapBaseCap(new HandleRef(this, (IntPtr) this.nativeCap), baseCap);
     if (status != 0)
     {
         throw SafeNativeMethods.Gdip.StatusException(status);
     }
 }
Exemple #6
0
 public CustomLineCap(GraphicsPath fillPath,
                      GraphicsPath strokePath,
                      LineCap baseCap, float baseInset)
 {
     this.fillPath   = fillPath;
     this.strokePath = strokePath;
     this.baseCap    = baseCap;
     this.baseInset  = baseInset;
 }
 public void Ctor_InvalidLineCap_ReturnsFlat(LineCap baseCap)
 {
     using (GraphicsPath fillPath = new GraphicsPath())
         using (GraphicsPath strokePath = new GraphicsPath())
             using (CustomLineCap customLineCap = new CustomLineCap(fillPath, strokePath, baseCap, 0f))
             {
                 Assert.Equal(LineCap.Flat, customLineCap.BaseCap);
             }
 }
 public void BaseCap_SetThenGet_Success(LineCap baseCap)
 {
     using (GraphicsPath strokePath = new GraphicsPath())
         using (CustomLineCap customLineCap = new CustomLineCap(null, strokePath))
         {
             customLineCap.BaseCap = baseCap;
             Assert.Equal(baseCap, customLineCap.BaseCap);
         }
 }
Exemple #9
0
 public LineRenderElement(Vector from, Vector to, int width, Color color)
 {
     DrawPen    = new Pen(color, width);
     StartPoint = from;
     EndPoint   = to;
     Width      = width;
     EndCap     = LineCap.NoAnchor;
     StartCap   = LineCap.NoAnchor;
 }
Exemple #10
0
        /// <include file='doc\CustomLineCap.uex' path='docs/doc[@for="CustomLineCap.GetStrokeCaps"]/*' />
        /// <devdoc>
        ///    Gets the caps used to start and end lines.
        /// </devdoc>
        public void GetStrokeCaps(out LineCap startCap, out LineCap endCap)
        {
            int status = SafeNativeMethods.GdipGetCustomLineCapStrokeCaps(new HandleRef(this, nativeCap), out startCap, out endCap);

            if (status != SafeNativeMethods.Ok)
            {
                throw SafeNativeMethods.StatusException(status);
            }
        }
Exemple #11
0
        private void _SetBaseCap(LineCap baseCap)
        {
            int status = SafeNativeMethods.GdipSetCustomLineCapBaseCap(new HandleRef(this, nativeCap), baseCap);

            if (status != SafeNativeMethods.Ok)
            {
                throw SafeNativeMethods.StatusException(status);
            }
        }
Exemple #12
0
        /// <include file='doc\CustomLineCap.uex' path='docs/doc[@for="CustomLineCap.SetStrokeCaps"]/*' />
        /// <devdoc>
        ///    Sets the caps used to start and end lines.
        /// </devdoc>
        public void SetStrokeCaps(LineCap startCap, LineCap endCap)
        {
            int status = SafeNativeMethods.Gdip.GdipSetCustomLineCapStrokeCaps(new HandleRef(this, nativeCap), startCap, endCap);

            if (status != SafeNativeMethods.Gdip.Ok)
            {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }
        }
	public CustomLineCap(GraphicsPath fillPath,
						 GraphicsPath strokePath,
						 LineCap baseCap, float baseInset)
			{
				this.fillPath = fillPath;
				this.strokePath = strokePath;
				this.baseCap = baseCap;
				this.baseInset = baseInset;
			}
 public void BaseCap_Set_InvalidLineCap_ThrowsArgumentException(LineCap baseCap)
 {
     using (GraphicsPath strokePath = new GraphicsPath())
         using (CustomLineCap customLineCap = new CustomLineCap(null, strokePath))
         {
             AssertExtensions.Throws <ArgumentException>(null, () => customLineCap.BaseCap = baseCap);
             Assert.Equal(LineCap.Flat, customLineCap.BaseCap);
         }
 }
Exemple #15
0
        public static void drawLines(NvgContext vg, float x, float y, float w, float h, float t)
        {
            int   i, j;
            float pad = 5.0f, s = w / 9.0f - pad * 2;

            float[] pts = new float[4 * 2];
            float   fx, fy;

            LineCap[] joins = new LineCap[] { LineCap.Miter, LineCap.Round, LineCap.Bevel };
            LineCap[] caps  = new LineCap[] { LineCap.Butt, LineCap.Round, LineCap.Square };

            vg.Save();
            pts[0] = -s * 0.25f + (float)Math.Cos(t * 0.3f) * s * 0.5f;
            pts[1] = (float)Math.Sin(t * 0.3f) * s * 0.5f;
            pts[2] = -s * 0.25f;
            pts[3] = 0;
            pts[4] = s * 0.25f;
            pts[5] = 0;
            pts[6] = s * 0.25f + (float)Math.Cos(-t * 0.3f) * s * 0.5f;
            pts[7] = (float)Math.Sin(-t * 0.3f) * s * 0.5f;

            for (i = 0; i < 3; i++)
            {
                for (j = 0; j < 3; j++)
                {
                    fx = x + s * 0.5f + (i * 3 + j) / 9.0f * w + pad;
                    fy = y - s * 0.5f + pad;

                    vg.LineCap(caps[i]);
                    vg.LineJoin(joins[j]);

                    vg.StrokeWidth(s * 0.3f);
                    vg.StrokeColor(new Color(0, 0, 0, 160));
                    vg.BeginPath();
                    vg.MoveTo(fx + pts[0], fy + pts[1]);
                    vg.LineTo(fx + pts[2], fy + pts[3]);
                    vg.LineTo(fx + pts[4], fy + pts[5]);
                    vg.LineTo(fx + pts[6], fy + pts[7]);
                    vg.Stroke();

                    vg.LineCap(LineCap.Butt);
                    vg.LineJoin(LineCap.Bevel);

                    vg.StrokeWidth(1.0f);
                    vg.StrokeColor(new Color(0, 192, 255, 255));
                    vg.BeginPath();
                    vg.MoveTo(fx + pts[0], fy + pts[1]);
                    vg.LineTo(fx + pts[2], fy + pts[3]);
                    vg.LineTo(fx + pts[4], fy + pts[5]);
                    vg.LineTo(fx + pts[6], fy + pts[7]);
                    vg.Stroke();
                }
            }

            vg.Restore();
        }
 public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
 {
     IntPtr zero = IntPtr.Zero;
     int status = SafeNativeMethods.Gdip.GdipCreateCustomLineCap(new HandleRef(fillPath, (fillPath == null) ? IntPtr.Zero : fillPath.nativePath), new HandleRef(strokePath, (strokePath == null) ? IntPtr.Zero : strokePath.nativePath), baseCap, baseInset, out zero);
     if (status != 0)
     {
         throw SafeNativeMethods.Gdip.StatusException(status);
     }
     this.SetNativeLineCap(zero);
 }
Exemple #17
0
 /// <summary>Creates a <see cref="Pen" /> from the <see cref="Image" />.</summary>
 /// <param name="image">The image.</param>
 /// <param name="width">The width.</param>
 /// <param name="startCap">The start cap.</param>
 /// <param name="endCap">The end cap.</param>
 /// <returns>The <see cref="Pen" />.</returns>
 public static Pen ToPen(this Image image, float width = 1, LineCap startCap = LineCap.Custom, LineCap endCap = LineCap.Custom)
 {
     using (TextureBrush _textureBrush = new TextureBrush(image))
     {
         return(new Pen(_textureBrush, width)
         {
             StartCap = startCap, EndCap = endCap
         });
     }
 }
Exemple #18
0
        private Pen()
        {
            //Color = Color.White;
            Alignment  = PenAlignment.Center;
            MiterLimit = 10f;
            JoinLimit  = (float)(Math.PI / 8);

            _startCap = LineCap.Flat;
            _endCap   = LineCap.Flat;
        }
        public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
        {
            IntPtr zero   = IntPtr.Zero;
            int    status = SafeNativeMethods.Gdip.GdipCreateCustomLineCap(new HandleRef(fillPath, (fillPath == null) ? IntPtr.Zero : fillPath.nativePath), new HandleRef(strokePath, (strokePath == null) ? IntPtr.Zero : strokePath.nativePath), baseCap, baseInset, out zero);

            if (status != 0)
            {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }
            this.SetNativeLineCap(zero);
        }
Exemple #20
0
 public void Deserialize(BinaryFormatter bf, Stream s)
 {
     version         = (int)bf.Deserialize(s);
     _baseColor      = (Color)bf.Deserialize(s);
     _highlightColor = (Color)bf.Deserialize(s);
     _alpha          = (int)bf.Deserialize(s);
     _startCap       = (LineCap)bf.Deserialize(s);
     _endCap         = (LineCap)bf.Deserialize(s);
     _lineJoin       = (LineJoin)bf.Deserialize(s);
     _width          = (float)bf.Deserialize(s);
 }
 /// <summary>
 /// 在原有波形上添加一条线
 /// 不可动态循环
 /// </summary>
 /// <param name="listX">X轴</param>
 /// <param name="listY">Y轴</param>
 /// <param name="listColor">线条颜色</param>
 /// <param name="listWidth">线条宽度</param>
 /// <param name="listLineJoin">线条连接点</param>
 /// <param name="listLineCap">线条起始线帽</param>
 /// <param name="listDrawStyle">线条样式</param>
 public void f_AddPix(ref List<float> listX, ref List<float> listY, Color listColor, int listWidth, LineJoin listLineJoin, LineCap listLineCap, DrawStyle listDrawStyle)
 {
     //装载
     _listX.Add(listX);
     _listY.Add(listY);
     _listColor.Add(listColor);
     _listWidth.Add(listWidth);
     _listLineJoin.Add(listLineJoin);
     _listLineCap.Add(listLineCap);
     _listDrawStyle.Add(listDrawStyle);
 }
Exemple #22
0
 public void SetLineAk(LineCap l, bool end)
 {
     if (end)
     {
         _lineEnd = l;
     }
     else
     {
         _lineStart = l;
     }
 }
Exemple #23
0
        private static void GetEndCap(EndCap ec, out LineCap endcaps, out DashCap dashcaps)
        {
            switch (ec)
            {
            case EndCap.Flat: endcaps = LineCap.Flat; dashcaps = DashCap.Flat; break;

            case EndCap.Square: endcaps = LineCap.Square; dashcaps = DashCap.Flat; break;

            default: endcaps = LineCap.Round; dashcaps = DashCap.Round; break;
            }
        }
Exemple #24
0
 public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
 {
     if (isModifiable)
     {
         Status status = SafeNativeMethods.Gdip.GdipSetPenLineCap197819(nativeObject, startCap, endCap, dashCap);
         SafeNativeMethods.Gdip.CheckStatus(status);
     }
     else
     {
         throw new ArgumentException("This Pen object can't be modified.");
     }
 }
Exemple #25
0
 private void setLineCap(java.awt.BasicStroke s)
 {
     try
     {
         LineCap plc = J2C.ConvertLineCap(s.getEndCap());
         pen.SetLineCap(plc, plc, pen.DashCap);
     }
     catch (ArgumentException aex)
     {
         Console.WriteLine(aex.StackTrace);
     }
 }
Exemple #26
0
 public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
 {
     if (isModifiable)
     {
         Status status = GDIPlus.GdipSetPenLineCap197819(nativeObject, startCap, endCap, dashCap);
         GDIPlus.CheckStatus(status);
     }
     else
     {
         throw new ArgumentException(Locale.GetText("This Pen object can't be modified."));
     }
 }
        public void SetThenGetStrokeCaps_Success(LineCap startCap, LineCap endCap)
        {
            using (GraphicsPath strokePath = new GraphicsPath())
                using (CustomLineCap customLineCap = new CustomLineCap(null, strokePath))
                {
                    customLineCap.SetStrokeCaps(startCap, endCap);
                    customLineCap.GetStrokeCaps(out LineCap retrievedStartCap, out LineCap retrievedEndCap);

                    Assert.Equal(startCap, retrievedStartCap);
                    Assert.Equal(endCap, retrievedEndCap);
                }
        }
Exemple #28
0
 /// <summary>
 /// Constructor for MacOSX Optimized Progress
 /// </summary>
 /// <param name="MacOSX_Optimized_m_Interval">The mac osx optimized m interval.</param>
 /// <param name="MacOSX_Optimized_m_StartAngle">The mac osx optimized m start angle.</param>
 /// <param name="MacOSX_Optimized_m_AngleIncrement">The mac osx optimized m angle increment.</param>
 /// <param name="MacOSX_Optimized_m_SpokesCount">The mac osx optimized m spokes count.</param>
 /// <param name="macOSX_Max_Spokes">The mac osx maximum spokes.</param>
 /// <param name="MacOSX_Optimized_startCap">The mac osx optimized start cap.</param>
 /// <param name="MacOSX_Optimized_endCap">The mac osx optimized end cap.</param>
 /// <param name="_automatic">The automatic.</param>
 /// <param name="MacOSX_Optimized_m_Rotation">The mac osx optimized m rotation.</param>
 /// <param name="macOSX_Optimized_tick_Color">Color of the mac osx optimized tick.</param>
 public ProgressInput(
     //ProgressType progressType,
     //ProgressBar solidBars,
     int MacOSX_Optimized_m_Interval,
     float MacOSX_Optimized_m_StartAngle,
     float MacOSX_Optimized_m_AngleIncrement,
     int MacOSX_Optimized_m_SpokesCount,
     int macOSX_Max_Spokes,
     LineCap MacOSX_Optimized_startCap,
     LineCap MacOSX_Optimized_endCap,
     MacOSX_automatic _automatic,
     ZeroitThematicProgress.MacOSX_Direction MacOSX_Optimized_m_Rotation,
     Color macOSX_Optimized_tick_Color
     ) : this(
         //ProgressType.Bar,
         //CircularProgress.ZeroitProgressBarCircular,
         ProgressBar.IPMacOSXOptimized,
         //ProgressIndicator.MacOSXOptimized,
         SmoothingMode.HighQuality,
         TextRenderingHint.AntiAlias,
         PeaceAnimatorEasing.BounceEaseIn,
         transparencyEasingType.BounceEaseIn,
         ZeroitThematicProgress.HatchBrushType.ForwardDiagonal,
         false,
         false,
         false,
         false,
         false,
         "%",
         Color.FromArgb(254, 84, 84),
         Color.DeepPink,
         0,
         100,
         5000,
         10,
         10,
         270
         )
 {
     //this.progressType = progressType;
     //this.solidBars = solidBars;
     this.MacOSX_Optimized_m_Interval       = MacOSX_Optimized_m_Interval;
     this.MacOSX_Optimized_m_StartAngle     = MacOSX_Optimized_m_StartAngle;
     this.MacOSX_Optimized_m_AngleIncrement = MacOSX_Optimized_m_AngleIncrement;
     this.MacOSX_Optimized_m_SpokesCount    = MacOSX_Optimized_m_SpokesCount;
     this.macOSX_Max_Spokes         = macOSX_Max_Spokes;
     this.MacOSX_Optimized_startCap = MacOSX_Optimized_startCap;
     this.MacOSX_Optimized_endCap   = MacOSX_Optimized_endCap;
     this._automatic = _automatic;
     this.MacOSX_Optimized_m_Rotation = MacOSX_Optimized_m_Rotation;
     this.macOSX_Optimized_tick_Color = macOSX_Optimized_tick_Color;
 }
Exemple #29
0
 public StrokeMath()
 {
     m_width = 0.5;
     m_width_abs = 0.5;
     m_width_eps = 0.5 / 1024.0;
     m_width_sign = 1;
     m_miter_limit = 4.0;
     m_inner_miter_limit = 1.01;
     m_approx_scale = 1.0;
     m_line_cap = LineCap.Butt;
     m_line_join = LineJoin.Miter;
     m_inner_join = InnerJoin.Miter;
 }
Exemple #30
0
        public void DrawLine(PointF p1, PointF p2, Color color, float width, LineCap startCap = LineCap.Flat, LineCap endCap = LineCap.Flat)
        {
            var tempWidth    = pen.Width;
            var tempStartCap = pen.StartCap;
            var tempEndCap   = pen.EndCap;


            SetPenConfig(width, startCap, endCap);

            DrawLine(p1, p2, color);

            SetPenConfig(tempWidth, tempStartCap, tempEndCap);
        }
Exemple #31
0
		public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
		{
			IntPtr fill = IntPtr.Zero;
			IntPtr stroke = IntPtr.Zero;

			if (fillPath != null)
				fill = fillPath.nativePath;
			if (strokePath != null)
				stroke = strokePath.nativePath;

			Status status = GDIPlus.GdipCreateCustomLineCap (fill, stroke, baseCap, baseInset, out nativeObject);
			GDIPlus.CheckStatus (status);
		}
 /// <summary>
 /// 清空原有数据并加载一条波形数据
 /// </summary>
 /// <param name="listX">X轴</param>
 /// <param name="listY">Y轴</param>
 /// <param name="listColor">线条颜色</param>
 /// <param name="listWidth">线条宽度</param>
 /// <param name="listLineJoin">线条连接点</param>
 /// <param name="listLineCap">线条起始线帽</param>
 /// <param name="listDrawStyle">线条样式</param>
 public void f_LoadOnePix(ref List<float> listX, ref List<float> listY, Color listColor, int listWidth, LineJoin listLineJoin, LineCap listLineCap,DrawStyle listDrawStyle)
 {
     //重新初始化
     f_ClearAllPix();
     //装载
     _listX.Add(listX);
     _listY.Add(listY);
     _listColor.Add(listColor);
     _listWidth.Add(listWidth);
     _listLineJoin.Add(listLineJoin);
     _listLineCap.Add(listLineCap);
     _listDrawStyle.Add(listDrawStyle);
 }
Exemple #33
0
 public DrawEllipse(int x, int y, int width, int height, Color lineColor, Color fillColor, bool filled, int lineWidth, DrawingPens.PenType penType, LineCap endCap)
 {
     Rectangle = new Rectangle(x, y, width, height);
     Center    = new Point(x + (width / 2), y + (height / 2));
     TipText   = String.Format("Ellipse Center @ {0}, {1}", Center.X, Center.Y);
     Color     = lineColor;
     FillColor = fillColor;
     Filled    = filled;
     PenWidth  = lineWidth;
     PenType   = penType;
     EndCap    = endCap;
     Initialize();
 }
Exemple #34
0
		public BaseLine(Color color, DashStyle dashStyle,float thickness, LineCap startLineCap, LineCap endLineCap, DashCap dashLineCap)
		{
			if (color == Color.White) {
				this.color = Color.Black;
			}
			
			this.color = color;
			this.dashStyle = dashStyle;
			this.thickness = thickness;
			this.startLineCap = startLineCap;
			this.endLineCap = endLineCap;
			this.dashLineCap = dashLineCap;
		}
Exemple #35
0
        /**
         * Set/get line caps: start, end, and dash
         */
        /// <include file='doc\Pen.uex' path='docs/doc[@for="Pen.SetLineCap"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Sets the values that determine the style of
        ///       cap used to end lines drawn by this <see cref='System.Drawing.Pen'/>.
        ///    </para>
        /// </devdoc>
        public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
        {
            if (immutable)
            {
                throw new ArgumentException(SR.GetString(SR.CantChangeImmutableObjects, "Pen"));
            }
            int status = SafeNativeMethods.GdipSetPenLineCap197819(new HandleRef(this, nativePen), (int)startCap, (int)endCap, (int)dashCap);

            if (status != SafeNativeMethods.Ok)
            {
                throw SafeNativeMethods.StatusException(status);
            }
        }
	// Map the cap style from "System.Drawing" to "Xsharp".
	private static CapStyle MapCapStyle(LineCap style)
			{
				switch(style)
				{
					case LineCap.Square:
						return CapStyle.CapProjecting;
					case LineCap.Flat:
						return CapStyle.CapButt;
					case LineCap.Round:
					default:
						return CapStyle.CapRound;
				}
			}
Exemple #37
0
 public void Deserialize(BinaryFormatter bf, Stream s)
 {
     version    = (int)bf.Deserialize(s);
     _dashStyle = (DashStyle)bf.Deserialize(s);
     _width     = (float)bf.Deserialize(s);
     _startCap  = (LineCap)bf.Deserialize(s);
     _endCap    = (LineCap)bf.Deserialize(s);
     _lineJoin  = (LineJoin)bf.Deserialize(s);
     _dashCap   = (DashCap)bf.Deserialize(s);
     _isPiple   = (bool)bf.Deserialize(s);
     _brushData.Deserialize(bf, s);
     _pipleData.Deserialize(bf, s);
 }
Exemple #38
0
 public Pen(Brush brush, float width)
 {
     _brush      = (Brush)brush.Clone();;
     _width      = width;
     _dashStyle  = DashStyle.Solid;
     _startCap   = LineCap.Flat;
     _dashCap    = DashCap.Flat;
     _endCap     = LineCap.Flat;
     _alignment  = PenAlignment.Center;
     _lineJoin   = LineJoin.Miter;
     _miterLimit = 10f;
     _transform  = new Matrix();
 }
Exemple #39
0
 public StrokeMath()
 {
     _width             = 0.5;
     _width_abs         = 0.5;
     _width_eps         = 0.5 / 1024.0;
     _width_sign        = 1;
     _miter_limit       = 4.0;
     _inner_miter_limit = 1.01;
     _approx_scale      = 1.0;
     _line_cap          = LineCap.Butt;
     _line_join         = LineJoin.Miter;
     _inner_join        = InnerJoin.Miter;
 }
Exemple #40
0
 // Methods
 public Stroke()
 {
     this.pen = Pens.Black;
     this.brush = new SolidColor(Color.Empty);
     this.strokeColor = Color.Empty;
     this.Width = 1f;
     this.Linecap = LineCap.Square;
     this.Linejoin = LineJoin.Miter;
     this.MiterLimit = 4;
     this.DashArray = null;
     this.DashOffset = 0f;
     this.Opacity = 1f;
 }
		public Pen (Brush brush, float width)
		{
			_brush = (Brush)brush.Clone();;
			_width = width;
			_dashStyle = DashStyle.Solid;
			_startCap = LineCap.Flat;
			_dashCap = DashCap.Flat;
			_endCap = LineCap.Flat;
			_alignment = PenAlignment.Center;
			_lineJoin = LineJoin.Miter;
			_miterLimit = 10f;
			_transform = new Matrix();
		}
        public DrawPolygon(int x1, int y1, int x2, int y2, Color lineColor, int lineWidth, DrawingPens.PenType penType, LineCap endCap)
        {
            pointArray = new ArrayList();
            pointArray.Add(new Point(x1, y1));
            pointArray.Add(new Point(x2, y2));
            Color    = lineColor;
            PenWidth = lineWidth;
            PenType  = penType;
            EndCap   = endCap;

            LoadCursor();
            Initialize();
        }
        public void SetLineCap(LineCap startCap, LineCap endCap, System.Drawing.Drawing2D.DashCap dashCap)
        {
            if (this.immutable)
            {
                throw new ArgumentException(System.Drawing.SR.GetString("CantChangeImmutableObjects", new object[] { "Pen" }));
            }
            int status = SafeNativeMethods.Gdip.GdipSetPenLineCap197819(new HandleRef(this, this.NativePen), (int)startCap, (int)endCap, (int)dashCap);

            if (status != 0)
            {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }
        }
        [InlineData(LineCap.Custom + 1, LineCap.Flat)] // Above valid enum range
        public void SetStrokeCaps_InvalidLineCap_ThrowsArgumentException(LineCap startCap, LineCap endCap)
        {
            using (GraphicsPath strokePath = new GraphicsPath())
                using (CustomLineCap customLineCap = new CustomLineCap(null, strokePath))
                {
                    AssertExtensions.Throws <ArgumentException>(null, () => customLineCap.SetStrokeCaps(startCap, endCap));

                    // start and end cap should be unchanged.
                    customLineCap.GetStrokeCaps(out LineCap retrievedStartCap, out LineCap retrievedEndCap);
                    Assert.Equal(LineCap.Flat, retrievedStartCap);
                    Assert.Equal(LineCap.Flat, retrievedEndCap);
                }
        }
Exemple #45
0
 // Methods
 public Stroke()
 {
     this.pen         = Pens.Black;
     this.brush       = new SolidColor(Color.Empty);
     this.strokeColor = Color.Empty;
     this.Width       = 1f;
     this.Linecap     = LineCap.Square;
     this.Linejoin    = LineJoin.Miter;
     this.MiterLimit  = 4;
     this.DashArray   = null;
     this.DashOffset  = 0f;
     this.Opacity     = 1f;
 }
Exemple #46
0
 public Stroke(ISvgBrush brush)
 {
     this.pen = brush.Pen;
     //this.brush = new SolidColor(pen.Color);
     this.strokeColor = pen.Color;
     this.Width = 1f;
     this.Linecap = LineCap.Square;
     this.Linejoin = LineJoin.Miter;
     this.MiterLimit = 4;
     this.DashArray = null;
     this.DashOffset = 0f;
     this.Opacity = 1f;
     this.brush = brush.Clone();
 }
        public CustomLineCap(
            GraphicsPath fillPath,
            GraphicsPath strokePath,
            LineCap baseCap,
            float baseInset
            )
        {
            nativeCap = new GpCustomLineCap();
            GpPath nativeFillPath = null;
            GpPath nativeStrokePath = null;

            if (fillPath != null)
                nativeFillPath = fillPath.nativePath;
            if (strokePath != null)
                nativeStrokePath = strokePath.nativePath;

            lastResult = NativeMethods.GdipCreateCustomLineCap(
                            nativeFillPath, nativeStrokePath,
                            baseCap, baseInset, out nativeCap);
        }
        /// <summary>
        /// Creates a new set of cartographic lines that together form a line with a border.  Since a compound
        /// pen is used, it is possible to use this to create a transparent line with just two border parts.
        /// </summary>
        /// <param name="fillColor">The fill color for the line</param>
        /// <param name="borderColor">The border color of the line</param>
        /// <param name="width">The width of the entire line</param>
        /// <param name="dash">The dash pattern to use</param>
        /// <param name="caps">The style of the start and end caps</param>
        public LineSymbolizer(Color fillColor, Color borderColor, double width, DashStyle dash, LineCap caps)
        {
            _strokes = new CopyList<IStroke>();
            ICartographicStroke bs = new CartographicStroke(borderColor);
            bs.Width = width;
            bs.StartCap = caps;
            bs.EndCap = caps;
            bs.DashStyle = dash;
            bs.CompoundArray = new[]{0F, 0.2F, 0.8F, 1F};
            _strokes.Add(bs);

            ICartographicStroke cs = new CartographicStroke(fillColor);
            cs.Width = width;
            cs.StartCap = caps;
            cs.EndCap = caps;
            cs.DashStyle = dash;
            cs.Width = width - 2;
            cs.CompoundArray = new[]{.2F, .8F};
            _strokes.Add(cs);
        }
Exemple #49
0
        /// <summary>
        /// Creates a new <see cref="ShapeStyle"/> instance.
        /// </summary>
        /// <param name="name">The shape style name.</param>
        /// <param name="sa">The stroke color alpha channel.</param>
        /// <param name="sr">The stroke color red channel.</param>
        /// <param name="sg">The stroke color green channel.</param>
        /// <param name="sb">The stroke color blue channel.</param>
        /// <param name="fa">The fill color alpha channel.</param>
        /// <param name="fr">The fill color red channel.</param>
        /// <param name="fg">The fill color green channel.</param>
        /// <param name="fb">The fill color blue channel.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="textStyle">The text style.</param>
        /// <param name="lineStyle">The line style.</param>
        /// <param name="startArrowStyle">The start arrow style.</param>
        /// <param name="endArrowStyle">The end arrow style.</param>
        /// <param name="lineCap">The line cap.</param>
        /// <param name="dashes">The line dashes.</param>
        /// <param name="dashOffset">The line dash offset.</param>
        /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns>
        public static ShapeStyle Create(string name = "", byte sa = 0xFF, byte sr = 0x00, byte sg = 0x00, byte sb = 0x00, byte fa = 0xFF, byte fr = 0x00, byte fg = 0x00, byte fb = 0x00, double thickness = 2.0, TextStyle textStyle = null, LineStyle lineStyle = null, ArrowStyle startArrowStyle = null, ArrowStyle endArrowStyle = null, LineCap lineCap = LineCap.Round, string dashes = default(string), double dashOffset = 0.0)
        {
            var style = new ShapeStyle()
            {
                Name = name,
                Stroke = ArgbColor.Create(sa, sr, sg, sb),
                Fill = ArgbColor.Create(fa, fr, fg, fb),
                Thickness = thickness,
                LineCap = lineCap,
                Dashes = dashes,
                DashOffset = dashOffset,
                LineStyle = lineStyle ?? LineStyle.Create("Line"),
                TextStyle = textStyle ?? TextStyle.Create("Text")
            };

            style.StartArrowStyle = startArrowStyle ?? ArrowStyle.Create("Start", style);
            style.EndArrowStyle = endArrowStyle ?? ArrowStyle.Create("End", style);

            return style;
        }
Exemple #50
0
        /// <summary>
        /// Creates a new set of cartographic lines that together form a line with a border.  Since a compound
        /// pen is used, it is possible to use this to create a transparent line with just two border parts.
        /// </summary>
        /// <param name="fillColor">The fill color for the line</param>
        /// <param name="borderColor">The border color of the line</param>
        /// <param name="width">The width of the entire line</param>
        /// <param name="dash">The dash pattern to use</param>
        /// <param name="startCap">The style of the start cap</param>
        /// <param name="endCap">The style of the end cap</param>
        public LineSymbolizer(Color fillColor, Color borderColor, double width, DashStyle dash, LineCap startCap, LineCap endCap)
        {
            _strokes = new CopyList<IStroke>();
            ICartographicStroke bs = new CartographicStroke(borderColor)
                                         {
                                             Width = width,
                                             StartCap = startCap,
                                             EndCap = endCap,
                                             DashStyle = dash,
                                         };
            _strokes.Add(bs);

            ICartographicStroke cs = new CartographicStroke(fillColor)
                                         {
                                             StartCap = startCap,
                                             EndCap = endCap,
                                             DashStyle = dash,
                                             Width = width - 2,
                                         };
            _strokes.Add(cs);
        }
Exemple #51
0
                private static void DeserializeLineCap(SerializationInfo info, string label, out LineCap lineCap, out CustomLineCap customLineCap)
                {
                    lineCap = (LineCap)info.GetInt32(label + "Cap");
                    customLineCap = null;
                    if (lineCap != LineCap.Custom)
                        return;

                    customLineCap = (CustomLineCap)info.GetValue("Custom" + label + "Cap", typeof(CustomLineCap));
                }
Exemple #52
0
 private static void SerializeLineCap(SerializationInfo info, string label, LineCap lineCap,
     CustomLineCap customLineCap)
 {
     if (lineCap == LineCap.Custom)
     {
         if (CustomEndCapSerializable(customLineCap))
         {
             info.AddValue(label + "Cap", (int)lineCap);
             info.AddValue("Custom" + label + "Cap", customLineCap);
         }
         else
             info.AddValue(label+"Cap", (int)LineCap.Round);
     }
     else
         info.AddValue(label+"Cap", (int)lineCap);
 }
 ///<summary>
 /// Creates a new DrawableStrokeLineCap instance.
 ///</summary>
 ///<param name="lineCap">The line cap.</param>
 public DrawableStrokeLineCap(LineCap lineCap)
 {
   LineCap = lineCap;
 }
	public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset) {}
 public CustomLineCap(GraphicsPath fillPath,
                      GraphicsPath strokePath,
                      LineCap baseCap) :
     this(fillPath, strokePath, baseCap, 0) {}
        /// <include file='doc\CustomLineCap.uex' path='docs/doc[@for="CustomLineCap.GetStrokeCaps"]/*' />
        /// <devdoc>
        ///    Gets the caps used to start and end lines.
        /// </devdoc>
        public void GetStrokeCaps(out LineCap startCap, out LineCap endCap) 
        {
            int status = SafeNativeMethods.Gdip.GdipGetCustomLineCapStrokeCaps(new HandleRef(this, nativeCap), out startCap, out endCap);

            if (status != SafeNativeMethods.Gdip.Ok)
                throw SafeNativeMethods.Gdip.StatusException(status);
        }
		public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
		{
			throw new NotImplementedException();
		}
Exemple #58
0
	// Set the line capabilities.
	public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
			{
				Dispose();
				this.startCap = startCap;
				this.endCap = endCap;
				this.dashCap = dashCap;
			}
Exemple #59
0
        public static extern GpStatus GdipCreateCustomLineCap(GpPath fillPath, GpPath strokePath,
LineCap baseCap, float baseInset, out GpCustomLineCap customCap);
		public void SetStrokeCaps(LineCap startCap, LineCap endCap)
		{
			throw new NotImplementedException();
		}