Beispiel #1
0
        private bool _active = false;                   // should be drawed ?

        #endregion

        #region Constructor

        /// <summary> Constructor.
        /// </summary>
        /// <param name="parentNode">The father of this node.</param>
        /// <param name="nodeModel">The encapsulated <see cref="NodeModel"/>.</param>
        /// <param name="renderer">The drawing model.</param>
        public NodeView(CompositeNodeView parentNode, NodeModel nodeModel, Renderer renderer)
        {
            _parentNode = parentNode;
            _nodeModel  = nodeModel;
            _renderer   = renderer;

            this.Opacity = 0.9;
            this.Child   = new NodeLabel(this);

            _ze                = new EuclidianVector(nodeModel.OriginalCoordinates);
            _oldZe             = new EuclidianVector(_ze);
            _screenCoordinates = new ScreenVector();

            // store this object in INode -> NodeView mapping
            renderer.MapNode(nodeModel.Node, this);

            renderer.Children.Add(this);
        }
        private Dictionary <NodeView, Geodesic> _geodesics = null; // geodesics linking the children

        #endregion

        #region Constructor

        /// <summary> Constructor.
        /// </summary>
        /// <param name="father">The father of this node.</param>
        /// <param name="node">The encapsulated <see cref="NodeModel"/>.</param>
        /// <param name="renderer">The drawing model.</param>
        public CompositeNodeView(CompositeNodeView father, CompositeNodeModel node, Renderer renderer)
            : base(father, node, renderer)
        {
            _node       = node;
            _childNodes = new List <NodeView>();
            _geodesics  = new Dictionary <NodeView, Geodesic>();

            NodeView __child   = null;
            NodeView __brother = null;
            bool     __first   = true;
            bool     __second  = false;

            foreach (NodeModel childNode in _node.Children)
            {
                if (childNode.IsLeaf)
                {
                    __child = new NodeView(this, childNode, renderer);
                }
                else
                {
                    __child = new CompositeNodeView(this, (CompositeNodeModel)childNode, renderer);
                }
                this.AddChild(__child);
                if (__first)
                {
                    __brother = __child;
                    __first   = false;
                    __second  = true;
                }
                else if (__second)
                {
                    __child.Brother   = __brother;
                    __brother.Brother = __child;
                    __brother         = __child;
                    __second          = false;
                }
                else
                {
                    __child.Brother = __brother;
                    __brother       = __child;
                }
            }
        }