public static void Store(KeyBindings kb) { BinaryFormatter bf = new BinaryFormatter(); using (FileStream fs = new FileStream(FilePath, FileMode.Create)) { bf.Serialize(fs, kb); fs.Close(); } }
public static void LoadDefault(KeyBindings kb) { kb[KeyBindingType.Forward] = Keys.W; kb[KeyBindingType.Brake] = Keys.S; kb[KeyBindingType.TurnLeft] = Keys.A; kb[KeyBindingType.TurnRight] = Keys.D; kb[KeyBindingType.Skill_1] = Keys.D1; kb[KeyBindingType.Skill_2] = Keys.D2; kb[KeyBindingType.Skill_3] = Keys.D3; kb[KeyBindingType.Skill_4] = Keys.D4; }
public static KeyBindings Load() { KeyBindings kb = null; if (File.Exists(FilePath)) { BinaryFormatter bf = new BinaryFormatter(); using (FileStream fs = new FileStream(FilePath, FileMode.Open)) { kb = (KeyBindings)bf.Deserialize(fs); fs.Close(); } } else { kb = new KeyBindings(); LoadDefault(kb); Store(kb); } return kb; }