/// <summary> /// First init /// </summary> private void Init() { // Set rpogramstate to running ProgramState.IsRunning = true; // Read the config files on startup ConfigFileHelpers.ReadServerConfigFile(); // Try to connect to the server Task.Run(async() => { await ProgramState.ServerConnection.ConnectAsync(); await DatabaseHelpers.Init(); }); // Set the current screen CurrentScreen = MainPages.WellcomeScreen; // The await does not work for some f****** reason! while (DatabaseHelpers.AllProducts == null) { ; } // Set this VM VM = this; }
/// <summary> /// Switches to another user control /// </summary> /// <param name="control">A user control to show</param> public static void SwithToControl(UserControl control) { var main = (MainWindow)Application.Current.MainWindow; if (main.TransitionControl.Content is Calculator) { (main.TransitionControl.Content as Calculator).SaveMemSession(); ConfigFileHelpers.SerializeFunctionUsageStats(); ConfigFileHelpers.SerializeConstantUsageStats(); Properties.Settings.Default.Save(); } var dispose = main.TransitionControl.Content as IDisposable; if (dispose != null) { dispose.Dispose(); } main.TransitionControl.Content = null; foreach (Flyout flyout in main.Flyouts.Items) { flyout.IsOpen = false; } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); main.TransitionControl.Content = control; }
private async void Init() { ConfigFileHelpers.ReadServerConfigFile(); if (!await ProgramState.Server.ConnectAsync()) { MessageBox.Show("Kunde inte etablera anslutning till servern.\nProgrammet körs i offline-läge."); } }
private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = !WindowManager.CloseAll(); if (TransitionControl.Content is Calculator) { ConfigFileHelpers.SerializeFunctionUsageStats(); ConfigFileHelpers.SerializeConstantUsageStats(); } App.SaveSettings(); Properties.Settings.Default.Save(); }
public async void Init() { ProgramState.IsRunning = true; ConfigFileHelpers.ReadServerConfigFile(); if (await ProgramState.ServerConnection.ConnectAsync()) { MessageBox.Show("Terminal is connected to the server"); } else { MessageBox.Show("Could not connect to the server, RUNNING IN OFFLINE MODE"); } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { try { if (this.IsDesignMode()) { return; } UsageStats = ConfigFileHelpers.DeSerializeFunctionUsageStats(); } catch (Exception) { UsageStats = new Dictionary <string, uint>(); } RenderMostUsed(); }