Example #1
0
        private void RefreshRecordingDropDownButton()
        {
            if (SelectedRecordingDevice == null)
            {
                btnSetRecordingDefault.Enabled = false;
                return;
            }

            if (SelectedRecordingDevice.ID == AudioDeviceManager.DefaultRecordingDevice.ID)
            {
                mnuSetRecordingDefault.CheckState = CheckState.Checked;
            }
            else
            {
                mnuSetRecordingDefault.CheckState = CheckState.Unchecked;
            }

            if (SelectedRecordingDevice.ID == AudioDeviceManager.DefaultRecordingCommDevice.ID)
            {
                mnuSetRecordingCommunicationDefault.CheckState = CheckState.Checked;
            }
            else
            {
                mnuSetRecordingCommunicationDefault.CheckState = CheckState.Unchecked;
            }

            if (FavouriteDeviceManager.IsFavouriteDevice(SelectedRecordingDevice.ID))
            {
                mnuFavouriteRecordingDevice.CheckState = CheckState.Checked;
            }
            else
            {
                mnuFavouriteRecordingDevice.CheckState = CheckState.Unchecked;
            }

            if (ConfigurationSettings.StartupRecordingDeviceID == SelectedRecordingDevice.ID)
            {
                mnuSetRecordingStartupDevice.CheckState = CheckState.Checked;
            }
            else
            {
                mnuSetRecordingStartupDevice.CheckState = CheckState.Unchecked;
            }

            if (SelectedRecordingDevice.State == AudioDeviceState.Unplugged)
            {
                btnSetRecordingDefault.Enabled      = false;
                mnuFavouriteRecordingDevice.Enabled = false;
            }
            else
            {
                btnSetRecordingDefault.Enabled      = true;
                mnuFavouriteRecordingDevice.Enabled = true;
            }
        }
Example #2
0
        private void RefreshNotifyIconItems()
        {
            notifyIconStrip.Items.Clear();

            int playbackCount  = 0;
            int recordingCount = 0;

            ReadOnlyCollection <AudioDevice> list = AudioDeviceManager.PlayBackDevices;

            foreach (AudioDevice ad in list)
            {
                if (FavouriteDeviceManager.FavouriteDeviceCount > 0 && !FavouriteDeviceManager.IsFavouriteDevice(ad))
                {
                    continue;
                }

                var item = new ToolStripMenuItem(ad.FullName);
                item.Tag     = ad;
                item.Checked = ad.ID == AudioDeviceManager.DefaultPlaybackDevice.ID;
                notifyIconStrip.Items.Add(item);
                playbackCount++;
            }

            if (playbackCount > 0)
            {
                notifyIconStrip.Items.Add(new ToolStripSeparator());
            }

            list = AudioDeviceManager.RecordingDevices;

            foreach (AudioDevice ad in AudioDeviceManager.RecordingDevices)
            {
                if (FavouriteDeviceManager.FavouriteDeviceCount > 0 && !FavouriteDeviceManager.IsFavouriteDevice(ad))
                {
                    continue;
                }

                var item = new ToolStripMenuItem(ad.FullName);
                item.Tag     = ad;
                item.Checked = ad.ID == AudioDeviceManager.DefaultRecordingDevice.ID;
                notifyIconStrip.Items.Add(item);
                recordingCount++;
            }

            if (recordingCount > 0)
            {
                notifyIconStrip.Items.Add(new ToolStripSeparator());
            }

            notifyIconStrip.Items.Add(exitToolStripMenuItem);

            notifyIcon1.Text = AudioDeviceManager.DefaultPlaybackDevice.FullName;
        }
Example #3
0
        private void RefreshRecordingDropDownButton()
        {
            if (SelectedRecordingDevice == null)
            {
                btnSetRecordingDefault.Enabled = false;
                return;
            }

            mnuSetRecordingDefault.CheckState = SelectedRecordingDevice.IsDefaultDevice
                ? CheckState.Checked
                : CheckState.Unchecked;

            mnuSetRecordingCommunicationDefault.CheckState = SelectedRecordingDevice.IsDefaultCommunicationsDevice
                ? CheckState.Checked
                : CheckState.Unchecked;

            mnuFavouriteRecordingDevice.CheckState = FavouriteDeviceManager.IsFavouriteDevice(SelectedRecordingDevice.Id)
                ? CheckState.Checked
                : CheckState.Unchecked;

            mnuSetRecordingStartupDevice.CheckState = Program.Settings.StartupRecordingDeviceID ==
                                                      SelectedRecordingDevice.Id
                ? CheckState.Checked
                : CheckState.Unchecked;

            if (SelectedRecordingDevice.State == DeviceState.Unplugged)
            {
                btnSetRecordingDefault.Enabled      = false;
                mnuFavouriteRecordingDevice.Enabled = false;
            }
            else
            {
                btnSetRecordingDefault.Enabled      = true;
                mnuFavouriteRecordingDevice.Enabled = true;
            }
        }
