コード例 #1
0
        public void SnapToFirstRepeatedZoomSnapPoint()
        {
            Scroller       scroller = null;
            Rectangle      rectangleScrollerContent = null;
            AutoResetEvent scrollerLoadedEvent      = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                rectangleScrollerContent = new Rectangle();
                scroller = new Scroller();

                SetupDefaultUI(scroller, rectangleScrollerContent, scrollerLoadedEvent);
            });

            WaitForEvent("Waiting for Loaded event", scrollerLoadedEvent);

            // Jump to absolute zoom factor, and center the content in the viewport.
            ZoomTo(scroller,
                   zoomFactor: 6.0f,
                   centerPointX: 690.0f,
                   centerPointY: 340.0f,
                   AnimationMode.Disabled,
                   SnapPointsMode.Default);

            // Add zoom repeated snap point with different offset and start.
            RunOnUIThread.Execute(() =>
            {
                RepeatedZoomSnapPoint snapPoint = new RepeatedZoomSnapPoint(
                    offset: 5,
                    interval: 6,
                    start: 1,
                    end: 9);

                scroller.ZoomSnapPoints.Add(snapPoint);
            });

            // Flick with zoom factor velocity to naturally land around factor 1.5.
            ZoomFrom(scroller,
                     zoomFactorVelocity: -5.0f,
                     inertiaDecayRate: 0.6675f,
                     centerPointX: 150.0f,
                     centerPointY: 100.0f,
                     hookViewChanged: false);

            RunOnUIThread.Execute(() =>
            {
                // ZoomFactor expected to have snapped to first instance of repeated snap point: 5.
                // Scroll offsets do not snap and end close to 2850, 1400 for a centered content.
                Verify.IsTrue(Math.Abs(scroller.HorizontalOffset - 2850.0) < 1.0);
                Verify.IsTrue(Math.Abs(scroller.VerticalOffset - 1400.0) < 1.0);
                Verify.AreEqual(5.0f, scroller.ZoomFactor);
            });
        }
 private void BtnMRAddSnapPoint_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         double offset   = Convert.ToDouble(txtMRSnapPointOffset.Text);
         double interval = Convert.ToDouble(txtMRSnapPointInterval.Text);
         double start    = Convert.ToDouble(txtMRSnapPointStart.Text);
         double end      = Convert.ToDouble(txtMRSnapPointEnd.Text);
         RepeatedZoomSnapPoint newSnapPoint = new RepeatedZoomSnapPoint(offset, interval, start, end);
         markupScrollPresenter.ZoomSnapPoints.Add(newSnapPoint);
     }
     catch (Exception ex)
     {
         this.fullLogs.Add(ex.ToString());
         txtExceptionReport.Text = ex.ToString();
     }
 }