public MainWindow() { AvaloniaXamlLoader.Load(this); #if DEBUG this.AttachDevTools(); #endif // Register this window on App object App.CurrentApp.RegisterWindow(this); // Find control objects _ctrlConnectionProfile = this.Find <ConnectionProfileView>("CtrlConnectionProfile"); // Update title var versionInfoAttrib = Assembly.GetExecutingAssembly() .GetCustomAttribute <AssemblyInformationalVersionAttribute>(); var versionString = versionInfoAttrib?.InformationalVersion ?? ""; this.Title = $"{this.Title} {versionString}"; this.Find <TextBlock>("TxtTitle").Text = this.Title; // Register view services var ctrlDialogHost = this.Find <MainWindowFrame>("CtrlWindowFrame").DialogHostControl; var helpRepo = new IntegratedDocRepository(Assembly.GetExecutingAssembly()); this.ViewServices.Add(new ConnectionConfigControlService(ctrlDialogHost)); this.ViewServices.Add(new MessageBoxControlService(ctrlDialogHost)); this.ViewServices.Add(new ExportViewService(ctrlDialogHost)); this.ViewServices.Add(new ImportViewService(ctrlDialogHost)); this.ViewServices.Add(new SaveFileDialogService(this)); this.ViewServices.Add(new OpenFileDialogService(this)); this.ViewServices.Add(new AboutDialogService(ctrlDialogHost)); this.ViewServices.Add(new HelpBrowserService(this, helpRepo)); this.ViewServices.Add(new ViewResourceService(App.CurrentApp)); // Load initial main view model this.ViewModel = new MainWindowViewModel(); this.ViewModel.PropertyChanged += this.OnViewModel_PropertyChanged; this.DataContext = this.ViewModel; // Configure error handling CommonErrorHandling.Current.MainWindow = this; }
public MainWindow() { AvaloniaXamlLoader.Load(this); // Apply initial theme this.SetTheme(MessageCommunicatorGlobalProperties.Current.CurrentTheme); MessageBus.Current.ListenWeak(this); var versionInfoAttrib = Assembly.GetExecutingAssembly() .GetCustomAttribute <AssemblyInformationalVersionAttribute>(); var versionString = versionInfoAttrib?.InformationalVersion ?? ""; this.Title = $"{this.Title} {versionString}"; // Register view services var ctrlDialogHost = this.FindControl <DialogHostControl>("CrtlDialogHost"); var helpRepo = new IntegratedDocRepository(Assembly.GetExecutingAssembly()); this.ViewServices.Add(new ConnectionConfigControlService(ctrlDialogHost)); this.ViewServices.Add(new MessageBoxControlService(ctrlDialogHost)); this.ViewServices.Add(new ExportViewService(ctrlDialogHost)); this.ViewServices.Add(new ImportViewService(ctrlDialogHost)); this.ViewServices.Add(new SaveFileDialogService(this)); this.ViewServices.Add(new OpenFileDialogService(this)); this.ViewServices.Add(new AboutDialogService(ctrlDialogHost)); this.ViewServices.Add(new HelpBrowserService(this, helpRepo)); //this.ViewServices.Add(new HelpViewerService(ctrlDialogHost, helpRepo)); // Load initial main view model this.ViewModel = new MainWindowViewModel(); this.DataContext = this.ViewModel; #if DEBUG this.AttachDevTools(); #endif // Configure error handling CommonErrorHandling.Current.MainWindow = this; }