Exemplo n.º 1
0
        private void ShowZoomInfo()
        {
            _timer.Stop();
            TimeUnit timeUnit = TimeUnitHelpers.GetFloorTimeUnit(SegmentSize);
            double   segmentSizeInTimeUnits = SegmentSize / (double)timeUnit.GetTimeUnitDuration();

            ZoomInfoLabel.Content    = $"Segment size: {SegmentSize} ({segmentSizeInTimeUnits, 0:0.##}{timeUnit.GetTimeUnitAsString()})";
            ZoomInfoPanel.Visibility = Visibility.Visible;
            _timer.Start();
        }
Exemplo n.º 2
0
        private void SetLabelIntervalParameters()
        {
            long segmentSize = SegmentSize.DisplayedValue;
            long minLabelIntervalDuration = segmentSize * MinLabelIntervalWidthInPixels;

            (double Value, TimeUnit Unit)minIntervalDurationInUnits = TimeUnitHelpers.ConvertTicksToTime(minLabelIntervalDuration);
            if (!TimeUnitFactors.TryGetBestTimeFactor(minIntervalDurationInUnits.Value, minIntervalDurationInUnits.Unit, out double factor))
            {
                return;
            }

            LabelIntervalWidth    = factor * MinLabelIntervalWidthInPixels / minIntervalDurationInUnits.Value;
            LabelIntervalDuration = (long)factor * minIntervalDurationInUnits.Unit.GetTimeUnitDuration();
            LabelIntervalUnit     = TimeUnitHelpers.GetFloorTimeUnit(LabelIntervalDuration);
        }
        public void FloorTimeUnitIsCorrect()
        {
            Assert.Equal(TimeUnit.CpuTick, TimeUnitHelpers.GetFloorTimeUnit(Durations.CpuTick));
            Assert.Equal(TimeUnit.CpuTick, TimeUnitHelpers.GetFloorTimeUnit(Durations.CpuTick * 9));

            Assert.Equal(TimeUnit.Microsecond, TimeUnitHelpers.GetFloorTimeUnit(Durations.Microsecond));

            Assert.Equal(TimeUnit.Second, TimeUnitHelpers.GetFloorTimeUnit(Durations.Second + 1));
            Assert.Equal(TimeUnit.Second, TimeUnitHelpers.GetFloorTimeUnit(Durations.Second));

            Assert.Equal(TimeUnit.Minute, TimeUnitHelpers.GetFloorTimeUnit(Durations.Minute + 1));
            Assert.Equal(TimeUnit.Minute, TimeUnitHelpers.GetFloorTimeUnit(Durations.Minute));

            Assert.Equal(TimeUnit.Hour, TimeUnitHelpers.GetFloorTimeUnit(Durations.Hour + 1));
            Assert.Equal(TimeUnit.Hour, TimeUnitHelpers.GetFloorTimeUnit(Durations.Hour));
            Assert.Equal(TimeUnit.Hour, TimeUnitHelpers.GetFloorTimeUnit(Durations.Hour * 1000));
        }