AddHomeWorkspace() public method

Add a new HomeWorkspace and set as current
public AddHomeWorkspace ( ) : void
return void
Beispiel #1
0
        public DynamoViewModel(DynamoController controller, string commandFilePath)
        {
            //create the model
            _model = new DynamoModel();
            dynSettings.Controller.DynamoModel = _model;

            //register for property change notifications
            //on the model and the controller
            _model.PropertyChanged += _model_PropertyChanged;
            dynSettings.Controller.PropertyChanged += Controller_PropertyChanged;
            _model.Workspaces.CollectionChanged += Workspaces_CollectionChanged;

            _model.AddHomeWorkspace();
            _model.CurrentWorkspace = _model.HomeSpace;

            Controller = controller;

            //Register for a notification when the update manager downloads an update
            dynSettings.Controller.UpdateManager.UpdateDownloaded += Instance_UpdateDownloaded;

            // Instantiate an AutomationSettings to handle record/playback.
            automationSettings = new AutomationSettings(this, commandFilePath);

            OpenCommand = new DelegateCommand(_model.Open, _model.CanOpen);
            ShowOpenDialogAndOpenResultCommand = new DelegateCommand(_model.ShowOpenDialogAndOpenResult, _model.CanShowOpenDialogAndOpenResultCommand);
            WriteToLogCmd = new DelegateCommand(_model.WriteToLog, _model.CanWriteToLog);
            PostUiActivationCommand = new DelegateCommand(_model.PostUIActivation, _model.CanDoPostUIActivation);
            AddNoteCommand = new DelegateCommand(_model.AddNote, _model.CanAddNote);
            AddToSelectionCommand = new DelegateCommand(_model.AddToSelection, _model.CanAddToSelection);
            ShowNewFunctionDialogCommand = new DelegateCommand(_model.ShowNewFunctionDialogAndMakeFunction, _model.CanShowNewFunctionDialogCommand);
            SaveRecordedCommand = new DelegateCommand(SaveRecordedCommands, CanSaveRecordedCommands);
            InsertPausePlaybackCommand = new DelegateCommand(ExecInsertPausePlaybackCommand, CanInsertPausePlaybackCommand);
            GoHomeCommand = new DelegateCommand(GoHomeView, CanGoHomeView);
            SelectAllCommand = new DelegateCommand(SelectAll, CanSelectAll);
            ShowSaveDialogAndSaveResultCommand = new DelegateCommand(ShowSaveDialogAndSaveResult, CanShowSaveDialogAndSaveResult);
            SaveCommand = new DelegateCommand(_model.Save, _model.CanSave);
            SaveAsCommand = new DelegateCommand(_model.SaveAs, _model.CanSaveAs);
            HomeCommand = new DelegateCommand(_model.Home, _model.CanGoHome);
            NewHomeWorkspaceCommand = new DelegateCommand(MakeNewHomeWorkspace, CanMakeNewHomeWorkspace);
            GoToWorkspaceCommand = new DelegateCommand(GoToWorkspace, CanGoToWorkspace);
            DeleteCommand = new DelegateCommand(_model.Delete, _model.CanDelete);
            ExitCommand = new DelegateCommand(Exit, CanExit);
            ToggleFullscreenWatchShowingCommand = new DelegateCommand(ToggleFullscreenWatchShowing, CanToggleFullscreenWatchShowing);
            ToggleCanNavigateBackgroundCommand = new DelegateCommand(ToggleCanNavigateBackground, CanToggleCanNavigateBackground);
            AlignSelectedCommand = new DelegateCommand(AlignSelected, CanAlignSelected); ;
            ShowSaveDialogIfNeededAndSaveResultCommand = new DelegateCommand(ShowSaveDialogIfNeededAndSaveResult, CanShowSaveDialogIfNeededAndSaveResultCommand);
            SaveImageCommand = new DelegateCommand(SaveImage, CanSaveImage);
            ShowSaveImageDialogAndSaveResultCommand = new DelegateCommand(ShowSaveImageDialogAndSaveResult, CanShowSaveImageDialogAndSaveResult);
            UndoCommand = new DelegateCommand(Undo, CanUndo);
            RedoCommand = new DelegateCommand(Redo, CanRedo);
            CopyCommand = new DelegateCommand(_model.Copy, _model.CanCopy);
            PasteCommand = new DelegateCommand(_model.Paste, _model.CanPaste);
            ToggleConsoleShowingCommand = new DelegateCommand(ToggleConsoleShowing, CanToggleConsoleShowing);
            CancelRunCommand = new DelegateCommand(Controller.CancelRunCmd, Controller.CanCancelRunCmd);
            RunExpressionCommand = new DelegateCommand(Controller.RunExprCmd, Controller.CanRunExprCmd);
            DisplayFunctionCommand = new DelegateCommand(Controller.DisplayFunction, Controller.CanDisplayFunction);
            SetConnectorTypeCommand = new DelegateCommand(SetConnectorType, CanSetConnectorType);
            ReportABugCommand = new DelegateCommand(Controller.ReportABug, Controller.CanReportABug);
            GoToWikiCommand = new DelegateCommand(GoToWiki, CanGoToWiki);
            GoToSourceCodeCommand = new DelegateCommand(GoToSourceCode, CanGoToSourceCode);
            ShowPackageManagerSearchCommand = new DelegateCommand(ShowPackageManagerSearch, CanShowPackageManagerSearch);
            ShowInstalledPackagesCommand = new DelegateCommand(ShowInstalledPackages, CanShowInstalledPackages);
            PublishCurrentWorkspaceCommand = new DelegateCommand(PublishCurrentWorkspace, CanPublishCurrentWorkspace);
            PublishSelectedNodesCommand = new DelegateCommand(PublishSelectedNodes, CanPublishSelectedNodes);
            ShowHideConnectorsCommand = new DelegateCommand(ShowConnectors, CanShowConnectors);
            SelectNeighborsCommand = new DelegateCommand(SelectNeighbors, CanSelectNeighbors);
            ClearLogCommand = new DelegateCommand(dynSettings.Controller.ClearLog, dynSettings.Controller.CanClearLog);
            PanCommand = new DelegateCommand(Pan, CanPan);
            ZoomInCommand = new DelegateCommand(ZoomIn, CanZoomIn);
            ZoomOutCommand = new DelegateCommand(ZoomOut, CanZoomOut);
            FitViewCommand = new DelegateCommand(FitView, CanFitView);
            TogglePanCommand = new DelegateCommand(TogglePan, CanTogglePan);
            EscapeCommand = new DelegateCommand(Escape, CanEscape);
            SelectVisualizationInViewCommand = new DelegateCommand(SelectVisualizationInView, CanSelectVisualizationInView);
            GetBranchVisualizationCommand = new DelegateCommand(GetBranchVisualization, CanGetBranchVisualization);
            TogglePreviewBubbleVisibilityCommand = new DelegateCommand(TogglePreviewBubbleVisibility, CanTogglePreviewBubbleVisibility);
            ExportToSTLCommand = new DelegateCommand(ExportToSTL, CanExportToSTL);
            ImportLibraryCommand = new DelegateCommand(ImportLibrary, CanImportLibrary);
            SetLengthUnitCommand = new DelegateCommand(SetLengthUnit, CanSetLengthUnit);
            SetAreaUnitCommand = new DelegateCommand(SetAreaUnit, CanSetAreaUnit);
            SetVolumeUnitCommand = new DelegateCommand(SetVolumeUnit, CanSetVolumeUnit);
            ShowAboutWindowCommand = new DelegateCommand(ShowAboutWindow, CanShowAboutWindow);
            CheckForUpdateCommand = new DelegateCommand(CheckForUpdate, CanCheckForUpdate);
            SetNumberFormatCommand = new DelegateCommand(SetNumberFormat, CanSetNumberFormat);

            DynamoLogger.Instance.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Instance_PropertyChanged);

            DynamoSelection.Instance.Selection.CollectionChanged += SelectionOnCollectionChanged;
            dynSettings.Controller.VisualizationManager.PropertyChanged += VisualizationManager_PropertyChanged;

            this.Model.PropertyChanged += (e, args) =>
            {
                if (args.PropertyName == "CurrentWorkspace" && dynSettings.Controller.DynamoModel.CurrentWorkspace != null)
                {
                    var visibleWorkspace =
                        (dynSettings.Controller.DynamoModel.CurrentWorkspace is CustomNodeWorkspaceModel);

                    dynSettings.Controller.SearchViewModel.SearchElements
                        .Where(x => x.Name == "Input" || x.Name == "Output")
                        .OfType<NodeSearchElement>()
                        .ToList()
                        .ForEach(x => x.SetSearchable(visibleWorkspace));

                    dynSettings.Controller.SearchViewModel.SearchAndUpdateResultsSync();
                }
            };

            UsageReportingManager.Instance.PropertyChanged += CollectInfoManager_PropertyChanged;

            WatchIsResizable = false;
        }