private void OnCurrentWorkspaceChanged(Graph.Workspaces.IWorkspaceModel obj) { if (!(obj is HomeWorkspaceModel hwm)) { extension.Closed(); return; } if (string.IsNullOrEmpty(hwm.FileName)) { GraphDescription = string.Empty; GraphAuthor = string.Empty; HelpLink = null; Thumbnail = null; } else { currentWorkspace = hwm; RaisePropertyChanged(nameof(GraphDescription)); RaisePropertyChanged(nameof(GraphAuthor)); RaisePropertyChanged(nameof(HelpLink)); RaisePropertyChanged(nameof(Thumbnail)); } CustomProperties.Clear(); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var obj = JObject.Load(reader); var isCustomNode = obj["IsCustomNode"].Value <bool>(); var lastModifiedStr = obj["LastModified"].Value <string>(); var lastModified = DateTime.ParseExact(lastModifiedStr, "yyyy-MM-dd", CultureInfo.InvariantCulture); var author = obj["LastModifiedBy"].Value <string>(); var description = obj["Description"].Value <string>(); var guidStr = obj["Uuid"].Value <string>(); var guid = Guid.Parse(guidStr); var name = obj["Name"].Value <string>(); var elementResolver = obj["ElementResolver"].ToObject <ElementResolver>(serializer); var nmc = (NodeModelConverter)serializer.Converters.First(c => c is NodeModelConverter); nmc.ElementResolver = elementResolver; // nodes var nodes = obj["Nodes"].ToObject <IEnumerable <NodeModel> >(serializer); // notes var notes = obj["Notes"].ToObject <IEnumerable <NoteModel> >(serializer); if (notes.Any()) { foreach (var n in notes) { serializer.ReferenceResolver.AddReference(serializer.Context, n.GUID.ToString(), n); } } // connectors // Although connectors are not used in the construction of the workspace // we need to deserialize this collection, so that they connect to their // relevant ports. var connectors = obj["Connectors"].ToObject <IEnumerable <ConnectorModel> >(serializer); // annotations var annotations = obj["Annotations"].ToObject <IEnumerable <AnnotationModel> >(serializer); var info = new WorkspaceInfo(guid.ToString(), name, description, Dynamo.Models.RunType.Automatic); WorkspaceModel ws; if (isCustomNode) { ws = new CustomNodeWorkspaceModel(factory, nodes, notes, annotations, Enumerable.Empty <PresetModel>(), elementResolver, info); } else { ws = new HomeWorkspaceModel(guid, engine, scheduler, factory, Enumerable.Empty <KeyValuePair <Guid, List <CallSite.RawTraceData> > >(), nodes, notes, annotations, Enumerable.Empty <PresetModel>(), elementResolver, info, verboseLogging, isTestMode); } return(ws); }
internal void SendAsynchronously(HomeWorkspaceModel workspace, WorkspaceProperties workspaceProperties = null) { State = UploadState.Uploading; Task.Factory.StartNew(() => { var result = this.Send(workspace, workspaceProperties); var serverResponce = serverResponceRegex.Match(result); if (serverResponce.Success) { State = UploadState.Succeeded; Error = UploadErrorType.None; CustomizerURL = String.Concat(serverUrl, serverResponce.Value); } else if (InvalidNodeNames != null) { Error = UploadErrorType.InvalidNodes; } else { // If there wasn't any error during uploading, // that means it's some error on the server side. Error = UploadErrorType.UnknownServerError; } }); }
public ViewportWindowViewModel(ViewLoadedParams p, string defaultPackagePath) { // Save a reference to our loaded parameters which // is required in order to access the workspaces readyParams = p; // TODO: This API will be obsoleted in future Dynamo releases // Turn off Dynamo background preview if it's enabled (p.BackgroundPreviewViewModel as Dynamo.Wpf.ViewModels.Watch3D.HelixWatch3DViewModel).Active = false; // Save a reference to the default packages directory PackagePath = defaultPackagePath; // Subscribe to NodeAdded and NodeRemoved events p.CurrentWorkspaceModel.NodeAdded += CurrentWorkspaceModel_NodeAdded; p.CurrentWorkspaceModel.NodeRemoved += CurrentWorkspaceModel_NodeRemoved; // TODO: this could be dangerous if called in custom node ws HomeWorkspaceModel currentWS = readyParams.CurrentWorkspaceModel as HomeWorkspaceModel; // TODO: opening/changing WS needs more attention // Register all nodes that currently exist in the WS foreach (NodeModel node in currentWS.Nodes) { node.RenderPackagesUpdated += CurrentWorkspaceModel_UpdateViewportGeometry; node.PropertyChanged += CurrentWorkspaceModel_nodePropertyChanged; } }
private void Updater_ElementsUpdated(object sender, ElementUpdateEventArgs e) { switch (e.Operation) { case ElementUpdateEventArgs.UpdateType.Added: break; case ElementUpdateEventArgs.UpdateType.Modified: bool dynamoTransaction = e.Transactions.Contains(TransactionWrapper.TransactionName); HomeWorkspaceModel hwm = null; if (revitDynamoModel != null) { hwm = revitDynamoModel.CurrentWorkspace as HomeWorkspaceModel; } if (!dynamoTransaction || (hwm != null && hwm.RunSettings.RunType == RunType.Manual)) { Updater_ElementsModified(e.GetUniqueIds()); } break; case ElementUpdateEventArgs.UpdateType.Deleted: Updater_ElementsDeleted(e.RevitDocument, e.Elements); break; default: break; } }
protected virtual void Evaluate(HomeWorkspaceModel workspace) { var dynamoModel = workspace.DynamoModel; var sw = new Stopwatch(); try { sw.Start(); dynamoModel.EngineController.GenerateGraphSyncData(workspace.Nodes); if (dynamoModel.EngineController.HasPendingGraphSyncData) { ExecutionEvents.OnGraphPreExecution(); Eval(workspace); } } catch (Exception ex) { //Catch unhandled exception if (ex.Message.Length > 0) { dynamoModel.Logger.Log(ex); } OnRunCancelled(true); if (DynamoModel.IsTestMode) // Throw exception for NUnit. { throw new Exception(ex.Message + ":" + ex.StackTrace); } } finally { sw.Stop(); InstrumentationLogger.LogAnonymousEvent("Run", "Eval"); InstrumentationLogger.LogAnonymousTimedEvent("Perf", "EvalTime", sw.Elapsed); dynamoModel.Logger.Log( string.Format("Evaluation completed in {0}", sw.Elapsed)); } // When evaluation is completed, we mark all // nodes as ForceReexecuteOfNode = false to prevent // cyclical graph updates. It is therefore the responsibility // of the node implementor to mark this flag = true, if they // want to require update. foreach (var n in workspace.Nodes) { n.ForceReExecuteOfNode = false; } dynamoModel.OnEvaluationCompleted(this, EventArgs.Empty); ExecutionEvents.OnGraphPostExecution(); }
public void Init() { OpenModel(Path.Combine(TestDirectory, "core", "DelayedGraphExecution.dyn")); wModel = CurrentDynamoModel.CurrentWorkspace as HomeWorkspaceModel; wModel.RunSettings.RunType = RunType.Automatic; originalNodeCount = workspaceNodes().Count(); CurrentDynamoModel.Scheduler.TaskStateChanged += taskStateHandler; }
private void UnlinkFromCurrentWorkspace() { if (currentWorkspace != null) { UnsubscribeGraphEvents(currentWorkspace); DynamoModel.OnRequestDispatcherInvoke(() => { this.linterManager.RuleEvaluationResults.Clear(); }); currentWorkspace = null; OnUnlink(); } }
/// <summary> /// This method is called by task creator to associate the trace data with /// the current instance of virtual machine. The given WorkspaceModel can /// optionally contain saved trace data in a previous execution session. As /// a side-effect, this method resets "WorkspaceModel.PreloadedTraceData" /// data member to ensure the correctness of the execution flow. /// </summary> /// <param name="controller">Reference to the EngineController on which the /// loaded trace data should be set.</param> /// <param name="workspace">The workspace from which the trace data should /// be retrieved.</param> /// <returns>If the given WorkspaceModel contains saved trace data, this /// method returns true, in which case the task needs to be scheduled. /// Otherwise, the method returns false.</returns> /// internal bool Initialize(EngineController controller, HomeWorkspaceModel workspace) { if (controller == null || (controller.LiveRunnerCore == null)) return false; engineController = controller; traceData = workspace.PreloadedTraceData; TargetedWorkspace = workspace; workspace.PreloadedTraceData = null; return ((traceData != null) && traceData.Any()); }
private void LinkToWorkspace(HomeWorkspaceModel workspace) { if (workspace != null) { currentWorkspace = workspace; SubscribeNodeEvents(); SubscribeGraphEvents(); InitializeRules(); OnLink(); } }
public void DisableProfiling() { if (!this.IsEnabled) { return; } HomeWorkspaceModel workspace = this.loadedParameters.CurrentWorkspaceModel as HomeWorkspaceModel; this.engineController.EnableProfiling(false, workspace, new List <NodeModel>()); this.IsEnabled = false; }
/// <summary> /// When switching workspaces or closing NodePropertyPalette extension, /// unsubscribe workspace events for profiling /// </summary> /// <param name="workspace">target workspace</param> private void UnsubscribeWorkspaceEvents(HomeWorkspaceModel workspace) { workspace.NodeAdded -= CurrentWorkspaceModel_NodeAdded; workspace.NodeRemoved -= CurrentWorkspaceModel_NodeRemoved; workspace.EvaluationStarted -= CurrentWorkspaceModel_EvaluationStarted; workspace.EvaluationCompleted -= CurrentWorkspaceModel_EvaluationCompleted; foreach (var node in workspace.Nodes) { node.NodeExecutionBegin -= OnNodeExecutionBegin; node.NodeExecutionEnd -= OnNodeExecutionEnd; } }
public ViewportWindowViewModel(ReadyParams p) { // Save a reference to our loaded parameters which // is required in order to access the workspaces readyParams = p; // Subscribe to NodeAdded and NodeRemoved events p.CurrentWorkspaceModel.NodeAdded += CurrentWorkspaceModel_NodeAdded; p.CurrentWorkspaceModel.NodeRemoved += CurrentWorkspaceModel_NodeRemoved; // TODO this could be dangerous if called in custom node ws HomeWorkspaceModel currentWS = readyParams.CurrentWorkspaceModel as HomeWorkspaceModel; //currentWS.RefreshCompleted += CurrentWorkspaceModel_NodesChanged; }
public void EnableProfiling() { if (this.IsEnabled) { return; } HomeWorkspaceModel workspace = this.dynamoSession != null ? this.dynamoSession.Workspace as HomeWorkspaceModel : this.loadedParameters.CurrentWorkspaceModel as HomeWorkspaceModel; this.engineController.EnableProfiling(true, workspace, workspace.Nodes); this.IsEnabled = true; }
/// <summary> /// This method is called by task creator to associate the trace data with /// the current instance of virtual machine. The given WorkspaceModel can /// optionally contain saved trace data in a previous execution session. As /// a side-effect, this method resets "WorkspaceModel.PreloadedTraceData" /// data member to ensure the correctness of the execution flow. /// </summary> /// <param name="controller">Reference to the EngineController on which the /// loaded trace data should be set.</param> /// <param name="workspace">The workspace from which the trace data should /// be retrieved.</param> /// <returns>If the given WorkspaceModel contains saved trace data, this /// method returns true, in which case the task needs to be scheduled. /// Otherwise, the method returns false.</returns> /// internal bool Initialize(EngineController controller, HomeWorkspaceModel workspace) { if (controller == null || (controller.LiveRunnerCore == null)) { return(false); } engineController = controller; traceData = workspace.PreloadedTraceData; TargetedWorkspace = workspace; workspace.PreloadedTraceData = null; return((traceData != null) && traceData.Any()); }
/// <summary> /// Sends workspace and its' dependencies to Flood. /// </summary> /// <returns>String which is response from server.</returns> internal string Send(HomeWorkspaceModel workspace, WorkspaceProperties workspaceProperties = null) { if (String.IsNullOrWhiteSpace(serverUrl)) { Error = UploadErrorType.ServerNotFound; return(Resources.FailedMessage); } if (String.IsNullOrWhiteSpace(authenticationProvider.Username)) { Error = UploadErrorType.AuthenticationFailed; return(Resources.FailedMessage); } if (authenticationProvider == null) { Error = UploadErrorType.AuthProviderNotFound; return(Resources.FailedMessage); } if (reachClient == null) { reachClient = new WorkspaceStorageClient(authenticationProvider, serverUrl); } var dependencies = WorkspaceDependencies.Collect(workspace, customNodeManager); string result; try { result = reachClient.Send( workspace, dependencies.CustomNodeWorkspaces, workspaceProperties); InvalidNodeNames = null; } catch (InvalidNodesException ex) { InvalidNodeNames = ex.InvalidNodeNames; result = Resources.FailedMessage; } catch { result = Resources.FailedMessage; } return(result); }
/// <summary> /// When switching workspaces or closing NodePropertyPalette extension, /// subscribe workspace events for profiling /// </summary> /// <param name="workspace">target workspace</param> private void SubscribeWorkspaceEvents(HomeWorkspaceModel workspace) { workspace.NodeAdded += CurrentWorkspaceModel_NodeAdded; workspace.NodeRemoved += CurrentWorkspaceModel_NodeRemoved; workspace.EvaluationStarted += CurrentWorkspaceModel_EvaluationStarted; workspace.EvaluationCompleted += CurrentWorkspaceModel_EvaluationCompleted; foreach (var node in workspace.Nodes) { var profiledNode = new PropertyPaletteNodeViewModel(node); PropertyPaletteNodes.Add(profiledNode); node.NodeExecutionBegin += OnNodeExecutionBegin; node.NodeExecutionEnd += OnNodeExecutionEnd; } RaisePropertyChanged(nameof(PropertyPaletteNodesCollection)); }
/// <summary> /// Sends workspace and its' dependencies to Flood. /// </summary> /// <returns>String which is response from server.</returns> private IReachHttpResponse Send(HomeWorkspaceModel workspace, WorkspaceProperties workspaceProperties = null) { if (reachClient == null) { reachClient = new WorkspaceStorageClient(authenticationProvider, serverUrl); } var dependencies = WorkspaceDependencies.Collect(workspace, customNodeManager); InvalidNodeNames = null; return(reachClient.Send( workspace, dependencies.CustomNodeWorkspaces, workspaceProperties)); }
public HomeWorkspaceViewModel(HomeWorkspaceModel model, DynamoViewModel dynamoViewModel) : base(model, dynamoViewModel) { RunSettingsViewModel = new RunSettingsViewModel(((HomeWorkspaceModel)model).RunSettings, this, dynamoViewModel); RunSettingsViewModel.PropertyChanged += RunSettingsViewModel_PropertyChanged; StartPeriodicTimerCommand = new DelegateCommand(StartPeriodicTimer, CanStartPeriodicTimer); StopPeriodicTimerCommand = new DelegateCommand(StopPeriodicTimer, CanStopPeriodicTimer); CheckAndSetPeriodicRunCapability(); var hwm = (HomeWorkspaceModel)Model; hwm.EvaluationStarted += hwm_EvaluationStarted; hwm.EvaluationCompleted += hwm_EvaluationCompleted; hwm.SetNodeDeltaState += hwm_SetNodeDeltaState; }
protected virtual void Evaluate(HomeWorkspaceModel workspace) { var dynamoModel = workspace.DynamoModel; var sw = new Stopwatch(); try { sw.Start(); dynamoModel.EngineController.GenerateGraphSyncData(workspace.Nodes); //No additional work needed if (dynamoModel.EngineController.HasPendingGraphSyncData) { Eval(workspace); } } catch (Exception ex) { //Catch unhandled exception if (ex.Message.Length > 0) { dynamoModel.Logger.Log(ex); } OnRunCancelled(true); if (DynamoModel.IsTestMode) // Throw exception for NUnit. { throw new Exception(ex.Message + ":" + ex.StackTrace); } } finally { sw.Stop(); InstrumentationLogger.LogAnonymousEvent("Run", "Eval"); InstrumentationLogger.LogAnonymousTimedEvent("Perf", "EvalTime", sw.Elapsed); dynamoModel.Logger.Log( string.Format("Evaluation completed in {0}", sw.Elapsed)); } dynamoModel.OnEvaluationCompleted(this, EventArgs.Empty); }
private void RunSync(HomeWorkspaceModel workspaceModel) { do { Evaluate(workspaceModel); if (execInternval == null) { break; } int sleep = execInternval.Value; Thread.Sleep(sleep); } while (!cancelSet); RunComplete(workspaceModel); }
/// <summary> /// Method to group together all the tasks associated with an execution being complete /// </summary> private void RunComplete(HomeWorkspaceModel workspaceModel) { var dynamoModel = workspaceModel.DynamoModel; dynamoModel.OnRunCompleted(this, false); lock (RunControlMutex) { Running = false; dynamoModel.RunEnabled = true; } if (cancelSet) { dynamoModel.ResetEngine(true); cancelSet = false; } }
public HomeWorkspaceViewModel(HomeWorkspaceModel model, DynamoViewModel dynamoViewModel) : base(model, dynamoViewModel) { RunSettingsViewModel = new RunSettingsViewModel(((HomeWorkspaceModel)model).RunSettings, this, dynamoViewModel); RunSettingsViewModel.PropertyChanged += RunSettingsViewModel_PropertyChanged; StartPeriodicTimerCommand = new DelegateCommand(StartPeriodicTimer, CanStartPeriodicTimer); StopPeriodicTimerCommand = new DelegateCommand(StopPeriodicTimer, CanStopPeriodicTimer); CheckAndSetPeriodicRunCapability(); var hwm = (HomeWorkspaceModel)Model; hwm.EvaluationStarted += hwm_EvaluationStarted; hwm.EvaluationCompleted += hwm_EvaluationCompleted; hwm.SetNodeDeltaState +=hwm_SetNodeDeltaState; dynamoViewModel.Model.ShutdownStarted += Model_ShutdownStarted; }
private void OnCurrentWorkspaceChanged(IWorkspaceModel obj) { HomeWorkspaceModel incomingWorkspace = obj as HomeWorkspaceModel; //If incoming workspace is not of expected type we will unlink from current workspace. //This will happen when you edit a custom node for example. //Other than that we do not expect to have a change event for the same workspace, //we assume something went bad in this case and we also unlink. //If the incoming workspace is default home screen workspace we also unlink. if (incomingWorkspace is null || currentWorkspace == incomingWorkspace || String.IsNullOrEmpty(incomingWorkspace.FileName)) { UnlinkFromCurrentWorkspace(); return; } LinkToWorkspace(incomingWorkspace); }
/// <summary> /// Get all of the dependencies from a workspace /// </summary> /// <param name="workspace">The workspace to read the dependencies from</param> /// <param name="customNodeManager">A custom node manager to look up dependencies</param> /// <returns>A WorkspaceDependencies object containing the workspace and its CustomNodeWorkspaceModel dependencies</returns> public static WorkspaceDependencies Collect(HomeWorkspaceModel workspace, ICustomNodeManager customNodeManager) { if (workspace == null) { throw new ArgumentNullException("workspace"); } if (customNodeManager == null) { throw new ArgumentNullException("customNodeManager"); } // collect all dependencies var dependencies = new HashSet <CustomNodeDefinition>(); foreach (var node in workspace.Nodes.OfType <Function>()) { dependencies.Add(node.Definition); foreach (var dep in node.Definition.Dependencies) { dependencies.Add(dep); } } var customNodeWorkspaces = new List <ICustomNodeWorkspaceModel>(); foreach (var dependency in dependencies) { ICustomNodeWorkspaceModel customNodeWs; var workspaceExists = customNodeManager.TryGetFunctionWorkspace(dependency.FunctionId, false, out customNodeWs); if (!workspaceExists) { throw new InvalidOperationException(String.Format(Resources.CustomNodeDefinitionNotFoundErrorMessage, dependency.FunctionName)); } if (!customNodeWorkspaces.Contains(customNodeWs)) { customNodeWorkspaces.Add(customNodeWs); } } return(new WorkspaceDependencies(workspace, customNodeWorkspaces)); }
/// <summary> /// Enables or disables profiling depending on the given argument /// </summary> /// <param name="enable">Indicates enabling or disabling of profiling.</param> /// <param name="workspace">The workspace to enable or disable profiling for.</param> /// <param name="nodes">The list of nodes to enable or disable profiling for.</param> public void EnableProfiling(bool enable, HomeWorkspaceModel workspace, IEnumerable <NodeModel> nodes) { Validity.Assert(workspace != null, "Workspace cannot be null"); Validity.Assert(nodes != null, "Node list cannot be null"); if (enable) { if (astBuilder.ProfilingSession == null) { astBuilder.ProfilingSession = new ProfilingSession(); } } else { astBuilder.ProfilingSession.Dispose(); astBuilder.ProfilingSession = null; } workspace.MarkNodesAsModifiedAndRequestRun(nodes, true); }
public GraphMetadataViewModel(ViewLoadedParams viewLoadedParams, GraphMetadataViewExtension extension) { this.viewLoadedParams = viewLoadedParams; this.extension = extension; this.currentWorkspace = viewLoadedParams.CurrentWorkspaceModel as HomeWorkspaceModel; this.linterManager = viewLoadedParams.StartupParams.LinterManager; this.viewLoadedParams.CurrentWorkspaceChanged += OnCurrentWorkspaceChanged; // using this as CurrentWorkspaceChanged wont trigger if you: // Close a saved workspace and open a New homeworkspace.. // This means that properties defined in the previous opened workspace will still be showed in the extension. // CurrentWorkspaceCleared will trigger everytime a graph is closed which allows us to reset the properties. this.viewLoadedParams.CurrentWorkspaceCleared += OnCurrentWorkspaceChanged; if (linterManager != null) { linterManager.PropertyChanged += OnLinterManagerPropertyChange; } CustomProperties = new ObservableCollection <CustomPropertyControl>(); InitializeCommands(); }
private static void TryOpenAndExecuteWorkspaceInCommandData(DynamoRevitCommandData commandData) { if (commandData.JournalData == null) { return; } if (commandData.JournalData.ContainsKey(JournalKeys.DynPathKey)) { bool isAutomationMode = CheckJournalForKey(commandData, JournalKeys.AutomationModeKey); bool forceManualRun = CheckJournalForKey(commandData, JournalKeys.ForceManualRunKey); if (ModelState == RevitDynamoModelState.StartedUIless) { revitDynamoModel.OpenFileFromPath(commandData.JournalData[JournalKeys.DynPathKey], forceManualRun); } else { dynamoViewModel.OpenIfSavedCommand.Execute(new Dynamo.Models.DynamoModel.OpenFileCommand(commandData.JournalData[JournalKeys.DynPathKey], forceManualRun)); dynamoViewModel.ShowStartPage = false; } //If we are in automation mode the model will run anyway (on the main thread //without the idle loop) regardless of the DynPathExecuteKey. if (!isAutomationMode && commandData.JournalData.ContainsKey(JournalKeys.DynPathExecuteKey)) { bool executePath = false; bool.TryParse(commandData.JournalData[JournalKeys.DynPathExecuteKey], out executePath); if (executePath) { HomeWorkspaceModel modelToRun = revitDynamoModel.CurrentWorkspace as HomeWorkspaceModel; if (modelToRun != null) { modelToRun.Run(); return; } } } } }
private void OnCurrentWorkspaceClosing(IWorkspaceModel obj) { HomeWorkspaceModel workspaceAboutToClose = obj as HomeWorkspaceModel; //It can be a CustomNodeWorkspaceModel which we are not interested in processing if (workspaceAboutToClose is null) { return; } //we only care about the workspace we are linked to if (workspaceAboutToClose != currentWorkspace) { return; } foreach (var rule in linterRules) { rule?.CleanupRule(workspaceAboutToClose); } UnlinkFromCurrentWorkspace(); }
private async void EvaluateGraph(HomeWorkspaceModel model) { Application.Current.Dispatcher.Invoke(new Action(() => { this.completedNodes = new List <NodeModel>(); this.warningNodes = new List <NodeModel>(); this.errorNodes = new List <NodeModel>(); WarningStacker.Children.Clear(); WorkspaceModel currentWorkSpace = BeyondDynamo.Utils.DynamoVM.CurrentSpace; foreach (NodeModel node in currentWorkSpace.Nodes) { if (node.State == ElementState.Active) { completedNodes.Add(node); } else if (node.State == ElementState.Error) { errorNodes.Add(node); } else if (node.State == ElementState.Warning || node.State == ElementState.PersistentWarning) { warningNodes.Add(node); string warningText = BeyondDynamoFunctions.GetNodeViewModel(node).ErrorBubble.FullContent; Button warningButton = new Button() { Style = (Style)this.Resources["WarningButton"], Content = warningText }; warningButton.Click += WarningButton_Click;; WarningStacker.Children.Add(warningButton); } else { } } })); }
public ViewportWindowViewModel(ReadyParams p, string defaultPackagePath) { // Save a reference to our loaded parameters which // is required in order to access the workspaces readyParams = p; // Save a reference to the default packages directory PackagePath = defaultPackagePath; // Subscribe to NodeAdded and NodeRemoved events p.CurrentWorkspaceModel.NodeAdded += CurrentWorkspaceModel_NodeAdded; p.CurrentWorkspaceModel.NodeRemoved += CurrentWorkspaceModel_NodeRemoved; // TODO this could be dangerous if called in custom node ws HomeWorkspaceModel currentWS = readyParams.CurrentWorkspaceModel as HomeWorkspaceModel; // TODO opening/changing WS needs more attention // Register all nodes that currently exist in the WS foreach (NodeModel node in currentWS.Nodes) { node.RenderPackagesUpdated += CurrentWorkspaceModel_UpdateViewportGeometry; node.PropertyChanged += CurrentWorkspaceModel_nodePropertyChanged; } }
private void OnEvaluationStarted(object sender, EventArgs e) { HomeWorkspaceModel workspace = sender as HomeWorkspaceModel; if (workspace == null) { return; } if (!this.dynamoSession.Workspace.Equals(workspace)) { this.OnWorkspaceChanged(workspace); } if (!this.engineController.Equals(workspace.EngineController)) { this.ResetEngineController(workspace.EngineController, this.IsEnabled); } if (this.IsEnabled) { this.dynamoSession?.Start(); } }
/// <summary> /// Add a new HomeWorkspace and set as current /// </summary> /// <api_stability>1</api_stability> public void AddHomeWorkspace() { var defaultWorkspace = new HomeWorkspaceModel( EngineController, Scheduler, NodeFactory, DebugSettings.VerboseLogging, IsTestMode,string.Empty); RegisterHomeWorkspace(defaultWorkspace); AddWorkspace(defaultWorkspace); CurrentWorkspace = defaultWorkspace; }
private void RegisterHomeWorkspace(HomeWorkspaceModel newWorkspace) { newWorkspace.EvaluationCompleted += OnEvaluationCompleted; newWorkspace.RefreshCompleted += OnRefreshCompleted; newWorkspace.Disposed += () => { newWorkspace.EvaluationCompleted -= OnEvaluationCompleted; newWorkspace.RefreshCompleted -= OnRefreshCompleted; }; }
private bool OpenHomeWorkspace( XmlDocument xmlDoc, WorkspaceInfo workspaceInfo, out WorkspaceModel workspace) { var nodeGraph = NodeGraph.LoadGraphFromXml(xmlDoc, NodeFactory); var newWorkspace = new HomeWorkspaceModel( EngineController, Scheduler, NodeFactory, Utils.LoadTraceDataFromXmlDocument(xmlDoc), nodeGraph.Nodes, nodeGraph.Notes, nodeGraph.Annotations, nodeGraph.Presets, nodeGraph.ElementResolver, workspaceInfo, DebugSettings.VerboseLogging, IsTestMode ); RegisterHomeWorkspace(newWorkspace); workspace = newWorkspace; return true; }
private void AssertManual(HomeWorkspaceModel ws) { Assert.AreEqual(RunType.Manual, ws.RunSettings.RunType); }
private void AssertAuto(HomeWorkspaceModel ws) { Assert.AreEqual(RunType.Automatic, ws.RunSettings.RunType); }