/// <summary> /// Constructor. /// </summary> public PollIntervalSlider() { this.IsSnapToTickEnabled = true; this.Minimum = LogScaleConverter.Convert(1000 * 5); this.Maximum = LogScaleConverter.Convert(1000 * 60 * 60 * 24); this.TickPlacement = TickPlacement.BottomRight; this.AutoToolTipPlacement = AutoToolTipPlacement.BottomRight; // Add ticks to the slider. DoubleCollection tickMarks = new DoubleCollection(); tickMarks.Add(LogScaleConverter.Convert(1000 * 5)); // 5 seconds. tickMarks.Add(LogScaleConverter.Convert(1000 * 15)); tickMarks.Add(LogScaleConverter.Convert(1000 * 30)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 3)); // 3 minutes. tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 10)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 30)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 3)); // 3 hours. tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 8)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 12)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 24)); this.Ticks = tickMarks; }
private string FormatToolTip(int value) { value = LogScaleConverter.ConvertBack(value); TimeSpan timeSpan = new TimeSpan(0, 0, value); if (value < 60) { return(timeSpan.ToString("%s") + " " + Properties_Resources.Seconds); } else if (value == 60) { return(timeSpan.ToString("%m") + " " + Properties_Resources.Minute); } else if (value < 60 * 60) { return(timeSpan.ToString("%m") + " " + Properties_Resources.Minutes); } else if (value == 60 * 60) { return(timeSpan.ToString("%h") + " " + Properties_Resources.Hour); } else if (value < 60 * 60 * 24) { return(timeSpan.ToString("%h") + " " + Properties_Resources.Hours); } else { return(timeSpan.ToString("%d") + " " + Properties_Resources.Day); } }
/// <summary> /// Constructor. /// </summary> public PollIntervalSlider(TextBlock sliderLabel) { this.sliderLabel = sliderLabel; this.IsSnapToTickEnabled = true; this.Minimum = LogScaleConverter.Convert(1000 * 5); this.Maximum = LogScaleConverter.Convert(1000 * 60 * 60 * 24); this.TickPlacement = TickPlacement.BottomRight; // Add ticks to the slider. DoubleCollection tickMarks = new DoubleCollection(); tickMarks.Add(LogScaleConverter.Convert(1000 * 5)); // 5 seconds. tickMarks.Add(LogScaleConverter.Convert(1000 * 15)); tickMarks.Add(LogScaleConverter.Convert(1000 * 30)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 3)); // 3 minutes. tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 10)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 30)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 3)); // 3 hours. tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 8)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 12)); tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 24)); this.Ticks = tickMarks; // Show current value in UI. ShowCurrentValue(); }