public DCSBiosInputWindow(DCSAirframe dcsAirframe, string description)
 {
     InitializeComponent();
     _dcsAirframe     = dcsAirframe;
     _description     = description;
     _dcsbiosControls = DCSBIOSControlLocator.GetInputControls();
 }
 private void SetAirframe()
 {
     if (IsLoaded && ComboBoxAirframe.SelectedItem != null)
     {
         _dcsAirframe = EnumEx.GetValueFromDescription <DCSAirframe>(ComboBoxAirframe.SelectedItem.ToString());
         DCSBIOSControlLocator.Airframe = _dcsAirframe;
     }
 }
Exemple #3
0
 public DCSBiosOutputFormulaWindow(DCSAirframe dcsAirframe, string description, DCSBIOSOutputFormula dcsBiosOutputFormula)
 {
     InitializeComponent();
     _dcsAirframe          = dcsAirframe;
     _description          = description;
     _dcsbiosOutputFormula = dcsBiosOutputFormula;
     DCSBIOSControlLocator.LoadControls();
     _dcsbiosControls = DCSBIOSControlLocator.GetIntegerOutputControls();
 }
Exemple #4
0
 public DCSBIOSControlsConfigsWindow(DCSAirframe dcsAirframe, string header, string description)
 {
     InitializeComponent();
     _dcsAirframe            = dcsAirframe;
     _header                 = header;
     _description            = description;
     TextBoxDescription.Text = _description;
     ShowItems();
 }
Exemple #5
0
 public DCSBIOSInputControlsWindow(DCSAirframe dcsAirframe, string header, string description, bool showSequenced = false)
 {
     InitializeComponent();
     _dcsAirframe            = dcsAirframe;
     _header                 = header;
     _description            = description;
     TextBoxDescription.Text = _description;
     _showSequenced          = showSequenced;
     ShowItems();
 }
 public DCSBiosOutputTriggerWindow(DCSAirframe dcsAirframe, string description, bool showCriteria = true)
 {
     InitializeComponent();
     _showCriteria  = showCriteria;
     _dcsAirframe   = dcsAirframe;
     _description   = description;
     _dcsBiosOutput = new DCSBIOSOutput();
     DCSBIOSControlLocator.LoadControls();
     _dcsbiosControls = DCSBIOSControlLocator.GetIntegerOutputControls();
 }
 public DCSBiosInputWindow(DCSAirframe dcsAirframe, string description, DCSBIOSInput dcsBiosInput)
 {
     InitializeComponent();
     _dcsAirframe     = dcsAirframe;
     _description     = description;
     _dcsBiosInput    = dcsBiosInput;
     _dcsbiosControl  = DCSBIOSControlLocator.GetControl(_dcsBiosInput.ControlId);
     _dcsbiosControls = DCSBIOSControlLocator.GetInputControls();
     PopulateComboBoxInterfaceType(_dcsBiosInput);
 }
 public DCSBiosOutputFormulaWindow(DCSAirframe dcsAirframe, string description, bool userEditsDescription = false)
 {
     InitializeComponent();
     _dcsAirframe          = dcsAirframe;
     _description          = description;
     _userEditsDescription = userEditsDescription;
     _dcsBiosOutput        = new DCSBIOSOutput();
     DCSBIOSControlLocator.LoadControls();
     _dcsbiosControls = DCSBIOSControlLocator.GetIntegerOutputControls();
 }
Exemple #9
0
 public void SelectedAirframe(DCSAirframe dcsAirframe)
 {
     try
     {
         //nada
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(471173, ex);
     }
 }
 public LEDConfigsWindow(DCSAirframe dcsAirframe, string description, SaitekPanelLEDPosition saitekPanelLEDPosition, List <DcsOutputAndColorBinding> colorOutputBindings, SaitekPanel callingPanel)
 {
     InitializeComponent();
     _dcsAirframe            = dcsAirframe;
     _saitekPanelLEDPosition = saitekPanelLEDPosition;
     _callingPanel           = callingPanel;
     if (colorOutputBindings != null)
     {
         _colorOutputBindings = colorOutputBindings;
     }
     _description = description;
     ShowItems();
 }
Exemple #11
0
 public DCSBIOSControlsConfigsWindow(DCSAirframe dcsAirframe, string header, List <DCSBIOSInput> dcsbiosInputs, string description)
 {
     InitializeComponent();
     _dcsAirframe = dcsAirframe;
     if (dcsbiosInputs != null)
     {
         _dcsbiosInputs = dcsbiosInputs;
     }
     _header                 = header;
     _description            = description;
     TextBoxDescription.Text = _description;
     ShowItems();
 }
