public MainWindow() { ConsoleLogger.Init(); AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); window = this; InitializeComponent(); WindowConfig.Init(); //the timer is used to let the window initialize first, then move the screen DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(100); timer.Start(); timer.Tick += new EventHandler(delegate(object s, EventArgs a) { if (WindowConfig.IsAutoRestart == 1) { this.Height = WindowConfig.WindowHeight; this.Width = WindowConfig.WindowWidth; this.Top = WindowConfig.WindowTop; this.Left = WindowConfig.WindowLeft; this.WindowState = WindowConfig.WindowState; } //reset the window config WindowConfig.IsAutoRestart = 0; WindowConfig.Save(); timer.Stop(); }); DataContext = new MainWindowViewModel(); //set the default selection to 1 leftControlBar.SelectedIndex = 0; Modality.AddDefault(); RP.AddDefault(); Doctor.AddDefault(); Room.AddDefault(); //Start the timer, restart the program automatically every day WindowAutoRestart.Init(); InjectionsManager.Init(); NetworkManager.Init(this, WindowConfig.IsAutoRestart == 1, WindowConfig.IsServer == 1); }