Beispiel #1
0
        private void HandleMapping(CCMapping mapping, ControlChangeEvent cc)
        {
            if (mapping == null)
            {
                return;
            }

            switch (mapping.Mapping.MixerMatchString)
            {
            case "System Volume":
                ActionSystemVolume(mapping, cc);
                break;

            case "System Mic Volume":
                ActionSystemMicVolume(mapping, cc);
                break;

            case "Current Window":
                var curWindowCaption = GetCaptionOfActiveWindow();
                var curWindowPids    = GetPID($"^{curWindowCaption}$");
                ActionPID(curWindowPids, mapping, cc);
                return;

            case "N/A":
                return;

            default:
                var mappingPids = GetPID(mapping.Mapping.MixerMatchString);
                ActionPID(mappingPids, mapping, cc);
                break;
            }
        }
        public WindowCCRemap(CCMapping mapping)
        {
            InitializeComponent();
            Enum.GetValues(typeof(MixerFunction)).OfType <MixerFunction>().ToList().ForEach(function => comboMixerFunction.Items.Add(function));
            Enum.GetValues(typeof(ControlType)).OfType <ControlType>().ToList().ForEach(type => comboCCType.Items.Add(type));

            CCNumber = mapping.CCNumber;
            comboMixerFunction.SelectedValue = mapping.Mapping.MixerFunction;
            comboCCType.SelectedValue        = mapping.Mapping.CCType;
            textMixerName.Text = mapping.Mapping.MixerMatchString;
            ;
        }
 private void UnselectListItem(CCMapping removedItem)
 {
     if (currentSelectionButton == null)
     {
         return;
     }
     currentSelectionButton.Background = UnselectedBrush;
     currentSelectionButton            = null;
     textCCNumber.Text    = "";
     textMapping.Text     = "";
     currentSelectionItem = null;
 }
 private void SelectListItem(CCMapping newItem)
 {
     if (!ccButtonsHash.ContainsKey(newItem.CCNumber))
     {
         return;
     }
     currentSelectionButton            = ccButtonsHash[newItem.CCNumber];
     currentSelectionButton.Background = SelectionBrush;
     textCCNumber.Text    = newItem.CCNumber;
     textMapping.Text     = newItem.Mapping.MixerMatchString + "|" + newItem.Mapping.MixerFunction;
     currentSelectionItem = newItem;
 }
Beispiel #5
0
        private static void ActionSystemMicVolume(CCMapping mapping, ControlChangeEvent cc)
        {
            if (mapping.Mapping.MixerFunction == MixerFunction.Mute)
            {
                var isMuted = cc.ControlValue >= 1;
                AudioManager.SetMasterMicVolumeMute(isMuted);
                return;
            }

            var newVol = (cc.ControlValue / 127f) * 100f;

            AudioManager.SetMasterMicVolume(newVol);
        }
Beispiel #6
0
        private static void ActionPID(IEnumerable <int> pids, CCMapping mapping, ControlChangeEvent cc)
        {
            foreach (var pid in pids)
            {
                if (mapping.Mapping.MixerFunction == MixerFunction.Mute)
                {
                    var isMuted = cc.ControlValue >= 1;
                    AudioManager.SetApplicationMute(pid, isMuted);
                    continue;
                }

                var newVol = (cc.ControlValue / 127f) * 100f;
                try
                {
                    AudioManager.SetApplicationVolume(pid, newVol);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Error {e} occurred.");
                }
            }
        }