示例#1
0
 // Set the line capabilities.
 public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
 {
     Dispose();
     this.startCap = startCap;
     this.endCap   = endCap;
     this.dashCap  = dashCap;
 }
示例#2
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));
        }
示例#3
0
文件: PenPlus.cs 项目: windygu/haina
        // Set/get line caps: start, end, and dash

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

        public void SetLineCap(LineCap startCap,
                               LineCap endCap,
                               DashCap dashCap)
        {
            SetStatus(GdiPlus.GdipSetPenLineCap197819(nativePen,
                                                      startCap, endCap, dashCap));
        }
示例#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)));
        }
示例#5
0
        /// <summary>
        /// Create a valid descriptor of an edge.
        /// </summary>
        public static string FormatEdge(double width, Color colour, LineCap cap, DashCap dashCap, double[] dashPattern)
        {
            List <string> fragments = new List <string>(5);

            fragments.Add(string.Format("width={0:0.##}", width));
            fragments.Add("colour=" + ExtensionMethods.FormatColour(colour));

            for (int i = 0; i < _capValues.Length; i++)
            {
                if (_capValues[i] == cap)
                {
                    fragments.Add("cap=" + _capNames[i]);
                    break;
                }
            }

            if (dashPattern != null && dashPattern.Length > 0)
            {
                for (int i = 0; i < _dashCapValues.Length; i++)
                {
                    if (_dashCapValues[i] == dashCap)
                    {
                        fragments.Add("dashcap=" + _dashCapNames[i]);
                        break;
                    }
                }
                fragments.Add(string.Format("pattern=({0})", string.Join(",", dashPattern)));
            }

            return("edge: " + string.Join(", ", fragments));
        }
示例#6
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics  grfx      = e.Graphics;
            Rectangle rectColor = new Rectangle(e.Bounds.Left, e.Bounds.Top, 2 * e.Bounds.Height, e.Bounds.Height);

            rectColor.Inflate(-1, -1);

            Rectangle rectText = new Rectangle(e.Bounds.Left + 2 * e.Bounds.Height,
                                               e.Bounds.Top,
                                               e.Bounds.Width - 2 * e.Bounds.Height,
                                               e.Bounds.Height);

            if (this.Enabled)
            {
                e.DrawBackground();
            }

            DashCap    item           = e.Index >= 0 ? (DashCap)Items[e.Index] : DashCap.Flat;
            SolidBrush foreColorBrush = new SolidBrush(e.ForeColor);

            Pen linePen = new Pen(foreColorBrush, (float)Math.Ceiling(0.5 * e.Bounds.Height));

            linePen.DashStyle = DashStyle.Dot;
            linePen.DashCap   = item;

            grfx.DrawLine(linePen,
                          rectColor.Left, 0.5f * (rectColor.Top + rectColor.Bottom),
                          rectColor.Right, 0.5f * (rectColor.Top + rectColor.Bottom));
            grfx.DrawString(item.ToString(), Font, foreColorBrush, rectText);
        }
示例#7
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;
            }
        }
示例#8
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."));
     }
 }
示例#9
0
    void SetDataSource(DashCap selected)
    {
      this.BeginUpdate();

      Items.Clear();
      foreach (DashCap o in Enum.GetValues(typeof(DashCap)))
        Items.Add(o);

      SelectedItem = selected;

      this.EndUpdate();
    }
示例#10
0
文件: Pen.cs 项目: stantoxt/corefx
 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.");
     }
 }
示例#11
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;
		}
示例#12
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);
            }
        }
示例#13
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);
 }
示例#14
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();
 }
示例#15
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();
		}
