Example #1
0
        /// <summary>
        /// Invoked when the user changes profile
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void Profiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            EqualizerProfile profile = SettingsManager.GetEqualizerProfile(Profiles.SelectedItem as string);

            AskToSave();
            SettingsManager.CurrentEqualizerProfile = profile;
        }
Example #2
0
        /// <summary>
        /// Checks if any values has been changed.
        /// </summary>
        /// <param name="profile">The profile to compare to</param>
        /// <returns>True if any values has been changed, otherwise false</returns>
        private bool AnyChanged(EqualizerProfile profile = null)
        {
            if (profile == null)
            {
                profile = SettingsManager.CurrentEqualizerProfile;
            }

            float[] levels = new float[]
            {
                (float)F32.Value / 10f,
                (float)F64.Value / 10f,
                (float)F125.Value / 10f,
                (float)F250.Value / 10f,
                (float)F500.Value / 10f,
                (float)F1K.Value / 10f,
                (float)F2K.Value / 10f,
                (float)F4K.Value / 10f,
                (float)F8K.Value / 10f,
                (float)F16K.Value / 10f,
            };

            for (int i = 0; i < levels.Count(); i++)
            {
                float a = profile.Levels[i];
                float b = levels[i];
                if (Math.Round(a, 2) != Math.Round(b, 2))
                {
                    return(true);
                }
            }

            return(Math.Round(profile.EchoLevel, 2) != Math.Round(Echo.Value, 2));
        }
Example #3
0
        /// <summary>
        /// Checks if any values has been changed.
        /// </summary>
        /// <param name="profile">The profile to compare to</param>
        /// <returns>True if any values has been changed, otherwise false</returns>
        private bool AnyChanged(EqualizerProfile profile = null)
        {
            if (profile == null)
                profile = SettingsManager.CurrentEqualizerProfile;

            float[] levels = new float[]
            {
                (float)F125.Value / 10f,
                (float)F250.Value / 10f,
                (float)F500.Value / 10f,
                (float)F1K.Value / 10f,
                (float)F2K.Value / 10f,
                (float)F4K.Value / 10f,
                (float)F8K.Value / 10f,
                (float)F16K.Value / 10f,
            };

            for (int i = 0; i < levels.Count(); i++)
            {
                float a = profile.Levels[i];
                float b = levels[i];
                if (Math.Round(a, 2) != Math.Round(b, 2)) return true;
            }

            return (Math.Round(profile.EchoLevel, 2) != Math.Round(Echo.Value, 2));
        }
Example #4
0
        /// <summary>
        /// Save the settings
        /// </summary>
        private void Save()
        {
            EqualizerProfile profile = SettingsManager.CurrentEqualizerProfile;

            float[] levels = new float[]
            {
                (float)F32.Value / 10f,
                (float)F64.Value / 10f,
                (float)F125.Value / 10f,
                (float)F250.Value / 10f,
                (float)F500.Value / 10f,
                (float)F1K.Value / 10f,
                (float)F2K.Value / 10f,
                (float)F4K.Value / 10f,
                (float)F8K.Value / 10f,
                (float)F16K.Value / 10f,
            };

            float echo = (float)Echo.Value;

            // create new profile
            if (profile.IsProtected)
            {
                List <string> occupied = new List <string>();
                foreach (EqualizerProfile p in SettingsManager.EqualizerProfiles)
                {
                    occupied.Add(p.Name);
                    if (p.IsProtected)
                    {
                        occupied.Add(U.T("EqualizerProfile" + p.Name));
                    }
                }
                NameDialog dialog = new NameDialog(occupied);
                dialog.ShowDialog();
                if (dialog.DialogResult == true)
                {
                    profile = SettingsManager.CreateEqualizerLevel(U.CleanXMLString(dialog.ProfileName.Text), levels, echo);
                    SettingsManager.EqualizerProfiles.Add(profile);
                    Profiles.Items.Add(profile.Name);
                    SettingsManager.CurrentEqualizerProfile = profile;
                }
            }

            // update profile
            else
            {
                profile.Levels    = levels;
                profile.EchoLevel = echo;
            }

            Refresh();
        }
Example #5
0
        /// <summary>
        /// Invoked when the user clicks "Remove"
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            EqualizerProfile profile      = SettingsManager.CurrentEqualizerProfile;
            string           itemToRemove = Profiles.SelectedItem as string;
            int index = Profiles.Items.IndexOf(itemToRemove) - 1;

            if (index < 0)
            {
                index = 0;
            }
            SettingsManager.EqualizerProfiles.Remove(profile);
            Profiles.SelectedIndex = index;
            Profiles.Items.Remove(itemToRemove);
        }
Example #6
0
        /// <summary>
        /// Invoked when the user clicks "Rename"
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void Rename_Click(object sender, RoutedEventArgs e)
        {
            List <string> occupied = new List <string>();

            foreach (EqualizerProfile p in SettingsManager.EqualizerProfiles)
            {
                occupied.Add(p.Name);
                if (p.IsProtected)
                {
                    occupied.Add(U.T("EqualizerProfile" + p.Name));
                }
            }
            EqualizerProfile profile = SettingsManager.CurrentEqualizerProfile;
            NameDialog       dialog  = new NameDialog(occupied, profile.Name);

            dialog.ShowDialog();
            if (dialog.DialogResult == true)
            {
                string oldName = profile.Name;
                string newName = U.CleanXMLString(dialog.ProfileName.Text);

                for (int i = 0; i < Profiles.Items.Count; i++)
                {
                    if (Profiles.Items[i] as string == oldName)
                    {
                        Profiles.Items[i] = newName;
                    }
                }

                foreach (EqualizerProfile p in SettingsManager.EqualizerProfiles)
                {
                    if (p.Name == oldName)
                    {
                        p.Name = newName;
                    }
                }

                profile.Name = newName;
                SettingsManager.CurrentEqualizerProfile = profile;
            }
        }
Example #7
0
        /// <summary>
        /// Invoked when the user clicks "New"
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void New_Click(object sender, RoutedEventArgs e)
        {
            List <string> occupied = new List <string>();

            foreach (EqualizerProfile p in SettingsManager.EqualizerProfiles)
            {
                occupied.Add(p.Name);
                if (p.IsProtected)
                {
                    occupied.Add(U.T("EqualizerProfile" + p.Name));
                }
            }
            NameDialog dialog = new NameDialog(occupied);

            dialog.ShowDialog();
            if (dialog.DialogResult == true)
            {
                EqualizerProfile profile = SettingsManager.CreateEqualizerLevel(U.CleanXMLString(dialog.ProfileName.Text), new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0);
                SettingsManager.EqualizerProfiles.Add(profile);
                Profiles.Items.Add(profile.Name);
                AskToSave();
                SettingsManager.CurrentEqualizerProfile = profile;
            }
        }