/// <summary> /// The Loaded event for the Window where we will execute code that should run when the Window /// is first put into place. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void MainWindow_Loaded(object sender, RoutedEventArgs e) { // We are going to hide the window while it's loading, we will show it at the end of this // to avoid the flickering and repositioning the settings being loaded causes. this.Hide(); if (Utilities.Utilities.IsRunningAsUwp()) { // The settings for the app load in the app startup, they will then try to load the last profile that was used. App.Conveyor.EchoInfo($"{{GA{{gvalon {{GM{{gud {{GC{{glient{{x: Version {Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString() ?? "Unknown"} (UWP)"); MenuItemUpdateClient.Visibility = Visibility.Collapsed; } else { // The settings for the app load in the app startup, they will then try to load the last profile that was used. App.Conveyor.EchoInfo($"{{GA{{gvalon {{GM{{gud {{GC{{glient{{x: Version {Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString() ?? "Unknown"}"); } try { int count = Utilities.Utilities.UpdatePlugins(); if (count == 1) { App.Conveyor.EchoSuccess($"{count.ToString()} plugin was updated."); } else if (count > 1) { App.Conveyor.EchoSuccess($"{count.ToString()} plugins were updated."); } } catch (Exception ex) { App.Conveyor.EchoError("An error occurred copying updated plugins."); App.Conveyor.EchoError(ex.Message); } try { int count = Utilities.Utilities.CleanupUpdatesFolder(); if (count > 0) { App.Conveyor.EchoInfo($"{count.ToString()} files(s) deleted from the updates folder."); } } catch (Exception ex) { App.Conveyor.EchoError("An error occurred removing old updates from the updates folder."); App.Conveyor.EchoError(ex.Message); } try { this.DataContext = this.ViewModel; // Wire up any events that have to be wired up through code. TextInput.Editor.PreviewKeyDown += this.Editor_PreviewKeyDown; // Wire up what we're going to do for the search box. TitleBar.SearchBox.SearchExecuted += this.SearchBox_SearchExecutedAsync; // Pass the necessary reference from this page to the Interpreter. Add the interpreter // references. this.Interp = AppServices.GetService <Interpreter>(); // Setup the handler so when it wants to write to the main window it can by raising the echo event. Interp.Echo += this.InterpreterEcho; // Setup the tick timer. TickTimer = new TickTimer(App.Conveyor); // Setup the scheduled and batch tasks. this.ScheduledTasks = new ScheduledTasks(this.Interp); this.BatchTasks = new BatchTasks(this.Interp); // Load any plugin classes from the plugins folder. They will be "activated" when a mud who matches // the plugin IP is connected to. this.LoadPlugins(); } catch (Exception ex) { App.Conveyor.EchoError("A critical error on startup occurred."); App.Conveyor.EchoError(ex.Message); App.Conveyor.EchoError(ex?.StackTrace ?? "No stack trace available."); } // Show the connection manager, if they don't select something, exit the entire program. var cm = new ConnectionManagerWindow(); var result = cm.ShowDialog(); if (!result.GetValueOrDefault(false)) { App.InstanceGlobals.SkipSaveOnExit = true; Application.Current.Shutdown(0); } // We're at the end of load, show the window. this.Show(); }
/// <summary> /// Shows the connection manager window. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MenuItemConnectionManager_OnClick(object sender, RoutedEventArgs e) { var cm = new ConnectionManagerWindow(); cm.ShowDialog(); }