private void buttonView_Click(object sender, RoutedEventArgs e)
        {
            if (Tree.SelectedNode == null)
            {
                MessageBox.Show(Application.Current.MainWindow, "No entry selected", Utils.ProductName,
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var node = Tree.SelectedNode.Tag as StartupEntry;

            if (node != null && !node.IsLeaf)
            {
                return;
            }

            Main.Watcher.Event("Startup Manager", "View");

            if (node != null && node.RegKey == null)
            {
                // Folder

                try
                {
                    Process.Start(node.Parent.SectionName);
                }
                catch (Exception ex)
                {
                    string message = $"Unable to open startup folder.\nThe following error occurred: {ex.Message}";

                    MessageBox.Show(Application.Current.MainWindow, message, Utils.ProductName, MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
            else
            {
                // Registry key

                try
                {
                    if (node != null)
                    {
                        RegEditGo.GoTo(node.RegKey.Name, node.SectionName);
                    }
                }
                catch (Exception ex)
                {
                    string message =
                        $"Unable to open registry key in RegEdit.\nThe following error occurred: {ex.Message}";

                    MessageBox.Show(Application.Current.MainWindow, message, Utils.ProductName, MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
        }
Esempio n. 2
0
        private void toolStripButtonView_Click(object sender, EventArgs e)
        {
            if (this.treeViewAdv1.SelectedNodes.Count > 0)
            {
                if (!(this.treeViewAdv1.SelectedNode.Tag as StartupManagerNode).IsLeaf)
                {
                    return;
                }

                string strItem = (this.treeViewAdv1.SelectedNode.Tag as StartupManagerNode).Item;
                string strPath = (this.treeViewAdv1.SelectedNode.Parent.Tag as StartupManagerNode).Section;

                if (strPath.StartsWith("HKEY"))
                {
                    RegEditGo.GoTo(strPath, strItem);
                }
                else
                {
                    System.Diagnostics.Process.Start("explorer.exe", strPath);
                }
            }
        }
        private void contextMenuResults_Clicked(object sender, RoutedEventArgs e)
        {
            switch ((string)(sender as MenuItem)?.Header)
            {
            case "Select All":
            {
                SetCheckedItems(true);
                break;
            }

            case "Select None":
            {
                SetCheckedItems(false);
                break;
            }

            case "Invert Selection":
            {
                SetCheckedItems(null);
                break;
            }

            case "Exclude Selection":
            {
                if (Tree.SelectedNode == null)
                {
                    MessageBox.Show(Application.Current.MainWindow, "No registry key is selected", Utils.ProductName,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                var regKeyPath = (Tree.SelectedNode.Tag as BadRegistryKey)?.RegKeyPath;

                var excludeItem = new ExcludeItem {
                    RegistryPath = regKeyPath
                };
                if (!Settings.Default.ArrayExcludeList.Contains(excludeItem))
                {
                    Settings.Default.ArrayExcludeList.Add(excludeItem);
                    MessageBox.Show(Application.Current.MainWindow,
                                    $"Added registry key ({regKeyPath}) to the exclude list", Utils.ProductName,
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                    Tree.RemoveNode(Tree.SelectedNode);
                }
                else
                {
                    MessageBox.Show(Application.Current.MainWindow, $"Registry key ({regKeyPath}) already exists",
                                    Utils.ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
                }
                break;
            }

            case "View In RegEdit":
            {
                if (Tree.SelectedNode == null)
                {
                    MessageBox.Show(Application.Current.MainWindow, "No registry key is selected", Utils.ProductName,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                try
                {
                    var regKeyPath      = (Tree.SelectedNode.Tag as BadRegistryKey)?.RegKeyPath;
                    var regKeyValueName = (Tree.SelectedNode.Tag as BadRegistryKey)?.ValueName;

                    RegEditGo.GoTo(regKeyPath, regKeyValueName);
                }
                catch (Exception ex)
                {
                    string message =
                        $"Unable to open registry key in RegEdit.\nThe following error occurred: {ex.Message}";

                    MessageBox.Show(Application.Current.MainWindow, message, Utils.ProductName, MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }

                break;
            }
            }
        }