コード例 #1
0
        private ListViewItem AddValueToList(Microsoft.Win32.RegistryKey key, RegistryExplorer.Registry.RegValue value)
        {
            ListViewItem item = lstValues.Items.Add(value.Name);

            item.ImageKey = GetValueTypeIcon(value.Kind);
            item.Name     = value.Name;
            item.Tag      = key;

            item.SubItems.Add(RegistryExplorer.Registry.Extensions.ToDataType(value.Kind));
            ListViewItem.ListViewSubItem subItem = item.SubItems.Add(value.ToString());
            subItem.Tag = value;
            return(item);
        }
コード例 #2
0
        public DWordEditor(RegistryExplorer.Registry.RegValue value) : base(value)
        {
            InitializeComponent();
            string data;

            if (value.Kind == Microsoft.Win32.RegistryValueKind.DWord)
            {
                data = ((int)value.Data).ToString("x");
            }
            else
            {
                data = ((long)value.Data).ToString("x");
            }
        }
コード例 #3
0
        private void LoadValues(Microsoft.Win32.RegistryKey key)
        {
            toolStripStatusLabel1.Text = key.Name;
            lstValues.Items.Clear();
            System.Collections.Generic.List <RegistryExplorer.Registry.RegValue> values =
                RegistryExplorer.Registry.RegistryExplorerr.GetValues(key);

            if (values != null)
            {
                if (values.Count == 0)
                {
                    AddValueToList(key, CreateDefaultValue());
                }
                else
                {
                    lstValues.SuspendLayout();

                    RegistryExplorer.Registry.RegValue defaultValue = CreateDefaultValue();


                    // if (values.SingleOrDefault((val) => val.Name == defaultValue.Name) == null)
                    //      AddValueToList(key, defaultValue);


                    bool hasDefaultValue = false;
                    foreach (RegistryExplorer.Registry.RegValue val in values)
                    {
                        if (val.Name == defaultValue.Name)
                        {
                            hasDefaultValue = true;
                            break;
                        }
                    }

                    if (!hasDefaultValue)
                    {
                        AddValueToList(key, defaultValue);
                    }

                    foreach (RegistryExplorer.Registry.RegValue value in values)
                    {
                        AddValueToList(key, value);
                    }

                    lstValues.ResumeLayout();
                }
            }
        }
コード例 #4
0
        private void OnValueEditAction()
        {
            if (lstValues.SelectedItems.Count == 1)
            {
                RegistryExplorer.Registry.RegValue value = (RegistryExplorer.Registry.RegValue)
                                                           lstValues.SelectedItems[0].SubItems[2].Tag;

                if (value.ParentKey != null)
                {
                    RegistryExplorer.Editors.ValueEditor editor = null;

                    switch (value.Kind)
                    {
                    case Microsoft.Win32.RegistryValueKind.Binary:
                        editor = new RegistryExplorer.Editors.BinaryEditor(value);
                        break;

                    case Microsoft.Win32.RegistryValueKind.MultiString:
                        editor = new RegistryExplorer.Editors.MultiStringEditor(value);
                        break;

                    case Microsoft.Win32.RegistryValueKind.DWord:
                    case Microsoft.Win32.RegistryValueKind.QWord:
                        editor = new RegistryExplorer.Editors.DWordEditor(value);
                        break;

                    case Microsoft.Win32.RegistryValueKind.String:
                    case Microsoft.Win32.RegistryValueKind.ExpandString:
                        editor = new RegistryExplorer.Editors.StringEditor(value);
                        break;

                    case Microsoft.Win32.RegistryValueKind.Unknown:
                    default:
                        break;
                    }

                    if (editor != null)
                    {
                        if (editor.ShowDialog(this) == DialogResult.OK)
                        {
                            RefreshValues();
                        }
                    }
                }
            }
        }
コード例 #5
0
        private void lstValues_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            lstValues.LabelEdit = false;
            ListViewItem item    = lstValues.Items[e.Item];
            string       valName = e.Label == null ? item.Text : e.Label;

            try
            {
                Microsoft.Win32.RegistryKey        readOnlyKey = (Microsoft.Win32.RegistryKey)item.Tag;
                Microsoft.Win32.RegistryKey        key         = RegistryExplorer.Registry.RegKey.Parse(readOnlyKey.Name, true).Key;
                RegistryExplorer.Registry.RegValue value       = (RegistryExplorer.Registry.RegValue)item.SubItems[2].Tag;
                key.SetValue(valName, value.Data, value.Kind);
                item.Name            = valName;
                item.SubItems[2].Tag = new RegistryExplorer.Registry.RegValue(readOnlyKey, valName);
            }
            catch
            {
                item.Remove();
                UIUtility.DisplayError(this, RegistryExplorer.Properties.Resources.Error_CreateValueFail);
            }
        }
コード例 #6
0
 public ValueEditor(RegistryExplorer.Registry.RegValue value) : this()
 {
     Value            = value;
     txtName.Text     = value.Name;
     txtName.Modified = false;
 }
コード例 #7
0
 public StringEditor(RegistryExplorer.Registry.RegValue value) : base(value)
 {
     InitializeComponent();
     txtData.Text = value.Data.ToString();
 }
コード例 #8
0
 public MultiStringEditor(RegistryExplorer.Registry.RegValue value)
     : base(value)
 {
     InitializeComponent();
     txtData.Text = string.Join("\r\n", ((string[])value.Data));
 }
コード例 #9
0
 public BinaryEditor(RegistryExplorer.Registry.RegValue value) : base(value)
 {
     InitializeComponent();
     byteProvider         = new DynamicByteProvider((byte[])value.Data);
     txtData.ByteProvider = byteProvider;
 }