Exemplo n.º 1
0
        public void SaveSettings(ref BLINK.Settings settings)
        {
            BinaryFormatter binaryFormatter = new BinaryFormatter();

            using (FileStream fs = new FileStream(Path.Combine(PersonalFolder, "settings"), FileMode.Create))
            {
                if (settings == null)
                {
                    settings = new BLINK.Settings();
                }
                binaryFormatter.Serialize(fs, settings);
                Log.Debug("BLINK", $"Setting Saved: CenterPoint - {settings.CenterPoint}");
                Log.Debug("BLINK", $"Setting Saved: TurnThreshold - {settings.TurnThreshold}");
                Log.Debug("BLINK", $"Setting Saved: AcceleroThreshold - {settings.AcceleroThreshold}");
                fs.Close();
            }
        }
Exemplo n.º 2
0
 public void LoadSettings(ref BLINK.Settings settings)
 {
     if (!File.Exists(Path.Combine(PersonalFolder, "settings")))
     {
         SaveSettings(ref settings);
     }
     else
     {
         BinaryFormatter binaryFormatter = new BinaryFormatter();
         using (FileStream fs = new FileStream(Path.Combine(PersonalFolder, "settings"), FileMode.Open))
         {
             BLINK.Settings.Singleton = binaryFormatter.Deserialize(fs) as BLINK.Settings;
             Log.Debug("BLINK", $"Setting Loaded: CenterPoint - {settings.CenterPoint}");
             Log.Debug("BLINK", $"Setting Loaded: TurnThreshold - {settings.TurnThreshold}");
             Log.Debug("BLINK", $"Setting Loaded: AcceleroThreshold - {settings.AcceleroThreshold}");
             fs.Close();
         }
     }
 }