Ejemplo n.º 1
0
        private void u_removePluginButton_Click(object sender, EventArgs e)
        {
            PreferenceConnector callback = PreferenceConnector.SharedInstance;

            if (callback == null)
            {
                // Show alert.
                return;
            }

            int    index  = this.u_pluginComboBox.SelectedIndex;
            string locale = CultureInfo.CurrentUICulture.Name;

            if (index > -1 && index < callback.numberOfUnloadableSignedModules())
            {
                string name    = callback.localizedNameOfUnloadableSignedModulesAtIndex(index);
                string message = "Do you really want to unload \"" + name + "\"?";
                if (locale.Equals("zh-TW"))
                {
                    message = "\u60a8\u78ba\u5b9a\u8981\u89e3\u9664\u5b89\u88dd\u300c" + name + "\u300d\u55ce\uff1f";
                }
                else if (locale.Equals("zh-CN"))
                {
                    message = "\u60a8\u786e\u5b9a\u8981\u89e3\u9664\u5b89\u88c5\u201c" + name + "\u201d\u5417\uff1f";
                }

                DialogResult dialogResult = MessageBox.Show(message, string.Empty, MessageBoxButtons.YesNo);
                if (dialogResult.Equals(DialogResult.Yes))
                {
                    bool result = callback.unloadSignedModuleAtIndex(index);
                    if (result)
                    {
                        string title = "Successfully unloaded the plugin!";
                        if (locale.Equals("zh-TW"))
                        {
                            title = "\u6210\u529f\u89e3\u9664\u5b89\u88dd";
                        }
                        else if (locale.Equals("zh-CN"))
                        {
                            title = "\u6210\u529f\u89e3\u9664\u5b89\u88c5";
                        }

                        message = "Since your software is changed, we have to quit the preference program";
                        if (locale.Equals("zh-TW"))
                        {
                            message = "\u56e0\u70ba\u60a8\u7684\u8f38\u5165\u6cd5\u7cfb\u7d71\u8a2d\u5b9a\u5df2\u7d93\u6539\u8b8a\uff0c\u6211\u5011\u73fe\u5728\u5fc5\u9808\u95dc\u9589\u504f\u597d\u8a2d\u5b9a\u5de5\u5177\u3002";
                        }
                        else if (locale.Equals("zh-CN"))
                        {
                            message = "\u56e0\u4e3a\u60a8\u7684\u8f93\u5165\u6cd5\u7cfb\u7edf\u8bbe\u5b9a\u5df2\u7ecf\u6539\u53d8\uff0c\u6211\u4eec\u73b0\u5728\u5fc5\u987b\u5173\u95ed\u504f\u597d\u8bbe\u5b9a\u5de5\u5177\u3002";
                        }

                        MessageBox.Show(message, title);
                        Application.Exit();
                    }
                    else
                    {
                        string title = "Faild to unload this plugin!";
                        if (locale.Equals("zh-TW"))
                        {
                            title = "\u7121\u6cd5\u89e3\u9664\u5b89\u88dd\u9019\u500b\u5916\u639b\u7a0b\u5f0f\uff01";
                        }
                        else if (locale.Equals("zh-CN"))
                        {
                            title = "\u65e0\u6cd5\u89e3\u9664\u5b89\u88c5\u8fd9\u4e2a\u63d2\u4ef6\uff01";
                        }

                        message = "You may need System Administrator permission.";
                        if (locale.Equals("zh-TW"))
                        {
                            message = "\u5982\u679c\u5728 Windows Vista \u4e0b\uff0c\u60a8\u9700\u8981\u7cfb\u7d71\u7ba1\u7406\u54e1\u6b0a\u9650\uff0c\u624d\u80fd\u522a\u9664\u5916\u639b\u7a0b\u5f0f\u3002";
                        }
                        else if (locale.Equals("zh-CN"))
                        {
                            message = "\u5982\u679c\u5728 Windows Vista \u4e0b\uff0c\u60a8\u9700\u8981\u7cfb\u7edf\u7ba1\u7406\u5458\u6743\u9650\uff0c\u624d\u80fd\u5220\u9664\u63d2\u4ef6\u3002";
                        }

                        MessageBox.Show(message, title);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize the state of the user interface by the
        /// saved preference.
        /// </summary>
        private void InitUI()
        {
            string buffer;

            this.m_generalDictionary.TryGetValue("ShouldUseTransparentStatusBar", out buffer);
            if (buffer == "true")
            {
                this.u_transparentStatusBarCheckBox.Checked = true;
            }
            else
            {
                this.u_transparentStatusBarCheckBox.Checked = false;
            }

            this.m_generalDictionary.TryGetValue("ShouldUseSystemTray", out buffer);
            if (buffer == "true")
            {
                this.u_minimizeToSystemTrayCheckBox.Checked = true;
            }
            else
            {
                this.u_minimizeToSystemTrayCheckBox.Checked = false;
            }

            this.m_generalDictionary.TryGetValue("KeyboardFormShouldFollowCursor", out buffer);
            if (buffer == "true")
            {
                this.u_chkKeyboardFormShouldFollowCursor.Checked = true;
            }
            else
            {
                this.u_chkKeyboardFormShouldFollowCursor.Checked = false;
            }

            this.m_generalDictionary.TryGetValue("HighlightColor", out buffer);
            if (buffer == "Green")
            {
                this.u_highlightColorComboBox.SelectedIndex = 1;
            }
            else if (buffer == "Yellow")
            {
                this.u_highlightColorComboBox.SelectedIndex = 2;
            }
            else if (buffer == "Red")
            {
                this.u_highlightColorComboBox.SelectedIndex = 3;
            }
            else if (buffer.StartsWith("Color "))
            {
                this.u_highlightColorComboBox.SelectedIndex = 4;
            }
            else
            {
                this.u_highlightColorComboBox.SelectedIndex = 0;
            }

            this.m_generalDictionary.TryGetValue("BackgroundColor", out buffer);
            if (buffer == "White")
            {
                this.u_backgroundColorComboBox.SelectedIndex = 1;
            }
            else if (buffer.StartsWith("Color "))
            {
                this.u_backgroundColorComboBox.SelectedIndex = 2;
            }
            else
            {
                this.u_backgroundColorComboBox.SelectedIndex = 0;
            }

            this.m_generalDictionary.TryGetValue("TextColor", out buffer);
            if (buffer == "Black")
            {
                this.u_textColorComboBox.SelectedIndex = 1;
            }
            else if (buffer.StartsWith("Color "))
            {
                this.u_textColorComboBox.SelectedIndex = 2;
            }
            else
            {
                this.u_textColorComboBox.SelectedIndex = 0;
            }

            this.m_generalDictionary.TryGetValue("BackgroundPattern", out buffer);
            if (buffer == "true")
            {
                this.u_backgroundPatternCheckBox.Checked = true;
            }
            else
            {
                this.u_backgroundPatternCheckBox.Checked = false;
            }

            this.m_generalDictionary.TryGetValue("ShouldPlaySoundOnTypingError", out buffer);
            if (buffer == "true")
            {
                this.u_beepCheckBox.Checked = true;
            }
            else
            {
                this.u_beepCheckBox.Checked = false;
            }

            this.m_generalDictionary.TryGetValue("SoundFilename", out buffer);

            // @zonble
            // You know what? The information of the media path
            // (C:\Windows\Media is restored in registry,
            // and there is no better way to obtain this information!

            #region Get the media file path.
            if (IsVistaOrLater)
            {
                try
                {
                    RegistryKey registryKey = Registry.LocalMachine;
                    registryKey = registryKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion", false);
                    if (registryKey != null)
                    {
                        string MediaPathUnexpanded = registryKey.GetValue("MediaPathUnexpanded").ToString();
                        m_mediaPath = Environment.ExpandEnvironmentVariables(MediaPathUnexpanded);
                    }
                }
                catch { }
            }
            else if (IsXp)
            {
                try
                {
                    RegistryKey registryKey = Registry.LocalMachine;
                    registryKey = registryKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion", false);
                    if (registryKey != null)
                    {
                        m_mediaPath = registryKey.GetValue("MediaPath").ToString();
                    }
                }
                catch { }
            }
            #endregion

            #region Set the sound list.
            if (Directory.Exists(m_mediaPath))
            {
                DirectoryInfo dirInfo  = new DirectoryInfo(m_mediaPath);
                FileInfo[]    fileInfo = dirInfo.GetFiles("*.wav");
                if (fileInfo.Length > 0)
                {
                    foreach (FileInfo f in fileInfo)
                    {
                        string name = f.Name;
                        u_soundListComboBox.Items.Add(f);
                        if (buffer != "Default")
                        {
                            if (buffer == f.FullName)
                            {
                                this.u_soundListComboBox.Text = name;
                            }
                        }
                    }
                }
                else
                {
                    this.u_radioCustomizedSound.Enabled = false;
                    this.u_soundListComboBox.Enabled    = false;
                    this.u_radioDefaultSound.Checked    = true;
                }
            }
            else
            {
                this.u_radioCustomizedSound.Enabled = false;
                this.u_soundListComboBox.Enabled    = false;
                this.u_radioDefaultSound.Checked    = true;
            }

            if (buffer == "Default" || buffer.Length == 0)
            {
                this.u_radioDefaultSound.Checked = true;
            }
            else
            {
                this.u_radioCustomizedSound.Checked = true;
            }

            #endregion

            this.u_pluginComboBox.Enabled     = false;
            this.u_removePluginButton.Enabled = false;
            PreferenceConnector callback = PreferenceConnector.SharedInstance;
            if (callback != null)
            {
                int count = callback.numberOfUnloadableSignedModules();
                if (count > 0)
                {
                    this.u_pluginComboBox.Enabled = true;
                    for (int i = 0; i < count; i++)
                    {
                        string name = callback.localizedNameOfUnloadableSignedModulesAtIndex(i);
                        this.u_pluginComboBox.Items.Add(name);
                    }
                }
            }
        }