public DrawingRectangleAdorner(PictureBox pictureBox)
        {
            pictureBox.MouseDown += PictureBox_MouseDown;
            pictureBox.MouseMove += PictureBox_MouseMove;
            pictureBox.MouseUp += PictureBox_MouseUp;
            pictureBox.Paint += PictureBox_Paint;

            control = pictureBox;

            rect = RectangleF.Empty;

            Pen = new Pen(Colors.Green, 5);
        }
示例#2
0
		static Pen GetPen (Generator generator, Color color, float thickness = 1f, DashStyle dashStyle = null)
		{
			var cache = generator.Cache<PenKey, Pen> (cacheKey);
			Pen pen;
			lock (cache) {
				var key = new PenKey (color.ToArgb (), thickness, dashStyle);
				if (!cache.TryGetValue (key, out pen)) {
					pen = new Pen (color, thickness, generator);
					if (dashStyle != null) pen.DashStyle = dashStyle;
					cache.Add (key, pen);
				}
			}
			return pen;
		}
        public DrawingPenAdorner(PictureBox pictureBox)
        {
            pictureBox.MouseDown += PictureBox_MouseDown;
            pictureBox.MouseMove += PictureBox_MouseMove;
            pictureBox.MouseUp += PictureBox_MouseUp;
            pictureBox.Paint += PictureBox_Paint;

            control = pictureBox;

            Paths = new List<Path>();

            Pen = new Pen(Colors.Green, 10);
            Pen.LineCap = PenLineCap.Round;
            Pen.LineJoin = PenLineJoin.Round;
        }
示例#4
0
		public void SetMiterLimit(Pen widget, float miterLimit)
		{
			throw new NotImplementedException();
		}
示例#5
0
		public void SetLineCap(Pen widget, PenLineCap lineCap)
		{
			throw new NotImplementedException();
		}
示例#6
0
		public void SetLineJoin(Pen widget, PenLineJoin lineJoin)
		{
			throw new NotImplementedException();
		}
示例#7
0
		public void SetThickness(Pen widget, float thickness)
		{
			throw new NotImplementedException();
		}
示例#8
0
		public void SetColor(Pen widget, Color color)
		{
			throw new NotImplementedException();
		}
示例#9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="style"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        private Pen ToPen(BaseStyle style, Func<double, float> scale)
        {
            var pen = new Pen(
                ToColor(style.Stroke),
                scale(style.Thickness / _state.Zoom));

            switch (style.LineCap)
            {
                case Test2d.LineCap.Flat:
                    pen.LineCap = PenLineCap.Butt;
                    break;
                case Test2d.LineCap.Square:
                    pen.LineCap = PenLineCap.Square;
                    break;
                case Test2d.LineCap.Round:
                    pen.LineCap = PenLineCap.Round;
                    break;
            }
            if (style.Dashes != null)
            {
                pen.DashStyle = new DashStyle(
                    (float)style.DashOffset,
                    style.Dashes.Select(x => (float)x).ToArray());
            }
            return pen;
        }
示例#10
0
文件: PenHandler.cs 项目: mhusen/Eto
		public PenLineJoin GetLineJoin(Pen widget)
		{
			return widget.ToAndroid().StrokeJoin.ToEto();
		}
示例#11
0
文件: PenHandler.cs 项目: mhusen/Eto
		public void SetThickness(Pen widget, float thickness)
		{
			widget.ToAndroid().StrokeWidth = thickness;
		}
示例#12
0
文件: PenHandler.cs 项目: mhusen/Eto
		public float GetThickness(Pen widget)
		{
			return widget.ToAndroid().StrokeWidth;
		}
示例#13
0
文件: PenHandler.cs 项目: mhusen/Eto
		public void SetColor(Pen widget, Color color)
		{
			widget.ToAndroid().Color = color.ToAndroid();
		}
示例#14
0
文件: PenHandler.cs 项目: mhusen/Eto
		public Color GetColor(Pen widget)
		{
			return widget.ToAndroid().Color.ToEto();
		}
示例#15
0
		void Draw(Graphics g, Action<Pen> action)
		{
			var path = new GraphicsPath();
			path.AddLines(new PointF(0, 0), new PointF(100, 40), new PointF(0, 30), new PointF(50, 70));

			for (int i = 0; i < 4; i++)
			{
				float thickness = 1f + i * PenThickness;
				var pen = new Pen(Colors.Black, thickness);
				pen.LineCap = this.LineCap;
				pen.LineJoin = this.LineJoin;
				pen.DashStyle = this.DashStyle;
				if (action != null)
					action(pen);
				var y = i * 20;
				g.DrawLine(pen, 10, y, 110, y);
				
				y = 80 + i * 50;
				g.DrawRectangle(pen, 10, y, 100, 30);

				y = i * 70;
				g.DrawArc(pen, 140, y, 100, 80, 160, 160);
				
				y = i * 70;
				g.DrawEllipse(pen, 260, y, 100, 50);
				
				g.SaveTransform();
				y = i * 70;
				g.TranslateTransform(400, y);
				g.DrawPath(pen, path);
				g.RestoreTransform();
			}
		}
