private Shortcut AddShortcut()
        {
            // Create new shortcut
            Shortcut shortcut = new Shortcut()
            {
                Name = nameTxtBox.Text,
                Keyword = keywordTxtBox.Text,
                URL = urlTxtBox.Text
            };

            // Save the shortcut to the registry
            if (shortcut.Save())
            {
                shortcuts.Add(shortcut);
                ResetFields();
            }
            else
            {
                MessageBox.Show("Error Creating Shortcut", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return shortcut;
        }
Example #2
0
        public static ObservableCollection<Shortcut> LoadShortcuts()
        {
            ObservableCollection<Shortcut> shortcuts = new ObservableCollection<Shortcut>();

            RegistryKey searchUrls = Registry.CurrentUser.OpenSubKey(SEARCH_URL_KEY);

            string[] subKeys = searchUrls.GetSubKeyNames();

            foreach (string key in subKeys)
            {
                RegistryKey regKey = Registry.CurrentUser.OpenSubKey(SEARCH_URL_KEY + "\\" + key);

                Shortcut shortcut = new Shortcut(
                    regKey.GetValue("ShortcutName") == null ? "" : regKey.GetValue("ShortcutName").ToString(),
                    key,
                    regKey.GetValue("").ToString());

                shortcuts.Add(shortcut);
            }

            return shortcuts;
        }