Ejemplo n.º 1
0
//		RectangleF _viewBox;

		public WmfGraphics (BinaryWriter tw, RectangleF viewBox)
		{
//			_viewBox = viewBox;
			fw = tw;
			_fontMetrics = new WmfGraphicsFontMetrics ();
			SetColor (Colors.Black);			
			_states.Push (_state);
		}
Ejemplo n.º 2
0
		public SvgGraphics (TextWriter tw, RectangleF viewBox)
		{
			_viewBox = viewBox;
			_tw = tw;
			IncludeXmlAndDoctype = true;
			SetColor (Colors.Black);			
			_states.Push (_state);
		}
Ejemplo n.º 3
0
		public static RectangleF Union (RectangleF a, RectangleF b)
		{
			var left = Math.Min (a.Left, b.Left);
			var top = Math.Min (a.Top, b.Top);
			return new RectangleF (left,
				top,
				Math.Max (a.Right, b.Right) - left,
				Math.Max (a.Bottom, b.Bottom) - top);
		}
Ejemplo n.º 4
0
		void Initialize ()
		{
			var bounds = Bounds;

			visibleArea = bounds.ToRectangleF ();

			canvas = new Canvas (bounds.ToRectangleF ()) {
				AutoresizingMask = UIViewAutoresizing.FlexibleDimensions,
			};

			BackgroundColor = Colors.White;

			scrollContent = new Canvas (new RectangleF (PointF.Empty, contentSize)) {
				Opaque = false,
				BackgroundColor = UIColor.Clear.GetColor (),
			};
			scrollContent.TouchBegan += HandleTouchBegan;
			scrollContent.TouchMoved += HandleTouchMoved;
			scrollContent.TouchEnded += HandleTouchEnded;
			scrollContent.TouchCancelled += HandleTouchCancelled;

			scroll = new Scroller (bounds) {
				AutoresizingMask = UIViewAutoresizing.FlexibleDimensions,
				MinimumZoomScale = 1/4.0f,
				MaximumZoomScale = 4.0f,
				AlwaysBounceVertical = true,
				AlwaysBounceHorizontal = true,
				BackgroundColor = UIColor.Clear,
			};

			scroll.AddSubview (scrollContent);
			scroll.ContentSize = contentSize.ToSizeF ();

			TouchEnabled = true;
			TouchDelayed = true;

			scroll.ViewForZoomingInScrollView = delegate {
				return scrollContent;
			};
			scroll.ZoomingEnded += delegate {
			};
			scroll.Scrolled += HandleScrolled;

			AddSubviews (canvas, scroll);

			//
			// Prime the visible area
			//
			HandleScrolled (scroll, EventArgs.Empty);

			//
			// Ready to Draw
			//
			SetVisibleArea ();
			canvas.Drawing += HandleDrawing;
		}
Ejemplo n.º 5
0
		public CanvasDrawingEventArgs (IGraphics graphics, RectangleF visibleArea)
		{
			Graphics = graphics;
			VisibleArea = visibleArea;
		}
Ejemplo n.º 6
0
		public static void DrawOval(this IGraphics g, RectangleF r, float w)
		{
			g.DrawOval (r.Left, r.Top, r.Width, r.Height, w);
		}
Ejemplo n.º 7
0
		public static List<RectangleF> GetIntersections (this List<RectangleF> boxes, RectangleF box)
		{
			var r = new List<RectangleF> ();
			foreach (var b in boxes) {
				if (b.IntersectsWith (box)) {
					r.Add (b);
				}
			}
			return r;
		}
Ejemplo n.º 8
0
		public static void FillRoundedRect(this IGraphics g, RectangleF r, float radius)
		{
			g.FillRoundedRect (r.Left, r.Top, r.Width, r.Height, radius);
		}
Ejemplo n.º 9
0
		public static void FillOval(this IGraphics g, RectangleF r)
		{
			g.FillOval (r.Left, r.Top, r.Width, r.Height);
		}
Ejemplo n.º 10
0
		public View (RectangleF frame)
			: base (frame.ToRectangleF ())
		{
		}
Ejemplo n.º 11
0
		public static void DrawRoundedRect(this IGraphics g, RectangleF r, float radius, float w)
		{
			g.DrawRoundedRect (r.Left, r.Top, r.Width, r.Height, radius, w);
		}
Ejemplo n.º 12
0
		public void Invalidate (RectangleF frame)
		{
			SetNeedsDisplayInRect (frame.ToRectangleF ());
		}
Ejemplo n.º 13
0
		public bool IntersectsWith(RectangleF rect)
		{
			return !((Left >= rect.Right) || (Right <= rect.Left) ||
			         (Top >= rect.Bottom) || (Bottom <= rect.Top));
		}
Ejemplo n.º 14
0
		public ScrollableCanvas (RectangleF frame)
			: base (frame)
		{
			Initialize ();
		}
Ejemplo n.º 15
0
		public void Invalidate (RectangleF frame)
		{
			canvas.Invalidate ();
		}
Ejemplo n.º 16
0
		public void SetVisibleArea ()
		{
			var s = (float)scroll.ZoomScale;

			var va = scroll.Bounds.ToRectangleF ();
			va.X /= s;
			va.Y /= s;
			va.Width /= s;
			va.Height /= s;

			visibleArea = va;

			canvas.Invalidate ();
		}
Ejemplo n.º 17
0
        public WmfGraphics (Stream s, RectangleF viewBox) 
			: this(new BinaryWriter (s, System.Text.Encoding.UTF8), viewBox)
		{
		}
Ejemplo n.º 18
0
		public Canvas (RectangleF frame)
			: base (frame)
		{
			Initialize ();
		}
Ejemplo n.º 19
0
		public static void AddBottomRoundedRect (this CGContext c, RectangleF b, float r)
		{
			c.MoveTo (b.Left, b.Top + r);
			c.AddLineToPoint (b.Left, b.Bottom - r);
			
			c.AddArc (b.Left + r, b.Bottom - r, r, (float)(Math.PI), (float)(Math.PI / 2), true);
			
			c.AddLineToPoint (b.Right - r, b.Bottom);
			
			c.AddArc (b.Right - r, b.Bottom - r, r, (float)(-3 * Math.PI / 2), (float)(0), true);
			
			c.AddLineToPoint (b.Right, b.Top);
			
			c.AddLineToPoint (b.Left, b.Top);
		}
Ejemplo n.º 20
0
		public void Invalidate (RectangleF dirtyRect)
		{
			Invalidate (dirtyRect.ToRect ());
		}
Ejemplo n.º 21
0
		public static void DrawString(this IGraphics g, string s, RectangleF p, Font f, LineBreakMode lineBreak, TextAlignment align)
		{
			g.SetFont (f);
			g.DrawString (s, p.Left, p.Top, p.Width, p.Height, lineBreak, align);
		}
Ejemplo n.º 22
0
		string AddGradient (Gradient g, RectangleF bounds)
		{
			var url = "url(#grad" + grads.Count + ")";
			grads.Add (new GradientAndBounds { Gradient = g, Bounds = bounds });
			return url;
		}