コード例 #1
0
        void LoadUserSetting(UserSetting userSetting)
        {
            _UserSetting = userSetting;
            if (_UserSetting == null)
            {
                Data = null;
                return;
            }
            MapTypeComboBox.ItemsSource = new List <MapType>()
            {
                MapType.Button, MapType.Axis, MapType.Slider, MapType.POV
            }
            .Select(x => x.ToString()).ToList();
            MapTypeComboBox.SelectedItem     = MapType.Button.ToString();
            MapEventTypeComboBox.ItemsSource = Enum.GetValues(typeof(MapEventType)).Cast <MapEventType>()
                                               .Select(x => x.ToString()).ToList();
            MapEventTypeComboBox.SelectedItem = MapEventType.EnterUpLeaveDown.ToString();
            MapRpmTypeComboBox.ItemsSource    = Enum.GetValues(typeof(MapRpmType)).Cast <MapRpmType>()
                                                .Select(x => x.ToString()).ToList();
            MapRpmTypeComboBox.SelectedItem = MapRpmType.DownIncrease.ToString();
            UserMacrosTabPage.Header        = string.Format("User Macros for {0}", userSetting.InstanceName);

            RefreshList();

            // https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.keys?view=netcore-3.1
            AllKeys = ((Key[])Enum.GetValues(typeof(Key))).ToList();
            AddKeys(Control1KeysComboBox, "Mod", new Key[] {
                Key.Shift, Key.ShiftKey, Key.LShiftKey, Key.RShiftKey,
                Key.Control, Key.ControlKey, Key.LControlKey, Key.RControlKey,
                Key.Alt, Key.Menu, Key.RMenu, Key.LMenu,
                Key.LWin, Key.RWin,
            });
            AddKeys(CharKeysComboBox, "Key", AllKeys.Where(x => x >= Key.A && x <= Key.Z || x == Key.Space));
            AddKeys(NumPadKeysComboBox, "NumPad", AllKeys.Where(x => x >= Key.NumPad0 && x <= Key.NumPad9));
            AddKeys(FKeysComboBox, "F-Key", AllKeys.Where(x => x >= Key.F1 && x <= Key.F24));
            AddKeys(Control2KeysComboBox, "Control", new Key[] {
                Key.Escape, Key.Tab, Key.CapsLock, Key.Back, Key.Enter,
                Key.Insert, Key.Delete, Key.Home, Key.End, Key.PageUp, Key.PageDown, Key.NumLock
            });
            // Add remaining keys
            AddKeys(OtherKeysComboBox, "Other", AllKeys);
            AddKeys(MouseKeysComboBox, "Mouse", new Key[] { Key.LButton, Key.MButton, Key.RButton, Key.XButton1, Key.XButton2 });
            // Add X360CE buttons.
            var xKeys = Enum.GetValues(typeof(MapCode)).Cast <MapCode>()
                        .Where(x => SettingsConverter.IsButtonOrDirection(x));
            var sKeys = xKeys.Select(x => x.ToString()).Distinct().ToList();

            sKeys.Insert(0, "XInput");
            XButtonsComboBox.ItemsSource       = sKeys;
            XButtonsComboBox.SelectedIndex     = alwaysSelectedIndex;
            XButtonsComboBox.SelectionChanged += KeysComboBox_SelectionChanged;
        }