Exemplo n.º 1
0
        public void ImportSettings(string settings)
        {
            if (!settings.StartsWith("PZ69DisplayValue{"))
            {
                throw new Exception("Invalid setting for RadioPanelPZ69DisplayValue, cannot import.");
            }

            // PZ69DisplayValue{UpperCom1|UpperActive|124.12}\o/\\?\hid#vid_06a3&pid_0d67#9&231fd360&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
            var tmp = settings.Split(new[] { SaitekConstants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries)[0].Replace("PZ69DisplayValue{", string.Empty);

            tmp = tmp.Replace("}", string.Empty);

            // UpperCom1|UpperActive|124.12
            var array = tmp.Split('|');

            try
            {
                Value              = array[2];
                RadioPanelDisplay  = (RadioPanelPZ69Display)Enum.Parse(typeof(RadioPanelPZ69Display), array[1]);
                RadioPanelPZ69Knob = (RadioPanelPZ69KnobsEmulator)Enum.Parse(typeof(RadioPanelPZ69KnobsEmulator), array[0]);
            }
            catch (Exception ex)
            {
                throw new Exception($"Failed to import setting for RadioPanelPZ69Display{Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}");
            }
        }
Exemplo n.º 2
0
        public void AddOrUpdateBIPLinkKeyBinding(RadioPanelPZ69KnobsEmulator radioPanelPZ69Knob, BIPLinkPZ69 bipLinkPZ69, bool whenTurnedOn)
        {
            if (bipLinkPZ69.BIPLights.Count == 0)
            {
                RemoveRadioPanelKnobFromList(ControlListPZ69.BIPS, radioPanelPZ69Knob, whenTurnedOn);
                IsDirtyMethod();
                return;
            }
            //This must accept lists
            var found = false;

            foreach (var bipLink in _bipLinks)
            {
                if (bipLink.RadioPanelPZ69Knob == radioPanelPZ69Knob && bipLink.WhenTurnedOn == whenTurnedOn)
                {
                    bipLink.BIPLights          = bipLinkPZ69.BIPLights;
                    bipLink.Description        = bipLinkPZ69.Description;
                    bipLink.RadioPanelPZ69Knob = radioPanelPZ69Knob;
                    bipLink.WhenTurnedOn       = whenTurnedOn;
                    found = true;
                    break;
                }
            }
            if (!found && bipLinkPZ69.BIPLights.Count > 0)
            {
                bipLinkPZ69.RadioPanelPZ69Knob = radioPanelPZ69Knob;
                bipLinkPZ69.WhenTurnedOn       = whenTurnedOn;
                _bipLinks.Add(bipLinkPZ69);
            }
            IsDirtyMethod();
        }
Exemplo n.º 3
0
        public override void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (BIPLinkPZ69)");
            }
            if (settings.StartsWith("RadioPanelBIPLink{"))
            {
                //RadioPanelBIPLink{1UpperCOM1}\o/BIPLight{Position_1_4|GREEN|FourSec|f5fe6e63e0c05a20f519d4b9e46fab3e}\o/BIPLight{Position_1_4|GREEN|FourSec|f5fe6e63e0c05a20f519d4b9e46fab3e}\o/Description["Set Engines On"]\o/\\?\hid#vid_06a3&pid_0d67#9&231fd360&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                // 0 1 2 3
                var parameters = settings.Split(new[] { SaitekConstants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                //RadioPanelBIPLink{1UpperCOM1}
                var param0 = parameters[0].Replace("RadioPanelBIPLink{", "").Replace("}", "").Trim();
                //1UpperCOM1
                WhenOnTurnedOn = param0.Substring(0, 1) == "1";
                param0         = param0.Substring(1);
                _panelPZ69Knob = (RadioPanelPZ69KnobsEmulator)Enum.Parse(typeof(RadioPanelPZ69KnobsEmulator), param0);

                for (var i = 0; i < parameters.Length; i++)
                {
                    if (parameters[i].StartsWith("BIPLight"))
                    {
                        var tmpBipLight = new BIPLight();
                        _bipLights.Add(GetNewKeyValue(), tmpBipLight);
                        tmpBipLight.ImportSettings(parameters[i]);
                    }
                    if (parameters[i].StartsWith("Description["))
                    {
                        var tmp = parameters[i].Replace("Description[", "").Replace("]", "");
                        _description = tmp;
                    }
                }
            }
        }
        internal override void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (KeyBinding)");
            }

            if (settings.StartsWith("RadioPanelOSPZ69{"))
            {
                // RadioPanelOSPZ69{1UpperCOM1}\o/OSCommand{FILE\o/ARGUMENTS\o/NAME}\o/\\?\hid#vid_06a3&pid_0d67#9&231fd360&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                var parameters = settings.Split(new[] { SaitekConstants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                // RadioPanelOSPZ69{1UpperCOM1}
                var param0 = parameters[0].Replace("RadioPanelOSPZ69{", string.Empty).Replace("}", string.Empty);

                // 1UpperCOM1
                WhenTurnedOn   = (param0.Substring(0, 1) == "1");
                param0         = param0.Substring(1);
                _panelPZ69Knob = (RadioPanelPZ69KnobsEmulator)Enum.Parse(typeof(RadioPanelPZ69KnobsEmulator), param0);

                // OSCommand{FILE\o/ARGUMENTS\o/NAME}
                OSCommandObject = new OSCommand();
                OSCommandObject.ImportString(parameters[1]);
            }
        }
