コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();

            notifyIcon.ContextMenuStrip = cmsTray;

            VolUpHotkey     = Properties.Settings.Default.VolUpHotkey;
            VolUpModifier   = Properties.Settings.Default.VolUpModifier;
            VolDownHotkey   = Properties.Settings.Default.VolDownHotkey;
            VolDownModifier = Properties.Settings.Default.VolDownModifier;
            MuteHotkey      = Properties.Settings.Default.MuteHotkey;
            MuteModifier    = Properties.Settings.Default.MuteModifier;
            VolumeSteps     = Properties.Settings.Default.LastVolStep;
            SoftMuteLevel   = Properties.Settings.Default.SoftMuteLevel;
            PTTHotkey       = Properties.Settings.Default.PTTHotkey;

            if (VolumeSteps != 0)
            {
                nudVolumeSteps.Value = VolumeSteps;
            }

            if (SoftMuteLevel != 0)
            {
                nudSoftMuteLevel.Value = SoftMuteLevel;
            }

            RegisterHotKey(this.Handle, 1, (int)VolUpModifier, (int)VolUpHotkey);
            RegisterHotKey(this.Handle, 2, (int)VolDownModifier, (int)VolDownHotkey);
            RegisterHotKey(this.Handle, 3, (int)MuteModifier, (int)MuteHotkey);

            var converter = new KeysConverter();

            tbxVolUpHotkey.Clear();
            if (((int)VolUpModifier & 1) != 0)
            {
                tbxVolUpHotkey.AppendText("ALT+");
            }
            if (((int)VolUpModifier & 2) != 0)
            {
                tbxVolUpHotkey.AppendText("CTRL+");
            }
            if (((int)VolUpModifier & 4) != 0)
            {
                tbxVolUpHotkey.AppendText("SHIFT+");
            }
            tbxVolUpHotkey.AppendText(converter.ConvertToString(VolUpHotkey));

            tbxVolDownHotkey.Clear();
            if (((int)VolDownModifier & 1) != 0)
            {
                tbxVolDownHotkey.AppendText("ALT+");
            }
            if (((int)VolDownModifier & 2) != 0)
            {
                tbxVolDownHotkey.AppendText("CTRL+");
            }
            if (((int)VolDownModifier & 4) != 0)
            {
                tbxVolDownHotkey.AppendText("SHIFT+");
            }
            tbxVolDownHotkey.AppendText(converter.ConvertToString(VolDownHotkey));

            tbxMuteHotkey.Clear();
            if (((int)MuteModifier & 1) != 0)
            {
                tbxMuteHotkey.AppendText("ALT+");
            }
            if (((int)MuteModifier & 2) != 0)
            {
                tbxMuteHotkey.AppendText("CTRL+");
            }
            if (((int)MuteModifier & 4) != 0)
            {
                tbxMuteHotkey.AppendText("SHIFT+");
            }
            tbxMuteHotkey.AppendText(converter.ConvertToString(MuteHotkey));

            tbxPTTHotkey.Clear();
            tbxPTTHotkey.AppendText(converter.ConvertToString(PTTHotkey));

            VolumeSteps = decimal.ToInt32(nudVolumeSteps.Value);

            volumeMixer = new VolumeMixer();

            cmbEndpoints.DataSource = volumeMixer.GetEndpointNames();
            cmbAppName.DataSource   = volumeMixer.GetSessionNames();

            int maxwidth = 166;

            foreach (string item in cmbEndpoints.Items)
            {
                if (maxwidth < TextRenderer.MeasureText(item, cmbEndpoints.Font).Width)
                {
                    maxwidth = TextRenderer.MeasureText(item, cmbEndpoints.Font).Width;
                }
            }

            cmbEndpoints.DropDownWidth = maxwidth;

            maxwidth = 166;

            foreach (string item in cmbAppName.Items)
            {
                if (maxwidth < TextRenderer.MeasureText(item, cmbAppName.Font).Width)
                {
                    maxwidth = TextRenderer.MeasureText(item, cmbAppName.Font).Width;
                }
            }

            cmbAppName.DropDownWidth = maxwidth;

            if (cmbEndpoints.FindStringExact(Properties.Settings.Default.LastEndpointName) != -1)
            {
                cmbEndpoints.SelectedIndex = cmbEndpoints.FindStringExact(Properties.Settings.Default.LastEndpointName);
            }
        }
コード例 #2
0
 private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     volumeMixer = new VolumeMixer();
 }