Exemple #1
0
 public static void LoadKeybinds()
 {
     if (File.Exists(Path.Combine(MainWindow.AppDataDir, "bindings.dat")))
     {
         try
         {
             using (var f = new FileStream(Path.Combine(MainWindow.AppDataDir, "bindings.dat"), FileMode.Open))
             {
                 Logger.Write("Loading keybind profile");
                 var x = new DataContractSerializer(typeof(KeybindProfile));
                 _keybind = (KeybindProfile)x.ReadObject(f);
             }
         }
         catch
         {
             Logger.Write("No profile found. Loading default keybinds.");
             _keybind = new KeybindProfile {
                 Keybinds = ControllerData.DefaultBinds
             };
         }
     }
     else
     {
         _keybind = new KeybindProfile {
             Keybinds = ControllerData.DefaultBinds
         };
     }
     BindingsUpdated?.Invoke();
 }
Exemple #2
0
 public static void ResetBinds()
 {
     _keybind          = new KeybindProfile();
     _keybind.Keybinds = new Dictionary <ControllerButton, Key>(ControllerData.DefaultBinds);
     SaveKeybinds();
     BindingsUpdated?.Invoke();
 }
Exemple #3
0
 public static bool WriteFile(KeybindProfile Profile, string Filename)
 {
     try
     {
         using (var outfile = new FileStream(Filename, FileMode.Create))
         {
             var x = new DataContractSerializer(typeof(KeybindProfile));
             x.WriteObject(outfile, Profile);
             return(true);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return(false);
 }
Exemple #4
0
 public static void LoadProfile(KeybindProfile profile)
 {
     _keybind = profile;
     BindingsUpdated?.Invoke();
 }