Esempio n. 1
0
        private void LoadSettings()
        {
            _settings = PushToTalk.Properties.Settings.Default;
            _settings.Reload();

            // Read settings
            _key = _settings.DefaultKey;
            String message = _lookup.GetMessage(_key);

            lblDirections.Content = "Current Key: ";
            lblKey.Content        = message;

            _keyDownVolumeLevel = (float)_settings.VolumeLevelOnKeyDown;
            _volumeSlider.Value = _settings.VolumeLevelOnKeyDown * 100.0;
            Console.WriteLine("Loaded volume settings. Volume=" + _settings.VolumeLevelOnKeyDown);

            // Apply minimizetotray if applicable
            if (_settings.MinimizeToTray)
            {
                _minimizeCheckBox.IsChecked = true;
                MinimizeToTray.Enable();
            }
            else
            {
                _minimizeCheckBox.IsChecked = false;
                MinimizeToTray.Disable();
            }
        }
Esempio n. 2
0
 private void UnmuteMic()
 {
     foreach (MMDevice mic in _microphones)
     {
         mic.AudioEndpointVolume.Mute = false;
     }
     Console.WriteLine("Unmuting Microphones");
     MinimizeToTray.ChangeIcon(_unmuteIcon);
 }
Esempio n. 3
0
        private void _minimizeCheckBox_Checked(object sender, RoutedEventArgs e)
        {
            // Disable minimizing to task tray if desired
            if (_minimizeCheckBox.IsChecked == true)
            {
                MinimizeToTray.Enable();
            }
            else
            {
                MinimizeToTray.Disable();
            }

            SaveSettings();
        }
Esempio n. 4
0
        public MainWindow()
        {
            InitializeComponent();

            _interceptor.Initialize();
            _interceptor.AddCallback(OnKeyAction);

            // Get the active microphone and speakers
            MMDeviceEnumerator deviceEnumerator = new MMDeviceEnumerator();
            MMDeviceCollection micList          = deviceEnumerator.EnumerateAudioEndPoints(EDataFlow.eCapture, EDeviceState.DEVICE_STATE_ACTIVE);
            MMDeviceCollection speakerList      = deviceEnumerator.EnumerateAudioEndPoints(EDataFlow.eRender, EDeviceState.DEVICE_STATE_ACTIVE);

            String defaultId = deviceEnumerator.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia).ID;

            // ?? TODO: Add support for selecting applications that when their audio is above a certain level, turn down the audio of other applications.
            //DevicePeriod dp = _activeSpeaker.DevicePeriod;
            //Console.WriteLine(dp.DefaultPeriod);
            //Console.WriteLine(dp.MinimumPeriod);



            for (int i = 0; i < micList.Count; i++)
            {
                MMDevice mic = micList[i];
                _microphones.Add(mic);
                Console.WriteLine("Found microphone: " + mic.FriendlyName + " " + mic.ID);
            }

            for (int i = 0; i < speakerList.Count; i++)
            {
                MMDevice speakerDevice = speakerList[i];
                Speaker  speaker       = new Speaker(speakerDevice, speakerDevice.AudioEndpointVolume.VolumeRange, speakerDevice.AudioEndpointVolume.MasterVolumeLevel);
                _speakers.Add(speaker);
                Console.WriteLine("Found speaker: " + speaker.FriendlyName + " " + speaker.ID);

                if (speaker.ID == defaultId)
                {
                    _activeSpeaker = speaker;
                }
            }

            MinimizeToTray.Initialize(this, _muteIcon);
        }