コード例 #1
0
 private void CustomSaveButton_Click(object sender, RoutedEventArgs e)
 {
     if (Globals.CheckFileNameIsValid(CustomNameTextBox.Text) == false)
     {
         MessageBox.Show(LanguageSelector.Get("FileNameIsInvalidError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     var path = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + CustomNameTextBox.Text + ".json";
     var pointsPath = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + CustomNameTextBox.Text + "_KeyPoints.json";
     if (File.Exists(path) || File.Exists(pointsPath))
     {
         if (MessageBox.Show(LanguageSelector.Get("Overwritten"), LanguageSelector.Get("Confirm"), MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel)
         {
             return;
         }
     }
     File.WriteAllText(path, Json.Serializer.ToReadable(Json.Serializer.Serialize(Globals.KeyActions)));
     if (Globals.LeftControllerPoints == null) Globals.LeftControllerPoints = new List<UPoint>();
     if (Globals.RightControllerPoints == null) Globals.RightControllerPoints = new List<UPoint>();
     if (Globals.LeftControllerStickPoints == null) Globals.LeftControllerStickPoints = new List<UPoint>();
     if (Globals.RightControllerStickPoints == null) Globals.RightControllerStickPoints = new List<UPoint>();
     var points = new KeyPointsModel()
     {
         LeftCenterKeyEnable = Globals.LeftControllerCenterEnable,
         RightCenterKeyEnable = Globals.RightControllerCenterEnable,
         LeftTouchPadPoints = new List<UPoint>(Globals.LeftControllerPoints),
         RightTouchPadPoints = new List<UPoint>(Globals.RightControllerPoints),
         LeftStickPoints = new List<UPoint>(Globals.LeftControllerStickPoints),
         RightStickPoints = new List<UPoint>(Globals.RightControllerStickPoints),
         EnableSkeletal = Globals.EnableSkeletal,
     };
     File.WriteAllText(pointsPath, Json.Serializer.ToReadable(Json.Serializer.Serialize(points)));
     PresetComboBox.ItemsSource = Directory.EnumerateFiles(Globals.GetCurrentAppDir() + PresetDirectory, "*.json").Where(d => d.Contains("_KeyPoints.json") == false).Select(d => System.IO.Path.GetFileNameWithoutExtension(d));
 }
コード例 #2
0
        private void CustomSaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (Globals.CheckFileNameIsValid(CustomNameTextBox.Text) == false)
            {
                MessageBox.Show(LanguageSelector.Get("FileNameIsInvalidError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            var path = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + CustomNameTextBox.Text + ".json";

            if (File.Exists(path))
            {
                if (MessageBox.Show(LanguageSelector.Get("Overwritten"), LanguageSelector.Get("Confirm"), MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }
            File.WriteAllText(path, Json.Serializer.ToReadable(Json.Serializer.Serialize(Globals.KeyActions)));
            PresetComboBox.ItemsSource = Directory.EnumerateFiles(Globals.GetCurrentAppDir() + PresetDirectory, "*.json").Select(d => System.IO.Path.GetFileNameWithoutExtension(d));
        }