Inheritance: NodeRenderer, ISingleDepthNodeRenderer
Esempio n. 1
0
        private void OnGetRelatedNodesByIdCompleted(object sender, ReturnedNodesEventArgs e)
        {
            int count  = 0;
            int length = e.Nodes.Length - 1;

            if (Views.ContainsKey(FocalNodeId))
            {
                CurrentView = Views[FocalNodeId];
            }
            else
            {
                CurrentView = new NavigatorView();

                Views.Add(FocalNodeId, CurrentView);

                SingleDepthNodeRenderer focalNodeRenderer = null;

                foreach (INodeProxy nodeProxy in e.Nodes)
                {
                    if (nodeProxy.Id == FocalNodeId)
                    {
                        if (FocalNode == null)
                        {
                            FocalNode = nodeProxy;

                            focalNodeRenderer = new SingleDepthNodeRenderer(CurrentView, FocalNode, ThemeManagementObject, "Focal");

                            CurrentView.NodeRenderers.Add(focalNodeRenderer.Node.Id, focalNodeRenderer);

                            focalNodeRenderer.NodePositionUpdating += new EventHandler(OnNodePositionUpdating);
                            focalNodeRenderer.NodeDoubleClicked    += new EventHandler <NodeClickedArgs>(OnNodeDoubleClicked);
                        }
                    }
                    else
                    {
                        SingleDepthNodeRenderer nodeRenderer = new SingleDepthNodeRenderer(CurrentView, nodeProxy, ThemeManagementObject, "Default");

                        nodeRenderer.NodeIndex = count;
                        nodeRenderer.NodeCount = length;

                        CurrentView.NodeRenderers.Add(nodeRenderer.Node.Id, nodeRenderer);

                        nodeRenderer.NodePositionUpdating += new EventHandler(OnNodePositionUpdating);
                        nodeRenderer.NodeDoubleClicked    += new EventHandler <NodeClickedArgs>(OnNodeDoubleClicked);

                        count++;
                    }
                }

                if (focalNodeRenderer == null)
                {
                    return;
                }

                foreach (INodeRenderer nodeRenderer in CurrentView.NodeRenderers.Values)
                {
                    foreach (IDescriptorProxy descriptor in nodeRenderer.Node.Descriptors)
                    {
                        if (!CurrentView.RelationshipRenderers.ContainsKey(descriptor.Relationship.Id))
                        {
                            bool relationshipIsPresent = true;

                            foreach (IDescriptorProxy alternateDescriptor in descriptor.Relationship.Descriptors)
                            {
                                if (!CurrentView.NodeRenderers.ContainsKey(alternateDescriptor.Node.Id))
                                {
                                    relationshipIsPresent = false;
                                    break;
                                }
                            }

                            if (relationshipIsPresent)
                            {
                                ImprovedArrow arrow = new ImprovedArrow(CurrentView, descriptor.Relationship);

                                CurrentView.RelationshipRenderers.Add(descriptor.Relationship.Id, arrow);
                            }
                        }
                    }
                }
            }

            RendererNodesEventArgs rendererNodesEventArgs = new RendererNodesEventArgs(CurrentView);

            if (GetCurrentNodesCompleted != null)
            {
                GetCurrentNodesCompleted.Invoke(sender, rendererNodesEventArgs);
            }
        }
Esempio n. 2
0
        private void OnGetRelatedNodesByIdCompleted(object sender, ReturnedNodesEventArgs e)
        {
            int count = 0;
            int length = e.Nodes.Length - 1;

            if (Views.ContainsKey(FocalNodeId))
            {
                CurrentView = Views[FocalNodeId];
            }
            else
            {
                CurrentView = new NavigatorView();

                Views.Add(FocalNodeId, CurrentView);

                SingleDepthNodeRenderer focalNodeRenderer = null;

                foreach (INodeProxy nodeProxy in e.Nodes)
                {
                    if (nodeProxy.Id == FocalNodeId)
                    {
                        if (FocalNode == null)
                        {
                            FocalNode = nodeProxy;

                            focalNodeRenderer = new SingleDepthNodeRenderer(CurrentView, FocalNode, ThemeManagementObject, "Focal");

                            CurrentView.NodeRenderers.Add(focalNodeRenderer.Node.Id, focalNodeRenderer);

                            focalNodeRenderer.NodePositionUpdating += new EventHandler(OnNodePositionUpdating);
                            focalNodeRenderer.NodeDoubleClicked += new EventHandler<NodeClickedArgs>(OnNodeDoubleClicked);
                        }
                    }
                    else
                    {
                        SingleDepthNodeRenderer nodeRenderer = new SingleDepthNodeRenderer(CurrentView, nodeProxy, ThemeManagementObject, "Default");

                            nodeRenderer.NodeIndex = count;
                            nodeRenderer.NodeCount = length;

                            CurrentView.NodeRenderers.Add(nodeRenderer.Node.Id, nodeRenderer);

                            nodeRenderer.NodePositionUpdating += new EventHandler(OnNodePositionUpdating);
                            nodeRenderer.NodeDoubleClicked += new EventHandler<NodeClickedArgs>(OnNodeDoubleClicked);

                            count++;
                    }
                }

                if (focalNodeRenderer == null)
                {
                    return;
                }

                foreach (INodeRenderer nodeRenderer in CurrentView.NodeRenderers.Values)
                {
                    foreach (IDescriptorProxy descriptor in nodeRenderer.Node.Descriptors)
                    {
                        if (!CurrentView.RelationshipRenderers.ContainsKey(descriptor.Relationship.Id))
                        {
                            bool relationshipIsPresent = true;

                            foreach (IDescriptorProxy alternateDescriptor in descriptor.Relationship.Descriptors)
                            {
                                if (!CurrentView.NodeRenderers.ContainsKey(alternateDescriptor.Node.Id))
                                {
                                    relationshipIsPresent = false;
                                    break;
                                }
                            }

                            if (relationshipIsPresent)
                            {
                                ImprovedArrow arrow = new ImprovedArrow(CurrentView, descriptor.Relationship);

                                CurrentView.RelationshipRenderers.Add(descriptor.Relationship.Id, arrow);
                            }
                        }
                    }
                }
            }

            RendererNodesEventArgs rendererNodesEventArgs = new RendererNodesEventArgs(CurrentView);

            if (GetCurrentNodesCompleted != null)
            {
                GetCurrentNodesCompleted.Invoke(sender, rendererNodesEventArgs);
            }
        }