Ejemplo n.º 1
0
        public RibbonView()
        {
            InitializeComponent();
            StaticReferences.RibbonViewInstance = this;
            var dxEngineSettingsStorage = new DXEngineSettingsStorage();

            DXEngineSettings.Initialize(dxEngineSettingsStorage);
            this.MaxBackgroundThreadsCount = Environment.ProcessorCount - 1;
        }
Ejemplo n.º 2
0
        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));
                });
            });
        }