Ejemplo n.º 1
0
        private async void InteractiveEdgeCreated(object sender, EdgeEventArgs e)
        {
            INode  node  = (INode)e.Item.TargetPort.Owner;
            int    layer = GetLayer(node);
            IGraph graph = graphControl.Graph;

            // set the correct color for the layer
            graph.SetStyle(node,
                           new ShinyPlateNodeStyle {
                Brush = NodePlacerPanel.LayerBrushes[layer % NodePlacerPanel.LayerBrushes.Length]
            });
            // and the correct placer for the layer
            INodePlacer placer = null;

            if (layer >= nodePlacerPanel.NodePlacers.Count)
            {
                nodePlacerPanel.NodePlacers.Add(NodePlacerConfigurations.None);
            }
            else
            {
                INodePlacerConfiguration nodePlacerConfiguration = nodePlacerPanel.NodePlacers[layer].Configuration;
                placer = nodePlacerConfiguration.CreateNodePlacer();
            }
            placers[node] = placer ?? new DefaultNodePlacer();
            // execute the layout
            await ApplyLayout();

            // set the placer panel to the node's layer
            nodePlacerPanel.Level = layer;
        }
        public override void AdoptSettings(INodePlacer nodePlacer)
        {
            base.AdoptSettings(nodePlacer);
            var dnp = (AssistantNodePlacer)nodePlacer;
            //Configure the child placer configuration handler
            //Create a default configuration
            INodePlacer childNodePlacer = dnp.ChildNodePlacer;

            if (childNodePlacer is DefaultNodePlacer)
            {
                childNodePlacerCfg = new DefaultNodePlacerConfiguration();
                Type = ChildNodePlacerTypes.DefaultNodePlacer;
            }
            if (childNodePlacer is SimpleNodePlacer)
            {
                childNodePlacerCfg = new SimpleNodePlacerConfiguration();
                Type = ChildNodePlacerTypes.SimpleNodePlacer;
            }
            if (childNodePlacer is BusNodePlacer)
            {
                childNodePlacerCfg = new BusPlacerConfiguration();
                Type = ChildNodePlacerTypes.BusPlacer;
            }
            if (childNodePlacer is DoubleLineNodePlacer)
            {
                childNodePlacerCfg = new DoubleLinePlacerConfiguration();
                Type = ChildNodePlacerTypes.DoubleLinePlacer;
            }
            if (childNodePlacer is AspectRatioNodePlacer)
            {
                childNodePlacerCfg = new ARNodePlacerConfiguration();
                Type = ChildNodePlacerTypes.ARNodePlacer;
            }
            if (childNodePlacer is LeftRightNodePlacer)
            {
                childNodePlacerCfg = new LeftRightPlacerConfiguration();
                Type = ChildNodePlacerTypes.LeftRightPlacer;
            }
            //And adopt the current values
            childNodePlacerCfg.AdoptSettings(childNodePlacer);
        }