示例#16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="brush"></param>
        /// <param name="pen"></param>
        /// <param name="isStroked"></param>
        /// <param name="isFilled"></param>
        /// <param name="rect"></param>
        private static void DrawRectangleInternal(
            Graphics gfx,
            Brush brush,
            Pen pen,
            bool isStroked,
            bool isFilled,
            ref Rect2 rect)
        {
            if (isFilled)
            {
                gfx.FillRectangle(
                    brush,
                    (float)rect.X,
                    (float)rect.Y,
                    (float)rect.Width,
                    (float)rect.Height);
            }

            if (isStroked)
            {
                gfx.DrawRectangle(
                    pen,
                    (float)rect.X,
                    (float)rect.Y,
                    (float)rect.Width,
                    (float)rect.Height);
            }
        }
示例#17
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="stroke"></param>
        /// <param name="rect"></param>
        /// <param name="offsetX"></param>
        /// <param name="offsetY"></param>
        /// <param name="cellWidth"></param>
        /// <param name="cellHeight"></param>
        /// <param name="isStroked"></param>
        private void DrawGridInternal(
            Graphics gfx,
            Pen stroke,
            ref Rect2 rect,
            double offsetX, double offsetY,
            double cellWidth, double cellHeight,
            bool isStroked)
        {
            double ox = rect.X;
            double oy = rect.Y;
            double sx = ox + offsetX;
            double sy = oy + offsetY;
            double ex = ox + rect.Width;
            double ey = oy + rect.Height;

            for (double x = sx; x < ex; x += cellWidth)
            {
                var p0 = new PointF(
                    _scaleToPage(x),
                    _scaleToPage(oy));
                var p1 = new PointF(
                    _scaleToPage(x),
                    _scaleToPage(ey));
                DrawLineInternal(gfx, stroke, isStroked, ref p0, ref p1);
            }

            for (double y = sy; y < ey; y += cellHeight)
            {
                var p0 = new PointF(
                    _scaleToPage(ox),
                    _scaleToPage(y));
                var p1 = new PointF(
                    _scaleToPage(ex),
                    _scaleToPage(y));
                DrawLineInternal(gfx, stroke, isStroked, ref p0, ref p1);
            }
        }
示例#18
0
文件: PenHandler.cs 项目: mhusen/Eto
		public void SetLineJoin(Pen widget, PenLineJoin lineJoin)
		{
			widget.ToAndroid().StrokeJoin = lineJoin.ToAndroid();
		}
示例#19
0
		public Color GetColor(Pen widget)
		{
			throw new NotImplementedException();
		}
示例#20
0
文件: PenHandler.cs 项目: mhusen/Eto
		public PenLineCap GetLineCap(Pen widget)
		{
			return widget.ToAndroid().StrokeCap.ToEto();
		}
示例#21
0
		public float GetThickness(Pen widget)
		{
			throw new NotImplementedException();
		}
示例#22
0
文件: PenHandler.cs 项目: mhusen/Eto
		public void SetLineCap(Pen widget, PenLineCap lineCap)
		{
			var pen = widget.ToAndroid();
			pen.StrokeCap = lineCap.ToSD();
			SetDashStyle(widget, widget.DashStyle);
		}
示例#23
0
		public PenLineJoin GetLineJoin(Pen widget)
		{
			throw new NotImplementedException();
		}
示例#24
0
文件: PenHandler.cs 项目: mhusen/Eto
		public float GetMiterLimit(Pen widget)
		{
			return widget.ToAndroid().StrokeMiter;
		}
示例#25
0
		public PenLineCap GetLineCap(Pen widget)
		{
			throw new NotImplementedException();
		}
示例#26
0
文件: PenHandler.cs 项目: mhusen/Eto
		public void SetMiterLimit(Pen widget, float miterLimit)
		{
			widget.ToAndroid().StrokeMiter = miterLimit;
		}
示例#27
0
		public float GetMiterLimit(Pen widget)
		{
			throw new NotImplementedException();
		}
示例#28
0
文件: PenHandler.cs 项目: mhusen/Eto
		public void SetDashStyle(Pen widget, DashStyle dashStyle)
		{
			var pen = widget.ToAndroid();

			if (dashStyle == null || dashStyle.IsSolid)
				pen.SetPathEffect(null);
			else
			{
				// TODO: create a new ag.DashPathEffect with the appropriate intervals
				throw new NotImplementedException();
			}
		}
示例#29
0
		public void SetDashStyle(Pen widget, DashStyle dashStyle)
		{
			throw new NotImplementedException();
		}
示例#30
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="gfx"></param>
 /// <param name="pen"></param>
 /// <param name="isStroked"></param>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 private static void DrawLineInternal(
     Graphics gfx,
     Pen pen,
     bool isStroked,
     ref PointF p0,
     ref PointF p1)
 {
     if (isStroked)
     {
         gfx.DrawLine(pen, p0, p1);
     }
 }