Exemple #1
0
 public ZOrderGraphEditorInputMode(ZOrderSupport support)
 {
     AddCommandHandler(Raise, support.Raise);
     AddCommandHandler(Lower, support.Lower);
     AddCommandHandler(ToFront, support.ToFront);
     AddCommandHandler(ToBack, support.ToBack);
 }
Exemple #2
0
 private void Cleanup()
 {
     MovedNodes = null;
     oldParents.Clear();
     maxOldZOrder.Clear();
     maxRootZOrder = Int32.MinValue;
     Graph         = null;
     ZOrderSupport = null;
 }
Exemple #3
0
        public ZOrderGraphClipboard(ZOrderSupport support)
        {
            this.Support = support;
            // copy z-order to item copied to clipboard
            this.ToClipboardCopier.NodeCopied += OnCopiedToClipboard;

            // copy z-order to item copied to graph and collect those copied items
            this.FromClipboardCopier.NodeCopied += OnCopiedFromClipboard;
            this.DuplicateCopier.NodeCopied     += OnCopiedFromClipboard;
        }
        public override void InitializeDrag(IInputModeContext context)
        {
            var graph = context.GetGraph();

            ZOrderSupport = graph.Lookup <ZOrderSupport>();

            // store initial parent of the node...
            this.initialParent = graph.GetParent(node);
            this.currentParent = initialParent;
            this.dragging      = true;
            base.InitializeDrag(context);
        }
Exemple #5
0
        /// <summary>
        /// Initializes the graph, z-order support and the input mode.
        /// </summary>
        /// <seealso cref="InitializeGraph"/>
        protected virtual void OnLoaded(object source, EventArgs e)
        {
            // initialize the graph
            InitializeGraph();

            // initialize consistent z-order support
            var zOrderSupport = new ZOrderSupport(graphControl);

            EnableGroupingOperations();

            ConfigureInputMode(zOrderSupport);

            LoadGraph();
        }
Exemple #6
0
        // Before the move gesture starts, we store all moved nodes, their parents and the maximum z-order of
        // children of their parents
        private void MoveStarting(object sender, InputModeEventArgs e)
        {
            Graph         = e.Context.GetGraph();
            ZOrderSupport = Graph.Lookup <ZOrderSupport>();

            // store all selected nodes which might get reparented
            MovedNodes = Geim.GraphSelection.SelectedNodes.ToList();
            // sort this list by their relative z-order
            MovedNodes.Sort(ZOrderSupport);

            // calculate max z-order for all group nodes containing any moved node
            foreach (var node in MovedNodes)
            {
                var parent = Graph.GetParent(node);
                oldParents[node] = parent;
                GetOrCalculateMaxZOrder(parent);
            }
            // calculate max z-order of top-level nodes
            GetOrCalculateMaxZOrder(null);
        }
Exemple #7
0
        private void ConfigureInputMode(ZOrderSupport zOrderSupport)
        {
            var geim = graphControl.InputMode as GraphEditorInputMode;

            geim.FocusableItems = GraphItemTypes.None;
            // prevent interactive label changes since they display the z-index in this demo
            geim.SelectableItems             = GraphItemTypes.Node | GraphItemTypes.Edge;
            geim.AllowEditLabel              = false;
            geim.AllowAddLabel               = false;
            geim.AllowEditLabelOnDoubleClick = false;


            // update node labels showing the node's z-index
            geim.NodeCreated += (sender, args) => {
                var node = args.Item;
                UpdateLabel(node, zOrderSupport.GetZOrder(node));
            };

            geim.ElementsPasted += (sender, args) => {
                foreach (var node in graphControl.Graph.Nodes)
                {
                    UpdateLabel(node, zOrderSupport.GetZOrder(node));
                }
            };

            geim.ElementsDuplicated += (sender, args) => {
                foreach (var node in graphControl.Graph.Nodes)
                {
                    UpdateLabel(node, zOrderSupport.GetZOrder(node));
                }
            };

            zOrderSupport.ZOrderChanged += (sender, args) => {
                if (args.Node is INode)
                {
                    UpdateLabel(args.Node as INode, args.NewZOrder);
                }
            };
        }
        /// <summary>
        /// Decorates the lookup of <paramref name="graph"/> to provide the <paramref name="zOrderSupport"/>.
        /// </summary>
        private static void AddZOrderSupportLookup(IGraph graph, ZOrderSupport zOrderSupport)
        {
            var graphLookupDecorator = graph.Lookup <ILookupDecorator>();

            new LookupDecorator <IGraph, ZOrderSupport>(graphLookupDecorator, true, true).SetImplementation(zOrderSupport);
        }
Exemple #9
0
 public ZOrderGraphModelManager(GraphControl graphControl, ZOrderSupport zOrderSupport) : base(graphControl, graphControl.ContentGroup)
 {
     ZOrderSupport = zOrderSupport;
     // The ItemModelManager.Comparer needs the user objects to be accessible from the main canvas objects
     ProvideUserObjectOnMainCanvasObject = true;
 }