protected virtual void OnAxisChanged(ViewportAxis oldValue, ViewportAxis newValue)
 {
     RaiseEvent(new RoutedPropertyChangedEventArgs <ViewportAxis>(oldValue, newValue)
     {
         RoutedEvent = AxisChangedEvent
     });
 }
Пример #2
0
        protected static Interval ToViewInterval(ViewportAxis axis)
        {
            var v = axis.View;
            var s = v.Start;
            var e = v.End;

            return(new Interval(Math.Min(s, e), Math.Max(s, e)));
        }
Пример #3
0
        public override IEnumerable <Tuple <double, string> > GetMarks(ViewportAxis axis)
        {
            var interval = ToViewInterval(axis);

            foreach (var index in _indexes)
            {
                if (interval.Start <= index.Item1 && interval.End >= index.Item1)
                {
                    yield return(new Tuple <double, string>(ToClient(axis, index.Item1), index.Item2));
                }
            }
        }
Пример #4
0
        public override void IterateMajorGrid(ViewportAxis axis, Action <double> action)
        {
            var interval = ToViewInterval(axis);

            foreach (var index in _indexes)
            {
                if (interval.Start <= index.Item1 && interval.End >= index.Item1)
                {
                    action.Invoke(ToClient(axis, index.Item1));
                }
            }
        }
Пример #5
0
        public override void IterateMajorGrid(ViewportAxis axis, Action <double> action)
        {
            if (axis == null)
            {
                return;
            }

            var interval = ToViewInterval(axis);

            var majorStep = Math.Abs(ToValue(axis, MinMajorGridStep) - ToValue(axis, 0));

            IterateGrid(axis, interval, majorStep, action);
        }
Пример #6
0
        private void IterateGrid(ViewportAxis axis, Interval interval, double mstep, Action <double> action)
        {
            var mstart = interval.Start;

            var pow = Math.Floor(Math.Log10(mstep)); //степень шага

            mstep = Round(mstep, pow);

            mstart = Math.Ceiling(mstart / mstep) * mstep;
            for (var i = mstart; i <= interval.End; i += mstep)
            {
                action.Invoke(ToClient(axis, i));
            }
        }
Пример #7
0
        public override void IterateMinorGrid(ViewportAxis axis, Action <double> minorGridAction)
        {
            var interval = ToViewInterval(axis);

            var next = -MathHelper.RoundLogMax(LongLogEps);// first;
            var prev = 0.0;

            while (next >= interval.Start) //обходим отрицательные значения в логарифмической части
            {
                if (ToClient(axis, prev) - MinStep >= ToClient(axis, next))
                {
                    prev = next;
                }
                for (int i = 2; i < 10; i++)
                {
                    minorGridAction.Invoke(ToClient(axis, next * i));
                }
                next *= 10;
            }

            if (LongLogEps > interval.Start)
            {
                next = MathHelper.RoundLogMax(LongLogEps);
            }
            else
            {
                next = MathHelper.RoundLogMax(interval.Start);
            }
            prev = 0.0;
            while (next <= interval.End) //Обходим положительные значения в логарифмической части
            {
                for (int i = 2; i < 10; i++)
                {
                    minorGridAction.Invoke(ToClient(axis, next * i));
                }
                if (ToClient(axis, prev) + MinStep <= ToClient(axis, next))
                {
                    prev = next;
                }
                next *= 10;
            }
        }
Пример #8
0
        public override IEnumerable <Tuple <double, string> > GetMarks(ViewportAxis axis)
        {
            var interval = ToViewInterval(axis);

            var next = -MathHelper.RoundLogMax(LongLogEps);// first;
            var prev = 0.0;

            while (next >= interval.Start) //обходим отрицательные значения в логарифмической части
            {
                if (ToClient(axis, prev) - MinStep >= ToClient(axis, next))
                {
                    yield return(new Tuple <double, string>(ToClient(axis, next), next.ToString()));

                    prev = next;
                }
                next *= 10;
            }

            if (interval.Start < 0)
            {
                yield return(new Tuple <double, string>(ToClient(axis, 0), 0.ToString())); //Добавляем ноль(линейная часть)
            }
            if (LongLogEps > interval.Start)
            {
                next = MathHelper.RoundLogMax(LongLogEps);
            }
            else
            {
                next = MathHelper.RoundLogMax(interval.Start);
            }
            prev = 0.0;
            while (next <= interval.End) //Обходим положительные значения в логарифмической части
            {
                if (ToClient(axis, prev) + MinStep <= ToClient(axis, next))
                {
                    yield return(new Tuple <double, string>(ToClient(axis, next), next.ToString()));

                    prev = next;
                }
                next *= 10;
            }
        }
