Example #1
0
        public void DrawValueLabel(double value)
        {
            if (Maximum - Minimum <= 0)
            {
                return;
            }

            Label nLabel = new Label();

            nLabel.Content             = Math.Round(LinExpConvert.ConvertBack(value, Minimum, Maximum, true, false), DecimalPlaces).ToString();
            nLabel.FontSize            = 8;
            nLabel.HorizontalAlignment = HorizontalAlignment.Stretch;
            nLabel.VerticalAlignment   = VerticalAlignment.Bottom;
            nLabel.Foreground          = (SolidColorBrush)Application.Current.Resources["Text"];
            nLabel.Tag = "ValueLabel";
            nLabel.VerticalContentAlignment = VerticalAlignment.Center;
            nLabel.Padding = new Thickness(0);

            Slider s    = (Slider)FindName("VSlider");
            double newY = (value / (Maximum - Minimum)) * (s.ActualHeight - 20) - (s.ActualHeight - 20) * (Minimum / (Maximum - Minimum)) + 10; //+5 to account for internal padding in the slider

            newY -= (nLabel.FontSize + nLabel.Padding.Bottom + nLabel.Padding.Top) / 2;                                                         //This should work to calculate the height of the element
            //Console.WriteLine("Creating value label @" + newY + " //Value=" + LinToExp(value).ToString());

            nLabel.Margin = new Thickness(0, 0, 0, newY);
            Grid g = (Grid)FindName("SliderGrid");

            Grid.SetRow(nLabel, 0);
            Grid.SetColumn(nLabel, 2);

            g.Children.Add(nLabel);
        }
Example #2
0
        private double CalculateBellEQGain(EQ.Band band, double x)
        {
            double freq = LinExpConvert.Convert(band.Freq, band.Freq.Min, band.Freq.Max);
            double gain = LinExpConvert.Convert(band.Gain, band.Gain.Min, band.Gain.Max);
            double q    = band.Q;//LinExpConvert.Convert(band.Q, band.Q.Min, band.Q.Max);

            return(gain * Math.Exp(-((x - freq) * (x - freq)) / (2 * (W_FACTOR / q) * (W_FACTOR / q))));
        }
Example #3
0
        private double CalculateFilterEQGain(EQ.Band band, double x)
        {
            double freq = LinExpConvert.Convert(band.Freq, band.Freq.Min, band.Freq.Max);
            double gain = LinExpConvert.Convert(band.Gain, band.Gain.Min, band.Gain.Max);
            double q    = band.Q;// LinExpConvert.Convert(band.Q, band.Q.Min, band.Q.Max);

            return(-Math.Exp(-(x - freq) / (1.5 * W_FACTOR)));
        }
Example #4
0
        private void Ellipse_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouseDown)
            {
                Point newMousePosition = GetMousePos();                   // e.GetPosition((Ellipse)sender); This is better

                double dY = previousMousePosition.Y - newMousePosition.Y; //(previousMousePosition.Y - newMousePosition.Y);

                if (newMousePosition.Y >= System.Windows.SystemParameters.PrimaryScreenHeight - 1)
                {
                    int x = (int)newMousePosition.X;
                    int y = 0;
                    SetCursorPos(x, y);
                    previousMousePosition.Y = -1;
                }
                else if (newMousePosition.Y <= 1)
                {
                    int x = (int)newMousePosition.X;
                    int y = (int)System.Windows.SystemParameters.PrimaryScreenHeight;
                    SetCursorPos(x, y);
                    previousMousePosition.Y = System.Windows.SystemParameters.PrimaryScreenHeight + 1;
                }

                if (Math.Abs(dY) > mouseMoveThreshold)
                {
                    double aval = Math.Abs(Value);
                    //Value += Math.Sign(dY) * Step * SettingsManager.Settings.KnobSensistivity;
                    //Conver to linear space before adding the change to create the exponential response
                    double nVal = Value;
                    if (Exponential)
                    {
                        nVal = LinExpConvert.Convert(nVal, Minimum, Maximum);
                    }
                    nVal += Math.Sign(dY) * Step * SettingsManager.Settings.KnobSensistivity;
                    if (Exponential)
                    {
                        nVal = LinExpConvert.ConvertBack(Math.Clamp(nVal, Minimum, Maximum), Minimum, Maximum);
                    }

                    if (double.IsNaN(nVal))
                    {
                        nVal = 0;
                    }

                    SetCurrentValue(ValueProperty, nVal);
                    previousMousePosition = newMousePosition;
                }
            }
        }
Example #5
0
        private void Ellipse_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            double d = e.Delta / 120; // Mouse wheel 1 click (120 delta) = 1 step

            d *= 2;                   //Just make it a bit more sensitive
            double nVal = Value;

            if (Exponential)
            {
                nVal = LinExpConvert.Convert(nVal, Minimum, Maximum);
            }
            nVal += Math.Sign(d) * Step * SettingsManager.Settings.KnobSensistivity;
            if (Exponential)
            {
                nVal = LinExpConvert.ConvertBack(Math.Clamp(nVal, Minimum, Maximum), Minimum, Maximum);
            }
            SetCurrentValue(ValueProperty, nVal);
        }