/// <summary> /// Configures table editing specific parts. /// </summary> private void ConfigureTableEditing() { //Create a new TEIM instance which also allows drag and drop tableEditorInputMode = new TableEditorInputMode { //Enable drag & drop StripeDropInputMode = { Enabled = true }, //Maximal level for both reparent and drag and drop is 2 ReparentStripeHandler = new ReparentStripeHandler { MaxColumnLevel = 2, MaxRowLevel = 2 }, //Set the priority higher than for the handle input mode so that handles win if both gestures are possible Priority = graphEditorInputMode.HandleInputMode.Priority + 1 }; //Add to GEIM graphEditorInputMode.Add(tableEditorInputMode); //Tooltip and context menu stuff for tables graphEditorInputMode.ContextMenuItems = GraphItemTypes.Node; graphEditorInputMode.PopulateItemContextMenu += graphEditorInputMode_PopulateItemContextMenu; graphEditorInputMode.PopulateItemContextMenu += graphEditorInputMode_PopulateNodeContextMenu; graphEditorInputMode.MouseHoverInputMode.QueryToolTip += MouseHoverInputMode_QueryToolTip; // we don't provide candidates for the pool nodes, so tell the input mode not to create edges, if // there aren't any candidates. That way, we can start marquee selection inside pool nodes graphEditorInputMode.CreateEdgeInputMode.UseHitItemsCandidatesOnly = true; graphEditorInputMode.AllowGroupingOperations = true; }
/// <summary> /// Registers the <see cref="GraphEditorInputMode"/> as the <see cref="CanvasControl.InputMode"/> /// and initializes the marquee input mode that clears the area of the marquee rectangle. /// </summary> private void InitializeInputModes() { // enable undo/redo support graphControl.Graph.SetUndoEngineEnabled(true); // create an input mode to edit graphs var editMode = new GraphEditorInputMode(); // create an input mode to clear the area of a marquee rectangle // using the right mouse button var marqueeClearInputMode = new MarqueeSelectionInputMode { PressedRecognizer = MouseEventRecognizers.RightPressed, DraggedRecognizer = MouseEventRecognizers.RightDragged, ReleasedRecognizer = MouseEventRecognizers.RightReleased, CancelRecognizer = KeyEventRecognizers.EscapePressed.Or(MouseEventRecognizers.LostCaptureDuringDrag), Template = new MarqueeClearTemplate() }; // handle dragging the marquee marqueeClearInputMode.DragStarting += OnDragStarting; marqueeClearInputMode.Dragged += OnDragged; marqueeClearInputMode.DragCanceled += OnDragCanceled; marqueeClearInputMode.DragFinished += OnDragFinished; // add this mode to the edit mode editMode.Add(marqueeClearInputMode); // and install the edit mode into the canvas graphControl.InputMode = editMode; }
/// <summary> /// Initializes the graph and the input mode. /// </summary> protected override void OnLoad(EventArgs e) { DecorateModelItemLookupForCustomSnappingBehaviour(); var graphSnapContext = CreateGraphSnapContext(); var labelSnapContext = CreateLabelSnapContext(); InitializeGrid(graphSnapContext); // Initialize two free snap lines that are also visualized in the GraphCanvasComponent AdditionalSnapLineVisualCreators = new List <AdditionalSnapLineVisualCreator>(); AddAdditionalSnapLineVisualCreator(new PointD(0, -70), new PointD(500, -70)); AddAdditionalSnapLineVisualCreator(new PointD(-230, -50), new PointD(-230, 400)); // Initialize the input mode for this demo var graphEditorInputMode = new GraphEditorInputMode { SnapContext = graphSnapContext, LabelSnapContext = labelSnapContext }; // add an input mode that allows to move the custom AdditionalSnapLines graphEditorInputMode.Add(new AdditionalSnapLineMoveInputMode(this) { Priority = -50 }); GraphControl.InputMode = graphEditorInputMode; InitializeGraphDefaults(); // Initialize the graph by reading it from a file. ReadGraph("Resources\\CustomSnapping.graphml"); }
private void OnWindowLoaded(object sender, RoutedEventArgs e) { // Set a nicer node style and create the sample graph GraphControl.Graph.NodeDefaults.Style = new ShinyPlateNodeStyle { Brush = Brushes.Orange }; GraphEditorInputMode.Add(lensInputMode); InitializeGraph(GraphControl.Graph); }
/// <summary> /// Registers the <see cref="GraphEditorInputMode"/> as the <see cref="CanvasControl.InputMode"/> /// and initializes the input mode for dropping components. /// </summary> private void InitializeInputModes() { // create a GraphEditorInputMode instance var editMode = new GraphEditorInputMode(); GraphControl.InputMode = editMode; // add the input mode to drop components var graphDropInputMode = new ComponentDropInputMode(); graphDropInputMode.DragEntered += OnDragStarting; graphDropInputMode.DragOver += OnDragged; graphDropInputMode.ItemCreated += OnDragFinished; graphDropInputMode.DragLeft += OnDragCanceled; editMode.Add(graphDropInputMode); }
private void OnLoaded(object sender, EventArgs e) { // enable undo engine graphControl.Graph.SetUndoEngineEnabled(true); graphEditorInputMode = new GraphEditorInputMode(); // prepare orthogonal edge editing graphEditorInputMode.OrthogonalEdgeEditingContext = new OrthogonalEdgeEditingContext { Enabled = false }; // allow grouping operations graphEditorInputMode.AllowGroupingOperations = true; // prepare snapping graphEditorInputMode.SnapContext = new GraphSnapContext { Enabled = false }; graphControl.InputMode = graphEditorInputMode; // set minimum and maximum sizes for all non-group nodes (group nodes should be able to grow larger so they can // contain arbitrary numbers of nodes) var sizeConstraintProvider = new NodeSizeConstraintProvider(new SizeD(10, 10), new SizeD(100, 100)); graphControl.Graph .GetDecorator() .NodeDecorator .SizeConstraintProviderDecorator .SetFactory(node => !graphControl.Graph.IsGroupNode(node), node => sizeConstraintProvider); // add a custom input mode to the GraphEditorInputMode that shows a single set of handles when multiple nodes are selected nodeGroupResizingInputMode = new NodeGroupResizingInputMode { Margins = new InsetsD(10), Mode = NodeGroupResizing.ResizeMode.Resize }; graphEditorInputMode.Add(nodeGroupResizingInputMode); // load sample graph graphControl.ImportFromGraphML("Resources/sampleGraph.graphml"); graphControl.FitContent(); graphControl.Graph.GetUndoEngine().Clear(); // set style defaults graphControl.Graph.NodeDefaults.Style = new ShinyPlateNodeStyle { Brush = Brushes.Orange }; Color groupNodeColor = Color.FromArgb(255, 214, 229, 248); var groupNodeDefaults = graphControl.Graph.GroupNodeDefaults; groupNodeDefaults.Style = new PanelNodeStyle { Color = groupNodeColor, Insets = new InsetsD(5, 18, 5, 5), LabelInsetsColor = groupNodeColor, }; groupNodeDefaults.Labels.Style = new DefaultLabelStyle { StringFormat = { Alignment = StringAlignment.Far } }; groupNodeDefaults.Labels.LayoutParameter = InteriorStretchLabelModel.North; cmbResizeMode.SelectedIndex = 0; }