Пример #1
0
        /// <summary>
        /// Constructor for session panel creation.
        /// </summary>
        /// <param name="device">Selected device.</param>
        /// <param name="session">Current session of device.</param>
        public VolumePanel(MMDevice device, AudioSessionControl session)
        {
            this.devicePanel = false;
            this.device = device;
            this.session = session;
            InitializeComponent();

            cmbDevice.Visible = false;
            Process process = Process.GetProcessById((int)session.GetProcessID);
            if (session.IsSystemSoundsSession)
            {
                lblName.Text = "System Sounds";
                pbProcessIcon.Visible = false;
                btnSoundProperties.Visible = true;
                var iconAddress = session.IconPath.Split(',');
                var icon = IconExtractor.Extract(iconAddress[0], int.Parse(iconAddress[1]), true);
                if (icon != null)
                    btnSoundProperties.Image = icon.ToBitmap();
                tooltip.SetToolTip(btnSoundProperties, lblName.Text);
            }
            else
            {
                pbProcessIcon.Image = Icon.ExtractAssociatedIcon(process.MainModule.FileName).ToBitmap();
                lblName.Text = process.MainWindowTitle != "" ? process.MainWindowTitle : process.ProcessName;
                pbProcessIcon.Visible = true;
                btnSoundProperties.Visible = false;
                tooltip.SetToolTip(pbProcessIcon, lblName.Text);
            }
            tooltip.SetToolTip(lblName, lblName.Text);

            session.RegisterEventClient(this);
            UpdateVolume();
            UpdateMuted();
        }
Пример #2
0
        private void AudioSessionManager_OnSessionCreated(object sender, IAudioSessionControl newSession)
        {
            var audioSessionControl = new AudioSessionControl(newSession);

            if (_audioSessionControl == null && audioSessionControl.GetProcessID == Process.GetCurrentProcess().Id)
            {
                _audioSessionControl = audioSessionControl;
                _audioSessionControl.RegisterEventClient(this);

                if (_audioSessionControl.SimpleAudioVolume.Mute)
                {
                    _isMuted = true;
                }

                UpdateVolume();
                UpdateIsMuted();
            }
        }