Esempio n. 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="item"></param>
        /// <param name="name"></param>
        public NameSpaceTreeNode(DataDictionary.Types.NameSpace item)
            : base(item, null, false)
        {
            subNameSpaces = new NameSpaceSubNameSpacesTreeNode(Item);
            ranges        = new RangesTreeNode(Item);
            enumerations  = new EnumerationsTreeNode(Item);
            structures    = new StructuresTreeNode(Item);
            collections   = new CollectionsTreeNode(Item);
            stateMachines = new StateMachinesTreeNode(Item);
            functions     = new FunctionsTreeNode(Item);
            procedures    = new NameSpaceProceduresTreeNode(Item);
            variables     = new NameSpaceVariablesTreeNode(Item);
            rules         = new NameSpaceRulesTreeNode(Item);

            Nodes.Add(subNameSpaces);
            Nodes.Add(ranges);
            Nodes.Add(enumerations);
            Nodes.Add(structures);
            Nodes.Add(collections);
            Nodes.Add(stateMachines);
            Nodes.Add(functions);
            Nodes.Add(procedures);
            Nodes.Add(variables);
            Nodes.Add(rules);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the stat message according to the list of namespaces provided
        /// </summary>
        /// <param name="paragraphs"></param>
        /// <returns></returns>
        public static string CreateStatMessage(List <DataDictionary.Types.NameSpace> namespaces, bool isFolder)
        {
            string result = "";

            int ranges       = 0;
            int enumerations = 0;
            int structures   = 0;
            int collections  = 0;
            int functions    = 0;
            int procedures   = 0;
            int variables    = 0;
            int rules        = 0;

            List <DataDictionary.Types.NameSpace> allNamespaces = new List <DataDictionary.Types.NameSpace>();

            foreach (DataDictionary.Types.NameSpace aNamespace in namespaces)
            {
                allNamespaces.AddRange(collectNamespaces(aNamespace));
            }

            foreach (DataDictionary.Types.NameSpace aNamespace in allNamespaces)
            {
                ranges       += aNamespace.Ranges.Count;
                enumerations += aNamespace.Enumerations.Count;
                structures   += aNamespace.Structures.Count;
                collections  += aNamespace.Collections.Count;
                functions    += aNamespace.Functions.Count;
                procedures   += aNamespace.Procedures.Count;
                variables    += aNamespace.Variables.Count;
                rules        += aNamespace.Rules.Count;
            }

            if (!isFolder)
            {
                result += "The namespace " + namespaces[0].Name + " contains ";
            }
            else
            {
                result += namespaces.Count + (namespaces.Count > 1 ? " namespaces " : " namespace ") + "selected, containing ";
            }

            result += (allNamespaces.Count - namespaces.Count) + (allNamespaces.Count - namespaces.Count > 1 ? " sub-namespaces, " : " sub-namespace, ") +
                      ranges + (ranges > 1 ? " ranges, " : " range, ") +
                      enumerations + (enumerations > 1 ? " enumerations, " : " enumeration, ") +
                      structures + (structures > 1 ? " structures, " : " structure, ") +
                      collections + (collections > 1 ? " collections, " : " collection, ") +
                      functions + (functions > 1 ? " functions, " : " function, ") +
                      procedures + (procedures > 1 ? " procedures, " : " procedure, ") +
                      variables + (variables > 1 ? " variables and " : " variable and ") +
                      rules + (rules > 1 ? " rules." : " rule.");

            return(result);
        }
        /// <summary>
        ///     Accepts a drop event
        /// </summary>
        /// <param name="sourceNode"></param>
        public override void AcceptDrop(BaseTreeNode sourceNode)
        {
            base.AcceptDrop(sourceNode);

            if (_isDirectory)
            {
                BaseTreeNode parent = Parent as BaseTreeNode;
                if (parent != null)
                {
                    parent.AcceptDrop(sourceNode);
                }
            }
            else
            {
                if (sourceNode is VariableTreeNode)
                {
                    NameSpaceVariablesTreeNode node = SubNode <NameSpaceVariablesTreeNode>();
                    if (node != null)
                    {
                        node.AcceptDrop(sourceNode);
                    }
                }
                else if (sourceNode is ProcedureTreeNode)
                {
                    NameSpaceProceduresTreeNode node = SubNode <NameSpaceProceduresTreeNode>();
                    if (node != null)
                    {
                        node.AcceptDrop(sourceNode);
                    }
                }
                else if (sourceNode is RuleTreeNode)
                {
                    NameSpaceRulesTreeNode node = SubNode <NameSpaceRulesTreeNode>();
                    if (node != null)
                    {
                        node.AcceptDrop(sourceNode);
                    }
                }
                else if (sourceNode is StructureTreeNode)
                {
                    StructuresTreeNode node = SubNode <StructuresTreeNode>();
                    if (node != null)
                    {
                        node.AcceptDrop(sourceNode);
                    }
                }
                else if (sourceNode is FunctionTreeNode)
                {
                    FunctionsTreeNode node = SubNode <FunctionsTreeNode>();
                    if (node != null)
                    {
                        node.AcceptDrop(sourceNode);
                    }
                }
                else if (sourceNode is InterfaceTreeNode)
                {
                    InterfacesTreeNode node = SubNode <InterfacesTreeNode>();
                    if (node != null)
                    {
                        node.AcceptDrop(sourceNode);
                    }
                }
                else if (sourceNode is NameSpaceTreeNode)
                {
                    DialogResult result = MessageBox.Show(
                        Resources.NameSpaceTreeNode_AcceptDrop_This_will_move_the_namespace__are_you_sure___,
                        Resources.NameSpaceTreeNode_AcceptDrop_Confirm_moving_the_namespace,
                        MessageBoxButtons.OKCancel,
                        MessageBoxIcon.Question);
                    if (result == DialogResult.OK)
                    {
                        NameSpaceTreeNode nameSpaceTreeNode = sourceNode as NameSpaceTreeNode;
                        NameSpace         nameSpace         = nameSpaceTreeNode.Item;

                        nameSpaceTreeNode.Delete();
                        Item.appendNameSpaces(nameSpace);
                    }
                }
            }
        }