Example #1
0
        private void resetFloatingWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // save cursor position as floating window position
            commonSet.SaveFloatingWindowPosition(Control.MousePosition.X, Control.MousePosition.Y);

            // close floating window
            commonSet.EndProcess(commonSet.floatingWindowProcessName);

            // open floating window
            if (!commonSet.StartProcess(commonSet.floatingWindowExecutableName))
            {
                if (loadedLanguageIndex == 1)
                {
                    MessageBox.Show("不能顯示懸浮窗。\n請重新下載本程式。");
                }
                else if (loadedLanguageIndex == 2)
                {
                    MessageBox.Show("フローティング・ウィンドウが表示できない。\nもう一度プログラムをダウンロードしてください。");
                }
                else
                {
                    // show erroe message if the floating window cannot be shown
                    MessageBox.Show("Cannot show the floating window.\nPlease download the program again.");
                }
            }
        }
Example #2
0
        private void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            // check if the input is in range
            double updateFrequencyTemp;

            if (Double.TryParse(this.UpdateFrequencyLabel.Text, out updateFrequencyTemp))
            {
                if (updateFrequencyTemp < minFrequency)
                {
                    if (this.LanguageSelectionBox.SelectedIndex == 1)
                    {
                        MessageBox.Show(String.Format("刷新頻率不能少於 {0}。", minFrequency));
                    }
                    else if (this.LanguageSelectionBox.SelectedIndex == 2)
                    {
                        MessageBox.Show(String.Format("更新頻度は {0} より小さくすることはできない。", minFrequency));
                    }
                    else
                    {
                        MessageBox.Show(String.Format("Update frequency cannot be less than {0}.", minFrequency));
                    }
                    UpdateFrequencySlider.Value = minFrequency;
                    UpdateFrequencyLabel.Text   = minFrequency.ToString();
                    return;
                }
                else if (updateFrequencyTemp > maxFrequency)
                {
                    if (this.LanguageSelectionBox.SelectedIndex == 1)
                    {
                        MessageBox.Show(String.Format("刷新頻率不能大於 {0}。", maxFrequency));
                    }
                    else if (this.LanguageSelectionBox.SelectedIndex == 2)
                    {
                        MessageBox.Show(String.Format("更新頻度は {0} より大きくすることはできない。", maxFrequency));
                    }
                    else
                    {
                        MessageBox.Show(String.Format("Update frequency cannot be larger than {0}.", maxFrequency));
                    }
                    UpdateFrequencySlider.Value = maxFrequency;
                    UpdateFrequencyLabel.Text   = maxFrequency.ToString();
                    return;
                }
            }
            else
            {
                // tell the user to input a number
                if (this.LanguageSelectionBox.SelectedIndex == 1)
                {
                    MessageBox.Show("請輸入1個有效的數字。\n例如: 1.50。");
                }
                else if (this.LanguageSelectionBox.SelectedIndex == 2)
                {
                    MessageBox.Show("10進数を入力してください。\n例:1.50。");
                }
                else
                {
                    MessageBox.Show("Please input a decimal number. E.g. 1.50.");
                }
                this.UpdateFrequencyLabel.Text = "1";
                return;
            }


            // apply auto start setting
            commonSet.ApplyAutoStartSetting(autoStartChecked);

            SaveSetting();

            // change the words as selected language
            //changeLanguages();

            // change the config window to selected theme
            changeTheme();


            // check if the floating window is opened, if yes turn off the floating window
            commonSet.EndProcess(commonSet.floatingWindowProcessName);

            /* this part is done by base process
             * // check if floating window need to be shown
             * if (this.DisplaySelectionBox.SelectedIndex == 0 || this.DisplaySelectionBox.SelectedIndex == 2)
             * {
             *  // check if the floating window is showing
             *  ShowFloatingWindow();
             * }
             * else
             * {
             *  //fw.Close();
             * }
             */

            // restart the base process
            commonSet.EndProcess(commonSet.baseProgramProcessName);
            if (!commonSet.StartProcess(commonSet.baseProgramExecutableName))
            {
                // if the base cannot be started, show error message
                if (this.LanguageSelectionBox.SelectedIndex == 0)
                {
                    // show English message
                    MessageBox.Show("Main program may be corrupted\nPlease download this program again.");
                }
                else if (this.LanguageSelectionBox.SelectedIndex == 1)
                {
                    // show Chinese message
                    MessageBox.Show("主程序可能已被損毀\n請重新下載本程式");
                }
                else if (this.LanguageSelectionBox.SelectedIndex == 2)
                {
                    // show Japanese message
                    MessageBox.Show("メインプログラムが破損している可能性がある。もう一度プログラムをダウンロードしてください。\n");
                }
            }
        }