Esempio n. 1
0
        private Cortege2 <double, TimeSpan> CalculateStep(Cortege2 <double, DateTime> start, Point o, Point tip)
        {
            if (Step.HasValue)
            {
                return(Step.Value);
            }
            try
            {
                var len         = Direction == FastAxisDirection.X ? Math.Abs(tip.X - o.X) : Math.Abs(tip.Y - o.Y);
                var numMinSteps = len / minPixelsPerPoint;
                if (numMinSteps < 1)
                {
                    return(new Cortege2 <double, TimeSpan>(0, TimeSpan.Zero));
                }

                if (!IsDateTime)
                {
                    var fractStep = (MaxValue.a - start.a) / numMinSteps;
                    return(new Cortege2 <double, TimeSpan>(NearestCeilingStep(fractStep),
                                                           TimeSpan.MinValue));
                }

                var fractSpan = (MaxValue.b - start.b).TotalMilliseconds / numMinSteps;
                var span      = NearestCeilingTimeSpan(fractSpan);
                return(new Cortege2 <double, TimeSpan>(0, span));
            }
            catch
            {
                return(new Cortege2 <double, TimeSpan>(0, TimeSpan.MaxValue));
            }
        }
Esempio n. 2
0
        private Cortege2 <double, TimeSpan> CalculateStep(Cortege2 <double, DateTime> start, Point o, Point tip)
        {
            if (Step.HasValue)
            {
                return(Step.Value);
            }
            var len         = Direction == FastAxisDirection.X ? Math.Abs(tip.X - o.X) : Math.Abs(tip.Y - o.Y);
            var numMinSteps = len / minPixelsPerPoint;

            if (!IsDateTime)
            {
                var fractStep = (MaxValue.a - start.a) / numMinSteps;
                Math.
            }

            var fractSpan = (MaxValue.b - start.b).TotalSeconds / numMinSteps;

            if (fractSpan < 1)
            {
                return(new Cortege2 <double, TimeSpan>(0, new TimeSpan(0, 0, 0, 0, (int)(fractSpan * 1000))));
            }
            if (fractSpan < 60)
            {
                return(new Cortege2 <double, TimeSpan>(0, new TimeSpan(0, 0, 5 * ((int)fractSpan / 5))));
            }
        }
Esempio n. 3
0
        private string DeriveFormatFromStep(Cortege2 <double, TimeSpan> step)
        {
            if (!string.IsNullOrEmpty(LabelFormat))
            {
                return(LabelFormat);
            }
            if (!IsDateTime)
            {
                var abs = Math.Abs(step.a);
                if (abs > 100)
                {
                    return("f0");
                }
                if (abs > 15)
                {
                    return("f1");
                }
                if (abs > 1)
                {
                    return("f2");
                }
                if (abs > 0.1)
                {
                    return("f3");
                }
                if (abs > 0.01)
                {
                    return("f4");
                }
                return("g");
            }
            if (step.b > new TimeSpan(30, 0, 0, 0))
            {
                return(LongTimeString ? "dd.MM.yyyy" : "dd.MM");
            }

            if (step.b > new TimeSpan(1, 0, 0, 0))
            {
                return(LongTimeString ? "dd.MM HH:mm" : "dd.MM");
            }

            if (step.b > new TimeSpan(0, 8, 0, 0))
            {
                return(LongTimeString ? "dd.MM HH:mm" : "dd HH:mm");
            }

            if (step.b > new TimeSpan(0, 1, 0, 0))
            {
                return(LongTimeString ? "dd HH:mm" : "HH:mm");
            }

            if (step.b > new TimeSpan(0, 0, 0, 5))
            {
                return(LongTimeString ? "HH:mm:ss" : "mm:ss");
            }

            return(LongTimeString ? "mm:ss:ffff" : "ss:ffff");
        }
Esempio n. 4
0
 private string Cortege2String(Cortege2 <double, DateTime> c)
 {
     return(IsDateTime
                ? c.b.ToString("dd.MM.yyyy HH:mm:ss")
                : c.a.ToString("f5"));
 }