Пример #9
0
        public override void IterateMajorGrid(ViewportAxis axis, Action <double> action)
        {
            var interval = ToViewInterval(axis);

            var next = MathHelper.RoundLogMax(interval.Start);

            if (next < double.Epsilon)
            {
                next = double.Epsilon;
            }

            do
            {
                var nextClient = ToClient(axis, next);

                action.Invoke(nextClient);

                next *= 10;
            } while (next <= interval.End);
        }
Пример #10
0
        public override IEnumerable <Tuple <double, string> > GetMarks(ViewportAxis axis)
        {
            var interval = ToViewInterval(axis);

            var first = MathHelper.RoundLogMax(interval.Start);
            var next  = first;

            if (next < double.Epsilon)
            {
                next = double.Epsilon;
            }

            do
            {
                var nextClient = ToClient(axis, next);

                yield return(new Tuple <double, string>(nextClient, next.ToString(System.Globalization.CultureInfo.CurrentUICulture)));

                next *= 10;
            } while (next <= interval.End);
        }
Пример #11
0
        public override void IterateMajorGrid(ViewportAxis axis, Action <double> action)
        {
            var interval = ToViewInterval(axis);

            var next = -MathHelper.RoundLogMax(LongLogEps);// first;
            var prev = 0.0;

            while (next >= interval.Start) //обходим отрицательные значения в логарифмической части
            {
                if (ToClient(axis, prev) - MinStep >= ToClient(axis, next))
                {
                    action.Invoke(ToClient(axis, next));
                    prev = next;
                }
                next *= 10;
            }

            if (interval.Start < 0)
            {
                action.Invoke(ToClient(axis, 0));                     //Добавляем ноль(линейная часть)
            }
            if (LongLogEps > interval.Start)
            {
                next = MathHelper.RoundLogMax(LongLogEps);
            }
            else
            {
                next = MathHelper.RoundLogMax(interval.Start);
            }
            prev = 0.0;
            while (next <= interval.End) //Обходим положительные значения в логарифмической части
            {
                if (ToClient(axis, prev) + MinStep <= ToClient(axis, next))
                {
                    action.Invoke(ToClient(axis, next));
                    prev = next;
                }
                next *= 10;
            }
        }
Пример #12
0
        public override IEnumerable <Tuple <double, string> > GetMarks(ViewportAxis axis)
        {
            if (axis == null)
            {
                yield break;
            }

            var interval = ToViewInterval(axis);

            var majorStep = Math.Abs(ToValue(axis, MinMajorGridStep) - ToValue(axis, 0));
            var pow       = Math.Floor(Math.Log10(majorStep));

            majorStep = Round(majorStep, pow);

            var start = interval.Start;

            start = Math.Ceiling(start / majorStep) * majorStep;
            if (pow < -15)
            {
                pow = -15;
            }
            if (pow < 0)
            {
                start = Math.Round(start, -(int)pow);
            }

            var minorStep = Math.Abs(ToValue(axis, MinStep) - ToValue(axis, 0));

            if (minorStep <= double.Epsilon)
            {
                yield break;
            }

            foreach (var m in IterateMarks(axis, interval, minorStep, start))
            {
                yield return(m);
            }
        }
