Beispiel #1
0
        protected WinampTrackBarRenderer(WinampTrackBar trackBar)
        {
            if (trackBar == null)
            {
                throw new Exception("You have to pass the TrackBar object in the constructor!");
            }

            _trackBar = trackBar;
        }
        public HorizontalWinampTrackBarRenderer(WinampTrackBar trackBar) : base(trackBar)
        {
            if (trackBar == null)
            {
                throw new Exception("You have to pass the TrackBar object in the constructor!");
            }

            _trackBar = trackBar;
        }
Beispiel #3
0
        public int CalculateTickCount(WinampTrackBar 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);
        }
Beispiel #4
0
 public int CalculateTotalTickWidth(WinampTrackBar trackBar, int tickCount)
 {
     return((tickCount * trackBar.TickWidth) + ((tickCount - 1) * trackBar.TickSpacing));
 }
Beispiel #5
0
        public Dictionary <int, int> CalculateScaleFieldHeights(WinampTrackBar 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);
        }
Beispiel #6
0
 public int CalculateTotalScaleWidth(WinampTrackBar trackBar, int fieldCount)
 {
     return((fieldCount * trackBar.ScaleFieldWidth) + ((fieldCount - 1) * trackBar.ScaleFieldSpacing));
 }
Beispiel #7
0
        public int CalculateScaleFieldCount(WinampTrackBar 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)));
        }