Example #1
0
        private void FileTreeItemCtxMenu_New_Folder_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new NewKeyDlg()
            {
                PromptText = "Please enter the folder name:"
            };

            if (dlg.ShowDialog() == true)
            {
                var context = FileTree.SelectedItem as FileTreeViewItem;
                if (context.Type == FileTreeViewItemType.FILE)
                {
                    context = context.Parent;
                }
                var path = System.IO.Path.Combine(context.Path, dlg.InputName.Text);
                CreateDirectory(path, (IntPtr)0);
                var newItem = new FileTreeViewItem(path)
                {
                    Parent = context
                };
                int index = 0;
                for (; index < context.Items.Count; index++)
                {
                    if (context.Items[index].Type == FileTreeViewItemType.FILE)
                    {
                        break;
                    }
                }
                context.Items.Insert(index, newItem);
            }
        }
Example #2
0
        private void FileTreeItemCtxMenu_New_File_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new NewKeyDlg()
            {
                PromptText = "Please enter the file name:"
            };

            if (dlg.ShowDialog() == true)
            {
                var context = FileTree.SelectedItem as FileTreeViewItem;
                if (context.Type == FileTreeViewItemType.FILE)
                {
                    context = context.Parent;
                }
                var path = System.IO.Path.Combine(context.Path, dlg.InputName.Text);
                if (File.Exists(path))
                {
                    MessageBox.Show("File already exists.");
                    return;
                }
                var hFile = CreateFile(path, 0, 0, (IntPtr)0, 1, 0x80, (IntPtr)0);
                CloseHandle(hFile);
                var newItem = new FileTreeViewItem(path)
                {
                    Parent = context
                };
                context.Items.Add(newItem);
            }
        }
Example #3
0
        private void RegTreeItemCtxMenu_New_Key_Click(object sender, RoutedEventArgs e)
        {
            var newKeyDlg = new NewKeyDlg();

            if (newKeyDlg.ShowDialog() == true)
            {
                var    context = RegTree.SelectedItem as RegTreeViewItem;
                IntPtr newKey;
                var    name = newKeyDlg.InputName.Text;
                regNewKey(context.hKey, new KeyName {
                    Name = name
                }, out newKey);
                var newItem = new RegTreeViewItem(RegTreeViewItemType.FOLDER, newKey)
                {
                    Parent = context, Title = name, hKeyOpened = true
                };
                context.Items.Add(newItem);
            }
        }