Exemplo n.º 1
1
        public MainForm()
        {
            library = Library.Load();
            if (library == null)
            {
                library = new Library();
                library.Save();
            }
            library.LibraryChanged += library_LibraryChanged;

            settings = Settings.Load(SETTINGSPATH);
            if (settings == null)
                settings = new Settings();

            MMDeviceEnumerator enumerator = new MMDeviceEnumerator();
            defaultAudioDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
            this.musicPlayer.OpenCompleted += equalizerSettings_ShouldSet;

            this.equalizerSettings = EqualizerSettings.Load(EQUALIZERPATH);
            if (this.equalizerSettings == null)
            {
                this.equalizerSettings = new EqualizerSettings();
                this.equalizerSettings.Save(EQUALIZERPATH);
            }
            this.equalizerSettings.ValueChanged += equalizerSettings_ShouldSet;

            SetUpGlobalHotkeys();

            InitializeComponent();
        }
Exemplo n.º 2
0
        public MainForm()
        {
            library = Library.Load();
            if (library == null)
            {
                library = new Library();
                library.Save();
            }
            library.Changed += library_LibraryChanged;

            settings = Settings.Load(SettingsPath) ?? new Settings();

            musicPlayer.OpenCompleted += equalizerSettings_ShouldSet;
            musicPlayer.OpenCompleted += musicPlayer_ShouldPlay;
            musicPlayer.DeviceVolume = settings.DeviceVolume;

            equalizerSettings = EqualizerSettings.Load(EqualizerPath);
            if (equalizerSettings == null)
            {
                equalizerSettings = new EqualizerSettings();
                equalizerSettings.Save(EqualizerPath);
            }
            equalizerSettings.ValueChanged += equalizerSettings_ShouldSet;

            SetUpGlobalHotkeys();

            lfmHandler = new LastfmHandler();
            if (settings.ScrobblingEnabled)
                lfmHandler.ResumeSessionAsync();

            InitializeComponent();
            SetControlReferences();
        }
Exemplo n.º 3
0
        public static EqualizerSettings Load(string path)
        {
            Stream stream = null;

            float[] loadedValues = null;
            try
            {
                stream = File.OpenRead(path);
                XmlSerializer serializer = new XmlSerializer(typeof(float[]));
                loadedValues = (float[])serializer.Deserialize(stream);
            }
            catch
            {
                return(null);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
            EqualizerSettings eqSettings = new EqualizerSettings();

            eqSettings.values = loadedValues;
            return(eqSettings);
        }
Exemplo n.º 4
0
        public EqualizerWindow(EqualizerSettings equalizerSettings)
        {
            this.equalizerSettings = equalizerSettings;
            InitializeComponent();

            #region Create slider list
            sliderList = new List <TrackBar>();
            sliderList.Add(trackBar1);
            sliderList.Add(trackBar2);
            sliderList.Add(trackBar3);
            sliderList.Add(trackBar4);
            sliderList.Add(trackBar5);
            sliderList.Add(trackBar6);
            sliderList.Add(trackBar7);
            sliderList.Add(trackBar8);
            sliderList.Add(trackBar9);
            sliderList.Add(trackBar10);
            #endregion

            foreach (TrackBar tb in sliderList)
            {
                tb.Maximum = sliderMax;
                tb.Minimum = sliderMin;
                int index = Int32.Parse((string)tb.Tag);
                tb.Value = EqualizerToSlider(equalizerSettings[index]);
            }

            label1.Focus();
        }
Exemplo n.º 5
0
 public static EqualizerSettings Load(string path)
 {
     Stream stream = null;
     float[] loadedValues = null;
     try
     {
         stream = File.OpenRead(path);
         XmlSerializer serializer = new XmlSerializer(typeof(float[]));
         loadedValues = (float[])serializer.Deserialize(stream);
     }
     catch
     {
         return null;
     }
     finally
     {
         if (stream != null) stream.Close();
     }
     EqualizerSettings eqSettings = new EqualizerSettings();
     eqSettings.values = loadedValues;
     return eqSettings;
 }