示例#16
0
        protected override void SolveInstance(IGH_DataAccess access)
        {
            double width   = 0.0;
            Color  colour  = Color.Black;
            int    lineCap = 0;
            int    dashCap = 0;

            if (!access.GetData(0, ref width))
            {
                return;
            }
            if (!access.GetData(1, ref colour))
            {
                return;
            }
            if (!access.GetData(2, ref lineCap))
            {
                return;
            }
            if (!access.GetData(3, ref dashCap))
            {
                return;
            }

            List <double> pattern = new List <double>();

            access.GetDataList(4, pattern);

            LineCap actualLineCap = LineCap.Round;

            foreach (var cap in GdiCache._capValues)
            {
                if (lineCap == (int)cap)
                {
                    actualLineCap = cap;
                }
            }

            DashCap actualDashCap = DashCap.Flat;

            foreach (var cap in GdiCache._dashCapValues)
            {
                if (dashCap == (int)cap)
                {
                    actualDashCap = cap;
                }
            }

            access.SetData(0, GdiCache.FormatEdge((float)width, colour, actualLineCap, actualDashCap, pattern.ToArray()));
        }
示例#17
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = Thickness.GetHashCode();
         hashCode = (hashCode * 397) ^ (StrokeColor != null ? StrokeColor.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DashStyle != null ? DashStyle.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DashCap.GetHashCode();
         hashCode = (hashCode * 397) ^ StartLineCap.GetHashCode();
         hashCode = (hashCode * 397) ^ EndLineCap.GetHashCode();
         hashCode = (hashCode * 397) ^ LineJoin.GetHashCode();
         return(hashCode);
     }
 }
示例#18
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;
        }
示例#19
0
        /// <summary>
        /// Sets the values that determine the style of cap used to end lines drawn by this <see cref='Pen'/>.
        /// </summary>
        public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
        {
            if (_immutable)
            {
                throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, "Pen"));
            }
            int status = SafeNativeMethods.Gdip.GdipSetPenLineCap197819(new HandleRef(this, NativePen),
                                                                        unchecked ((int)startCap), unchecked ((int)endCap), unchecked ((int)dashCap));

            if (status != SafeNativeMethods.Gdip.Ok)
            {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }
        }
        private static Pen PenBorder(Color c, int width, DashCap dashCap, DashStyle dashStyle, float dashOffset, float[] dashPattern)
        {
            _pen            = new Pen(c, width);
            _pen.DashCap    = dashCap;
            _pen.DashOffset = dashOffset;
            _pen.DashStyle  = dashStyle;

            if (dashPattern != null)
            {
                _pen.DashPattern = dashPattern;
            }

            return(_pen);
        }
示例#21
0
        void SetDataSource(DashCap selected)
        {
            this.BeginUpdate();

            Items.Clear();
            foreach (DashCap o in Enum.GetValues(typeof(DashCap)))
            {
                Items.Add(o);
            }

            SelectedItem = selected;

            this.EndUpdate();
        }
示例#22
0
 private Int32 computeHashCode()
 {
     return(Alignment.GetHashCode() ^
            getSingleArrayHashCode(CompoundArray) ^
            MiterLimit.GetHashCode() ^
            BackgroundBrush.GetHashCode() ^
            DashOffset.GetHashCode() ^
            getSingleArrayHashCode(DashPattern) ^
            getStyleBrushesArrayHashCode(DashBrushes) ^
            DashStyle.GetHashCode() ^
            StartCap.GetHashCode() ^
            EndCap.GetHashCode() ^
            DashCap.GetHashCode() ^
            LineJoin.GetHashCode() ^
            Transform.GetHashCode() ^
            Width.GetHashCode() ^
            -18133844);
 }
示例#23
0
        /// <summary>
        /// Handles the randomization of the cartographic properties of this stroke.
        /// </summary>
        /// <param name="generator">The random class that generates the random numbers.</param>
        protected override void OnRandomize(Random generator)
        {
            base.OnRandomize(generator);
            DashStyle        = DashStyle.Custom;
            _dashCap         = generator.NextEnum <DashCap>();
            _startCap        = generator.NextEnum <LineCap>();
            _endCap          = generator.NextEnum <LineCap>();
            _dashButtons     = generator.NextBoolArray(1, 20);
            _compoundButtons = generator.NextBoolArray(1, 5);
            _offset          = generator.NextFloat(10);
            _joinType        = generator.NextEnum <LineJoinType>();
            int len = generator.Next(0, 1);

            if (len > 0)
            {
                _decorations.Clear();
                LineDecoration ld = new();
                ld.Randomize(generator);
                _decorations.Add(ld);
            }
        }
