public static void Main(string[] args) { Logger.Current = new Logger(); AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; GeneralSettings.Settings = GeneralSettings.Load(); PleasantSettings.Settings = PleasantSettings.Load(); BuildAvaloniaApp().Start(AppMain, args); }
public MainWindow() { AvaloniaXamlLoader.Load(this); this.AttachDevTools(); MainViewModel viewModel = new MainViewModel(); DataContext = viewModel; viewModel.NotificationManager = new WindowNotificationManager(this) { Position = NotificationPosition.TopRight, MaxItems = 3, ZIndex = 1 }; #if DEBUG KeyDown += (s, e) => { if (e.Key == Key.LeftShift) { _canGetAnException = true; } else { _canGetAnException = false; } }; #endif TemplateApplied += (s, e) => this.GetDataContext <MainViewModel>().Initialize(); Closing += async(s, e) => { e.Cancel = true; if (!_closing && !CancelClose) { GeneralSettings.Save(); PleasantSettings.Save(); for (int i = 0; i < viewModel.TabItems.Count; i++) { PleasantTabItem tabItem = viewModel.TabItems[i]; if (!tabItem.IsEditedIndicator) { continue; } viewModel.SelectedTab = tabItem; SavedResult result = await viewModel.SaveFile(tabItem, true); if (result == SavedResult.Cancel) { return; } } for (int i1 = 0; i1 < ModuleManager.System.Modules.Count; i1++) { ModuleManager.System.Modules[i1].Release(); } _closing = true; #if DEBUG if (_canGetAnException) { throw new System.Exception("Debug exception"); } #endif Close(); } else { e.Cancel = false; } }; WindowsManager.OtherModalWindows.CollectionChanged += OtherModalWindows_CollectionChanged; }