Example #4
0
        private void RefreshNotifyIconItems()
        {
            notifyIconStrip.Items.Clear();
            var playbackCount  = 0;
            var recordingCount = 0;

            checkBoxDisabledDevices.Checked = Program.Settings.ShowDisabledDevices;
            if (Program.Settings.ShowDisabledDevices)
            {
                _deviceStateFilter |= DeviceState.Disabled;
            }

            IEnumerable <IDevice> list = AudioDeviceManager.Controller.GetPlaybackDevices(_deviceStateFilter).ToList();

            foreach (var ad in list)
            {
                if (FavouriteDeviceManager.FavouriteDeviceCount > 0 && !FavouriteDeviceManager.IsFavouriteDevice(ad))
                {
                    continue;
                }

                var item = new ToolStripMenuItem
                {
                    Text    = ad.FullName,
                    Tag     = ad,
                    Checked = false
                };
                if (itemsToToggle.Contains(ad.Id))
                {
                    item.Checked = true;
                }
                notifyIconStrip.Items.Add(item);
                playbackCount++;
            }

            if (playbackCount > 0)
            {
                notifyIconStrip.Items.Add(new ToolStripSeparator());
            }

            list = AudioDeviceManager.Controller.GetCaptureDevices(_deviceStateFilter).ToList();

            foreach (var ad in list)
            {
                if (FavouriteDeviceManager.FavouriteDeviceCount > 0 && !FavouriteDeviceManager.IsFavouriteDevice(ad))
                {
                    continue;
                }

                var item = new ToolStripMenuItem
                {
                    Text    = ad.FullName,
                    Tag     = ad,
                    Checked = false
                };
                if (itemsToToggle.Contains(ad.Id))
                {
                    item.Checked = true;
                }
                notifyIconStrip.Items.Add(item);
                recordingCount++;
            }

            if (recordingCount > 0)
            {
                notifyIconStrip.Items.Add(new ToolStripSeparator());
            }

            notifyIconStrip.Items.Add(preferencesToolStripMenuItem);

            notifyIconStrip.Items.Add(exitToolStripMenuItem);

            var defaultDevice = AudioDeviceManager.Controller.DefaultPlaybackDevice;
            var notifyText    = "Audio Switcher";

            //The maximum length of the noitfy text is 64 characters. This keeps it under
            if (defaultDevice != null)
            {
                var devName = defaultDevice.FullName ?? defaultDevice.Name ?? notifyText;

                if (devName.Length >= 64)
                {
                    notifyText = devName.Substring(0, 60) + "...";
                }
                else
                {
                    notifyText = devName;
                }
            }

            notifyIcon1.Text = notifyText;
        }
Example #5
0
        private void RefreshRecordingDevices()
        {
            listBoxRecording.SuspendLayout();
            listBoxRecording.Items.Clear();

            foreach (AudioDevice ad in AudioDeviceManager.RecordingDevices)
            {
                var li = new ListViewItem();
                li.Text = ad.DeviceDescription;
                li.Tag  = ad;
                li.SubItems.Add(new ListViewItem.ListViewSubItem(li, ad.DeviceName));
                try
                {
                    string imageKey = ad.Icon;
                    if (AudioDeviceManager.DefaultRecordingDevice.ID == ad.ID)
                    {
                        li.SubItems.Add(new ListViewItem.ListViewSubItem(li, "Default Device"));
                        li.EnsureVisible();
                    }
                    else if (AudioDeviceManager.DefaultRecordingCommDevice.ID == ad.ID)
                    {
                        li.SubItems.Add(new ListViewItem.ListViewSubItem(li, "Default Communications Device"));
                        li.EnsureVisible();
                    }
                    else
                    {
                        string caption = "";
                        switch (ad.State)
                        {
                        case AudioDeviceState.Active:
                            caption = "Ready";
                            break;

                        case AudioDeviceState.Disabled:
                            caption   = "Disabled";
                            imageKey += "d";
                            break;

                        case AudioDeviceState.Unplugged:
                            caption   = "Not Plugged In";
                            imageKey += "d";
                            break;
                        }
                        li.SubItems.Add(new ListViewItem.ListViewSubItem(li, caption));
                    }

                    string imageMod = "";

                    if (ad.State != AudioDeviceState.Unplugged && FavouriteDeviceManager.IsFavouriteDevice(ad))
                    {
                        imageMod += "f";
                    }

                    if (AudioDeviceManager.DefaultPlaybackDevice.ID == ad.ID ||
                        AudioDeviceManager.DefaultRecordingDevice.ID == ad.ID)
                    {
                        imageMod += "e";
                    }
                    else if (AudioDeviceManager.DefaultPlaybackCommDevice.ID == ad.ID ||
                             AudioDeviceManager.DefaultRecordingCommDevice.ID == ad.ID)
                    {
                        imageMod += "c";
                    }

                    string imageToGen = imageKey + imageMod + ".png";

                    if (!imageList1.Images.Keys.Contains(imageToGen) &&
                        imageList1.Images.IndexOfKey(imageKey + ".png") >= 0)
                    {
                        Image    i = imageList1.Images[imageList1.Images.IndexOfKey(imageKey + ".png")];
                        Graphics g = Graphics.FromImage(i);
                        if (imageMod.Contains("f"))
                        {
                            g.DrawImage(Resources.f, i.Width - 12, 0);
                        }

                        if (imageMod.Contains("c"))
                        {
                            g.DrawImage(Resources.c, i.Width - 12, i.Height - 12);
                        }

                        if (imageMod.Contains("e"))
                        {
                            g.DrawImage(Resources.e, i.Width - 12, i.Height - 12);
                        }

                        imageList1.Images.Add(imageToGen, i);
                    }

                    if (imageList1.Images.IndexOfKey(imageToGen) >= 0)
                    {
                        li.ImageKey = imageToGen;
                    }
                }
                catch
                {
                    li.ImageKey = "unknown.png";
                }

                listBoxRecording.Items.Add(li);
            }

            RefreshNotifyIconItems();
            listBoxRecording.ResumeLayout();
        }
