コード例 #1
0
        /// <summary>
        /// Show the Notify Window with a message and the default title.
        /// </summary>
        /// <param name="Message">The content of the message.</param>
        public void Notify(string Message)
        {
            BIServerConnector callback = BIServerConnector.SharedInstance;

            if (callback != null)
            {
                if (!callback.isLoaderConfigKeyTrue("ShouldUseNotifyWindow"))
                {
                    return;
                }
            }

            if (this.InvokeRequired)
            {
                List <string> list = new List <string>();
                list.Add(Message);
                string currentLocale = CultureInfo.CurrentUICulture.Name;
                if (currentLocale.Equals("zh-TW"))
                {
                    list.Add("Yahoo! \u5947\u6469\u8f38\u5165\u6cd5");
                }
                else if (currentLocale.Equals("zh-CN"))
                {
                    list.Add("Yahoo! \u5947\u6469\u8f93\u5165\u6cd5");
                }
                else
                {
                    list.Add("Yahoo! KeyKey");
                }

                this.Invoke(new NotifyCallBack(InvokedNotify),
                            list.ToArray());
                return;
            }
            else
            {
                string currentLocale = CultureInfo.CurrentUICulture.Name;
                string Title         = "";
                if (currentLocale.Equals("zh-TW"))
                {
                    Title = "Yahoo! \u5947\u6469\u8f38\u5165\u6cd5";
                }
                else if (currentLocale.Equals("zh-CN"))
                {
                    Title = "Yahoo! \u5947\u6469\u8f93\u5165\u6cd5";
                }
                else
                {
                    Title = "Yahoo! KeyKey";
                }
                this.InvokedNotify(Message, Title);
            }
        }
コード例 #2
0
ファイル: BIKeyboardForm.cs プロジェクト: zhtw2013/KeyKey
        /// <summary>
        /// To set the location of the candidate window.
        /// The SetLocation() method is inherited from the BIForm class, however, the SetLocation()
        /// method of the candidate window do not move the window directly, but set a target location
        /// temporary, the window will move to the target location while re-drawing the window
        /// and the on-paint event is launched.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public new void SetLocation(int x, int y)
        {
            BIServerConnector callback = BIServerConnector.SharedInstance;

            if (callback != null)
            {
                if (callback.hasLoaderConfigKey("KeyboardFormShouldFollowCursor"))
                {
                    if (callback.isLoaderConfigKeyTrue("KeyboardFormShouldFollowCursor"))
                    {
                        this.m_targetPoint = new Point(x, y);
                        this.AdjustLocation();
                    }
                }
            }
        }
コード例 #3
0
        private void SetOpacityByConfig()
        {
            BIServerConnector callback = BIServerConnector.SharedInstance;

            if (callback != null)
            {
                if (callback.hasLoaderConfigKey("ShouldUseTransparentStatusBar"))
                {
                    if (callback.isLoaderConfigKeyTrue("ShouldUseTransparentStatusBar"))
                    {
                        this.Opacity = 0.5;
                    }
                    else
                    {
                        this.Opacity = 1.0;
                    }
                }
            }
        }