Exemplo n.º 5
0
        private void RemoveRadioPanelKnobFromList(ControlListPZ69 controlListPZ69, RadioPanelPZ69KnobsEmulator radioPanelPZ69Knob, bool whenTurnedOn)
        {
            var found            = false;
            var pz69DialPosition = GetDial(radioPanelPZ69Knob);

            if (controlListPZ69 == ControlListPZ69.ALL || controlListPZ69 == ControlListPZ69.KEYS)
            {
                foreach (var keyBinding in _keyBindings)
                {
                    if (keyBinding.RadioPanelPZ69Key == radioPanelPZ69Knob && keyBinding.WhenTurnedOn == whenTurnedOn && keyBinding.DialPosition == pz69DialPosition)
                    {
                        keyBinding.OSKeyPress = null;
                    }
                    found = true;
                    break;
                }
            }
            if (controlListPZ69 == ControlListPZ69.ALL || controlListPZ69 == ControlListPZ69.BIPS)
            {
                foreach (var bipLink in _bipLinks)
                {
                    if (bipLink.RadioPanelPZ69Knob == radioPanelPZ69Knob && bipLink.WhenTurnedOn == whenTurnedOn)
                    {
                        bipLink.BIPLights.Clear();
                    }
                    found = true;
                    break;
                }
            }

            if (found)
            {
                IsDirtyMethod();
            }
        }
Exemplo n.º 6
0
        internal override void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (KeyBinding)");
            }
            if (settings.StartsWith("RadioPanelKey{"))
            {
                //RadioPanelKey{1UpperCOM1}\o/OSKeyPress{[FiftyMilliSec,RCONTROL + RSHIFT + VK_R][FiftyMilliSec,RCONTROL + RSHIFT + VK_W]}\o/\\?\hid#vid_06a3&pid_0d67#9&231fd360&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                var parameters = settings.Split(new[] { SaitekConstants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                //RadioPanelKey{1UpperCOM1}
                var param0 = parameters[0].Trim().Substring(14);
                //1UpperCOM1}
                param0 = param0.Remove(param0.Length - 1, 1);
                //1UpperCOM1
                WhenTurnedOn   = (param0.Substring(0, 1) == "1");
                param0         = param0.Substring(1);
                _panelPZ69Knob = (RadioPanelPZ69KnobsEmulator)Enum.Parse(typeof(RadioPanelPZ69KnobsEmulator), param0);

                //OSKeyPress{[FiftyMilliSec,RCONTROL + RSHIFT + VK_R][FiftyMilliSec,RCONTROL + RSHIFT + VK_W]}
                OSKeyPress = new KeyPress();
                OSKeyPress.ImportString(parameters[1]);
            }
        }
