Ejemplo n.º 1
0
        /// <summary>
        /// The add to quick list.
        /// </summary>
        /// <param name="tagType">The tag type.</param>
        /// <param name="tagName">The tag name.</param>
        /// <remarks></remarks>
        private void addToQuickList(string tagType, string tagName)
        {
            // If we are using the registry, update it immediately
            if (Prefs.useRegistryEntries)
            {
                RegistryAccess.setValue(Microsoft.Win32.Registry.CurrentUser, RegistryAccess.RegPaths.Halo2 + @"Entity\ME\Tags\" + tagType + @"\", tagName, true);
            }

            bool isNewTagType = false;
            bool isNewTagPath = false;

            Prefs.QuickAccessTagType quickAccess = Prefs.GetQuickAccessTagType(tagType);
            if (quickAccess == null)
            {
                quickAccess = new Prefs.QuickAccessTagType();
                quickAccess.TagType = tagType;
                Prefs.QuickAccessTagTypes.Add(quickAccess);
                isNewTagType = true;
            }
            if (!quickAccess.TagPaths.Contains(tagName))
            {
                quickAccess.TagPaths.Add(tagName);
                isNewTagPath = true;
            }

            // already in the quick list
            if (!isNewTagType && !isNewTagPath) return;

            if (isNewTagType)
            {
                this.treeView1.Nodes.Add(tagType, tagType);
                this.treeView1.Nodes[this.treeView1.Nodes.IndexOfKey(tagType)].Nodes.Add(tagName);
            }
            else
            {
                int tagNum = this.treeView1.Nodes.IndexOfKey(tagType);
                bool found = false;
                for (int i = 0; i < this.treeView1.Nodes[tagNum].Nodes.Count; i++)
                {
                    if (this.treeView1.Nodes[tagNum].Nodes[i].Text == tagName)
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    this.treeView1.Nodes[tagNum].Nodes.Add(tagName);
                }
            }
        }