コード例 #4
0
        private void SetMiniModeTypeByConfig()
        {
            BIServerConnector callback = BIServerConnector.SharedInstance;

            if (callback != null)
            {
                if (callback.hasLoaderConfigKey("ShouldUseSystemTray"))
                {
                    if (callback.isLoaderConfigKeyTrue("ShouldUseSystemTray"))
                    {
                        this.m_isUsingSystemTrayMode = true;
                    }
                    else
                    {
                        this.m_isUsingSystemTrayMode = false;
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Show the Notify window with a message and the customized title.
        /// </summary>
        /// <param name="Message">The content of the message.</param>
        /// <param name="Title">The customized title.</param>
        public void Notify(string Message, string Title)
        {
            BIServerConnector callback = BIServerConnector.SharedInstance;

            if (callback != null)
            {
                if (!callback.isLoaderConfigKeyTrue("ShouldUseNotifyWindow"))
                {
                    return;
                }
            }
            if (this.InvokeRequired)
            {
                this.Invoke(new NotifyCallBack(InvokedNotify),
                            new object[] { Message, Title });
            }
            else
            {
                this.InvokedNotify(Message, Title);
            }
        }
コード例 #6
0
        private void CheckUpdate()
        {
            string versionInfo = TakaoPreference.UpdateHelper.GetVersionInfo();
            string signature   = TakaoPreference.UpdateHelper.GetVersionInfoSignature();

            if (versionInfo.Length == 0 || signature.Length == 0)
            {
                return;
            }
            bool valid = TakaoPreference.UpdateHelper.ValidateFile(versionInfo, signature);

            if (valid == false)
            {
                return;
            }

            if (TakaoPreference.UpdateHelper.ShouldUpdate(versionInfo) == true)
            {
                this.m_checkingUpdate = false;

                #region Check if user want to check for updates on launch.
                // Check if user want to check for updates on launch.
                // This information is stored in the preference plist file.
                BIServerConnector callback = BIServerConnector.SharedInstance;
                if (callback == null)
                {
                    return;
                }
                if (callback.hasLoaderConfigKey("ShouldCheckUpdateOnLaunch") == false)
                {
                    callback.setLoaderConfigKeyStringValue("ShouldCheckUpdateOnLaunch", "true");
                }
                if (callback.isLoaderConfigKeyTrue("ShouldCheckUpdateOnLaunch") == false)
                {
                    return;
                }
                #endregion

                #region Check if user ever checked "Do not notify me in a week".
                // Check if user ever checked "Do not notify me in a week".
                // This information is stored in Windows registry.

                RegistryKey registryKey = Registry.LocalMachine;
                registryKey = registryKey.OpenSubKey(@"SOFTWARE\Yahoo\KeyKey", true);

                if (registryKey != null)
                {
                    if (registryKey.GetValue("NextCheckDate") != null)
                    {
                        string timeString = registryKey.GetValue("NextCheckDate").ToString();
                        if (timeString.Length > 0)
                        {
                            DateTime nextCheckDate;
                            DateTime.TryParse(timeString, out nextCheckDate);

                            if (nextCheckDate < DateTime.Now.AddDays(7))
                            {
                                return;
                            }
                        }
                    }
                }
                #endregion

                this.ConfirmDownloadUpdate();
                return;
            }
        }
コード例 #7
0
        /// <summary>
        /// Initialize User Interface
        /// </summary>
        private void InitUI()
        {
            BIServerConnector           callback          = BIServerConnector.SharedInstance;
            Dictionary <string, string> extraInputMethods = new Dictionary <string, string>();
            Dictionary <string, string> outputFilters     = new Dictionary <string, string>();
            Dictionary <string, string> aroundFilters     = new Dictionary <string, string>();
            List <string> modulesSuppressedFromUI         = new List <string>();

            string currentInputMethod   = "";
            bool   useFullWidth         = true;
            bool   useSimplifiedChinese = false;
            bool   useEnglishKeyboard   = false;

            if (callback != null)
            {
                currentInputMethod = callback.stringValueForLoaderConfigKey("PrimaryInputMethod");
                if (currentInputMethod.Length == 0)
                {
                    currentInputMethod = callback.primaryInputMethod();
                }

                useSimplifiedChinese    = callback.isOutputFilterEnabled("ChineseCharacterConvertor-TC2SC");
                useFullWidth            = callback.isFullWidthCharacterMode();
                extraInputMethods       = callback.allInputMethodIdentifiersAndNames();
                outputFilters           = callback.allOutputFilterIdentifiersAndNames();
                aroundFilters           = callback.allAroundFilterIdentifiersAndNames();
                modulesSuppressedFromUI = callback.arrayValueForLoaderConfigKey("ModulesSuppressedFromUI");

                if (callback.isLoaderConfigKeyTrue("EnablesCapsLockAsAlphanumericModeToggle"))
                {
                    this.u_toolStrip.Items.Remove(u_toggleAlphanumericMode);
                }
            }

            // Load extra Input Method modules.

            this.u_toggleInputMethodDropDownMenu.Items.Clear();
            this.u_toggleInputMethodDropDownMenu.Items.AddRange(this.m_defualtInputMethodMenuItems);

            if (modulesSuppressedFromUI.Contains("SmartMandarin"))
            {
                this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_smartPhoneticToolStripMenuItem);
            }
            if (modulesSuppressedFromUI.Contains("TraditionalMandarins"))
            {
                this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_traditionalPhoneticToolStripMenuItem);
            }
            if (modulesSuppressedFromUI.Contains("Generic-cj-cin"))
            {
                this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_cangjieToolStripMenuItem);
            }
            if (modulesSuppressedFromUI.Contains("Generic-simplex-cin"))
            {
                this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_simplexToolStripMenuItem);
            }

            if (extraInputMethods.Count > 0)
            {
                ToolStrip               tempStrip = new ToolStrip();
                ToolStripItem[]         tempItems = new ToolStripItem[] { };
                ToolStripItemCollection genericInputMethodMenuItems = new ToolStripItemCollection(tempStrip, tempItems);

                foreach (KeyValuePair <string, string> genericInputMethod in extraInputMethods)
                {
                    string moduleID   = genericInputMethod.Key;
                    string moduleName = genericInputMethod.Value;

                    if (modulesSuppressedFromUI.Contains(moduleID))
                    {
                        continue;
                    }

                    System.Windows.Forms.ToolStripMenuItem newItem = new System.Windows.Forms.ToolStripMenuItem();

                    if (moduleID.Equals(currentInputMethod))
                    {
                        newItem.CheckState = CheckState.Checked;
                    }

                    newItem.AutoSize    = true;
                    newItem.Image       = global::BaseIMEUI.Properties.Resources.generic;
                    newItem.Name        = moduleID;
                    newItem.Text        = moduleName;
                    newItem.ToolTipText = moduleName;
                    newItem.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.ImageAlign  = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.Click      += new System.EventHandler(this.SelectInputMethod);
                    genericInputMethodMenuItems.Add(newItem);
                }

                if (u_toggleInputMethodDropDownMenu.Items.Count > 0 && genericInputMethodMenuItems.Count > 0)
                {
                    this.u_toggleInputMethodDropDownMenu.Items.Add(new ToolStripSeparator());
                }
                if (genericInputMethodMenuItems.Count > 0)
                {
                    this.u_toggleInputMethodDropDownMenu.Items.AddRange(genericInputMethodMenuItems);
                }
                tempStrip.Dispose();
            }

            // Avoids that there is no input method in the menu.
            if (this.u_toggleInputMethodDropDownMenu.Items.Count == 0)
            {
                this.u_toggleInputMethodDropDownMenu.Items.Add(this.u_smartPhoneticToolStripMenuItem);
            }

            this.u_configsDropDownMenu.Items.Clear();

            // Loads Around Filters.
            if (aroundFilters.Count > 0)
            {
                foreach (KeyValuePair <string, string> aroundFilter in aroundFilters)
                {
                    string moduleID   = aroundFilter.Key;
                    string moduleName = aroundFilter.Value;

                    // Makes the search and evanuator module always enabled.
                    if (moduleID.Equals("OneKey") || moduleID.Equals("Evaluator"))
                    {
                        if (callback != null && !callback.isAroundFilterEnabled(moduleID))
                        {
                            callback.toggleAroundFilter(moduleID);
                        }
                        continue;
                    }
                    // Leaves the ReverseLookup Modules hidden.
                    if (moduleID.StartsWith("ReverseLookup"))
                    {
                        continue;
                    }

                    System.Windows.Forms.ToolStripMenuItem newItem = new System.Windows.Forms.ToolStripMenuItem();
                    newItem.AutoSize = true;
                    if (callback != null && callback.isAroundFilterEnabled(moduleID) == true)
                    {
                        newItem.Image   = global::BaseIMEUI.Properties.Resources.menuCheck;
                        newItem.Checked = true;
                    }
                    else
                    {
                        newItem.Image   = global::BaseIMEUI.Properties.Resources.menuUncheck;
                        newItem.Checked = false;
                    }
                    newItem.Name        = moduleID;
                    newItem.Text        = moduleName;
                    newItem.ToolTipText = moduleName;
                    newItem.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.ImageAlign  = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.Click      += new System.EventHandler(this.aroundFilterToolStripMenuItem_Click);
                    this.u_configsDropDownMenu.Items.Add(newItem);
                }
                this.u_configsDropDownMenu.Items.Add(new ToolStripSeparator());
            }

            // Load Output Filters.

            if (outputFilters.Count > 0)
            {
                foreach (KeyValuePair <string, string> outputFilter in outputFilters)
                {
                    string ID   = outputFilter.Key;
                    string Name = outputFilter.Value;

                    System.Windows.Forms.ToolStripMenuItem newItem = new System.Windows.Forms.ToolStripMenuItem();
                    newItem.AutoSize = true;
                    if (callback != null && callback.isOutputFilterEnabled(ID) == true)
                    {
                        newItem.Image   = global::BaseIMEUI.Properties.Resources.menuCheck;
                        newItem.Checked = true;
                    }
                    else
                    {
                        newItem.Image   = global::BaseIMEUI.Properties.Resources.menuUncheck;
                        newItem.Checked = false;
                    }
                    newItem.Name        = ID;
                    newItem.Text        = Name;
                    newItem.ToolTipText = Name;
                    newItem.TextAlign   = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.ImageAlign  = System.Drawing.ContentAlignment.MiddleLeft;
                    newItem.Click      += new System.EventHandler(this.outputFilterToolStripMenuItem_Click);
                    u_configsDropDownMenu.Items.Add(newItem);
                }
                this.u_configsDropDownMenu.Items.Add(new ToolStripSeparator());
            }

            this.u_configsDropDownMenu.Items.AddRange(this.m_defualtConfigItems);

            #region Init the default input method

            ToolStripMenuItem targetItem = null;
            bool found = false;
            foreach (object item in this.u_toggleInputMethodDropDownMenu.Items)
            {
                if (item is ToolStripMenuItem)
                {
                    ToolStripMenuItem currentItem = (ToolStripMenuItem)item;
                    if (currentItem.Name.Equals(currentInputMethod))
                    {
                        found      = true;
                        targetItem = currentItem;
                        break;
                    }
                }
            }

            if (!found)
            {
                targetItem = (ToolStripMenuItem)this.u_toggleInputMethodDropDownMenu.Items[0];
            }

            if (targetItem != null)
            {
                this.u_toggleInputMethod.Image = targetItem.Image;
                this.u_toggleInputMethod.Text  = targetItem.Text;
                if (callback != null)
                {
                    callback.setPrimaryInputMethod(targetItem.Name, false);
                }
                targetItem.CheckState = CheckState.Checked;
            }

            #endregion

            if (useEnglishKeyboard == true)
            {
                this.u_toggleAlphanumericMode.Image = global::BaseIMEUI.Properties.Resources.english;
            }
            else
            {
                this.u_toggleAlphanumericMode.Image = global::BaseIMEUI.Properties.Resources.chinese;
            }

            if (useFullWidth == true)
            {
                this.u_toggleFullWidthCharacterMode.Image = global::BaseIMEUI.Properties.Resources.fullwidth;
            }
            else
            {
                this.u_toggleFullWidthCharacterMode.Image = global::BaseIMEUI.Properties.Resources.halfwidth;
            }

            if (useSimplifiedChinese == true)
            {
                this.u_toggleChineseCharacterConverter.Image = global::BaseIMEUI.Properties.Resources.zh_CN;
            }
            else
            {
                this.u_toggleChineseCharacterConverter.Image = global::BaseIMEUI.Properties.Resources.zh_TW;
            }
        }