protected SliderTrackBarRenderer(SliderTrackBar trackBar) { if (trackBar == null) { throw new Exception("You have to pass the TrackBar object in the constructor!"); } _trackBar = trackBar; }
public HorizontalSliderTrackBarRenderer(SliderTrackBar trackBar) : base(trackBar) { if (trackBar == null) { throw new Exception("You have to pass the TrackBar object in the constructor!"); } _trackBar = trackBar; }
public int CalculateTickCount(SliderTrackBar trackBar) { int width = trackBar.Orientation == Orientation.Horizontal ? trackBar.Width : trackBar.Height; int tickCount = (int)Math.Floor(((double)width + (double)trackBar.TickSpacing) / ((double)trackBar.TickWidth + (double)trackBar.TickSpacing)); if (trackBar.TickEmphasizeMinMaxAndZero && tickCount % 2 != 0) { tickCount -= 1; } return(tickCount); }
public int CalculateTotalTickWidth(SliderTrackBar trackBar, int tickCount) { return((tickCount * trackBar.TickWidth) + ((tickCount - 1) * trackBar.TickSpacing)); }
public Dictionary <int, int> CalculateScaleFieldHeights(SliderTrackBar trackBar, int fieldCount) { Dictionary <int, int> heightList = new Dictionary <int, int>(); if (fieldCount > 0) { double stepWidth; if (trackBar.Maximum >= trackBar.Minimum) { //Normal if ((trackBar.Maximum >= 0 && trackBar.Minimum >= 0) || (trackBar.Maximum <= 0 && trackBar.Minimum <= 0)) { stepWidth = 100 / ((double)fieldCount - 1); for (int i = 0; i < fieldCount; i++) { double stepValue = i * stepWidth; int absoluteStepValue = (int)Math.Abs(stepValue); double fraction = (double)absoluteStepValue / 100; double height = (fraction * ((double)trackBar.ScaleFieldMaxHeight - 2)) + 2; heightList.Add(i, (int)height); } } else { stepWidth = ((double)trackBar.Maximum - (double)trackBar.Minimum) / ((double)fieldCount - 1); for (int i = 0; i < fieldCount; i++) { double stepValue = (double)trackBar.Minimum + i * stepWidth; int absoluteStepValue = (int)Math.Abs(stepValue); double fraction; if (trackBar.ScaleFieldEqualizeHeights) { if (stepValue < 0) { fraction = (double)absoluteStepValue / (double)Math.Abs(trackBar.Minimum); } else { fraction = (double)absoluteStepValue / (double)Math.Abs(trackBar.Maximum); } } else { fraction = (double)absoluteStepValue / (double)Math.Max(Math.Abs(trackBar.Maximum), Math.Abs(trackBar.Minimum)); } double height = (fraction * ((double)trackBar.ScaleFieldMaxHeight - 2)) + 2; heightList.Add(i, (int)height); } } } else { //Turn that thing around... if ((trackBar.Maximum >= 0 && trackBar.Minimum >= 0) || (trackBar.Maximum <= 0 && trackBar.Minimum <= 0)) { stepWidth = 100 / ((double)fieldCount - 1); for (int i = 0; i < fieldCount; i++) { double stepValue = 100 - i * stepWidth; int absoluteStepValue = (int)Math.Abs(stepValue); double fraction = (double)absoluteStepValue / 100; double height = (fraction * ((double)trackBar.ScaleFieldMaxHeight - 2)) + 2; heightList.Add(i, (int)height); } } else { stepWidth = ((double)trackBar.Minimum - (double)trackBar.Maximum) / ((double)fieldCount - 1); for (int i = 0; i < fieldCount; i++) { double stepValue = (double)trackBar.Minimum - i * stepWidth; int absoluteStepValue = (int)Math.Abs(stepValue); double fraction; if (trackBar.ScaleFieldEqualizeHeights) { if (stepValue < 0) { fraction = (double)absoluteStepValue / (double)Math.Abs(trackBar.Maximum); } else { fraction = (double)absoluteStepValue / (double)Math.Abs(trackBar.Minimum); } } else { fraction = (double)absoluteStepValue / (double)Math.Max(Math.Abs(trackBar.Maximum), Math.Abs(trackBar.Minimum)); } double height = (fraction * ((double)trackBar.ScaleFieldMaxHeight - 2)) + 2; heightList.Add(i, (int)height); } } } } return(heightList); }
public int CalculateTotalScaleWidth(SliderTrackBar trackBar, int fieldCount) { return((fieldCount * trackBar.ScaleFieldWidth) + ((fieldCount - 1) * trackBar.ScaleFieldSpacing)); }
public int CalculateScaleFieldCount(SliderTrackBar trackBar) { int width = trackBar.Orientation == Orientation.Horizontal ? trackBar.Width : trackBar.Height; return((int)Math.Floor(((double)width + (double)trackBar.ScaleFieldSpacing) / ((double)trackBar.ScaleFieldWidth + (double)trackBar.ScaleFieldSpacing))); }