private void OnLoaded(object source, EventArgs args) { // Configure interaction and context menu var gvim = new GraphViewerInputMode { SelectableItems = GraphItemTypes.None }; gvim.ContextMenuItems = GraphItemTypes.Node; gvim.PopulateItemContextMenu += (sender, e) => { if (e.Item is INode node) { // Add a context menu entry; it will load all neighbors to the graph var showNeighbors = new ToolStripMenuItem("Show neighbors"); showNeighbors.Click += async delegate { await LoadNeighbors(node); }; var shortestPath = new ToolStripMenuItem("Calculate shortest path"); shortestPath.Click += delegate { ShowPathViewer(node); }; e.Menu.Items.Add(showNeighbors); e.Menu.Items.Add(shortestPath); e.ShowMenu = true; e.Handled = true; } }; graphControl.InputMode = gvim; graphControl.Center = PointD.Origin; connectionInfoPanel = new ConnectionDialog(ConnectionInfo); connectionInfoPanel.ShowDialog(this); // Assuming that the dialog is modal and the call is Connect_OnClick(null, null); }
public void OnLoaded(object source, EventArgs args) { // create and configure a new AggregateGraphWrapper var aggregateGraph = new AggregateGraphWrapper(graphControl.Graph); // set default label text sizes for aggregation labels aggregateGraph.AggregationNodeDefaults.Labels.Style = new DefaultLabelStyle { Font = new Font(FontFamily.GenericSansSerif, 28, FontStyle.Regular, GraphicsUnit.Pixel) }; aggregateGraph.AggregationEdgeDefaults.Labels.Style = new DefaultLabelStyle { Font = new Font(FontFamily.GenericSansSerif, 18, FontStyle.Regular, GraphicsUnit.Pixel) }; // assign it to the graphControl graphControl.Graph = aggregateGraph; // disable edge cropping, so thick aggregation edges run smoothly into nodes Graph.GetDecorator().PortDecorator.EdgePathCropperDecorator.HideImplementation(); // don't create edges in both directions when replacing edges by aggregation edges AggregateGraph.EdgeReplacementPolicy = EdgeReplacementPolicy.Undirected; graphViewerInputMode = new GraphViewerInputMode(); graphControl.InputMode = graphViewerInputMode; RegisterContextMenuCallback(); RegisterAggregationCallbacks(); graphControl.ImportFromGraphML("Resources/SampleGraph.graphml"); }
private void InitializeInputModes() { editMode = new GraphViewerInputMode { ClickableItems = GraphItemTypes.Node, SelectableItems = GraphItemTypes.None, MarqueeSelectableItems = GraphItemTypes.None, ToolTipItems = GraphItemTypes.None, FocusableItems = GraphItemTypes.Node, }; editMode.ItemDoubleClicked += OnItemDoubleClicked; // add key bindings editMode.KeyboardInputMode.AddKeyBinding(Keys.Add, Keys.None, Commands.IncreaseZoom); editMode.KeyboardInputMode.AddKeyBinding(Keys.Subtract, Keys.None, Commands.DecreaseZoom); editMode.KeyboardInputMode.AddKeyBinding(Keys.Enter, Keys.None, Commands.ZoomToCurrentItem); editMode.KeyboardInputMode.AddKeyBinding(Keys.Left, Keys.Control, Commands.ScrollPageLeft); editMode.KeyboardInputMode.AddKeyBinding(Keys.Right, Keys.Control, Commands.ScrollPageRight); editMode.KeyboardInputMode.AddKeyBinding(Keys.Up, Keys.Control, Commands.ScrollPageUp); editMode.KeyboardInputMode.AddKeyBinding(Keys.Down, Keys.Control, Commands.ScrollPageDown); editMode.KeyboardInputMode.AddKeyBinding(Keys.PageUp, Keys.Control, ShowParentCommand); editMode.KeyboardInputMode.AddKeyBinding(Keys.PageDown, Keys.Control, HideParentCommand); editMode.KeyboardInputMode.AddKeyBinding(Keys.Add, Keys.Control, ShowChildrenCommand); editMode.KeyboardInputMode.AddKeyBinding(Keys.Subtract, Keys.Control, HideChildrenCommand); // register command bindings editMode.KeyboardInputMode.AddCommandBinding(HideChildrenCommand, HideChildrenExecuted, CanExecuteHideChildren); editMode.KeyboardInputMode.AddCommandBinding(ShowChildrenCommand, ShowChildrenExecuted, CanExecuteShowChildren); editMode.KeyboardInputMode.AddCommandBinding(HideParentCommand, HideParentExecuted, CanExecuteHideParent); editMode.KeyboardInputMode.AddCommandBinding(ShowParentCommand, ShowParentExecuted, CanExecuteShowParent); editMode.KeyboardInputMode.AddCommandBinding(ShowAllCommand, ShowAllExecuted, CanExecuteShowAll); graphControl.InputMode = editMode; }
private async void OnLoaded(object source, EventArgs e) { // TODO graphViewerInputMode = new GraphViewerInputMode(); graphControl.InputMode = graphViewerInputMode; graphOverviewControl.GraphControl = graphControl; RegisterCommands(); // initialize properties panel InitializePropertiesPanel(); // initialize node click listener that toggles the aggregation status InitializeToggleAggregation(); InitializeHighlight(); // disable UI SetUiEnabled(false); // load sample graph OriginalGraph = await LoadGraphMlz("Resources/SampleGraph.graphmlz"); // run smart aggregation algorithm with default settings and set graph to graphControl await RunAggregationAndReplaceGraph(OriginalGraph); // notify UI OnInfoPanelPropertiesChanged(); // enable UI again SetUiEnabled(true); }
private void OnLoaded(object source, EventArgs args) { // Configure interaction and context menu var gvim = new GraphViewerInputMode { SelectableItems = GraphItemTypes.None }; gvim.ContextMenuItems = GraphItemTypes.Node; gvim.PopulateItemContextMenu += (sender, e) => { if (e.Item is INode node) { // Add a context menu entry; it will load all neighbors to the graph var showNeighbors = new MenuItem() { Header = "Show neighbors" }; showNeighbors.Click += async delegate { await LoadNeighbors(node); }; var shortestPath = new MenuItem() { Header = "Calculate shortest path" }; shortestPath.Click += delegate { ShowPathViewer(node); }; e.Menu.Items.Add(showNeighbors); e.Menu.Items.Add(shortestPath); e.ShowMenu = true; e.Handled = true; } }; graphControl.InputMode = gvim; graphControl.Center = PointD.Origin; }
/// <summary> /// Creates a mode and registers it as the /// <see cref="CanvasControl.InputMode"/>. /// </summary> protected virtual void InitializeInputModes() { var inputMode = new GraphViewerInputMode(); inputMode.NavigationInputMode.AllowCollapseGroup = true; inputMode.NavigationInputMode.AllowExpandGroup = true; // FitContent interferes with our viewport animation setup inputMode.NavigationInputMode.FitContentAfterGroupActions = false; inputMode.NavigationInputMode.GroupExpanded += NavigationInputMode_GroupExpanded; inputMode.NavigationInputMode.GroupCollapsed += NavigationInputMode_GroupCollapsed; graphControl.InputMode = inputMode; }
private void InitializeInputMode() { // we have a viewer application, so we can use the GraphViewerInputMode // -enable support for: tooltips on nodes and edges // -clicking on nodes // -focusing (via keyboard navigation) of nodes // -no selection // -no marquee var graphViewerInputMode = new GraphViewerInputMode { ToolTipItems = GraphItemTypes.LabelOwner, ClickableItems = GraphItemTypes.Node, FocusableItems = GraphItemTypes.Node, SelectableItems = GraphItemTypes.None, MarqueeSelectableItems = GraphItemTypes.None }; // we want to enable the user to collapse and expand groups interactively, even though we // are just a "viewer" application graphViewerInputMode.NavigationInputMode.AllowCollapseGroup = true; graphViewerInputMode.NavigationInputMode.AllowExpandGroup = true; // after expand/collapse/enter/exit operations - perform a fitContent operation to adjust // reachable area. graphViewerInputMode.NavigationInputMode.FitContentAfterGroupActions = true; // we don't have selection enabled and thus the commands should use the "currentItem" // property instead - this property is changed when clicking on items or navigating via // the keyboard. graphViewerInputMode.NavigationInputMode.UseCurrentItemForCommands = true; // we want to get reports of the mouse being hovered over nodes and edges // first enable queries graphViewerInputMode.ItemHoverInputMode.Enabled = true; // set the items to be reported graphViewerInputMode.ItemHoverInputMode.HoverItems = GraphItemTypes.Edge | GraphItemTypes.Node; // if there are other items (most importantly labels) in front of edges or nodes // they should be discarded, rather than be reported as "null" graphViewerInputMode.ItemHoverInputMode.DiscardInvalidItems = false; // whenever the currently hovered item changes call our method graphViewerInputMode.ItemHoverInputMode.HoveredItemChanged += OnHoveredItemChanged; // when the mouse hovers for a longer time over an item we may optionally display a // tooltip. Use this callback for querying the tooltip contents. graphViewerInputMode.QueryItemToolTip += OnQueryItemToolTip; // if we click on an item we want to perform a custom action, so register a callback graphViewerInputMode.ItemClicked += OnItemClicked; // also if someone clicked on an empty area we want to perform a custom group action graphViewerInputMode.ClickInputMode.Clicked += OnClickInputModeOnClicked; graphControl.InputMode = graphViewerInputMode; }
/// <summary> /// Creates a viewer input mode with a custom additional input mode that /// handles cursor changes for <see cref="IClickHandler"/>s. /// </summary> private static IInputMode CreateInputMode() { var gvim = new GraphViewerInputMode { SelectableItems = GraphItemTypes.None, FocusableItems = GraphItemTypes.None }; // Add our own input mode that handles cursor changes var clickHandlerMode = new ClickHandlerHoverInputMode(); gvim.Add(clickHandlerMode); return(gvim); }
private void InitializeInputMode() { // create the inputmode and disable selection and focus GraphViewerInputMode mode = new GraphViewerInputMode() { ClickableItems = GraphItemTypes.Node, SelectableItems = GraphItemTypes.None, FocusableItems = GraphItemTypes.None, }; // handle clicks on nodes mode.ItemClicked += (sender, e) => GotoReferencingNode((INode)e.Item); graphControl.InputMode = mode; }
/// <summary> /// Creates a mode and registers it as the /// <see cref="CanvasControl.InputMode"/>. /// </summary> protected virtual void InitializeInputModes() { // create a simple mode that reacts to mouse clicks on nodes. var graphViewerInputMode = new GraphViewerInputMode(); graphViewerInputMode.ClickableItems = GraphItemTypes.Node; graphViewerInputMode.ItemClicked += delegate(object sender, ItemClickedEventArgs <IModelItem> args) { if (args.Item is INode) { // toggle the collapsed state of the clicked node ToggleChildrenCommand.Execute((INode)args.Item, graphControl); } }; graphViewerInputMode.KeyboardInputMode.AddCommandBinding(ToggleChildrenCommand, ToggleChildrenExecuted); graphControl.InputMode = graphViewerInputMode; }
private async void GraphSourceWindow_OnLoaded(object sender, RoutedEventArgs e) { // create new input mode GraphViewerInputMode inputMode = new GraphViewerInputMode { SelectableItems = GraphItemTypes.None }; // add a custom input mode that allows dragging nodes from the graph to the lists inputMode.Add(new NodeDragInputMode { Priority = -1 }); graphControl.InputMode = inputMode; graphControl.FocusIndicatorManager.ShowFocusPolicy = ShowFocusPolicy.Always; graphSource = ((AdjacentNodesGraphSource)Application.Current.MainWindow.Resources["GraphSource"]); graphSource.NodesSource = CreateInitialBusinessData(); await ApplyLayout(false); }
private void InitializeInputMode() { // create the inputmode and disable selection and focus GraphViewerInputMode mode = new GraphViewerInputMode() { ClickableItems = GraphItemTypes.Node, SelectableItems = GraphItemTypes.None, FocusableItems = GraphItemTypes.None, }; // handle clicks on nodes mode.ItemClicked += (sender, e) => GotoReferencingNode((INode)e.Item); // register the command bindings for the custom commands mode.KeyboardInputMode.AddCommandBinding(PreviousPageCommand, PreviousPage_Executed, PreviousPage_CanExecute); mode.KeyboardInputMode.AddCommandBinding(NextPageCommand, NextPage_Executed, NextPage_CanExecute); graphControl.InputMode = mode; originalGraphControl.InputMode = new GraphViewerInputMode() { ClickableItems = GraphItemTypes.None, SelectableItems = GraphItemTypes.None }; }