private void LoadCannedMessages() { BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { List <string> cannedMessageCategories = callback.cannedMessageCategories(); if (cannedMessageCategories.Count == 0) { return; } int i = 0; foreach (string categoryName in cannedMessageCategories) { string categoryTag = "pCannedMessage_" + i; List <KeyValuePair <string, string> > list = callback.cannedMessagesOfCategory(i); bool editButtonVisible = false; if (i == cannedMessageCategories.Count - 1) { editButtonVisible = true; } this.CreateSmileyPanel(categoryTag, list, editButtonVisible); ToolStripMenuItem menuItem = new ToolStripMenuItem(); menuItem.Text = categoryName; menuItem.Name = categoryTag; menuItem.Tag = categoryTag; menuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.u_ToolStripDropDown.Items.Add(menuItem); i++; } } }
private void LoadBasicSymbols() { BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { List <string> symbolButtonCategories = callback.symbolButtonCategories(); if (symbolButtonCategories.Count == 0) { return; } int i = 0; foreach (string symbolButtonName in symbolButtonCategories) { string symbolButtonTag = "pSymbolButton_" + i; List <string> buttons = callback.symbolButtonsOfCategory(i); this.CreateButtonPanel(symbolButtonTag, buttons.ToArray()); ToolStripMenuItem menuItem = new ToolStripMenuItem(); menuItem.Text = symbolButtonName; menuItem.Name = symbolButtonTag; menuItem.Tag = symbolButtonTag; menuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.u_ToolStripDropDown.Items.Add(menuItem); i++; } } }
private void ClearWordCount(object sender, EventArgs e) { string message = "Do you really want to clear word count?"; string locale = CultureInfo.CurrentUICulture.Name; if (locale.Equals("zh-TW")) { message = "\u60a8\u78ba\u5b9a\u8981\u6e05\u9664\u5b57\u6578\u7d71\u8a08\u55ce\uff1f"; } else if (locale.Equals("zh-CN")) { message = "\u60a8\u786e\u5b9a\u8981\u6e05\u9664\u5b57\u6570\u7edf\u8ba1\u5417\uff1f"; } DialogResult result = MessageBox.Show(message, "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result.Equals(DialogResult.No)) { return; } BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { string wordCountModuleName = "YKAFWordCount"; callback.deleteAllKeysAndValuesInModuleConfig(wordCountModuleName); this.UpdateWordCount(); } }
private void u_wordCountEnableCheckBox_CheckedChanged(object sender, EventArgs e) { if (this.m_init) { return; } this.m_init = true; BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { string wordCountModuleName = "YKAFWordCount"; callback.toggleAroundFilter(wordCountModuleName); if (callback.isAroundFilterEnabled(wordCountModuleName)) { this.u_wordCountEnableCheckBox.Checked = true; this.SetWordCountLabelsEnabled(true); } else { this.u_wordCountEnableCheckBox.Checked = false; this.SetWordCountLabelsEnabled(false); } } this.m_init = false; }
public void SetFontHeight(long newHeightInPixel) { using (Graphics g = this.CreateGraphics()) { // @zonble // The unit of the height passed within the variable // "newHeightInPixel" is pixel, however, we need to know // the hieght in point, and then we are able to set the height // of a font object. So, we need to convert itfrom pixel to // point. BTW, during this conversion, we need to know the // current screen resolution (DPI). // the input is in px, but Font needs pt, so scale back float newHeight = (float)newHeightInPixel * 72.0F / g.DpiX; BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { if (callback.hasLoaderConfigKey("IMEUnawareComposingBufferHeightPt")) { // take this in ppt newHeight = (float)Int64.Parse(callback.stringValueForLoaderConfigKey("IMEUnawareComposingBufferHeightPt")); } } FontFamily fontFamily = Win32FontHelper.DefaultFontFamily(); Font font = new Font(fontFamily, newHeight, FontStyle.Regular, GraphicsUnit.Point, ((byte)(136))); this.Font = font; fontFamily.Dispose(); font.Dispose(); g.Dispose(); } }
private void GotoNextPage() { BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.gotoNextPage(); } }
private void SendOneKey(object sender, EventArgs e) { BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.sendOneKeyChar(); } }
/// <summary> /// Send string from the dictionary to the current application which activates Yahoo! KeyKey input method. /// </summary> /// <param name="text">The content text to send</param> public void SendString(string text) { BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.sendString(text + " "); } }
private void SendSelectionKey(char key) { BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.sendChar(key); } }
/// <summary> /// Send string to the client window by calling the sendString method. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SendString(object sender, EventArgs e) { Button b = (Button)sender; string text = b.Text; BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.sendString(text); } }
/// <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); } }
private void sendString(object sender, EventArgs e) { BIKeyboardButton b = (BIKeyboardButton)sender; string symbol = b.Symbol; BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.sendString(symbol); } this.Hide(); }
public new void Hide() { base.Hide(); // cancel the waiting state BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.cancelPunctuationKeyboardWaitingState(); } }
private void SaveMiniModeConfig() { BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { string value = "true"; if (this.m_isMiniMode == false) { value = "false"; } callback.setLoaderConfigKeyStringValue("ShouldUseMiniMode", value); } }
private void SaveLastUsedPage(string page) { if (this.m_init) { return; } BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.setLoaderConfigKeyStringValue("LastSymbolTablePage", page); } }
private void FetchOnlineDataAndCheckForUpdate() { ThreadStart threadStart = new ThreadStart(FetchOnlineDataAndCheckForUpdateInThread); Thread thread = new Thread(threadStart); thread.Start(); BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.startUpdateServerDataThread(); } }
/// <summary> /// Paint the appearance of the status bar in the mini mode. /// </summary> /// <param name="e"></param> private void PaintMiniMode(PaintEventArgs e) { Graphics g = e.Graphics; this.u_toolStrip.Visible = false; Size windowSize = new Size(this.u_toolStrip.Size.Width + this.u_toolStrip.Left + 10, this.u_toolStrip.Size.Height - 2); this.m_windowRect = new Rectangle(new Point(0, 0), windowSize); Rectangle windowRect = new Rectangle(0, 0, 64, windowSize.Height); Rectangle outside = windowRect; outside.Height += 1; outside.Width += 1; Region windowRegion = new Region(outside); this.Region = windowRegion; windowRegion.Dispose(); // Paint the header of the status bar with a Yahoo! logo. g.DrawImage(this.m_barhead, 0, 0, 36, outside.Height); BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { // If we are now in the Alphanumeric mode, the icon on the status bar // in the mini mode should be a icon title "EN", otherwise, it should // be the icon of the current Chinese Input Method. Image i; if (callback.isAlphanumericMode()) { i = this.u_toggleAlphanumericMode.Image; } else { i = this.u_toggleInputMethod.Image; } g.DrawImage(i, 40, 3, 20, 20); } Pen blackPen = new Pen(Color.Black); g.DrawRectangle(blackPen, windowRect); g.DrawLine(blackPen, new Point(36, 0), new Point(36, this.Height)); blackPen.Dispose(); }
/// <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(); } } } }
/// <summary> /// Toggle English / Chinese mode. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToggleAlphanumericMode(object sender, EventArgs e) { BIServerConnector callback = BIServerConnector.SharedInstance; string currentLocale = CultureInfo.CurrentUICulture.Name; if (callback != null) { if (callback.isAlphanumericMode()) { this.u_toggleAlphanumericMode.Image = this.m_imageChinese; if (currentLocale.Equals("zh-TW")) { this.Notify("\u4e2d\u6587\u6a21\u5f0f"); } else if (currentLocale.Equals("zh-CN")) { this.Notify("\u4E2D\u6587\u6A21\u5F0F"); } else { this.Notify("Switch to Chinese mode."); } callback.setAlphanumericMode(false); } else { this.u_toggleAlphanumericMode.Image = this.m_imageEnglish; if (currentLocale.Equals("zh-TW")) { this.Notify("\u82f1\u6587\u6a21\u5f0f"); } else if (currentLocale.Equals("zh-CN")) { this.Notify("\u82F1\u6587\u6A21\u5F0F"); } else { this.Notify("Switch to English mode."); } callback.setAlphanumericMode(true); } if (this.m_isMiniMode == true && m_isUsingSystemTrayMode == false) { this.Refresh(); } } }
/// <summary> /// Enable or diable an extra output filter. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void outputFilterToolStripMenuItem_Click(object sender, EventArgs e) { BIServerConnector callback = BIServerConnector.SharedInstance; string currentLocale = CultureInfo.CurrentUICulture.Name; ToolStripMenuItem currentItem = (ToolStripMenuItem)sender; string outputFilterName = currentItem.Name; string displayName = currentItem.Text; if (callback != null && outputFilterName != "") { callback.toggleOutputFilter(outputFilterName); if (currentItem.Checked == false) { currentItem.Checked = true; currentItem.Image = global::BaseIMEUI.Properties.Resources.menuCheck; if (currentLocale.Equals("zh-TW")) { this.Notify("\u300c" + displayName + "\u300d\u529f\u80fd\u5df2\u555f\u7528"); } else if (currentLocale.Equals("zh-CN")) { this.Notify("\u301D" + displayName + "\u301E\u529F\u80FD\u5DF2\u542F\u7528"); } else { this.Notify(displayName + " is on."); } } else { currentItem.Checked = false; currentItem.Image = global::BaseIMEUI.Properties.Resources.menuUncheck; if (currentLocale.Equals("zh-TW")) { this.Notify("\u300c" + displayName + "\u300d\u529f\u80fd\u5df2\u505c\u7528"); } else if (currentLocale.Equals("zh-CN")) { this.Notify("\u301D" + displayName + "\u301E\u529F\u80FD\u5DF2\u505C\u7528"); } else { this.Notify(displayName + " is off."); } } } }
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; } } } }
public void UpdateVersionInfo() { this.m_init = true; BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { if (callback.isRunningUnderWow64()) { this.u_version.Text += ", 64-bit"; } this.u_databaseVersion.Text = "Database version " + callback.databaseVersion(); } else { this.u_databaseVersion.Text = ""; } this.m_init = false; }
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; } } } }
/// <summary> /// Toggle full / half width roman letters. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToggleFullWidthCharacterMode(object sender, EventArgs e) { BIServerConnector callback = BIServerConnector.SharedInstance; string currentLocale = CultureInfo.CurrentUICulture.Name; if (callback != null) { callback.setFullWidthCharacterMode(!callback.isFullWidthCharacterMode()); if (!callback.isFullWidthCharacterMode()) { this.u_toggleFullWidthCharacterMode.Image = this.m_imageHalfWidth; if (currentLocale.Equals("zh-TW")) { this.Notify("\u534a\u5f62\u82f1\u6578\u6a21\u5f0f"); } else if (currentLocale.Equals("zh-CN")) { this.Notify("\u534a\u89d2\u82f1\u6570\u6a21\u5f0f"); } else { this.Notify("Half-width roman letters mode."); } } else { this.u_toggleFullWidthCharacterMode.Image = this.m_imageFullWidth; if (currentLocale.Equals("zh-TW")) { this.Notify("\u5168\u5f62\u82f1\u6578\u6a21\u5f0f"); } else if (currentLocale.Equals("zh-CN")) { this.Notify("\u5168\u89d2\u82f1\u6570\u6a21\u5f0f"); } else { this.Notify("Full-width roman letters mode."); } } } }
/// <summary> /// Switch to the selected input method in the menu. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SelectInputMethod(object sender, EventArgs e) { BIServerConnector callback = BIServerConnector.SharedInstance; string currentLocale = CultureInfo.CurrentUICulture.Name; if (callback != null) { ToolStripMenuItem currentItem = (ToolStripMenuItem)sender; this.u_toggleInputMethod.Image = currentItem.Image; this.u_toggleInputMethod.AutoSize = true; this.u_toggleInputMethod.Text = currentItem.Text; foreach (object item in u_toggleInputMethodDropDownMenu.Items) { if (!(item is ToolStripSeparator)) { ToolStripMenuItem toolStripMenuItem = (ToolStripMenuItem)item; toolStripMenuItem.CheckState = CheckState.Unchecked; } } currentItem.CheckState = CheckState.Checked; string currentInputMethod = currentItem.Name; callback.setPrimaryInputMethod(currentInputMethod, true); this.ResetStatusBarLocation(); if (currentLocale.Equals("zh-TW")) { this.Notify("\u9078\u7528" + currentItem.Text + "\u8f38\u5165\u6cd5"); } else if (currentLocale.Equals("zh-CN")) { this.Notify("\u9009\u7528" + currentItem.Text + "\u8F93\u5165\u6CD5"); } else { this.Notify("Current Input Method: " + currentItem.Text + "."); } } }
/// <summary> /// Toggle Traditional / Simplified Chinese mode. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToggleChineseCharacterConverter(object sender, EventArgs e) { BIServerConnector callback = BIServerConnector.SharedInstance; string currentLocale = CultureInfo.CurrentUICulture.Name; if (callback != null) { callback.toggleOutputFilter("ChineseCharacterConvertor-TC2SC"); if (!callback.isOutputFilterEnabled("ChineseCharacterConvertor-TC2SC")) { this.u_toggleChineseCharacterConverter.Image = this.m_imageZhTW; if (currentLocale.Equals("zh-TW")) { this.Notify("\u7e41\u9ad4\u4e2d\u6587\u8f38\u51fa"); } else if (currentLocale.Equals("zh-CN")) { this.Notify("\u7E41\u4F53\u4E2D\u6587\u6A21\u5F0F"); } else { this.Notify("Traditional Chinese mode."); } } else { this.u_toggleChineseCharacterConverter.Image = this.m_imageZhCN; if (currentLocale.Equals("zh-TW")) { this.Notify("\u7c21\u9ad4\u4e2d\u6587\u8f38\u51fa"); } else if (currentLocale.Equals("zh-CN")) { this.Notify("\u7B80\u4F53\u4E2D\u6587\u6A21\u5F0F"); } else { this.Notify("Simplified Chinese mode."); } } } }
/// <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); } }
private void u_listBox_DoubleClick(object sender, EventArgs e) { if (u_listBox.SelectedIndex < 0 || u_listBox.SelectedIndex >= this.m_symbolsList.Count) { return; } KeyValuePair <string, string> kvp = this.m_symbolsList[u_listBox.SelectedIndex]; string text = kvp.Value; if (text == null || text.Length == 0) { return; } BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { callback.sendString(text); } }
private int IndexOfLastUsedPage() { BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { if (callback.hasLoaderConfigKey("ShouldUseMiniMode") == false) { return(0); } string lastUsedPage = callback.stringValueForLoaderConfigKey("LastSymbolTablePage"); for (int i = 0; i < this.u_panelButtons.Controls.Count; i++) { Control c = this.u_panelButtons.Controls[i]; if (c.Name.Equals(lastUsedPage)) { return(i); } } } return(0); }
/// <summary> /// The shadowed Show() /// </summary> public new void Show() { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(this.Show)); return; } BIServerConnector callback = BIServerConnector.SharedInstance; if (callback != null) { // Get the color schema of the canidate window. if (callback.hasLoaderConfigKey("HighlightColor")) { string colorString = callback.stringValueForLoaderConfigKey("HighlightColor"); if (colorString.Equals("Green")) { this.m_hilightColor = Color.Green; this.m_hilightEndColor = Color.DarkGreen; } else if (colorString.Equals("Yellow")) { this.m_hilightColor = Color.Yellow; this.m_hilightEndColor = Color.DarkOrange; } else if (colorString.Equals("Red")) { this.m_hilightColor = Color.Red; this.m_hilightEndColor = Color.DarkRed; } else if (colorString.StartsWith("Color ")) { string aString = colorString.Remove(0, 6); Color aColor = Color.FromArgb(Int32.Parse(aString)); this.m_hilightColor = aColor; this.m_hilightEndColor = aColor; } else { this.m_hilightColor = Color.FromArgb(140, 91, 156); this.m_hilightEndColor = Color.FromArgb(140, 91, 156); } } if (callback.hasLoaderConfigKey("BackgroundColor")) { string colorString = callback.stringValueForLoaderConfigKey("BackgroundColor"); if (colorString.Equals("White")) { this.m_backgroundColor = Color.White; this.m_patternColor = Color.LightGray; } else if (colorString.StartsWith("Color ")) { string aString = colorString.Remove(0, 6); Color aColor = Color.FromArgb(Int32.Parse(aString)); this.m_backgroundColor = aColor; int r = aColor.R - 32; if (r < 0) { r = 0; } int g = aColor.G - 32; if (g < 0) { g = 0; } int b = aColor.B - 32; if (b < 0) { b = 0; } this.m_patternColor = Color.FromArgb(r, g, b); } else { this.m_backgroundColor = Color.Black; this.m_patternColor = Color.FromArgb(32, 32, 32); } } if (callback.hasLoaderConfigKey("TextColor")) { string colorString = callback.stringValueForLoaderConfigKey("TextColor"); if (colorString.Equals("Black")) { this.m_foregroundColor = Color.Black; } else if (colorString.StartsWith("Color ")) { string aString = colorString.Remove(0, 6); Color aColor = Color.FromArgb(Int32.Parse(aString)); this.m_foregroundColor = aColor; } else { this.m_foregroundColor = Color.White; } } if (callback.hasLoaderConfigKey("BackgroundPattern")) { string patternString = callback.stringValueForLoaderConfigKey("BackgroundPattern"); if (patternString.Equals("true")) { this.m_usePattern = true; } else { this.m_usePattern = false; } } else { this.m_usePattern = false; } } // The Candidate Window should be always on top. Win32FunctionHelper.ShowWindowTopMost(base.Handle); base.Visible = true; }