예제 #1
0
        /// <summary>
        ///     Change the currently visible workspace to a custom node's workspace
        /// </summary>
        /// <param name="symbol">The function definition for the custom node workspace to be viewed</param>
        internal void ViewCustomNodeWorkspace(FunctionDefinition symbol)
        {
            if (symbol == null)
            {
                throw new Exception("There is a null function definition for this node.");
            }

            if (_model.CurrentSpace.Name.Equals(symbol.Workspace.Name))
            {
                return;
            }

            dynWorkspaceModel newWs = symbol.Workspace;

            if (!this._model.Workspaces.Contains(newWs))
            {
                this._model.Workspaces.Add(newWs);
            }

            CurrentSpaceViewModel.OnStopDragging(this, EventArgs.Empty);

            _model.CurrentSpace = newWs;
            _model.CurrentSpace.OnDisplayed();

            //set the zoom and offsets events
            var vm = dynSettings.Controller.DynamoViewModel.Workspaces.First(x => x.Model == newWs);

            vm.OnCurrentOffsetChanged(this, new PointEventArgs(new Point(newWs.X, newWs.Y)));
            vm.OnZoomChanged(this, new ZoomEventArgs(newWs.Zoom));
        }