示例#24
0
文件: Pens.cs 项目: misiek/foo
 public static extern GpStatus GdipSetPenDashCap197819(GpPen pen, DashCap dashCap);
示例#25
0
		internal static extern Status GdipSetPenLineCap197819 (IntPtr pen, LineCap startCap, LineCap endCap, DashCap dashCap);
示例#26
0
GdipSetPenDashCap197819(GpPen pen, DashCap dashCap);
示例#27
0
 public DashCapComboBox(DashCap selected)
   : this()
 {
   SetDataSource(selected);
 }
示例#28
0
        public static void DrawBox(Graphics graphics, RectangleF rectangle, double scale, Color color, float borderWidth = 2, DashStyle dashStyle = DashStyle.Dot, DashCap dashCap = DashCap.Flat)
        {
            borderWidth *= (float)scale;

            using (SolidBrush brush = new SolidBrush(color))
            {
                graphics.FillRectangle(brush, rectangle);
            }

            if (borderWidth == 0)
            {
                return;
            }

            using (Pen pen = new Pen(color, borderWidth)
            {
                DashStyle = dashStyle,
                DashCap = dashCap
            })
            {
                graphics.DrawRectangle(pen, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
            }
        }
        /// <summary>
        /// 创建画笔
        /// </summary>
        /// <param name="brush">画刷</param>
        /// <param name="width">直线宽度</param>
        /// <param name="style">虚线样式</param>
        /// <param name="pattern">点线长度数组</param>
        /// <param name="cap">每个线段键帽样式</param>
        /// <param name="offset">直线的起点到短划线图案起始处的距离</param>
        /// <returns>画笔</returns>
        public static Pen CreatePen(Brush brush, int width, DashStyle style, float[] pattern, DashCap cap, float offset)
        {
            Pen pen = new Pen(brush);

            pen.Width     = width;
            pen.DashStyle = style;
            if (style == DashStyle.Custom && pattern != null && pattern.Length > 0)
            {
                pen.DashPattern = pattern;
            }
            pen.DashCap    = cap;
            pen.DashOffset = offset;
            return(pen);
        }
示例#30
0
文件: Pens.cs 项目: north0808/haina
 internal static extern GpStatus GdipGetPenDashCap197819(GpPen pen, out DashCap dashCap);
示例#31
0
文件: Pen.cs 项目: mind0n/hive
        /**
         * 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.Gdip.GdipSetPenLineCap197819(new HandleRef(this, this.NativePen), 
                unchecked((int)startCap), unchecked((int)endCap), unchecked((int)dashCap));

            if (status != SafeNativeMethods.Gdip.Ok)
                throw SafeNativeMethods.Gdip.StatusException(status);
        }
示例#32
0
文件: PenX.cs 项目: Altaxo/Altaxo
		/// <summary>
		/// Copies the properties of another instance to this instance.
		/// </summary>
		/// <param name="pen">the PenHolder object to copy</param>
		public void CopyFrom(PenX pen)
		{
			if (object.ReferenceEquals(this, pen))
				return;

			_SetPenVariable(null);

			this._configuredProperties = pen._configuredProperties;
			this._penType = pen.PenType;
			this._alignment = pen.Alignment;

			if (0 != (this._configuredProperties & Configured.Brush))
				this._brush = new BrushX(pen._brush);

			this._color = pen.Color;

			if (null != pen._compoundArray)
				this._compoundArray = (float[])pen.CompoundArray.Clone();
			else
				this._compoundArray = null;

			this._dashPattern = pen._dashPattern; // immutable
			this._dashCap = pen._dashCap;

			this._cachedDashStyle = pen._cachedDashStyle;

			if (null != pen._cachedDashPattern)
				this._cachedDashPattern = (float[])pen._cachedDashPattern.Clone();
			else
				this._cachedDashPattern = null;

			this._cachedDashOffset = pen._cachedDashOffset;

			this._endCap = pen.EndCap;
			this._lineJoin = pen.LineJoin;
			this._miterLimit = pen.MiterLimit;
			this._startCap = pen.StartCap;

			if (null != pen._transformation)
				this._transformation = pen.Transform.Clone();
			else
				this._transformation = null;

			this._width = pen.Width;

			// note: there is an problem with Pen.Clone() : if the Color of the pen
			// was set to a known color, the color of the cloned pen is the same, but no longer a known color
			// therefore we avoid the cloning of the pen here

			// if(m_CachedMode && null!=pen.m_Pen)
			//   _SetPenVariable( (Pen)pen.m_Pen.Clone() );
			// else
			//   _SetPenVariable(null);
		}
示例#33
0
 public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
 {
     StartCap = startCap;
 }
示例#34
0
        protected void DoDraw(PaintEventArgs e)
        {
            KeyValuePair <string, NamedSolidColorBrush>[] kvps = jc.Cores.ToArray();
            g = e.Graphics;
            Rectangle bounds = Screen.GetBounds(new Point());
            Random    rand   = new Random();

            SmoothingMode[] smodes = new SmoothingMode[] { SmoothingMode.AntiAlias, SmoothingMode.Default, SmoothingMode.HighQuality, SmoothingMode.HighSpeed, /*SmoothingMode.Invalid,*/ SmoothingMode.None };
            LineCap[]       lcaps  = new LineCap[] { LineCap.Triangle, LineCap.SquareAnchor, LineCap.Square, LineCap.RoundAnchor, LineCap.Round, LineCap.NoAnchor, LineCap.Flat, LineCap.DiamondAnchor, LineCap.Custom, LineCap.ArrowAnchor, LineCap.AnchorMask };
            DashCap[]       dcaps  = new DashCap[] { DashCap.Triangle, DashCap.Round, DashCap.Flat };
            g.SmoothingMode = smodes[rand.Next(0, smodes.Length)];
            FontFamily[] ffs = FontFamily.Families;
            string       ss  = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%^&*()_-+={[}\\]|\"':;?//>.<,";

            FontStyle[] styles  = new FontStyle[] { FontStyle.Bold, FontStyle.Italic, FontStyle.Regular, FontStyle.Strikeout, FontStyle.Underline };
            FontStyle[] jstyles = new FontStyle[] { FontStyle.Bold, FontStyle.Italic, FontStyle.Regular, FontStyle.Underline };
            for (;;)
            {
                int    top  = rand.Next(0, bounds.Height);
                int    left = rand.Next(0, bounds.Right);
                Point  loc  = new Point(left, top);
                int    wide = rand.Next(miniWide, bounds.Width);
                int    high = rand.Next(miniHigh, bounds.Height);
                Size   size = new Size(wide, high);
                byte[] rgb  = { 0, 0, 0, 0 };
                rand.NextBytes(rgb);
                if (!UseAlpha)
                {
                    rgb[0] = (byte)0xff;
                }
                KeyValuePair <string, NamedSolidColorBrush> kvp = kvps[rand.Next(0, kvps.Length)];
                NamedSolidColorBrush Nscb = kvp.Value;
                Color fore;
                if (UseJapaneseColor)
                {
                    Color jcc = Nscb.GetColor();
                    fore = Color.FromArgb((int)rgb[0], jcc.R, jcc.G, jcc.B);
                }
                else
                {
                    fore = Color.FromArgb((int)rgb[0], (int)rgb[1], (int)rgb[2], (int)rgb[3]);
                }
                Color back  = invert(fore);
                Brush brush = new SolidBrush(fore);
                Brush hsurb = new SolidBrush(back);
                Pen   pen   = new Pen(hsurb, Convert.ToSingle(rand.Next(ofPen.from, ofPen.upto)));
                pen.SetLineCap(lcaps[rand.Next(0, lcaps.Length)], lcaps[rand.Next(0, lcaps.Length)], dcaps[rand.Next(0, dcaps.Length)]);
                Rectangle rect   = new Rectangle(loc, size);
                Point[]   points = GeneratePoints(rand, bounds);
                try {
                    switch (what)
                    {
                    case WhatToDraw.Rectangular:
                        g.DrawRectangle(pen, rect);
                        g.FillRectangle(brush, rect);
                        if (UseJapaneseColor && !UseAlpha)
                        {
                            DrawSet ds = new DrawSet {
                                ffs     = ffs,
                                rand    = rand,
                                styles  = styles,
                                jstyles = jstyles,
                                rect    = rect,
                                kvp     = kvp,
                                Nscb    = Nscb,
                                hsurb   = hsurb,
                                pen     = pen
                            };
                            DrawJapaneseColorNames(ds);
                        }
                        break;

                    case WhatToDraw.Circle:
                        g.DrawEllipse(pen, rect);
                        g.FillEllipse(brush, rect);
                        if (UseJapaneseColor && !UseAlpha)
                        {
                            DrawSet ds = new DrawSet {
                                ffs     = ffs,
                                rand    = rand,
                                styles  = styles,
                                jstyles = jstyles,
                                rect    = rect,
                                kvp     = kvp,
                                Nscb    = Nscb,
                                hsurb   = hsurb,
                                pen     = pen
                            };
                            DrawJapaneseColorNames(ds);
                        }
                        break;

                    case WhatToDraw.Text:
                        float  fsize = Convert.ToSingle(rand.Next(ofFont.from, ofFont.upto));
                        Font   font  = new Font(ffs[rand.Next(0, ffs.Length)], fsize, styles[rand.Next(0, styles.Length)]);
                        PointF point = new PointF(left, top);
                        g.DrawString(ss.Substring(rand.Next(0, ss.Length), 1), font, brush, point);
                        g.RotateTransform(Convert.ToSingle(rand.Next(-360, 361)));
                        break;

                    case WhatToDraw.Line:
                        g.DrawLine(pen, loc, new Point(size));
                        break;

                    case WhatToDraw.Arc:
                        float a1 = Convert.ToSingle(rand.Next(-360, 361));
                        float a2 = Convert.ToSingle(rand.Next(-360, 361));
                        g.DrawArc(pen, rect, a1, a2);
                        break;

                    case WhatToDraw.Bezier:
                        int   x1 = rand.Next(0, bounds.Right);
                        int   x2 = rand.Next(0, bounds.Right);
                        int   y1 = rand.Next(0, bounds.Height);
                        int   y2 = rand.Next(0, bounds.Height);
                        Point p1 = loc;
                        Point p2 = new Point(size);
                        Point p3 = new Point(x1, y1);
                        Point p4 = new Point(x2, y2);
                        g.DrawBezier(pen, p1, p2, p3, p4);
                        break;

                    case WhatToDraw.Polygon:
                        g.DrawPolygon(pen, points);
                        g.FillPolygon(brush, points);
                        break;

                    case WhatToDraw.ClosedCurve:
                        g.DrawClosedCurve(pen, points);
                        g.FillClosedCurve(brush, points);
                        break;

                    case WhatToDraw.OfColorCode:
                        float  jfsize = Convert.ToSingle(rand.Next(miniSizej, UseJapaneseColor ? maxSizej : maxSize_));
                        Font   jfont  = new Font(ffs[rand.Next(0, ffs.Length)], jfsize, styles[rand.Next(0, jstyles.Length)]);
                        PointF jpoint = new PointF(left, top);
                        string text   = null;
                        for (int i = 0; i < 10; ++i)
                        {
                            if (AvoidBlankCharacter(jfont))
                            {
                                jfont = new Font(ffs[rand.Next(0, ffs.Length)], jfsize, styles[rand.Next(0, jstyles.Length)]);
                            }
                            else
                            {
                                break;
                            }
                        }
                        if (UseJapaneseColor)
                        {
                            text = String.Format("{0}({1})", kvp.Key, Nscb.Name);
                        }
                        else
                        {
                            string fore_Code = String.Format(UseAlpha ? "{0},{1},{2},{3}" : "{1},{2},{3}", fore.A, fore.R, fore.G, fore.B);
                            text = fore.IsNamedColor ? fore.Name : fore_Code;
                        }
                        g.DrawString(text, jfont, brush, jpoint);
                        g.RotateTransform(Convert.ToSingle(rand.Next(-360, 361)));
                        break;

#if false
                    case WhatToDraw.Background:
                        //This lets freeze for sure...I don't know why... as of July 17, 2019
                        this.BackColor = back;
                        this.ForeColor = fore;
                        break;
#endif
                    }
                } catch { }
                base.OnPaint(e);
                Application.DoEvents();
                if (isScreenSaver)
                {
                    System.Threading.Thread.Sleep(0);
                }
                if (!running)
                {
                    break;
                }
            }
        }