Exemplo n.º 7
0
        public void AddOrUpdateDCSBIOSBinding(RadioPanelPZ69KnobsEmulator knob, List <DCSBIOSInput> dcsbiosInputs, string description, bool whenTurnedOn)
        {
            if (dcsbiosInputs.Count == 0)
            {
                RemoveRadioPanelKnobFromList(ControlListPZ69.DCSBIOS, knob, whenTurnedOn);
                IsDirtyMethod();
                return;
            }
            //This must accept lists
            var found            = false;
            var pz69DialPosition = GetDial(knob);

            foreach (var dcsBiosBinding in _dcsBiosBindings)
            {
                if (dcsBiosBinding.DialPosition == pz69DialPosition && dcsBiosBinding.RadioPanelPZ69Knob == knob && dcsBiosBinding.WhenTurnedOn == whenTurnedOn)
                {
                    dcsBiosBinding.DCSBIOSInputs = dcsbiosInputs;
                    dcsBiosBinding.WhenTurnedOn  = whenTurnedOn;
                    dcsBiosBinding.Description   = description;
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                var dcsBiosBinding = new DCSBIOSBindingPZ69();
                dcsBiosBinding.RadioPanelPZ69Knob = knob;
                dcsBiosBinding.DialPosition       = pz69DialPosition;
                dcsBiosBinding.DCSBIOSInputs      = dcsbiosInputs;
                dcsBiosBinding.WhenTurnedOn       = whenTurnedOn;
                dcsBiosBinding.Description        = description;
                _dcsBiosBindings.Add(dcsBiosBinding);
            }
            IsDirtyMethod();
        }
Exemplo n.º 8
0
        public void AddOrUpdateDisplayValue(RadioPanelPZ69KnobsEmulator radioPanelPZ69Knob, string valueAsString, RadioPanelPZ69Display radioPanelDisplay)
        {
            if (string.IsNullOrEmpty(valueAsString))
            {
                ClearDisplayValue(radioPanelPZ69Knob, radioPanelDisplay);
                return;
            }
            var value = double.Parse(valueAsString, Common.GetPZ69FullDisplayNumberFormat());

            if (value < 0)
            {
                ClearDisplayValue(radioPanelPZ69Knob, radioPanelDisplay);
                return;
            }
            var found = false;

            foreach (var displayValue in _displayValues)
            {
                if (displayValue.RadioPanelPZ69Knob == radioPanelPZ69Knob && displayValue.RadioPanelDisplay == radioPanelDisplay)
                {
                    displayValue.Value = valueAsString;
                    found = true;
                }
            }
            if (!found)
            {
                var displayValue = new RadioPanelPZ69DisplayValue();
                displayValue.RadioPanelPZ69Knob = radioPanelPZ69Knob;
                displayValue.RadioPanelDisplay  = radioPanelDisplay;
                displayValue.Value = valueAsString;
                _displayValues.Add(displayValue);
            }
            IsDirtyMethod();
        }
Exemplo n.º 9
0
 public RadioPanelPZ69KnobEmulator(int group, int mask, bool isOn, RadioPanelPZ69KnobsEmulator radioPanelPZ69Knob)
 {
     Group = group;
     Mask  = mask;
     IsOn  = isOn;
     RadioPanelPZ69Knob = radioPanelPZ69Knob;
 }
Exemplo n.º 10
0
 private PZ69DialPosition GetDial(RadioPanelPZ69KnobsEmulator knob)
 {
     if (knob.ToString().Contains("Upper"))
     {
         return(_pz69UpperDialPosition);
     }
     return(_pz69LowerDialPosition);
 }
Exemplo n.º 11
0
 public void Clear(RadioPanelPZ69KnobsEmulator radioPanelPZ69Knob)
 {
     foreach (var keyBinding in _keyBindings)
     {
         if (keyBinding.RadioPanelPZ69Key == radioPanelPZ69Knob)
         {
             keyBinding.OSKeyPress = null;
         }
     }
     IsDirtyMethod();
 }
Exemplo n.º 12
0
        public void ClearDisplayValue(RadioPanelPZ69KnobsEmulator radioPanelPZ69Knob, RadioPanelPZ69Display radioPanelPZ69Display)
        {
            //This must accept lists

            /*foreach (var displayValue in _displayValues)
             * {
             *  if (displayValue.RadioPanelPZ69Knob == radioPanelPZ69Knob && displayValue.RadioPanelDisplay == radioPanelPZ69Display)
             *  {
             *      displayValue.Value = null;
             *  }
             * }*/
            _displayValues.RemoveWhere(x => x.RadioPanelPZ69Knob == radioPanelPZ69Knob && x.RadioPanelDisplay == radioPanelPZ69Display);
            IsDirtyMethod();
        }
Exemplo n.º 13
0
        public void DeleteDCSBIOSBinding(RadioPanelPZ69KnobsEmulator knob, bool whenTurnedOn)
        {
            var pz69DialPosition = GetDial(knob);

            //Removes config
            foreach (var dcsBiosBinding in _dcsBiosBindings)
            {
                if (dcsBiosBinding.DialPosition == pz69DialPosition && dcsBiosBinding.RadioPanelPZ69Knob == knob && dcsBiosBinding.WhenTurnedOn == whenTurnedOn)
                {
                    dcsBiosBinding.DCSBIOSInputs.Clear();
                    break;
                }
            }
            IsDirtyMethod();
        }
        internal override void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (DCSBIOSBindingPZ69)");
            }

            if (settings.StartsWith("RadioPanelDCSBIOSControl{"))
            {
                // RadioPanelDCSBIOSControl{COM1}\\o/{1UpperSmallFreqWheelInc|DCS-BIOS}\\o/\\o/DCSBIOSInput{AAP_CDUPWR|SET_STATE|1|0}\\o/\\\\?\\hid#vid_06a3&pid_0d06#9&244b4bcc&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\\o/PanelSettingsVersion=2X"
                var parameters = settings.Split(new[] { SaitekConstants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                // RadioPanelDCSBIOSControl{COM1}
                var param0 = parameters[0].Replace("RadioPanelDCSBIOSControl{", string.Empty).Replace("}", string.Empty);
                _pz69DialPosition = (PZ69DialPosition) Enum.Parse(typeof(PZ69DialPosition), param0);

                var param1 = parameters[1].Replace("{", string.Empty).Replace("}", string.Empty);
                WhenTurnedOn = (param1.Substring(0, 1) == "1");
                if (param1.Contains("|"))
                {
                    param1 = param1.Substring(1);
                    var stringArray = param1.Split(new[] {"|"}, StringSplitOptions.RemoveEmptyEntries);
                    _panelPZ69Knob = (RadioPanelPZ69KnobsEmulator) Enum.Parse(typeof(RadioPanelPZ69KnobsEmulator), stringArray[0]);
                    Description = stringArray[1];
                }
                else
                {
                    param1 = param1.Substring(1);
                    _panelPZ69Knob = (RadioPanelPZ69KnobsEmulator) Enum.Parse(typeof(RadioPanelPZ69KnobsEmulator), param1);
                }

                // The rest of the array besides last entry are DCSBIOSInput
                // DCSBIOSInput{AAP_EGIPWR|FIXED_STEP|INC}
                DCSBIOSInputs = new List<DCSBIOSInput>();
                for (var i = 0; i < parameters.Length; i++)
                {
                    if (parameters[i].StartsWith("DCSBIOSInput{"))
                    {
                        var dcsbiosInput = new DCSBIOSInput();
                        dcsbiosInput.ImportString(parameters[i]);
                        DCSBIOSInputs.Add(dcsbiosInput);
                    }
                }
            }
        }
 internal override void ImportSettings(string settings)
 {
     if (string.IsNullOrEmpty(settings))
     {
         throw new ArgumentException("Import string empty. (KeyBinding)");
     }
     if (settings.StartsWith("RadioPanelKeyDialPos{"))
     {
         var parameters = settings.Split(new[] { Constants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);
         var param0     = parameters[0].Replace("RadioPanelKeyDialPos{", "").Replace("}", "");
         _pz69DialPosition = (PZ69DialPosition)Enum.Parse(typeof(PZ69DialPosition), param0);
         var param1 = parameters[1].Replace("{", "").Replace("}", "");
         WhenTurnedOn   = param1.Substring(0, 1) == "1";
         param1         = param1.Substring(1);
         _panelPZ69Knob = (RadioPanelPZ69KnobsEmulator)Enum.Parse(typeof(RadioPanelPZ69KnobsEmulator), param1);
         OSKeyPress     = new KeyPress();
         OSKeyPress.ImportString(parameters[2]);
     }
 }
Exemplo n.º 16
0
        public void AddOrUpdateSequencedKeyBinding(string information, RadioPanelPZ69KnobsEmulator radioPanelPZ69Knob, SortedList <int, KeyPressInfo> sortedList, bool whenTurnedOn)
        {
            var pz69DialPosition = GetDial(radioPanelPZ69Knob);

            if (sortedList.Count == 0)
            {
                RemoveRadioPanelKnobFromList(ControlListPZ69.KEYS, radioPanelPZ69Knob, whenTurnedOn);
                IsDirtyMethod();
                return;
            }
            //This must accept lists
            var found = false;

            foreach (var keyBinding in _keyBindings)
            {
                if (keyBinding.RadioPanelPZ69Key == radioPanelPZ69Knob && keyBinding.WhenTurnedOn == whenTurnedOn && keyBinding.DialPosition == pz69DialPosition)
                {
                    if (sortedList.Count == 0)
                    {
                        keyBinding.OSKeyPress = null;
                    }
                    else
                    {
                        keyBinding.OSKeyPress   = new OSKeyPress(information, sortedList);
                        keyBinding.WhenTurnedOn = whenTurnedOn;
                    }
                    found = true;
                    break;
                }
            }
            if (!found && sortedList.Count > 0)
            {
                var keyBinding = new KeyBindingPZ69DialPosition();
                keyBinding.RadioPanelPZ69Key = radioPanelPZ69Knob;
                keyBinding.DialPosition      = pz69DialPosition;
                keyBinding.OSKeyPress        = new OSKeyPress(information, sortedList);
                keyBinding.WhenTurnedOn      = whenTurnedOn;
                _keyBindings.Add(keyBinding);
            }
            IsDirtyMethod();
        }
        internal override void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (KeyBinding)");
            }
            if (settings.StartsWith("RadioPanelOSPZ69Full{"))
            {
                var parameters = settings.Split(new[] { SeparatorChars }, StringSplitOptions.RemoveEmptyEntries);
                var param0     = parameters[0].Replace("RadioPanelOSPZ69Full{", "").Replace("}", "");
                _pz69DialPosition = (PZ69DialPosition)Enum.Parse(typeof(PZ69DialPosition), param0);
                var param1 = parameters[1].Replace("{", "").Replace("}", "");
                WhenTurnedOn   = param1.Substring(0, 1) == "1";
                param1         = param1.Substring(1);
                _panelPZ69Knob = (RadioPanelPZ69KnobsEmulator)Enum.Parse(typeof(RadioPanelPZ69KnobsEmulator), param1);

                //OSCommand{FILE\o/ARGUMENTS\o/NAME}
                OSCommandObject = new OSCommand();
                OSCommandObject.ImportString(parameters[2]);
            }
        }
