Пример #1
0
        public static bool IsExpandedNode(NodeViewData nvd)
        {
            Debug.Check(nvd != null && nvd.Node != null);
            if (nvd != null && nvd.Node != null)
            {
                bool defaultExpanded = !(nvd.Node is Nodes.ReferencedBehavior);

                if (defaultExpanded)
                {
                    //if there is a leaf node, collapse it
                    foreach (NodeViewData child in nvd.Children)
                    {
                        if (!child.CanBeExpanded())
                        {
                            //leaf node can't be expanded, there is a leaf node!
                            defaultExpanded = false;
                            break;
                        }
                    }
                }

                Nodes.Behavior behavior = nvd.Node.Behavior as Nodes.Behavior;

                if (behavior != null)
                {
                    behavior = behavior.GetTopBehavior();
                }

                string filename = (behavior != null) && !string.IsNullOrEmpty(behavior.Filename) ? behavior.RelativePath : string.Empty;

                if (!string.IsNullOrEmpty(filename) && _expandedNodeDict.ContainsKey(filename))
                {
                    Dictionary <string, ExpandedDatum> expandedNodes = _expandedNodeDict[filename];

                    string id = nvd.FullId;

                    if (!expandedNodes.ContainsKey(id))
                    {
                        return(defaultExpanded);
                    }

                    return(expandedNodes[id].isExpanded);
                }
                else
                {
                    //defaultExpanded = true;
                }

                return(defaultExpanded);
            }

            return(false);
        }
Пример #2
0
        public static bool IsExpandedConnector(NodeViewData nvd, string connector)
        {
            Debug.Check(nvd != null && nvd.Node != null);

            Nodes.Behavior behavior = nvd.Node.Behavior as Nodes.Behavior;

            if (behavior != null)
            {
                behavior = behavior.GetTopBehavior();
            }

            string filename = (behavior != null) && !string.IsNullOrEmpty(behavior.Filename) ? behavior.RelativePath : string.Empty;

            return(IsExpandedConnector(filename, nvd.Node.Id.ToString(), connector));
        }
Пример #3
0
        public static bool SetExpandedConnector(NodeViewData nvd, string connector, bool isConnectorExpanded)
        {
            Debug.Check(nvd != null && nvd.Node != null);

            Nodes.Behavior behavior = nvd.Node.Behavior as Nodes.Behavior;

            if (behavior != null)
            {
                behavior = behavior.GetTopBehavior();
            }

            if (behavior != null && !string.IsNullOrEmpty(behavior.Filename))
            {
                return(SetExpandedConnector(behavior.RelativePath, nvd.Node.Id.ToString(), connector, isConnectorExpanded));
            }

            return(false);
        }
Пример #4
0
        public static bool HasSetExpandedNodes(NodeViewData nvd)
        {
            Debug.Check(nvd != null && nvd.Node != null);

            Nodes.Behavior behavior = nvd.Node.Behavior as Nodes.Behavior;

            if (behavior != null)
            {
                behavior = behavior.GetTopBehavior();
            }

            string filename = (behavior != null) && !string.IsNullOrEmpty(behavior.Filename) ? behavior.RelativePath : string.Empty;

            if (!string.IsNullOrEmpty(filename) && _expandedNodeDict.ContainsKey(filename))
            {
                return(true);
            }

            return(false);
        }
Пример #5
0
        public static bool SetExpandedNode(NodeViewData nvd, bool isExpanded)
        {
            Debug.Check(nvd != null && nvd.Node != null);

            Nodes.Behavior b = nvd.Node.Behavior as Nodes.Behavior;

            if (b != null)
            {
                b = b.GetTopBehavior();

                Debug.Check(b != null);

                if (!string.IsNullOrEmpty(b.Filename))
                {
                    return(SetExpandedNode(b.RelativePath, nvd.FullId, isExpanded));
                }
            }

            return(false);
        }