示例#35
0
 GdipGetPenDashCap197819(GpPen pen, out DashCap dashCap);
示例#36
0
 GdipSetPenDashCap197819(GpPen pen, DashCap dashCap);
示例#37
0
 // Set/get line caps: start, end, and dash
 // Line cap and join APIs by using LineCap and LineJoin enums.
 public void SetLineCap(LineCap startCap,
     LineCap endCap,
     DashCap dashCap)
 {
     SetStatus(GdiPlus.GdipSetPenLineCap197819(nativePen,
                                startCap, endCap, dashCap));
 }
示例#38
0
        /*
         * Pen patterns look like this:
         *   edge: width=4.3, colo[u]r=(75,108,255), [cap=round], [pattern=(4,2,4,3)], [dashcap=flat]
         *   edge: width=4.3, colo[u]r=#ffab520c,    [cap=round], [pattern=(4,2,4,3)], [dashcap=flat]
         *
         * Fill patterns look like this:
         *   fill: colo[u]r=(75,108,255)
         *   fill: colo[u]r=#ffab520c
         *   fill: colo[u]r1=(75,108,255), colo[u]r2=(255,155,0), point1=(50,80), point2=(200,80), [wrap=something]
         *   fill: colo[u]r1=#ffab520c,    colo[u]r2=(255,155,0), point1=(50,80), point2=(200,80), [wrap=something]
         */

        /// <summary>
        /// Parse a piece of string and return the Pen it describes.
        /// Do *not* dispose of the object returned by this method and
        /// do *not* cache it.
        /// </summary>
        /// <param name="description">Pen description.</param>
        /// <param name="message">If parsing is not successful, the error message will be returned here.</param>
        /// <returns>Pen on successful parse, or null.</returns>
        public Pen ParseEdge(string description, out string message)
        {
            description = description.ToLowerInvariant();
            message     = null;

            if (_edges.TryGetValue(description, out Pen edge))
            {
                return(edge);
            }

            Dictionary <string, string> dic = ExtensionMethods.ParseDescription(description, out message);

            if (dic == null)
            {
                return(null);
            }

            if (!string.Equals(dic["type"], "edge", StringComparison.Ordinal))
            {
                message = "This is not an edge descriptor.";
                return(null);
            }
            if (!dic.ContainsKey("width"))
            {
                message = "Pen description does not contain a width value.";
                return(null);
            }
            if (!dic.ContainsKey("colour"))
            {
                message = "Pen description does not contain a colour value.";
                return(null);
            }

            if (!float.TryParse(dic["width"], out float width))
            {
                message = "Width value is not a valid number.";
                return(null);
            }
            if (!ExtensionMethods.TryParseColour(dic["colour"], out Color colour))
            {
                message = "Colour value is not valid.";
                return(null);
            }

            LineCap lineCap = LineCap.Round;

            if (dic.TryGetValue("cap", out string cap))
            {
                lineCap = ExtensionMethods.ParseNamedValues(cap, _capNames, _capValues, lineCap);
            }

            DashCap dashCap = DashCap.Flat;

            if (dic.TryGetValue("dashcap", out string dashcap))
            {
                dashCap = ExtensionMethods.ParseNamedValues(dashcap, _dashCapNames, _dashCapValues, dashCap);
            }

            float[] pattern = null;
            if (dic.TryGetValue("pattern", out string dashes))
            {
                pattern = ExtensionMethods.ToFloatArray(dashes);
                if (pattern == null)
                {
                    message = "Invalid dash pattern.";
                    return(null);
                }
            }

            edge = new Pen(colour, width)
            {
                StartCap = lineCap,
                EndCap   = lineCap,
                DashCap  = dashCap,
                LineJoin = LineJoin.Round
            };

            if (pattern != null && pattern.Length > 0)
            {
                edge.DashPattern = pattern;
            }

            ReleaseMemoryPressure();
            _edges.Add(description, edge);
            return(edge);
        }
