Exemplo n.º 1
0
 private void MergeFullDetails(IEnumerable <TreeItem> source)
 {
     foreach (var tiSource in source)
     {
         if (((PropType)tiSource.Item) == PropType.Group)
         {
             var tiTarget = FullDetails.Where(ti => ti.Name == tiSource.Name).FirstOrDefault();
             if (tiTarget == null)
             {
                 FullDetails.Add(tiSource.Clone());
             }
             else
             {
                 foreach (var ti in tiSource.Children)
                 {
                     string s = ModuloAsterisk(ti.Name);
                     if (tiTarget.Children.FirstOrDefault(t => ModuloAsterisk(t.Name) == s) == null)
                     {
                         tiTarget.AddChild(ti.Clone());
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        private void ParseFullDetailsString(string registryEntry)
        {
            FullDetails.Clear();

            Dictionary <string, TreeItem> groups = new Dictionary <string, TreeItem>();

            if (registryEntry.StartsWith("prop:"))
            {
                registryEntry = registryEntry.Remove(0, 5);
            }

            string[] props = registryEntry.Split(';');
            TreeItem curr  = null;

            foreach (string prop in props)
            {
                string[] parts = prop.Split('.');

                if (parts.Length == 3 && parts[0] == "System" && parts[1] == "PropGroup")
                {
                    // put following entries under the specified group
                    string group = parts[2];
                    if (!groups.TryGetValue(group, out curr))
                    {
                        // Mark the TreeItem as a group property
                        curr = new TreeItem(group, PropType.Group);
                        groups.Add(group, curr);
                    }
                }
                else if (curr != null)
                {
                    // Mark the TreeItem as a normal property
                    curr.AddChild(new TreeItem(prop, PropType.Normal));
                }
            }

            // Add the tree item roots to the displayable collection
            foreach (var ti in groups.Values)
            {
                FullDetails.Add(ti);
            }
        }
Exemplo n.º 3
0
        private void InsertGroup(TreeItem toInsert, TreeItem target, bool before)
        {
            if (target == null)
            {
                FullDetails.Add(toInsert);
            }
            else
            {
                int index;

                if ((PropType)target.Item == PropType.Group)
                {
                    index = FullDetails.IndexOf(target) + (before ? 0 : 1);
                }
                else
                {
                    index = FullDetails.IndexOf(target.Parent) + 1;
                }

                FullDetails.Insert(index, toInsert);
            }
        }