Beispiel #1
0
        private async Task UpdateDetailsGridAsync(RegistryTreeItem item)
        {
            values.Items.Clear();

            // Wait a bit in case the user moved to a different tree node quickly
            await Task.Delay(200);

            // Another tree node was selected in the meantime.
            if (item != tree.SelectedItem)
            {
                return;
            }

            if (item.Key.ValueCount > 0)
            {
                IOrderedEnumerable <string> names = item.Key.GetValueNames().OrderBy(x => x);

                using (Dispatcher.DisableProcessing())
                {
                    foreach (string name in names)
                    {
                        RegistryValueKind type  = item.Key.GetValueKind(name);
                        object            value = item.Key.GetValue(name);

                        if (type == RegistryValueKind.Binary && value is byte[] bytes)
                        {
                            value = BitConverter.ToString(bytes).Replace("-", " ");
                        }
                        else if (type == RegistryValueKind.DWord && value is int dword)
                        {
                            value = string.Format("0x{0:X}", dword) + $" ({dword})";
                        }
                        else if (type == RegistryValueKind.QWord && value is long qword)
                        {
                            value = string.Format("0x{0:X}", qword).ToLowerInvariant() + $" ({qword})";
                        }

                        string displayName = string.IsNullOrEmpty(name) ? "(Default)" : name;

                        values.Items.Add(new { Name = displayName, Type = type, Value = value });
                    }
                }
            }
            else
            {
                values.Items.Add(_defaultValue);
            }
        }
        private void PopulateNode(RegistryTreeItem item)
        {
            if (item.HasItems || item.Key.SubKeyCount == 0)
            {
                return;
            }

            using (Dispatcher.DisableProcessing())
            {
                foreach (string name in item.Key.GetSubKeyNames())
                {
                    RegistryKey subkey = item.Key.OpenSubKey(name, false);
                    var         child  = new RegistryTreeItem(subkey);

                    item.Items.Add(child);
                }
            }
        }
Beispiel #3
0
        private void OnLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            tree.Items.Clear();

            foreach (RegistryKey key in _keys)
            {
                var item = new RegistryTreeItem(key, true);

                tree.Items.Add(item);

                if (tree.SelectedItem == null)
                {
                    item.IsSelected = true;
                }
            }

            Focus();
        }
 public void Refresh(RegistryTreeItem item)
 {
     Items.Clear();
     PopulateNode(item);
     item.IsExpanded = true;
 }
Beispiel #5
0
 private void OnItemSelected(object sender, RegistryTreeItem e)
 {
     UpdateDetailsGridAsync(e).ConfigureAwait(false);
 }