Exemple #1
0
 void CommonConstructor()
 {
     if (_WaveOutDevices.Count > 0)
     {
         ManualDevice = _WaveOutDevices[0];
     }
 }
 /// <summary>
 /// Returns true if the other WaveOutDevice object is equal to this by content. (not necessarily by reference)
 /// Instead of overriding the Equals -method, I made this to avoid confusion and erroneous comparisons.
 /// </summary>
 /// <param name="another"></param>
 /// <returns></returns>
 public bool ValueEquals(WaveOutDevice another)
 {
     if (another != null)
     {
         return(Name == another.Name);
     }
     return(false);
 }
Exemple #3
0
        private void ComboBoxManual_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (SkipFlaggedEventHandlers)
            {
                return;
            }

            WaveOutDevice dev = comboBoxManual.SelectedItem as WaveOutDevice;

            if (dev != null)
            {
                FormMain.WaveOutPool.SetWaveOutDevice(dev);
                TheProfile.TheWaveOutDevice = dev;
            }

            InvokeChangeMade(new ChangeEventArgs(comboBoxManual));
        }
Exemple #4
0
        public void LoadFromXml(XElement xAudioDevicePool)
        {
            if (xAudioDevicePool != null)
            {
                if (Enum.TryParse(xAudioDevicePool.GetElementValueTrimmed("WaveOutDeviceSource"), out AudioDeviceSource src))
                {
                    WaveOutDeviceSource = src;
                }

                string waveOutName = xAudioDevicePool.GetElementValueTrimmed("WaveOutDeviceName");
                if (String.IsNullOrWhiteSpace(waveOutName))
                {
                    WaveOutDevice device = _WaveOutDevices.Where(d => d.Name == waveOutName).FirstOrDefault();
                    ManualDevice = device ?? _WaveOutDevices.FirstOrDefault();
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Sets the wave out device. WaveOutDeviceSource will be set to Manual.
        /// </summary>
        /// <param name=""></param>
        public void SetWaveOutDevice(WaveOutDevice device)
        {
            if (device == null)
            {
                //throw new Exception("Wave out device cannot be null.");
                // this should not happen anymore (fixed in profile loading)... but since we were not handling this exception, let's just cop out and change device source to windows
                SuppressFlaggedEvents = true;
                WaveOutDeviceSource   = AudioDeviceSource.Windows;
                SuppressFlaggedEvents = false;
                return;
            }

            SuppressFlaggedEvents = true;
            WaveOutDeviceSource   = AudioDeviceSource.Manual;
            SuppressFlaggedEvents = false;
            ManualDevice          = device;
            InvokeWaveOutDeviceChanged(EventArgs.Empty);
        }
Exemple #6
0
        void RefreshManualDeviceCombo()
        {
            WaveOutDevice previouslySelected = (comboBoxManual.SelectedItem as WaveOutDevice);

            SkipFlaggedEventHandlers = true;
            Enabled = false;
            comboBoxManual.DataSource = null;
            comboBoxManual.DataSource = AudioDevicePool.GetWaveOutDevices();
            Enabled = true;

            object matchToPreviouslySelected = null;

            foreach (var item in comboBoxManual.Items)
            {
                if ((item as WaveOutDevice).ValueEquals(previouslySelected))
                {
                    matchToPreviouslySelected = item;
                }
            }

            object matchToCurrentProfile = null;

            foreach (var item in comboBoxManual.Items)
            {
                if ((item as WaveOutDevice).ValueEquals(TheProfile?.TheWaveOutDevice))
                {
                    matchToCurrentProfile = item;
                }
            }

            if (matchToPreviouslySelected != null)
            {
                comboBoxManual.SelectedItem = matchToPreviouslySelected;
            }
            else if (matchToCurrentProfile != null)
            {
                comboBoxManual.SelectedItem = matchToCurrentProfile;
            }
            else if (previouslySelected != null)
            {
                TheProfile.TheWaveOutDevice = previouslySelected;
            }
            SkipFlaggedEventHandlers = false;
        }
Exemple #7
0
        private void ComboBoxDeviceSource_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (SkipFlaggedEventHandlers)
            {
                return;
            }

            TheProfile.WaveOutDeviceSource           = (AudioDeviceSource)comboBoxDeviceSource.SelectedItem;
            FormMain.WaveOutPool.WaveOutDeviceSource = (AudioDeviceSource)comboBoxDeviceSource.SelectedItem;

            SetControlVisibility();

            if (TheProfile.WaveOutDeviceSource == AudioDeviceSource.Manual)
            {
                WaveOutDevice dev = comboBoxManual.SelectedItem as WaveOutDevice;
                if (dev != null)
                {
                    FormMain.WaveOutPool.SetWaveOutDevice(dev);
                    TheProfile.TheWaveOutDevice = dev;
                }
            }

            InvokeChangeMade(new ChangeEventArgs(comboBoxDeviceSource));
        }