Exemplo n.º 18
0
        public void AddOrUpdateSingleKeyBinding(RadioPanelPZ69KnobsEmulator radioPanelPZ69Knob, string keys, KeyPressLength keyPressLength, bool whenTurnedOn)
        {
            var pz69DialPosition = GetDial(radioPanelPZ69Knob);

            if (string.IsNullOrEmpty(keys))
            {
                var tmp = new RadioPanelPZ69KeyOnOff(radioPanelPZ69Knob, whenTurnedOn);
                ClearAllBindings(pz69DialPosition, tmp);
                return;
            }
            var found = false;

            foreach (var keyBinding in _keyBindings)
            {
                if (keyBinding.RadioPanelPZ69Key == radioPanelPZ69Knob && keyBinding.WhenTurnedOn == whenTurnedOn && keyBinding.DialPosition == pz69DialPosition)
                {
                    if (string.IsNullOrEmpty(keys))
                    {
                        keyBinding.OSKeyPress = null;
                    }
                    else
                    {
                        keyBinding.OSKeyPress   = new OSKeyPress(keys, keyPressLength);
                        keyBinding.WhenTurnedOn = whenTurnedOn;
                    }
                    found = true;
                }
            }
            if (!found && !string.IsNullOrEmpty(keys))
            {
                var keyBinding = new KeyBindingPZ69DialPosition();
                keyBinding.RadioPanelPZ69Key = radioPanelPZ69Knob;
                keyBinding.DialPosition      = pz69DialPosition;
                keyBinding.OSKeyPress        = new OSKeyPress(keys, keyPressLength);
                keyBinding.WhenTurnedOn      = whenTurnedOn;
                _keyBindings.Add(keyBinding);
            }
            Common.DebugP("RadioPanelPZ69FullEmulator _keyBindings : " + _keyBindings.Count);
            IsDirtyMethod();
        }
Exemplo n.º 19
0
 public RadioPanelPZ69KeyOnOff(RadioPanelPZ69KnobsEmulator radioPanelPZ69Key, bool buttonState)
 {
     _radioPanelPZ69Key = radioPanelPZ69Key;
     _buttonState       = buttonState;
 }