private void BtnORAddSnapPoint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double offset   = Convert.ToDouble(txtORSnapPointOffset.Text);
                double interval = Convert.ToDouble(txtORSnapPointInterval.Text);
                double range    = Convert.ToDouble(txtORApplicableRange.Text);
                double start    = Convert.ToDouble(txtORSnapPointStart.Text);
                double end      = Convert.ToDouble(txtORSnapPointEnd.Text);

                ScrollerSnapPointBase newSnapPoint = new ScrollerSnapPointRegular(offset, interval, start, end, range, ScrollerSnapPointAlignment.Near);
                Color fillColor = GetNewColor();
                ScrollerTestHooks.SetSnapPointVisualizationColor(newSnapPoint, fillColor);
                markupScroller.VerticalSnapPoints.Add(newSnapPoint);

                double value = GetFirstRegularSnapPoint(offset, interval, start);

                int minColumn = FillSnapPoint(new List <double>(), start, end, fillColor);
                while (value <= end)
                {
                    FillSnapPoint(new List <double> {
                        value
                    }, Math.Max(start, value - range), Math.Min(end, value + range), fillColor, minColumn);
                    value += interval;
                }
                FixConsolidatedView();
            }
            catch (Exception ex)
            {
                this.fullLogs.Add(ex.ToString());
                txtExceptionReport.Text = ex.ToString();
            }
        }
        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);
                ScrollerSnapPointBase newSnapPoint = new ScrollerSnapPointRegular(offset, interval, start, end, ScrollerSnapPointAlignment.Near);
                Color fillColor = GetNewColor();
                ScrollerTestHooks.SetSnapPointVisualizationColor(newSnapPoint, fillColor);
                markupScroller.VerticalSnapPoints.Add(newSnapPoint);

                double        value  = GetFirstRegularSnapPoint(offset, interval, start);
                List <double> values = new List <double>();

                while (value <= end)
                {
                    values.Add(value);
                    value += interval;
                }

                FillSnapPoint(values, start, end, fillColor);
                FixConsolidatedView();
            }
            catch (Exception ex)
            {
                this.fullLogs.Add(ex.ToString());
                txtExceptionReport.Text = ex.ToString();
            }
        }
        public void OverlappingRegularSnapPointsThrow()
        {
            RunOnUIThread.Execute(() =>
            {
                Scroller scroller = new Scroller();
                ScrollerSnapPointRegular snapPoint1 = new ScrollerSnapPointRegular(offset:  10, interval: 10, start:  10, end: 100, alignment: ScrollerSnapPointAlignment.Near);
                ScrollerSnapPointRegular snapPoint2 = new ScrollerSnapPointRegular(offset:  10, interval: 10, start:  10, end: 100, alignment: ScrollerSnapPointAlignment.Near);
                ScrollerSnapPointRegular snapPoint3 = new ScrollerSnapPointRegular(offset:   0, interval:  2, start:   0, end:  12, alignment: ScrollerSnapPointAlignment.Near);
                ScrollerSnapPointRegular snapPoint4 = new ScrollerSnapPointRegular(offset:   0, interval:  2, start:   0, end:  10, alignment: ScrollerSnapPointAlignment.Near);
                ScrollerSnapPointRegular snapPoint5 = new ScrollerSnapPointRegular(offset: 100, interval:  2, start: 100, end: 200, alignment: ScrollerSnapPointAlignment.Near);

                scroller.VerticalSnapPoints.Add(snapPoint1);
                Verify.Throws <Exception>(() => { scroller.VerticalSnapPoints.Add(snapPoint2); });
                Verify.Throws <Exception>(() => { scroller.VerticalSnapPoints.Add(snapPoint3); });
                scroller.HorizontalSnapPoints.Add(snapPoint4);
                scroller.HorizontalSnapPoints.Add(snapPoint5);
            });
        }
        public void CanAddAndRemoveSnapPointsFromAScroller()
        {
            Scroller scroller = null;
            ScrollerSnapPointBase snapPointBase1 = null;
            ScrollerSnapPointBase snapPointBase2 = null;
            ScrollerSnapPointBase snapPointBase3 = null;
            ScrollerSnapPointBase snapPointBase4 = null;

            RunOnUIThread.Execute(() =>
            {
                scroller       = new Scroller();
                snapPointBase1 = new ScrollerSnapPointIrregular(snapPointValue: 10, alignment: ScrollerSnapPointAlignment.Near);
                snapPointBase2 = new ScrollerSnapPointIrregular(snapPointValue: 10, applicableRange: 3, alignment: ScrollerSnapPointAlignment.Near);
                snapPointBase3 = new ScrollerSnapPointRegular(offset:  10, interval: 10, start:  10, end: 100, alignment: ScrollerSnapPointAlignment.Near);
                snapPointBase4 = new ScrollerSnapPointRegular(offset: 100, interval: 10, start: 100, end: 200, applicableRange: 3, alignment: ScrollerSnapPointAlignment.Near);
                scroller.HorizontalSnapPoints.Add(snapPointBase1);
                scroller.VerticalSnapPoints.Add(snapPointBase1);
                scroller.ZoomSnapPoints.Add(snapPointBase1);
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual <int>(1, scroller.HorizontalSnapPoints.Count);
                Verify.AreEqual <int>(1, scroller.VerticalSnapPoints.Count);
                Verify.AreEqual <int>(1, scroller.ZoomSnapPoints.Count);
                scroller.HorizontalSnapPoints.Add(snapPointBase2);
                scroller.HorizontalSnapPoints.Add(snapPointBase3);
                scroller.HorizontalSnapPoints.Add(snapPointBase4);
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual <int>(4, scroller.HorizontalSnapPoints.Count);
                scroller.HorizontalSnapPoints.Remove(snapPointBase2);
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual <int>(3, scroller.HorizontalSnapPoints.Count);
                scroller.HorizontalSnapPoints.Remove(snapPointBase2);
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual <int>(3, scroller.HorizontalSnapPoints.Count);
                scroller.HorizontalSnapPoints.Clear();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual <int>(0, scroller.HorizontalSnapPoints.Count);
                Verify.AreEqual <int>(1, scroller.VerticalSnapPoints.Count);
                Verify.AreEqual <int>(1, scroller.ZoomSnapPoints.Count);
            });
        }