Exemple #12
0
        public DCSBIOSInputControlsWindow(DCSAirframe dcsAirframe, string header, List <DCSBIOSInput> dcsbiosInputs, string description, bool showSequenced = false)
        {
            InitializeComponent();
            _dcsAirframe = dcsAirframe;
            if (dcsbiosInputs != null)
            {
                _dcsbiosInputs = dcsbiosInputs;
            }
            _header                 = header;
            _description            = description;
            TextBoxDescription.Text = _description;
            _showSequenced          = showSequenced;

            ShowItems();
        }
 public static void LoadControls(string jsonDirectory, DCSAirframe airframe)
 {
     JSONDirectory = jsonDirectory;
     Airframe      = airframe;
     LoadControls();
 }
Exemple #14
0
 public void SelectedAirframe(DCSAirframe dcsAirframe)
 {
     _keyboardEmulation = dcsAirframe == DCSAirframe.NONE;
 }
Exemple #15
0
        public bool LoadProfile(string filename, IHardwareConflictResolver hardwareConflictResolver)
        {
            try
            {
                /*
                 * 0 Open specified filename (parameter) if not null
                 * 1 If exists open last profile used (settings)
                 * 2 Try and open default profile located in My Documents
                 * 3 If none found create default file
                 */
                _hardwareConflictResolver = hardwareConflictResolver;

                _isNewProfile = false;
                ClearAll();

                if (!string.IsNullOrEmpty(filename))
                {
                    _filename        = filename;
                    _lastProfileUsed = filename;
                }
                else
                {
                    if (!string.IsNullOrEmpty(_lastProfileUsed) && File.Exists(_lastProfileUsed))
                    {
                        _filename = _lastProfileUsed;
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (string.IsNullOrEmpty(_filename) || !File.Exists(_filename))
                {
                    //Main window will handle this
                    return(false);
                }

                /*
                 * Read all information and add InstanceID to all lines using BeginPanel and EndPanel
                 *
                 * PanelType=PZ55SwitchPanel
                 * PanelInstanceID=\\?\hid#vid_06a3&pid_0d06#8&3f11a32&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                 * BeginPanel
                 *      SwitchPanelKey{1KNOB_ENGINE_RIGHT}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_LEFT}\o/OSKeyPress{FiftyMilliSec,LCONTROL + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_BOTH}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_C}
                 * EndPanel
                 *
                 */
                _profileLoaded = true;
                Debug.WriteLine("ProfileHandler reading file ".Append(_filename));
                var    fileLines              = File.ReadAllLines(_filename);
                var    currentPanelType       = GamingPanelEnum.Unknown;
                string currentPanelInstanceID = null;
                string currentBindingHash     = null;
                var    insidePanel            = false;
                var    insideJSONPanel        = false;

                GenericPanelBinding genericPanelBinding = null;

                foreach (var fileLine in fileLines)
                {
                    if (fileLine.StartsWith("Airframe="))
                    {
                        if (fileLine.StartsWith("Airframe=NONE"))
                        {
                            //Backward compability
                            _airframe = DCSAirframe.KEYEMULATOR;
                        }
                        else
                        {
                            //Backward compability
                            var airframeAsString = fileLine.Replace("Airframe=", "").Trim();
                            if (airframeAsString.StartsWith("SA342"))
                            {
                                _airframe = DCSAirframe.SA342M;
                            }
                            else if (airframeAsString.StartsWith("P51D") || airframeAsString.StartsWith("TF51D"))
                            {
                                _airframe = DCSAirframe.P51D;
                            }
                            else if (airframeAsString.StartsWith("L39"))
                            {
                                _airframe = DCSAirframe.L39ZA;
                            }
                            else
                            {
                                _airframe = (DCSAirframe)Enum.Parse(typeof(DCSAirframe), airframeAsString);
                            }
                        }
                        DCSBIOSControlLocator.Airframe = _airframe;
                    }
                    else if (fileLine.StartsWith("OperationLevelFlag="))
                    {
                        Common.SetOperationModeFlag(int.Parse(fileLine.Replace("OperationLevelFlag=", "").Trim()));
                    }
                    else if (fileLine.StartsWith("UseGenericRadio="))
                    {
                        Common.UseGenericRadio = (bool.Parse(fileLine.Replace("UseGenericRadio=", "").Trim()));
                    }
                    else if (!fileLine.StartsWith("#") && fileLine.Length > 0)
                    {
                        //Process all these lines.
                        if (fileLine.StartsWith("PanelType="))
                        {
                            currentPanelType              = (GamingPanelEnum)Enum.Parse(typeof(GamingPanelEnum), fileLine.Replace("PanelType=", "").Trim());
                            genericPanelBinding           = new GenericPanelBinding();
                            genericPanelBinding.PanelType = currentPanelType;
                        }
                        else if (fileLine.StartsWith("PanelInstanceID="))
                        {
                            currentPanelInstanceID          = fileLine.Replace("PanelInstanceID=", "").Trim();
                            genericPanelBinding.HIDInstance = currentPanelInstanceID;
                            _profileFileInstanceIDs.Add(new KeyValuePair <string, GamingPanelEnum>(currentPanelInstanceID, currentPanelType));
                        }
                        else if (fileLine.StartsWith("BindingHash="))
                        {
                            currentBindingHash = fileLine.Replace("BindingHash=", "").Trim();
                            genericPanelBinding.BindingHash = currentBindingHash;
                        }
                        else if (fileLine.StartsWith("PanelSettingsVersion="))
                        {
                            //do nothing, this will be phased out
                        }
                        else if (fileLine.Equals("BeginPanel"))
                        {
                            insidePanel = true;
                        }
                        else if (fileLine.Equals("EndPanel"))
                        {
                            if (genericPanelBinding != null)
                            {
                                BindingMappingManager.RegisterBindingFromFile(genericPanelBinding);
                            }
                            insidePanel = false;
                        }
                        else if (fileLine.Equals("BeginPanelJSON"))
                        {
                            insideJSONPanel = true;
                        }
                        else if (fileLine.Equals("EndPanelJSON"))
                        {
                            if (genericPanelBinding != null)
                            {
                                BindingMappingManager.RegisterBindingFromFile(genericPanelBinding);
                            }
                            insideJSONPanel = false;
                        }
                        else
                        {
                            if (insidePanel)
                            {
                                var line = fileLine;
                                if (line.StartsWith("\t"))
                                {
                                    line = line.Replace("\t", "");
                                }

                                genericPanelBinding.Settings.Add(line);
                            }

                            if (insideJSONPanel)
                            {
                                genericPanelBinding.JSONAddLine(fileLine);
                            }
                        }
                    }
                }
                //For backwards compability 10.11.2018
                if (Common.GetOperationModeFlag() == 0)
                {
                    SetOperationLevelFlag();
                }

                CheckHardwareConflicts();

                SendBindingsReadEvent();
                return(true);
            }
            catch (Exception ex)
            {
                Common.ShowErrorMessageBox(ex);
                return(false);
            }
        }
        public bool LoadProfile(string filename)
        {
            try
            {
                Common.DebugP("LoadProfile filename : " + filename);
                if (!string.IsNullOrEmpty(filename))
                {
                    _filename        = filename;
                    _lastProfileUsed = filename;
                }

                /*
                 * 0 Open specified filename (parameter) if not null
                 * 1 If exists open last profile used (settings)
                 * 2 Try and open default profile located in My Documents
                 * 3 If none found create default file
                 */
                _isNewProfile = false;
                ClearAll();
                if (string.IsNullOrEmpty(_filename))
                {
                    if (!string.IsNullOrEmpty(_lastProfileUsed) && File.Exists(_lastProfileUsed))
                    {
                        _filename = _lastProfileUsed;
                    }
                    else if (File.Exists(DefaultFile()))
                    {
                        _filename        = DefaultFile();
                        _lastProfileUsed = filename;
                    }
                }

                Common.DebugP("LoadProfile _lastProfileUsed : " + _lastProfileUsed);
                Common.DebugP("LoadProfile _filename : " + _filename);

                if (string.IsNullOrEmpty(_filename) || !File.Exists(_filename))
                {
                    //Main window will handle this
                    Common.DebugP("LoadProfile returns false");
                    return(false);
                }

                /*
                 * Read all information and add InstanceID to all lines using BeginPanel and EndPanel
                 *
                 * PanelType=PZ55SwitchPanel
                 * PanelInstanceID=\\?\hid#vid_06a3&pid_0d06#8&3f11a32&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                 * BeginPanel
                 *      SwitchPanelKey{1KNOB_ENGINE_RIGHT}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_LEFT}\o/OSKeyPress{FiftyMilliSec,LCONTROL + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_BOTH}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_C}
                 * EndPanel
                 *
                 */
                _profileLoaded = true;
                var fileLines = File.ReadAllLines(_filename);
                SaitekPanelsEnum currentPanelType            = SaitekPanelsEnum.Unknown;
                string           currentPanelInstanceID      = null;
                string           currentPanelSettingsVersion = null;
                var          insidePanel = false;
                const string sepString   = "\\o/";

                foreach (var fileLine in fileLines)
                {
                    if (fileLine.StartsWith("Airframe="))
                    {
                        if (fileLine.StartsWith("Airframe=NONE"))
                        {
                            //Backward compability
                            _airframe = DCSAirframe.KEYEMULATOR;
                        }
                        else
                        {
                            //Backward compability
                            var airframeAsString = fileLine.Replace("Airframe=", "").Trim();
                            if (airframeAsString.StartsWith("SA342"))
                            {
                                _airframe = DCSAirframe.SA342M;
                            }
                            else if (airframeAsString.StartsWith("P51D") || airframeAsString.StartsWith("TF51D"))
                            {
                                _airframe = DCSAirframe.P51D;
                            }
                            else if (airframeAsString.StartsWith("L39"))
                            {
                                _airframe = DCSAirframe.L39ZA;
                            }
                            else
                            {
                                _airframe = (DCSAirframe)Enum.Parse(typeof(DCSAirframe), airframeAsString);
                            }
                        }
                        DCSBIOSControlLocator.Airframe      = _airframe;
                        DCSBIOSControlLocator.JSONDirectory = _jsonDirectory;
                    }
                    else if (fileLine.StartsWith("OperationLevelFlag="))
                    {
                        Common.SetOperationModeFlag(int.Parse(fileLine.Replace("OperationLevelFlag=", "").Trim()));
                    }
                    else if (fileLine.StartsWith("UseGenericRadio="))
                    {
                        Common.UseGenericRadio = (bool.Parse(fileLine.Replace("UseGenericRadio=", "").Trim()));
                    }
                    else if (!fileLine.StartsWith("#") && fileLine.Length > 2)
                    {
                        //Process all these lines.
                        if (fileLine.StartsWith("PanelType="))
                        {
                            currentPanelType = (SaitekPanelsEnum)Enum.Parse(typeof(SaitekPanelsEnum), fileLine.Replace("PanelType=", "").Trim());
                        }
                        else if (fileLine.StartsWith("PanelInstanceID="))
                        {
                            currentPanelInstanceID = fileLine.Replace("PanelInstanceID=", "").Trim();
                            _profileFileInstanceIDs.Add(new KeyValuePair <string, SaitekPanelsEnum>(currentPanelInstanceID, currentPanelType));
                        }
                        else if (fileLine.StartsWith("PanelSettingsVersion="))
                        {
                            currentPanelSettingsVersion = fileLine.Trim();
                        }
                        else if (fileLine.StartsWith("BeginPanel"))
                        {
                            insidePanel = true;
                        }
                        else if (fileLine.StartsWith("EndPanel"))
                        {
                            insidePanel = false;
                        }
                        else
                        {
                            if (insidePanel)
                            {
                                var line = fileLine;
                                if (line.StartsWith("\t"))
                                {
                                    line = line.Replace("\t", "");
                                }
                                if (currentPanelSettingsVersion != null)
                                {
                                    //0X marks that setting version isn't used (yet). Any number above 0 indicated the panel are using new versions of the settings
                                    //and that old settings won't be loaded.
                                    if (currentPanelSettingsVersion.EndsWith("0X"))
                                    {
                                        _listPanelSettingsData.Add(line + sepString + currentPanelInstanceID);
                                    }
                                    else
                                    {
                                        _listPanelSettingsData.Add(line + sepString + currentPanelInstanceID + sepString + currentPanelSettingsVersion);
                                    }
                                }
                                else
                                {
                                    _listPanelSettingsData.Add(line + sepString + currentPanelInstanceID);
                                }
                            }
                        }
                    }
                }
                //For backwards compability 10.11.2018
                if (Common.GetOperationModeFlag() == 0)
                {
                    SetOperationLevelFlag();
                }

                SendSettingsReadEvent();
                CheckAllProfileInstanceIDsAgainstAttachedHardware();
                return(true);
            }
            catch (Exception ex)
            {
                Common.ShowErrorMessageBox(1061, ex);
                return(false);
            }
        }
Exemple #17
0
        public bool LoadProfile(string filename)
        {
            try
            {
                Common.DebugP("LoadProfile filename : " + filename);
                if (!string.IsNullOrEmpty(filename))
                {
                    _filename        = filename;
                    _lastProfileUsed = filename;
                }

                /*
                 * 0 Open specified filename (parameter) if not null
                 * 1 If exists open last profile used (settings)
                 * 2 Try and open default profile located in My Documents
                 * 3 If none found create default file
                 */
                _isNewProfile = false;
                ClearAll();
                if (string.IsNullOrEmpty(_filename))
                {
                    if (!string.IsNullOrEmpty(_lastProfileUsed) && File.Exists(_lastProfileUsed))
                    {
                        _filename = _lastProfileUsed;
                    }
                    else if (File.Exists(DefaultFile()))
                    {
                        _filename        = DefaultFile();
                        _lastProfileUsed = filename;
                    }
                }

                Common.DebugP("LoadProfile _lastProfileUsed : " + _lastProfileUsed);
                Common.DebugP("LoadProfile _filename : " + _filename);

                if (string.IsNullOrEmpty(_filename) || !File.Exists(_filename))
                {
                    //Main window will handle this
                    Common.DebugP("LoadProfile returns false");
                    return(false);
                }

                /*
                 * Read all information and add InstanceID to all lines using BeginPanel and EndPanel
                 *
                 * PanelType=PZ55SwitchPanel
                 * PanelInstanceID=\\?\hid#vid_06a3&pid_0d06#8&3f11a32&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
                 * BeginPanel
                 *      SwitchPanelKey{1KNOB_ENGINE_RIGHT}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_LEFT}\o/OSKeyPress{FiftyMilliSec,LCONTROL + VK_Q}
                 *      SwitchPanelKey{1KNOB_ENGINE_BOTH}\o/OSKeyPress{FiftyMilliSec,LSHIFT + VK_C}
                 * EndPanel
                 *
                 */
                var oldProfileStandard = true;
                var fileLines          = File.ReadAllLines(_filename);
                foreach (var fileLine in fileLines)
                {
                    if (fileLine.StartsWith("PanelType="))
                    {
                        oldProfileStandard = false;
                        break;
                    }
                }
                SaitekPanelsEnum currentPanelType       = SaitekPanelsEnum.Unknown;
                string           currentPanelInstanceID = null;
                var insidePanel = false;
                var sepString   = "\\o/";

                foreach (var fileLine in fileLines)
                {
                    if (fileLine.StartsWith("Airframe="))
                    {
                        _airframe = (DCSAirframe)Enum.Parse(typeof(DCSAirframe), fileLine.Replace("Airframe=", "").Trim());
                        DCSBIOSControlLocator.Airframe      = _airframe;
                        DCSBIOSControlLocator.JSONDirectory = _jsonDirectory;
                    }
                    else if (!fileLine.StartsWith("#") && fileLine.Length > 2)
                    {
                        if (oldProfileStandard)
                        {
                            _listPanelSettingsData.Add(fileLine);
                        }
                        else
                        {
                            //Process all these lines.
                            if (fileLine.StartsWith("PanelType="))
                            {
                                currentPanelType = (SaitekPanelsEnum)Enum.Parse(typeof(SaitekPanelsEnum), fileLine.Replace("PanelType=", "").Trim());
                            }
                            else if (fileLine.StartsWith("PanelInstanceID="))
                            {
                                currentPanelInstanceID = fileLine.Replace("PanelInstanceID=", "").Trim();
                                _profileFileInstanceIDs.Add(new KeyValuePair <string, SaitekPanelsEnum>(currentPanelInstanceID, currentPanelType));
                            }
                            else if (fileLine.StartsWith("BeginPanel"))
                            {
                                insidePanel = true;
                            }
                            else if (fileLine.StartsWith("EndPanel"))
                            {
                                insidePanel = false;
                            }
                            else
                            {
                                if (insidePanel)
                                {
                                    if (fileLine.StartsWith("\t"))
                                    {
                                        _listPanelSettingsData.Add(fileLine.Substring(1) + sepString + currentPanelInstanceID);
                                    }
                                    else
                                    {
                                        _listPanelSettingsData.Add(fileLine.Substring(1) + sepString + currentPanelInstanceID);
                                    }
                                }
                            }
                        }
                    }
                }
                SendSettingsReadEvent();
                CheckAllProfileInstanceIDsAgainstAttachedHardware();
                return(true);
            }
            catch (Exception ex)
            {
                Common.ShowErrorMessageBox(1061, ex);
                return(false);
            }
        }