// Application OnStartup Override. protected override async void OnStartup(StartupEventArgs e) { Interactions.ShowFirstTimeSetup.RegisterHandler(interaction => { var dialog = new DialogHostView(); dialog.ViewModel.HostedViewModel = Locator.Current.GetService <FirstSetupWizardViewModel>(); return(Observable.Start(() => { var result = dialog.ShowDialog() == true; interaction.SetOutput(result); }, RxApp.MainThreadScheduler)); }); var settings = Locator.Current.GetService <ISettingsManager>(); var loggerService = Locator.Current.GetService <ILoggerService>(); // Startup speed boosting (HC) ApplicationHelper.StartProfileOptimization(); loggerService.Log("Starting application"); await Initializations.InitializeWebview2(loggerService); loggerService.Log("Initializing red database"); Initializations.InitializeThemeHelper(); // main app viewmodel loggerService.Log("Initializing Shell"); Initializations.InitializeShell(settings); loggerService.Log("Initializing Discord RPC API"); DiscordHelper.InitializeDiscordRPC(); loggerService.Log("Initializing Github API"); Initializations.InitializeGitHub(); // Some things can only be initialized after base.OnStartup(e); base.OnStartup(e); //loggerService.Info("Initializing NodeNetwork."); //NNViewRegistrar.RegisterSplat(); }
public ProjectExplorerView() { InitializeComponent(); TreeGrid.ItemsSourceChanged += TreeGrid_ItemsSourceChanged; TreeGridFlat.ItemsSourceChanged += TreeGridFlat_ItemsSourceChanged; TreeGrid.RowDragDropController.DragStart += RowDragDropController_DragStart; TreeGrid.RowDragDropController.DragOver += RowDragDropController_DragOver; TreeGrid.RowDragDropController.DragLeave += RowDragDropController_DragLeave; TreeGrid.RowDragDropController.Drop += RowDragDropController_Drop; TreeGrid.RowDragDropController.Dropped += RowDragDropController_Dropped; TreeGrid.RowDragDropController.CanAutoExpand = true; tabControl.SelectedIndexChanged += tabControl_SelectedIndexChanged; ViewModel = Locator.Current.GetService <ProjectExplorerViewModel>(); DataContext = ViewModel; this.WhenActivated(disposables => { Interactions.DeleteFiles.RegisterHandler( interaction => { var count = interaction.Input.Count(); var result = AdonisUI.Controls.MessageBox.Show( "The selected item(s) will be moved to the Recycle Bin.", "WolvenKit", AdonisUI.Controls.MessageBoxButton.OKCancel, AdonisUI.Controls.MessageBoxImage.Information, AdonisUI.Controls.MessageBoxResult.OK); if (result == AdonisUI.Controls.MessageBoxResult.OK) { interaction.SetOutput(true); } else { interaction.SetOutput(false); } }); Interactions.Rename.RegisterHandler( interaction => { var dialog = new DialogHostView(); var vm = Locator.Current.GetService <RenameDialogViewModel>(); vm.Text = interaction.Input; dialog.ViewModel.HostedViewModel = vm; return(Observable.Start(() => { var result = ""; dialog.Owner = Application.Current.MainWindow; dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (dialog.ShowDialog() == true) { var innerVm = (RenameDialogViewModel)dialog.ViewModel.HostedViewModel; result = innerVm.Text; } interaction.SetOutput(result); }, RxApp.MainThreadScheduler)); }); ViewModel.ExpandAll.Subscribe(x => ExpandAll()); ViewModel.CollapseAll.Subscribe(x => CollapseAll()); ViewModel.ExpandChildren.Subscribe(x => ExpandChildren()); ViewModel.CollapseChildren.Subscribe(x => CollapseChildren()); //EventBindings Observable .FromEventPattern(TreeGrid, nameof(TreeGrid.CellDoubleTapped)) .Subscribe(_ => OnCellDoubleTapped(_.Sender, _.EventArgs as TreeGridCellDoubleTappedEventArgs)) .DisposeWith(disposables); Observable .FromEventPattern(TreeGridFlat, nameof(TreeGridFlat.CellDoubleTapped)) .Subscribe(_ => OnCellDoubleTapped(_.Sender, _.EventArgs as TreeGridCellDoubleTappedEventArgs)) .DisposeWith(disposables); this.OneWayBind(ViewModel, viewModel => viewModel.BindGrid1, view => view.TreeGrid.ItemsSource) .DisposeWith(disposables); this.OneWayBind(ViewModel, viewModel => viewModel.BindGrid1, view => view.TreeGridFlat.ItemsSource) .DisposeWith(disposables); //ViewModel.WhenAnyValue(x => x.IsFlatModeEnabled).Subscribe(x => UpdateTreeGrid()); this.BindCommand(ViewModel, viewModel => viewModel.OpenRootFolderCommand, view => view.OpenFolderButton); }); }
public ProjectExplorerView() { InitializeComponent(); TreeGrid.ItemsSourceChanged += TreeGrid_ItemsSourceChanged; ViewModel = Locator.Current.GetService <ProjectExplorerViewModel>(); DataContext = ViewModel; this.WhenActivated(disposables => { Interactions.DeleteFiles.RegisterHandler( interaction => { var count = interaction.Input.Count(); var result = AdonisUI.Controls.MessageBox.Show( "The selected items will be deleted permanently.", "WolvenKit", AdonisUI.Controls.MessageBoxButton.OKCancel, AdonisUI.Controls.MessageBoxImage.Information, AdonisUI.Controls.MessageBoxResult.OK); if (result == AdonisUI.Controls.MessageBoxResult.OK) { interaction.SetOutput(true); } else { interaction.SetOutput(false); } }); Interactions.Rename.RegisterHandler( interaction => { var dialog = new DialogHostView(); var vm = Locator.Current.GetService <RenameDialogViewModel>(); vm.Text = interaction.Input; dialog.ViewModel.HostedViewModel = vm; return(Observable.Start(() => { var result = ""; dialog.Owner = Application.Current.MainWindow; dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (dialog.ShowDialog() == true) { var innerVm = (RenameDialogViewModel)dialog.ViewModel.HostedViewModel; result = innerVm.Text; } interaction.SetOutput(result); }, RxApp.MainThreadScheduler)); }); ViewModel.ExpandAll.Subscribe(x => ExpandAll()); ViewModel.CollapseAll.Subscribe(x => CollapseAll()); ViewModel.ExpandChildren.Subscribe(x => ExpandChildren()); ViewModel.CollapseChildren.Subscribe(x => CollapseChildren()); //EventBindings Observable .FromEventPattern(TreeGrid, nameof(TreeGrid.CellDoubleTapped)) .Subscribe(_ => OnCellDoubleTapped(_.Sender, _.EventArgs as TreeGridCellDoubleTappedEventArgs)) .DisposeWith(disposables); this.OneWayBind(ViewModel, viewModel => viewModel.BindGrid1, view => view.TreeGrid.ItemsSource) .DisposeWith(disposables); }); }
public RibbonView() { ViewModel = Locator.Current.GetService <RibbonViewModel>(); DataContext = ViewModel; InitializeComponent(); var dxEngineSettingsStorage = new DXEngineSettingsStorage(); DXEngineSettings.Initialize(dxEngineSettingsStorage); MaxBackgroundThreadsCount = Environment.ProcessorCount - 1; this.WhenActivated(disposables => { #region contextual tab bindings // project explorer CPEOpenFileButton.DataContext = Locator.Current.GetService <ProjectExplorerViewModel>(); OpeninFileContext.DataContext = Locator.Current.GetService <ProjectExplorerViewModel>(); CopyFileContext.DataContext = Locator.Current.GetService <ProjectExplorerViewModel>(); PasteFileContext.DataContext = Locator.Current.GetService <ProjectExplorerViewModel>(); DeleteFileContext.DataContext = Locator.Current.GetService <ProjectExplorerViewModel>(); RenameFileContext.DataContext = Locator.Current.GetService <ProjectExplorerViewModel>(); // asset browser this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.AssetBrowserVM.AddSelectedCommand, view => view.AddSelectedItemsButton).DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.AssetBrowserVM.ToggleModBrowserCommand, view => view.ModBrowserButton).DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.AssetBrowserVM.OpenFileLocationCommand, view => view.SearchOpenFileLocation).DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.AssetBrowserVM.AddSearchKeyCommand, view => view.SearchKindButton).DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.AssetBrowserVM.AddSearchKeyCommand, view => view.SearchKindButton).DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.AssetBrowserVM.AddSearchKeyCommand, view => view.SearchKindButton).DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.AssetBrowserVM.AddSearchKeyCommand, view => view.SearchKindButton).DisposeWith(disposables); #endregion _mainViewModel = Locator.Current.GetService <AppViewModel>(); _mainViewModel.ProjectExplorer.WhenAnyValue(x => x.IsActive).Subscribe(b => projectexplorercontextab.SetCurrentValue(ContextTabGroup.IsGroupVisibleProperty, b)); _mainViewModel.AssetBrowserVM.WhenAnyValue(x => x.IsActive).Subscribe(b => abcontextab.SetCurrentValue(ContextTabGroup.IsGroupVisibleProperty, b)); //_mainViewModel.ActiveDocument.WhenAnyValue(x => x != null && x.IsActive).Subscribe(b => // documentContextTab.SetCurrentValue(ContextTabGroup.IsGroupVisibleProperty, b)); #region commands this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.ShowHomePageCommand, view => view.HomePageButton) .DisposeWith(disposables); // App Menu this.BindCommand(ViewModel, viewModel => viewModel.OpenProjectCommand, view => view.AppMenuOpenProjectButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.NewProjectCommand, view => view.AppMenuNewProjectButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.PackProjectCommand, view => view.AppMenuPackProjectButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.PackInstallModCommand, view => view.AppMenuPackInstallButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.NewFileCommand, view => view.AppMenuNewFileButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.SaveFileCommand, view => view.AppMenuSaveFileButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.SaveAsCommand, view => view.AppMenuSaveAsFileButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.SaveAllCommand, view => view.AppMenuSaveAllFileButton) .DisposeWith(disposables); // General this.BindCommand(ViewModel, viewModel => viewModel.OpenProjectCommand, view => view.GeneralOpenProjectButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.NewProjectCommand, view => view.GeneralNewProjectButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.PackProjectCommand, view => view.GeneralPackProjectButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.PackInstallModCommand, view => view.GeneralPackInstallButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.NewFileCommand, view => view.GeneralNewFileButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.SaveFileCommand, view => view.GeneralSaveFileButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.SaveAsCommand, view => view.GeneralSaveAsButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.SaveAllCommand, view => view.GeneralSaveAllButton) .DisposeWith(disposables); //View this.BindCommand(ViewModel, viewModel => viewModel.ViewProjectExplorerCommand, view => view.ViewProjectExplorerButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.ViewAssetBrowserCommand, view => view.ViewAssetBrowserButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.ViewPropertiesCommand, view => view.ViewPropertiesButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.ViewLogCommand, view => view.ViewLogButton) .DisposeWith(disposables); //this.BindCommand(ViewModel, // viewModel => viewModel.ViewCodeEditorCommand, // view => view.ViewCodeEditorButton) // .DisposeWith(disposables); //Options this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.ShowSettingsCommand, view => view.OptionsShowSettingsButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.ShowBugReportCommand, view => view.OptionsShowBugReportButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.ShowFeedbackCommand, view => view.OptionsShowFeedbackButton) .DisposeWith(disposables); // Utilities this.BindCommand(ViewModel, viewModel => viewModel.ShowImportExportToolCommand, view => view.UtilitiesShowImportExportToolButton) .DisposeWith(disposables); // toolbar this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.NewFileCommand, view => view.ToolbarNewButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.SaveFileCommand, view => view.ToolbarSaveButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.SaveAsCommand, view => view.ToolbarSaveAsButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.SaveAllCommand, view => view.ToolbarSaveAllButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.NewProjectCommand, view => view.ToolbarNewProjectButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.PackModCommand, view => view.ToolbarPackProjectButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.PackInstallModCommand, view => view.ToolbarPackInstallButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel._mainViewModel.ShowSettingsCommand, view => view.ToolbarSettingsButton) .DisposeWith(disposables); #endregion Interactions.ShowBugReport.RegisterHandler(interaction => { var dialog = new DialogHostView(); dialog.ViewModel.HostedViewModel = Locator.Current.GetService <BugReportWizardViewModel>(); dialog.Owner = Application.Current.MainWindow; dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; return(Observable.Start(() => { var result = dialog.ShowDialog() == true; interaction.SetOutput(result); }, RxApp.MainThreadScheduler)); }); Interactions.ShowFeedback.RegisterHandler(interaction => { var dialog = new DialogHostView(); dialog.ViewModel.HostedViewModel = Locator.Current.GetService <FeedbackWizardViewModel>(); dialog.Owner = Application.Current.MainWindow; dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; return(Observable.Start(() => { var result = dialog.ShowDialog() == true; interaction.SetOutput(result); }, RxApp.MainThreadScheduler)); }); }); }