Example #6
0
        private void RefreshPlaybackDevices()
        {
            listBoxPlayback.SuspendLayout();
            listBoxPlayback.Items.Clear();
            foreach (var ad in AudioDeviceManager.Controller.GetPlaybackDevices(_deviceStateFilter).ToList())
            {
                var li = new ListViewItem();
                li.Text = ad.Name;
                li.Tag  = ad;
                li.SubItems.Add(new ListViewItem.ListViewSubItem(li, ad.InterfaceName));
                try
                {
                    var imageKey = "";
                    var imageMod = "";

                    if (ICON_MAP.ContainsKey(ad.Icon))
                    {
                        imageKey = ICON_MAP[ad.Icon];
                    }

                    if (ad.IsDefaultDevice)
                    {
                        li.SubItems.Add(new ListViewItem.ListViewSubItem(li, "Default Device"));
                        li.EnsureVisible();
                    }
                    else if (ad.IsDefaultCommunicationsDevice)
                    {
                        li.SubItems.Add(new ListViewItem.ListViewSubItem(li, "Default Communications Device"));
                        li.EnsureVisible();
                    }
                    else
                    {
                        var caption = "";
                        switch (ad.State)
                        {
                        case DeviceState.Active:
                            caption = "Ready";
                            break;

                        case DeviceState.Disabled:
                            caption   = "Disabled";
                            imageMod += "d";
                            break;

                        case DeviceState.Unplugged:
                            caption   = "Not Plugged In";
                            imageMod += "d";
                            break;
                        }
                        li.SubItems.Add(new ListViewItem.ListViewSubItem(li, caption));
                    }

                    if (ad.State != DeviceState.Unplugged && FavouriteDeviceManager.IsFavouriteDevice(ad))
                    {
                        imageMod += "f";
                    }

                    if (ad.IsDefaultDevice)
                    {
                        imageMod += "e";
                    }
                    else if (ad.IsDefaultCommunicationsDevice)
                    {
                        imageMod += "c";
                    }

                    var imageToGen = imageKey + imageMod;

                    if (!imageList1.Images.Keys.Contains(imageToGen))
                    {
                        Image i;
                        using (var icon = ExtractIconFromPath(ad.IconPath))
                        {
                            i = icon.ToBitmap();
                        }

                        if (ad.State == DeviceState.Disabled || ad.State == DeviceState.Unplugged)
                        {
                            i = ImageHelper.SetImageOpacity(i, 0.5F);
                        }

                        using (var g = Graphics.FromImage(i))
                        {
                            if (imageMod.Contains("f"))
                            {
                                g.DrawImage(Resources.f, i.Width - 12, 0);
                            }

                            if (imageMod.Contains("c"))
                            {
                                g.DrawImage(Resources.c, i.Width - 12, i.Height - 12);
                            }

                            if (imageMod.Contains("e"))
                            {
                                g.DrawImage(Resources.e, i.Width - 12, i.Height - 12);
                            }
                        }

                        imageList1.Images.Add(imageToGen, i);
                    }

                    if (imageList1.Images.IndexOfKey(imageToGen) >= 0)
                    {
                        li.ImageKey = imageToGen;
                    }
                }
                catch
                {
                    li.ImageKey = "unknown";
                }

                listBoxPlayback.Items.Add(li);
            }

            RefreshNotifyIconItems();
            listBoxPlayback.ResumeLayout();
        }