Ejemplo n.º 1
0
        /// <summary>
        /// Creates a Facet object from a collection of tree nodes
        /// </summary>
        /// <param name="nodes">The TreeNodeCollection used as source for this Facet object</param>
        /// <param name="name">The map file index corresponding to this facet</param>
        /// <returns>A Facet object representing the nodes collection</returns>
        public static Facet FromTreeNodes( TreeNodeCollection nodes, byte name )
        {
            Facet facet = new Facet();

            facet.MapValue = name;

            foreach ( TreeNode CatNode in nodes )
            {
                GenericNode Category = new GenericNode( CatNode.Text );

                foreach ( TreeNode SubNode in CatNode.Nodes )
                {
                    GenericNode Subsection = new GenericNode( SubNode.Text );
                    // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
                    Subsection.Elements = (List<object>)SubNode.Tag;
                    // Issue 10 - End

                    Category.Elements.Add( Subsection );
                }

                facet.m_Nodes.Add( Category );
            }

            return facet;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a new location to this facet
        /// </summary>
        /// <param name="loc">The location that should be added</param>
        /// <param name="category">The category name for the new location</param>
        /// <param name="subsection">The subsection name for the new location</param>
        public void AddLocation( Location loc, string category, string subsection )
        {
            GenericNode catNode = null;

            foreach ( GenericNode cat in m_Nodes )
            {
                if ( cat.Name.ToLower() == category.ToLower() )
                {
                    catNode = cat;
                    break;
                }
            }

            if ( catNode == null )
            {
                catNode = new GenericNode( category );
                m_Nodes.Add( catNode );
            }

            GenericNode subNode = null;

            foreach( GenericNode sub in catNode.Elements )
            {
                if ( sub.Name.ToLower() == subsection.ToLower() )
                {
                    subNode = sub;
                    break;
                }
            }

            if ( subNode == null )
            {
                subNode = new GenericNode( subsection );
                catNode.Elements.Add( subNode );
            }

            subNode.Elements.Add( loc );
        }