public RibbonView() { InitializeComponent(); StaticReferences.RibbonViewInstance = this; var dxEngineSettingsStorage = new DXEngineSettingsStorage(); DXEngineSettings.Initialize(dxEngineSettingsStorage); this.MaxBackgroundThreadsCount = Environment.ProcessorCount - 1; }
public MainWindow() { // When using the DXEngine from NuGet and when you have purchase a commercial version, // then uncomment the following line to activate the license uncomment (see your User Account web page for more info): //Ab3d.Licensing.DXEngine.LicenseHelper.SetLicense(licenseOwner: "[CompanyName]", // licenseType: "[LicenseType]", // license: "[LicenseText]"); // The following is a sample global exception handler that can be used // to get system info (with details about graphics card and drivers) // in case of exception in DXEngine. // You can use similar code to improve your error reporting data. AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { if (e.ExceptionObject is DXEngineException || e.ExceptionObject is SharpDX.SharpDXException) // SharpDXException is also related with using DirectX { string fullSystemInfo; try { // Note that using SystemInfo requires a reference to System.Management fullSystemInfo = Ab3d.DirectX.Client.Diagnostics.SystemInfo.GetFullSystemInfo(); } catch { fullSystemInfo = null; } // Here we just show a MessageBox with some exception info. // In a real application it is recommended to report or store full exception and system info (fullSystemInfo) MessageBox.Show(string.Format("Unhandled {0} occured while running the sample:\r\n{1}\r\n\r\nIf this is not expected, please report that to [email protected].", e.ExceptionObject.GetType().Name, ((Exception)e.ExceptionObject).Message), "Ab3d.DXEngine exception", MessageBoxButton.OK, MessageBoxImage.Error); } }; // Initialize the DXEngineSettings helper class // First create DXEngineSettingsStorage that is used to read and save user settings and can read overridden settings from application config file // After the DXEngineSettings is initialized we can use the DXEngineSettings.Current property var dxEngineSettingsStorage = new DXEngineSettingsStorage(); DXEngineSettings.Initialize(dxEngineSettingsStorage); // Set default value for MaxBackgroundThreadsCount (the value is set in the same way as in DXScene). // When we have only 1 core, then MaxBackgroundThreadsCount is set to 0 - no multi-threading // When we have 8 processors or less, then use all the processors (one for main thread and (ProcessorCount - 1) for background threads // When we have more the 8 processors, use 7 background threads. When using more threads the gains are very small. this.MaxBackgroundThreadsCount = Math.Min(7, Environment.ProcessorCount - 1); InitializeComponent(); DisableDiagnosticsButton(); this.Loaded += OnLoaded; this.Unloaded += delegate(object sender, RoutedEventArgs args) { CloseDiagnosticsWindow(); // If DiagnosticsWindow is not closed, then close it with closing main samples window if (DXEngineSettings.Current.SystemCapabilities != null) { DXEngineSettings.Current.SystemCapabilities.Dispose(); } }; ContentFrame.LoadCompleted += delegate(object o, NavigationEventArgs args) { // When content of ContentFrame is changed, we try to find the DXViewportView control // that is defined by the newly shown content. // First unsubscribe all previously subscribed events UnsubscribeLastShownDXViewportView(); // Find DXViewportView var foundDXViewportView = FindDXViewportView(ContentFrame.Content); SubscribeDXViewportView(foundDXViewportView); }; // SelectionChanged event handler is used to start the samples with the page set with _startupPage field. // SelectionChanged is used because SelectItem cannot be set from this.Loaded event. SampleList.SelectionChanged += delegate(object sender, SelectionChangedEventArgs args) { if (_startupPage != null) { string savedStartupPage = _startupPage; _startupPage = null; SelectItem(savedStartupPage); } }; }
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)); }); }); }