Exemplo n.º 1
0
        private void PopulateDocumentFromGraph()
        {
            if (!_populatingControl)
            {
                List <BaseNodeConfig> nodes = new List <BaseNodeConfig>();
                List <LineConfig>     lines = new List <LineConfig>();
                GraphData             graph = netEditor.Graph;

                foreach (var n in graph.Nodes)
                {
                    BaseNodeConfig node = (BaseNodeConfig)n.Tag;
                    node.X = n.Center.X;
                    node.Y = n.Center.Y;
                    node.Z = n.Z;

                    nodes.Add(node);
                }

                foreach (var l in graph.Lines)
                {
                    bool isWeak = false;
                    if (l.Tag != null)
                    {
                        isWeak = (bool)l.Tag;
                    }
                    LineConfig line = new LineConfig((BaseNodeConfig)l.SourceShape.Tag,
                                                     (BaseNodeConfig)l.DestShape.Tag, l.BiDirection, l.Label, isWeak);

                    lines.Add(line);
                }

                _document.UpdateGraph(nodes.ToArray(), lines.ToArray());
            }
        }
Exemplo n.º 2
0
        private void BuildDefaultProxyNetgraph(NetGraphDocument document)
        {
            List <BaseNodeConfig> nodes = new List <BaseNodeConfig>();

            ServerEndpointConfig server = new ServerEndpointConfig();

            server.Label = "SERVER";
            server.X     = 80;
            server.Y     = 150;
            nodes.Add(server);

            ClientEndpointConfig client = new ClientEndpointConfig();

            client.Label = "CLIENT";
            client.X     = 280;
            client.Y     = 150;
            nodes.Add(client);

            LogPacketConfig logout = new LogPacketConfig();

            logout.Label = "LOGOUT";
            logout.X     = 180;
            logout.Y     = 60;
            logout.Color = ColorValue.Pink;
            logout.Tag   = "Out";
            nodes.Add(logout);

            LogPacketConfig login = new LogPacketConfig();

            login.Label = "LOGIN";
            login.X     = 180;
            login.Y     = 240;
            login.Color = ColorValue.Powderblue;
            login.Tag   = "In";
            nodes.Add(login);

            List <LineConfig> lines = new List <LineConfig>();

            lines.Add(new LineConfig(server, logout, false, null, false));
            lines.Add(new LineConfig(logout, client, false, null, false));
            lines.Add(new LineConfig(client, login, false, null, false));
            lines.Add(new LineConfig(login, server, false, null, false));


            document.UpdateGraph(nodes.ToArray(), lines.ToArray());
        }