示例#39
0
文件: Pen.cs 项目: Profit0004/mono
                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."));
                }
示例#40
0
GdipSetPenLineCap197819(GpPen pen, LineCap startCap, LineCap endCap,
   DashCap dashCap);
示例#41
0
 public DashCapComboBox(DashCap selected)
     : this()
 {
     SetDataSource(selected);
 }
示例#42
0
文件: Pens.cs 项目: north0808/haina
 internal static extern GpStatus GdipSetPenLineCap197819(GpPen pen, LineCap startCap, LineCap endCap,  DashCap dashCap);
示例#43
0
GdipGetPenDashCap197819(GpPen pen, out DashCap dashCap);
示例#44
0
 public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
 {
     throw null;
 }
示例#45
0
 internal static extern Status GdipGetPenDashCap197819 (IntPtr pen, out DashCap dashCap);
 public CoordinateLineStyle SetDashCap(DashCap cap)
 {
     DashCap = cap;
     return(this);
 }
示例#47
0
 /// <summary>
 /// Handles the randomization of the cartographic properties of this stroke.
 /// </summary>
 /// <param name="generator">The random class that generates the random numbers</param>
 protected override void OnRandomize(Random generator)
 {
     base.OnRandomize(generator);
     DashStyle = DashStyle.Custom;
     _dashCap = generator.NextEnum<DashCap>();
     _startCap = generator.NextEnum<LineCap>();
     _endCap = generator.NextEnum<LineCap>();
     _dashButtons = generator.NextBoolArray(1, 20);
     _compoundButtons = generator.NextBoolArray(1, 5);
     _offset = generator.NextFloat(10);
     _joinType = generator.NextEnum<LineJoinType>();
     int len = generator.Next(0, 1);
     if (len > 0)
     {
         _decorations.Clear();
         LineDecoration ld = new LineDecoration();
         ld.Randomize(generator);
         _decorations.Add(ld);
     }
 }
