Esempio n. 1
0
        private NetworkVisualNode CreateVisualItem(object tag)
        {
            IRelevance relevance = tag as IRelevance;

            if (relevance != null)
            {
                if (relevance.Relevance < sliderRelevance.Minimum && relevance.Relevance != -1)
                {
                    sliderRelevance.Minimum = relevance.Relevance;
                    sliderRelevance.Value   = relevance.Relevance;
                }
            }

            NetworkVisualNode visualNode = new NetworkVisualNode();

            visualNode.ContentObject  = tag;
            visualNode.NodeSelected  += new NetworkVisualNode.NodeSelectedEventHandler(visualNode_NodeSelected);
            visualNode.NodeActivated += new NetworkVisualNode.NodeActivatedEventHandler(visualNode_NodeActivated);
            visualNode.NodeHovered   += new NetworkVisualNode.NodeHoveredEventHandler(visualNode_NodeHovered);
            visualNode.UpdateRelevence(sliderRelevance.Value <= sliderRelevance.Minimum ? -1 : sliderRelevance.Value);

            _canvas.Children.Add(visualNode);

            return(visualNode);
        }
Esempio n. 2
0
        void RenderConnectors()
        {
            foreach (KeyValuePair <Line, KeyValuePair <NetworkVisualNode, NetworkVisualNode> > kvp in _connectors)
            {
                NetworkVisualNode nvn1 = kvp.Value.Key;
                NetworkVisualNode nvn2 = kvp.Value.Value;

                kvp.Key.X1 = nvn1.Centre.X;
                kvp.Key.Y1 = nvn1.Centre.Y;
                kvp.Key.X2 = nvn2.Centre.X;
                kvp.Key.Y2 = nvn2.Centre.Y;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Clear the items in the network
        /// </summary>
        public void ClearItems()
        {
            _visibleNodes     = new List <object>();
            _edges            = new List <KeyValuePair <object, object> >();
            _connectors       = new Dictionary <Line, KeyValuePair <NetworkVisualNode, NetworkVisualNode> >();
            _visualItems      = new Dictionary <object, NetworkVisualNode>();
            _nodeParents      = new Dictionary <object, object>();
            _nodeCentre       = new Dictionary <object, Point>();
            _nodeVelocity     = new Dictionary <object, Vector>();
            _nodeAcceleration = new Dictionary <object, Vector>();
            _canvas.Children.Clear();
            _selectedNode = null;

            ResetSliders();
        }
Esempio n. 4
0
        void visualNode_NodeActivated(NetworkVisualNode node)
        {
            int childCount = 0;

            ICollection collection = node.ContentObject as ICollection;

            if (collection != null)
            {
                childCount = collection.Count;
            }

            if (childCount > 0)
            {
                // Expand the items, or collapse if it is already expanded
                node.IsExpanded = !node.IsExpanded;

                if (!node.IsExpanded)
                {
                    RemoveChildNodes(node.ContentObject);
                }

                object parent = _nodeParents[node.ContentObject];
                if (parent == null)
                {
                    parent = _rootNode;
                }

                SetLocations(parent, _nodeCentre[parent]);

                _settlingStart = DateTime.Now.Ticks;
                _updateTimer.Start();

                ScrollToPoint(_nodeCentre[node.ContentObject]);
            }
            else
            {
                // Has no children so activated it instead
                if (ItemActivated != null)
                {
                    ItemActivated(node.ContentObject);
                }
            }
        }
Esempio n. 5
0
        void visualNode_NodeSelected(NetworkVisualNode node)
        {
            if (_selectedNode != null)
            {
                _selectedNode.IsSelected = false;
            }

            _selectedNode = node;

            if (_selectedNode != null)
            {
                _selectedNode.IsSelected = true;
            }

            if (ItemSelected != null)
            {
                ItemSelected(node == null ? null : node.ContentObject);
            }
        }
Esempio n. 6
0
 void visualNode_NodeHovered(NetworkVisualNode node)
 {
     // When hovered move it to the front of all the other objects
     _canvas.Children.Remove(node);
     _canvas.Children.Add(node);
 }
        private static void OnSelectedBrushChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            NetworkVisualNode source = d as NetworkVisualNode;

            source.rectangleSelected.Fill = source.SelectedBrush;
        }