コード例 #1
0
        /// <summary>
        /// Searches a list for NodeViewData for this node. Internal use only.
        /// </summary>
        /// <param name="list">The list which is searched for the NodeViewData.</param>
        /// <returns>Returns null if no fitting NodeViewData could be found.</returns>
        public override NodeViewData FindNodeViewData(List <NodeViewData> list)
        {
            foreach (NodeViewData nvd in list)
            {
                if (nvd.Node is ReferencedBehavior)
                {
                    ReferencedBehavior refnode = (ReferencedBehavior)nvd.Node;

                    // if both nodes reference the same behaviour we copy the view related data
                    if (_referencedBehavior != null && refnode.Reference == _referencedBehavior ||
                        ReferenceFilename == refnode.ReferenceFilename)
                    {
                        NodeViewDataReferencedBehavior nvdrb   = (NodeViewDataReferencedBehavior)nvd;
                        NodeViewDataReferencedBehavior newdata = (NodeViewDataReferencedBehavior)CreateNodeViewData(nvd.Parent, nvd.RootBehavior);

                        // copy data
                        newdata.IsExpanded = nvdrb.IsExpanded;

                        // return new data
                        return(newdata);
                    }
                }

                if (nvd.Node == this)
                {
                    return(nvd);
                }
            }

            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Is called when the node was double-clicked. Used for referenced behaviours.
        /// </summary>
        /// <param name="nvd">The view data of the node in the current view.</param>
        /// <param name="layoutChanged">Does the layout need to be recalculated?</param>
        /// <returns>Returns if the node handled the double click or not.</returns>
        public override bool OnDoubleClick(NodeViewData nvd, out bool layoutChanged)
        {
            NodeViewDataReferencedBehavior nvdrb = (NodeViewDataReferencedBehavior)nvd;

            nvdrb.IsExpanded = !nvdrb.IsExpanded;

            layoutChanged = true;
            return(true);
        }
コード例 #3
0
        public override void Draw(Graphics graphics, NodeViewData nvd, bool isCurrent, bool isSelected, bool isDragged, PointF graphMousePos)
        {
            Brush defBrush = _defaultStyle.Background;

            NodeViewDataReferencedBehavior nvdrb = (NodeViewDataReferencedBehavior)nvd;

            if (_genericChildren.IsReadOnly)
            {
                _defaultStyle.Background = _defaultBrushCollapsed;
            }

            base.Draw(graphics, nvd, isCurrent, isSelected, isDragged, graphMousePos);

            _defaultStyle.Background = defBrush;
        }
コード例 #4
0
        public override void PreLayoutUpdate(NodeViewData nvd)
        {
            // check if we must update the children
            NodeViewDataReferencedBehavior nvdrb = (NodeViewDataReferencedBehavior)nvd;

            if (nvdrb.RebuildChildren ||
                _referencedBehavior != null && !nvdrb.IsExpanded && nvdrb.ReferencedBehaviorLastModification != _referencedBehavior.ModificationID)
            {
                nvdrb.RebuildChildren = false;

                ExpandNode(nvdrb);

                if (_referencedBehavior != null)
                {
                    nvdrb.ReferencedBehaviorLastModification = _referencedBehavior.ModificationID;
                }
            }

            base.PreLayoutUpdate(nvd);
        }
コード例 #5
0
		/// <summary>
		/// Exapnds and collapses the referenced node.
		/// </summary>
		/// <param name="nvdrb">The view data for this node.</param>
		public void ExpandNode(NodeViewDataReferencedBehavior nvdrb)
		{
			// if the referenced behaviours was not yet loaded, try so
			if(_referencedBehavior ==null)
			{
				LoadReferencedBehavior();

				// if we could not load it, skip
				if(_referencedBehavior ==null)
					return;
			}

			// this code can be called without a change of IsExpanded so you cannot assume that the current children were from the other state
			if(nvdrb.IsExpanded)
			{
				// clear the generated sub-reference graph
				_genericChildrenLocal.ClearChildren();

				// remove any remaining subitems because of minimum count
				for(int i= 0; i <_subItems.Count; ++i)
				{
					SubItemConnector subconn= _subItems[i] as SubItemConnector;
					if(subconn !=null && subconn.Connector ==_genericChildren)
					{
						RemoveSubItem(subconn);
						--i;
					}
				}

				// assign the connector of the behaviour
				_genericChildren= _referencedBehavior.GenericChildren;
				_children.SetConnector(_genericChildren);

				// add all the subitems needed
				int count= Math.Max(_genericChildren.ChildCount, _genericChildren.MinCount);
				for(int i= 0; i <count; ++i)
				{
					Node child= i <_genericChildren.ChildCount ? _genericChildren.GetChild(i) : null;
					AddSubItem(new SubItemConnector(_genericChildren, child, i));
				}
			}
			else
			{
				// remove all subitems of the behaviour
				for(int i= 0; i <_subItems.Count; ++i)
				{
					SubItemConnector subconn= _subItems[i] as SubItemConnector;
					if(subconn !=null && subconn.Connector ==_genericChildren)
					{
						RemoveSubItem(subconn);
						--i;
					}
				}

				// assign the connector for the sub-reference graph
				_genericChildren= _genericChildrenLocal;
				_children.SetConnector(_genericChildren);

				// make the connector writable to edit it
				_genericChildren.IsReadOnly= false;

				// add all the subitems needed
				int count= Math.Max(_genericChildren.ChildCount, _genericChildren.MinCount);
				for(int i= 0; i <count; ++i)
				{
					Node child= i <_genericChildren.ChildCount ? _genericChildren.GetChild(i) : null;
					AddSubItem(new SubItemConnector(_genericChildren, child, i));
				}

				// clear the generated sub-reference graph
				_genericChildren.ClearChildren();

				// generate the dummy nodes for the sub-referenced behaviours
				foreach(Node child in ((Node)_referencedBehavior).Children)
					GenerateReferencedBehaviorsTree(nvdrb.RootBehavior, this, child);

				// make the connector read-only so the user cannot modify it
				_genericChildren.IsReadOnly= true;
			}
		}
コード例 #6
0
        /// <summary>
        /// Exapnds and collapses the referenced node.
        /// </summary>
        /// <param name="nvdrb">The view data for this node.</param>
        public void ExpandNode(NodeViewDataReferencedBehavior nvdrb)
        {
            // if the referenced behaviours was not yet loaded, try so
            if (_referencedBehavior == null)
            {
                LoadReferencedBehavior();

                // if we could not load it, skip
                if (_referencedBehavior == null)
                {
                    return;
                }
            }

            // this code can be called without a change of IsExpanded so you cannot assume that the current children were from the other state
            if (nvdrb.IsExpanded)
            {
                // clear the generated sub-reference graph
                _genericChildrenLocal.ClearChildren();

                // remove any remaining subitems because of minimum count
                for (int i = 0; i < _subItems.Count; ++i)
                {
                    SubItemConnector subconn = _subItems[i] as SubItemConnector;
                    if (subconn != null && subconn.Connector == _genericChildren)
                    {
                        RemoveSubItem(subconn);
                        --i;
                    }
                }

                // assign the connector of the behaviour
                _genericChildren = _referencedBehavior.GenericChildren;
                _children.SetConnector(_genericChildren);

                // add all the subitems needed
                int count = Math.Max(_genericChildren.ChildCount, _genericChildren.MinCount);
                for (int i = 0; i < count; ++i)
                {
                    Node child = i < _genericChildren.ChildCount ? _genericChildren.GetChild(i) : null;
                    AddSubItem(new SubItemConnector(_genericChildren, child, i));
                }
            }
            else
            {
                // remove all subitems of the behaviour
                for (int i = 0; i < _subItems.Count; ++i)
                {
                    SubItemConnector subconn = _subItems[i] as SubItemConnector;
                    if (subconn != null && subconn.Connector == _genericChildren)
                    {
                        RemoveSubItem(subconn);
                        --i;
                    }
                }

                // assign the connector for the sub-reference graph
                _genericChildren = _genericChildrenLocal;
                _children.SetConnector(_genericChildren);

                // make the connector writable to edit it
                _genericChildren.IsReadOnly = false;

                // add all the subitems needed
                int count = Math.Max(_genericChildren.ChildCount, _genericChildren.MinCount);
                for (int i = 0; i < count; ++i)
                {
                    Node child = i < _genericChildren.ChildCount ? _genericChildren.GetChild(i) : null;
                    AddSubItem(new SubItemConnector(_genericChildren, child, i));
                }

                // clear the generated sub-reference graph
                _genericChildren.ClearChildren();

                // generate the dummy nodes for the sub-referenced behaviours
                foreach (Node child in ((Node)_referencedBehavior).Children)
                {
                    GenerateReferencedBehaviorsTree(nvdrb.RootBehavior, this, child);
                }

                // make the connector read-only so the user cannot modify it
                _genericChildren.IsReadOnly = true;
            }
        }