Пример #13
0
        protected override IEnumerable <Tuple <double, string> > IterateMarks(ViewportAxis axis, Interval interval, double mstep, double start)
        {
            var pow = Math.Floor(Math.Log10(mstep)); //степень шага

            mstep = Round(mstep, pow);

            if (pow < -15)
            {
                pow = -15;
            }

            for (var i = start; i < interval.End; i += mstep)
            {
                var iRound = pow < 0 ? Math.Round(i, -(int)pow) : i;
                yield return(new Tuple <double, string>(ToClient(axis, iRound), DateTime.FromOADate(iRound).ToString("yyyy/MM/dd HH:mm:ss")));
            }

            for (var i = start - mstep; i > interval.Start; i -= mstep)
            {
                var iRound = pow < 0 ? Math.Round(i, -(int)pow) : i;
                yield return(new Tuple <double, string>(ToClient(axis, iRound), DateTime.FromOADate(iRound).ToString("yyyy/MM/dd HH:mm:ss")));
            }
        }
Пример #14
0
        protected virtual IEnumerable <Tuple <double, string> > IterateMarks(ViewportAxis axis, Interval interval, double mstep, double start)
        {
            var pow = Math.Floor(Math.Log10(mstep)); //степень шага

            mstep = Round(mstep, pow);

            if (pow < -15)
            {
                pow = -15;
            }

            for (var i = start; i < interval.End; i += mstep)
            {
                var iRound = pow < 0 ? Math.Round(i, -(int)pow) : i;
                yield return(new Tuple <double, string>(ToClient(axis, iRound), iRound.ToString(@"G5")));
            }

            for (var i = start - mstep; i > interval.Start; i -= mstep)
            {
                var iRound = pow < 0 ? Math.Round(i, -(int)pow) : i;
                yield return(new Tuple <double, string>(ToClient(axis, iRound), iRound.ToString(@"G5")));
            }
        }
Пример #15
0
        public override void IterateMinorGrid(ViewportAxis axis, Action <double> minorGridAction)
        {
            var interval = ToViewInterval(axis);

            var first = MathHelper.RoundLogMax(interval.Start);
            var next  = first;

            if (next < double.Epsilon)
            {
                next = double.Epsilon;
            }

            // мелкие линии до первой крупной(ибо она не учитывается)
            var minorStart = MathHelper.RoundLogMin(interval.Start);

            for (int i = 2; i < 10; i++)
            {
                if (minorStart * i > interval.Start)
                {
                    minorGridAction.Invoke(ToClient(axis, minorStart * i));
                }
            }

            do
            {
                for (int i = 2; i < 10; i++)
                {
                    var view = next * i;
                    if (interval.Start < view && view < interval.End)
                    {
                        minorGridAction.Invoke(ToClient(axis, view));
                    }
                }

                next *= 10;
            } while (next <= interval.End);
        }
Пример #16
0
 public abstract IEnumerable <Tuple <double, string> > GetMarks(ViewportAxis axis);
Пример #17
0
 public override void IterateMinorGrid(ViewportAxis axis, Action <double> action)
 {
 }
Пример #18
0
 public abstract void IterateMajorGrid(ViewportAxis axis, Action <double> gridAction);
Пример #19
0
 protected static double ToClient(ViewportAxis axis, double value)
 {
     return(axis.ViewToClient(value));
 }
Пример #20
0
 public void InitalizeHorizontalAxis(ViewportAxis axis, AxisMarkProvider markProvider)
 {
     HorizontalAxis          = axis;
     BottomAxis.MarkProvider = markProvider;
     TopAxis.MarkProvider    = markProvider;
 }
Пример #21
0
 protected static double ToValue(ViewportAxis axis, double value)
 {
     return(axis.ClientToView(value));
 }
Пример #22
0
 public Viewport(ViewportAxis horizontalAxis, ViewportAxis verticalAxis)
 {
     VerticalAxis   = verticalAxis;
     HorizontalAxis = horizontalAxis;
 }
Пример #23
0
 public void InitalizeVerticalAxis(ViewportAxis axis, AxisMarkProvider markProvider)
 {
     VerticalAxis           = axis;
     LeftAxis.MarkProvider  = markProvider;
     RightAxis.MarkProvider = markProvider;
 }