public void AutoRunRegister() { if (commonSet.loadedAutoStart.ToLower().Equals("true")) { commonSet.ApplyAutoStartSetting(true); } else { commonSet.ApplyAutoStartSetting(false); } }
private void ApplyButton_Click(object sender, RoutedEventArgs e) { // save the configuration commonSet.SaveConfiguration(); // apply the autostart setting commonSet.ApplyAutoStartSetting(AutoStartCheckBox.IsChecked.Value); // save the time of next printing commonSet.ComputeNextTime(); commonSet.SaveNextTime(); MessageBox.Show("Configuration saved"); // update scheduled time commonSet.LoadNextTime(); ScheduledTimeTextBlock.Text = commonSet.loadedNextPrintingTime.ToString(); }
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"); } } }
private void AutoStartCheckBox_Checked(object sender, RoutedEventArgs e) { commonSet.autoStart = "true"; commonSet.SaveConfiguration(); commonSet.ApplyAutoStartSetting(true); }
public MainWindow() { // set the floating window always on top this.Topmost = true; executableConfigName = commonSet.configurationExecutableName; configFileName = commonSet.configFileName; InitializeComponent(); // check if the background process is running, if no, show message and end the program if (!commonSet.CheckIfRunning(commonSet.baseProgramProcessName)) { MessageBox.Show("Please run \"StartProcess.exe\" and use it to access the Floating Window."); this.Close(); } // check if any same programm is running if (commonSet.CheckIfRunningSameProcess(commonSet.floatingWindowProcessName)) { MessageBox.Show("Floating Window is opened already."); this.Close(); } // check if the program name is changed if (commonSet.CheckIfNameChanged(commonSet.floatingWindowProcessName)) { MessageBox.Show("Executable file name changed or corrupted.\nPlease download the program again."); this.Close(); } // do not show in taskbar this.ShowInTaskbar = false; // init common set commonSet.InitCommonSet(); // get Interface information GetInterfaceInformation(); // load setting LoadSetting(); // apply auto start setting commonSet.ApplyAutoStartSetting(loadedAutoStartCheck); // resize window ResizeWindow(); // Get Traffic information GetTrafficInformation(); // Load and set the position of floating window LoadPosition(); // Save position of floating window SavePosition(); // check minized CheckMinimized(); }