Пример #1
0
 public MainWindow()
 {
     this.DataContext = Data.db;
     InitializeComponent();
     /*statusBarComport.DataContext = Data.db;
     statusBarLastPing.DataContext = Data.db;
     statusBarEmergencyStop.DataContext = Data.db;
     statusBarFixedInputSequence.DataContext = Data.db;*/
     MathNet.Numerics.Control.LinearAlgebraProvider = new MklLinearAlgebraProvider();
     Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
     Thread.CurrentThread.Priority = ThreadPriority.Highest;
     if (File.Exists("cfg.bin"))
     {
         try
         {
             IFormatter formatter = new BinaryFormatter();
             using (Stream stream = new FileStream("cfg.bin", FileMode.Open, FileAccess.Read, FileShare.Read))
             {
                 Data.cfg = (Settings)formatter.Deserialize(stream);
             }
         }
         catch
         {
             Data.cfg = new Settings();
         }
         finally
         {
         }
     }
     else
     {
         Data.cfg = new Settings();
     }
     settingsWindow = new SettingsWindow();
     Data.vis = new Visualization(visCanvas, joystickCanvas);
     Data.vis.drawField();
     Debug.WriteLine("State Const {2}: {0} ({1})", Thread.CurrentThread.GetApartmentState(), Thread.CurrentThread.ManagedThreadId, System.Reflection.MethodBase.GetCurrentMethod().Name);
 }
Пример #2
0
 private void Window_Closed(object sender, EventArgs e)
 {
     settingsWindow.Close();
     settingsWindow = null;
     IFormatter formatter = new BinaryFormatter();
     using (Stream stream = new FileStream("cfg.bin", FileMode.Create, FileAccess.Write, FileShare.Read))
     {
         formatter.Serialize(stream, Data.cfg);
     }
 }