Example #1
0
        private void OnApply()
        {
            try
            {
                string newRedirectPath = RedirectPathTextBox.Text;
                if (newRedirectPath == null)
                {
                    newRedirectPath = "";
                }
                newRedirectPath = newRedirectPath.Trim();

                if (RedirectPath != null && !RedirectPath.Equals(newRedirectPath))
                {
                    RedirectPath = newRedirectPath;

                    if (ConfigStorage != null)
                    {
                        ConfigStorage.SetValue(Config.ConfigRedirectRegistryEntryKey, newRedirectPath);
                    }

                    RegisterHelper.SetRedirectPath(newRedirectPath, false);
                    if (ConfigStorage != null)
                    {
                        bool registryEntryEnabled = ConfigStorage.GetBool(Config.ConfigEnableRegistryEntryKey, Config.ConfigDefaultEnableRegistryEntryValue);
                        if (registryEntryEnabled)
                        {
                            RegisterHelper.PutEntry();
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
Example #2
0
        private static void InitializeRegistryEntry()
        {
            //Initialize shortcut helper
            ShortcutHelper shortcut = new ShortcutHelper();

            RegisterHelper.shortcut = shortcut;

            //Initialize registry entry if needed
            try
            {
                ConfigStorage configStorage = ConfigStorage.Global;
                if (configStorage == null)
                {
                    return;
                }

                string redirectPath = configStorage.GetValue(Config.ConfigRedirectRegistryEntryKey, Config.ConfigDefaultRedirectRegistryEntryValue);
                if (redirectPath != null)
                {
                    redirectPath = redirectPath.Trim();
                }
                if (redirectPath != null && redirectPath.Length > 0)
                {
                    string fullRedirectPath = FileHelper.GetByRelativePath(redirectPath);
                    if (fullRedirectPath != null)
                    {
                        RegisterHelper.SetRedirectPath(fullRedirectPath, false);
                    }
                }

                bool setRegistryEntry = configStorage.GetBool(Config.ConfigEnableRegistryEntryKey, Config.ConfigDefaultEnableRegistryEntryValue);

                if (setRegistryEntry)
                {
                    bool hasEntry = RegisterHelper.HasEntryWithCurrentPath();
                    if (!hasEntry)
                    {
                        RegisterHelper.PutEntry();
                    }
                }

                if (!setRegistryEntry)
                {
                    bool hasEntry = RegisterHelper.HasEntry();
                    if (hasEntry)
                    {
                        RegisterHelper.RemoveEntry();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }