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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 4
0
		public void SetMiterLimit(Pen widget, float miterLimit)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 5
0
		public void SetLineCap(Pen widget, PenLineCap lineCap)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 6
0
		public void SetLineJoin(Pen widget, PenLineJoin lineJoin)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 7
0
		public void SetThickness(Pen widget, float thickness)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 8
0
		public void SetColor(Pen widget, Color color)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 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;
        }
Exemplo n.º 10
0
		public PenLineJoin GetLineJoin(Pen widget)
		{
			return widget.ToAndroid().StrokeJoin.ToEto();
		}
Exemplo n.º 11
0
		public void SetThickness(Pen widget, float thickness)
		{
			widget.ToAndroid().StrokeWidth = thickness;
		}
Exemplo n.º 12
0
		public float GetThickness(Pen widget)
		{
			return widget.ToAndroid().StrokeWidth;
		}
Exemplo n.º 13
0
		public void SetColor(Pen widget, Color color)
		{
			widget.ToAndroid().Color = color.ToAndroid();
		}
Exemplo n.º 14
0
		public Color GetColor(Pen widget)
		{
			return widget.ToAndroid().Color.ToEto();
		}
Exemplo n.º 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();
			}
		}
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 18
0
		public void SetLineJoin(Pen widget, PenLineJoin lineJoin)
		{
			widget.ToAndroid().StrokeJoin = lineJoin.ToAndroid();
		}
Exemplo n.º 19
0
		public Color GetColor(Pen widget)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 20
0
		public PenLineCap GetLineCap(Pen widget)
		{
			return widget.ToAndroid().StrokeCap.ToEto();
		}
Exemplo n.º 21
0
		public float GetThickness(Pen widget)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 22
0
		public void SetLineCap(Pen widget, PenLineCap lineCap)
		{
			var pen = widget.ToAndroid();
			pen.StrokeCap = lineCap.ToSD();
			SetDashStyle(widget, widget.DashStyle);
		}
Exemplo n.º 23
0
		public PenLineJoin GetLineJoin(Pen widget)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 24
0
		public float GetMiterLimit(Pen widget)
		{
			return widget.ToAndroid().StrokeMiter;
		}
Exemplo n.º 25
0
		public PenLineCap GetLineCap(Pen widget)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 26
0
		public void SetMiterLimit(Pen widget, float miterLimit)
		{
			widget.ToAndroid().StrokeMiter = miterLimit;
		}
Exemplo n.º 27
0
		public float GetMiterLimit(Pen widget)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 28
0
		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();
			}
		}
Exemplo n.º 29
0
		public void SetDashStyle(Pen widget, DashStyle dashStyle)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 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);
     }
 }