internal void ApplyBulkOperation() { var selectedNodes = PropertyPaletteNodes.Where(n => n.Selected); switch (BulkOperation) { case BulkOperation.Delete: Delete(selectedNodes); break; case BulkOperation.Freeze: Freeze(selectedNodes); break; case BulkOperation.Unfreeze: Unfreeze(selectedNodes); break; case BulkOperation.Disconnect: Disconnect(selectedNodes); break; default: break; } }
private void CurrentWorkspaceModel_NodeAdded(NodeModel node) { // When a new node added on canvas, update PropertyPalette var profiledNode = new PropertyPaletteNodeViewModel(node); PropertyPaletteNodes.Add(profiledNode); RaisePropertyChanged(nameof(PropertyPaletteNodesCollection)); }
private void CurrentWorkspaceModel_NodeRemoved(NodeModel node) { var propertyPaletteNode = PropertyPaletteNodes.Where(n => n.NodeModel == node).FirstOrDefault(); if (propertyPaletteNode != null) { PropertyPaletteNodes.Remove(propertyPaletteNode); propertyPaletteNode.Dispose(); } RaisePropertyChanged(nameof(PropertyPaletteNodesCollection)); }
/// <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> /// 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; } foreach (var node in PropertyPaletteNodes) { node.Dispose(); } PropertyPaletteNodes.Clear(); }