Esempio n. 1
0
        private void AddNodes(IEnumerable <INode> nodes)
        {
            if (nodes == null)
            {
                return;
            }

            foreach (INode node in nodes)
            {
                if (node != null)
                {
                    _algorithm.AddNode(node);
                    var item = new NetworkViewNodeItem
                    {
                        Content = node
                    };
                    var binding = new Binding("NodeTemplate")
                    {
                        Source = this
                    };
                    BindingOperations.SetBinding(item, ContentPresenter.ContentTemplateProperty, binding);
                    SetZIndex(item, NodeZIndex);

                    _nodesToItems.Add(node, item);
                    Children.Add(item);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Is called when the left mouse button is released.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            if (_mouseDraggingNode != null)
            {
                _algorithm.Unfreeze(_mouseDraggingNode.Content as INode);
                _mouseDraggingNode = null;
                ReleaseMouseCapture();
            }

            base.OnMouseLeftButtonUp(e);
        }
Esempio n. 3
0
        /// <summary>
        ///     Is called when the left mouse button is pressed.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            HitTestResult result = VisualTreeHelper.HitTest(this, e.GetPosition(this));
            var           node   = result.VisualHit.FindFirstAncestorOfType <NetworkViewNodeItem>();

            if (node != null)
            {
                if (CaptureMouse())
                {
                    _mouseDraggingNode = node;
                    _algorithm.Freeze(node.Content as INode);
                    e.Handled = true;
                }
            }
            else
            {
                base.OnMouseLeftButtonDown(e);
            }
        }