Пример #1
0
        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();
            }
        }
Пример #2
0
        /// <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
        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);
        }
Пример #6
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;
        }
Пример #7
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;
            }
        }