private void DropReorderPanels(DragEventArgs e) { // Get the VisualizationPanel that's being dropped VisualizationPanel droppedPanel = e.Data.GetData(DragDropDataName.VisualizationPanel) as VisualizationPanel; if (droppedPanel != null) { // Find the index of the panel being moved, and the index we should move it to int moveToIndex = this.FindPanelMoveIndices(droppedPanel, this.dragDropAdorner.VerticalCenter, out int moveFromIndex); // Check that we're not just trying to put the panel back where it started if (moveFromIndex != moveToIndex) { droppedPanel.Container.Panels.Move(moveFromIndex, moveToIndex); } // Timeline Visualization Panels have multiple drag & drop operation types, only one of which // can be in effect at any time. If the panel being dropped is one of those then we need to // signal to it that this drag operation is done. TimelineVisualizationPanelView visualizationPanelView = e.Data.GetData(DragDropDataName.VisualizationPanelView) as TimelineVisualizationPanelView; if (visualizationPanelView != null) { visualizationPanelView.FinishDragDrop(); } } this.dragDropAdorner.Hide(); }
private HitTestFilterBehavior HitTestFilter(DependencyObject dependencyObject) { // We only want to "add to current panel" if that panel is a Timeline panel, other types don't support this if (dependencyObject is TimelineVisualizationPanelView) { this.hitTestResult = dependencyObject as TimelineVisualizationPanelView; return(HitTestFilterBehavior.Stop); } return(HitTestFilterBehavior.Continue); }
private void Items_Drop(object sender, DragEventArgs e) { if (e.Handled == false) { string dragOperation = e.Data.GetData("DragOperation") as string; if (dragOperation == "ReorderPanels") { // Get the VisualizationPanel that's being dropped VisualizationPanel droppedPanel = e.Data.GetData("VisualizationPanel") as VisualizationPanel; if (droppedPanel != null) { // Find the index of the panel being moved, and the index we should move it to int moveToIndex = this.FindPanelMoveIndices(droppedPanel, this.dragDropAdorner.VerticalCenter, out int moveFromIndex); // Check that we're not just trying to put the panel back where it started if (moveFromIndex != moveToIndex) { droppedPanel.Container.Panels.Move(moveFromIndex, moveToIndex); } // Timeline Visualization Panels have multiple drag & drop operation types, only one of which // can be in effect at any time. If the panel being dropped is one of those then we need to // signal to it that this drag operation is done. TimelineVisualizationPanelView visualizationPanelView = e.Data.GetData("VisualizationPanelView") as TimelineVisualizationPanelView; if (visualizationPanelView != null) { visualizationPanelView.FinishDragDrop(); } } this.dragDropAdorner.Hide(); this.Cursor = Cursors.Arrow; } e.Handled = true; } }
private void DropStream(DragEventArgs e) { StreamTreeNode streamTreeNode = e.Data.GetData(DragDropDataName.StreamTreeNode) as StreamTreeNode; 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.Visualize, streamTreeNode)) { return; } if (this.ExecuteCommandIfPresent(commands, ContextMenuName.VisualizeAsMilliseconds, streamTreeNode)) { return; } } else { if (this.ExecuteCommandIfPresent(commands, ContextMenuName.VisualizeInNewPanel, streamTreeNode)) { return; } if (this.ExecuteCommandIfPresent(commands, ContextMenuName.VisualizeAsMillisecondsInNewPanel, 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; } } } }