示例#48
0
 public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
 {
     StartCap = startCap;
     DashCap  = dashCap;
     EndCap   = endCap;
 }
示例#49
0
    /// <summary>
    /// Copies the properties of another instance to this instance.
    /// </summary>
    /// <param name="pen">the PenHolder object to copy</param>
    public void CopyFrom(PenX pen)
    {
      _SetPenVariable(null);

      this.m_ConfiguredProperties = pen.m_ConfiguredProperties;
      this.m_PenType = pen.PenType;
      this.m_Alignment = pen.Alignment;

      if (0 != (this.m_ConfiguredProperties & Configured.Brush))
        this.m_Brush = new BrushX(pen.m_Brush);

      this.m_Color = pen.Color;

      if (null != pen.m_CompoundArray)
        this.m_CompoundArray = (float[])pen.CompoundArray.Clone();
      else
        this.m_CompoundArray = null;

      this.m_DashCap = pen.DashCap;
      this.m_DashOffset = pen.DashOffset;

      if (null != pen.m_DashPattern)
        this.m_DashPattern = (float[])pen.DashPattern.Clone();
      else
        this.m_DashPattern = null;

      this.m_DashStyle = pen.DashStyle;
      this.m_EndCap = pen.EndCap;
      this.m_LineJoin = pen.LineJoin;
      this.m_MiterLimit = pen.MiterLimit;
      this.m_StartCap = pen.StartCap;

      if (null != pen.m_Transform)
        this.m_Transform = pen.Transform.Clone();
      else
        this.m_Transform = null;

      this.m_Width = pen.Width;

      // note: there is an problem with Pen.Clone() : if the Color of the pen
      // was set to a known color, the color of the cloned pen is the same, but no longer a known color
      // therefore we avoid the cloning of the pen here

      // if(m_CachedMode && null!=pen.m_Pen)
      //   _SetPenVariable( (Pen)pen.m_Pen.Clone() );
      // else
      //   _SetPenVariable(null);
    }
示例#50
0
	// Set the line capabilities.
	public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
			{
				Dispose();
				this.startCap = startCap;
				this.endCap = endCap;
				this.dashCap = dashCap;
			}
示例#51
0
 GdipSetPenLineCap197819(GpPen pen, LineCap startCap, LineCap endCap,
                         DashCap dashCap);