예제 #1
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;
        }
예제 #2
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;
		}