Exemplo n.º 1
0
        /// <summary>
        /// Returns the z-order previously stored for the <paramref name="node"/>.
        /// </summary>
        /// <remarks>
        /// The z-order stored in the <see cref="ZOrderSupport"/> is used as fallback for items currently not in the view.
        /// </remarks>
        /// <param name="node">The item to return the z-order for.</param>
        /// <returns>The z-order of the item.</returns>
        private int GetZOrder(INode node)
        {
            int zOrder;

            if (zOrders.TryGetValue(node, out zOrder))
            {
                return(zOrder);
            }
            return(Support.GetZOrder(node));
        }
Exemplo n.º 2
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);
                }
            };
        }