/// <inheritdoc /> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is IStreamTreeNode) { IStreamTreeNode streamTreeNode = value as IStreamTreeNode; if (streamTreeNode.IsStream) { var commands = PsiStudioContext.Instance.GetVisualizeStreamCommands(streamTreeNode); if (commands != null && commands.Count > 0) { return(Visibility.Visible); } } } return(Visibility.Hidden); }
private void StreamTreeNode_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { // If the left button is also pressed, then the user is probably wanting to // initiate a drag operation of the stream into the Visualization Container if (e.LeftButton == MouseButtonState.Pressed) { // Get the Tree Item that sent the event StackPanel treeNode = sender as StackPanel; if (treeNode != null) { IStreamTreeNode streamTreeNode = treeNode.DataContext as IStreamTreeNode; if (streamTreeNode != null && streamTreeNode.CanVisualize) { // Begin the Drag & Drop operation DataObject data = new DataObject(); data.SetData(DragDropDataName.DragDropOperation, DragDropOperation.DragDropStream); data.SetData(DragDropDataName.StreamTreeNode, streamTreeNode); DragDrop.DoDragDrop(treeNode, data, DragDropEffects.Move); } } } }
private bool ExecuteCommandIfPresent(List <TypeKeyedActionCommand> commands, string commandName, IStreamTreeNode streamTreeNode) { // Check if the command is in the list TypeKeyedActionCommand command = commands.Find(o => o.DisplayName.Equals(commandName, StringComparison.Ordinal)); if (command != null) { VisualizationContainer visualizationContainer = this.DataContext as VisualizationContainer; // If we're adding the stream to an existing Visualization Panel, then make sure it's the selected panel first. // Otherwise, make sure the last current panel is selected so that the new panel is created at the bottom. if (this.hitTestResult != null) { VisualizationPanel visualizationPanel = this.hitTestResult.DataContext as VisualizationPanel; visualizationContainer.CurrentPanel = visualizationPanel; } else if (visualizationContainer.Panels.Count > 0) { visualizationContainer.CurrentPanel = visualizationContainer.Panels[visualizationContainer.Panels.Count - 1]; } // Execute the command command.Execute(streamTreeNode); return(true); } return(false); }
private void DropStream(DragEventArgs e) { IStreamTreeNode streamTreeNode = e.Data.GetData(DragDropDataName.StreamTreeNode) as IStreamTreeNode; if (streamTreeNode != null) { // Get the list of Visualization Commands we can execute on this stream List <TypeKeyedActionCommand> commands = PsiStudioContext.Instance.GetVisualizeStreamCommands(streamTreeNode); // Find out if the mouse is above an existing Visualization Panel this.hitTestResult = null; Point pt = e.GetPosition(this.Items); VisualTreeHelper.HitTest( this.Items, new HitTestFilterCallback(this.HitTestFilter), new HitTestResultCallback(this.HitTestResultCallback), new PointHitTestParameters(pt)); // If we're above an existing Visualization Panel and there exists some "plot" commands, then execute // the "plot in new panel" command, otherwise execute whatever plot or visualize command we can find. if (this.hitTestResult != null) { if (this.ExecuteCommandIfPresent(commands, ContextMenuName.Plot, streamTreeNode)) { return; } if (this.ExecuteCommandIfPresent(commands, ContextMenuName.PlotAsMilliseconds, streamTreeNode)) { return; } } else { if (this.ExecuteCommandIfPresent(commands, ContextMenuName.PlotInNewPanel, streamTreeNode)) { return; } if (this.ExecuteCommandIfPresent(commands, ContextMenuName.PlotAsMillisecondsInNewPanel, streamTreeNode)) { return; } if (this.ExecuteCommandIfPresent(commands, ContextMenuName.Visualize, streamTreeNode)) { return; } if (this.ExecuteCommandIfPresent(commands, ContextMenuName.VisualizeAs2DDepth, streamTreeNode)) { return; } if (this.ExecuteCommandIfPresent(commands, ContextMenuName.VisualizeAs3DDepth, streamTreeNode)) { return; } if (this.ExecuteCommandIfPresent(commands, ContextMenuName.VisualizeAsPlanarDirection, streamTreeNode)) { return; } } } }