Esempio n. 1
0
        private async void PresetComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (PresetComboBox.SelectedItem == null)
            {
                return;
            }

            var path       = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + PresetComboBox.SelectedItem.ToString() + ".json";
            var pointsPath = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + PresetComboBox.SelectedItem.ToString() + "_KeyPoints.json";

            Globals.KeyActions = Json.Serializer.Deserialize <List <KeyAction> >(File.ReadAllText(path));
            KeyAction.KeyActionsUpgrade(Globals.KeyActions);
            UpdateKeyList();
            if (File.Exists(pointsPath))
            {
                var points = Json.Serializer.Deserialize <KeyPointsModel>(File.ReadAllText(pointsPath));
                Globals.LeftControllerPoints        = new List <UPoint>(points.LeftTouchPadPoints);
                Globals.RightControllerPoints       = new List <UPoint>(points.RightTouchPadPoints);
                Globals.LeftControllerStickPoints   = new List <UPoint>(points.LeftStickPoints);
                Globals.RightControllerStickPoints  = new List <UPoint>(points.RightStickPoints);
                Globals.LeftControllerCenterEnable  = points.LeftCenterKeyEnable;
                Globals.RightControllerCenterEnable = points.RightCenterKeyEnable;
                Globals.EnableSkeletal = points.EnableSkeletal;
                UpdateTouchPadPoints();
                UpdateStickPoints();
                await Globals.Client.SendCommandAsync(new PipeCommands.SetControllerTouchPadPoints
                {
                    isStick           = false,
                    LeftPoints        = Globals.LeftControllerPoints,
                    LeftCenterEnable  = LeftCenterKeyCheckBox.IsChecked.Value,
                    RightPoints       = Globals.RightControllerPoints,
                    RightCenterEnable = RightCenterKeyCheckBox.IsChecked.Value
                });

                await Globals.Client.SendCommandAsync(new PipeCommands.SetControllerTouchPadPoints
                {
                    isStick     = true,
                    LeftPoints  = Globals.LeftControllerStickPoints,
                    RightPoints = Globals.RightControllerStickPoints,
                });

                TouchPadApplyButton.IsEnabled = false;
            }
            await Globals.Client.SendCommandAsync(new PipeCommands.SetKeyActions {
                KeyActions = Globals.KeyActions
            });

            CustomNameTextBox.Text = PresetComboBox.SelectedItem.ToString();
            EnableSkeletalInputCheckBox.IsChecked = Globals.EnableSkeletal;
        }