public static bool ValidateFile(string packageFile, string signatureFile) { PreferenceConnector callback = PreferenceConnector.SharedInstance; if (callback == null) { return(false); } bool result = callback.validateFile(packageFile, signatureFile); return(result); }
/// <summary> /// handle the click event on the u_applyButton button to writer preference into XML files. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void u_applyButton_Click(object sender, EventArgs e) { this.SaveSettings(); u_applyButton.Enabled = false; PreferenceConnector callback = PreferenceConnector.SharedInstance; if (callback != null) { callback.syncLoaderAndCurrentModuleConfig(); } }
private void EditSymbolsInThread() { PreferenceConnector callback = PreferenceConnector.SharedInstance; if (callback != null) { string filename = callback.userFreeCannedMessagePath(); Process process = new Process(); process.StartInfo.FileName = "Notepad.exe"; process.StartInfo.Arguments = filename; process.Start(); } }
/// <summary> /// Handle the click event on the u_saveButton button to write preference into XML files and close the preference utility. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void u_saveButton_Click(object sender, EventArgs e) { this.SaveSettings(); PreferenceConnector callback = PreferenceConnector.SharedInstance; if (callback != null) { callback.syncLoaderAndCurrentModuleConfig(); } this.Close(); }
public static string GetVersionInfoSignature() { PreferenceConnector callback = PreferenceConnector.SharedInstance; if (callback == null) { return(""); } string filename = callback.temporaryFilename("VersionInfo.sig"); try { WebClient client = new WebClient(); client.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); client.DownloadFile(new Uri(callback.versionInfoSignatureURL()), filename); } catch { return(""); } return(filename); }
public static string GetVersionInfo() { PreferenceConnector callback = PreferenceConnector.SharedInstance; if (callback == null) { return(""); } string filename = callback.temporaryFilename("VersionInfo.xml"); string userInfoForPOST = "&userinfo=" + callback.userInfoForPOST(); WebRequest request = null; try { Encoding encode = Encoding.GetEncoding("utf-8"); byte[] arrB = encode.GetBytes(userInfoForPOST); request = WebRequest.Create(callback.versionInfoURL()); request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); request.Timeout = 1000 * 5; request.ContentType = "application/x-www-form-urlencoded"; request.Method = "POST"; Stream reqStream = request.GetRequestStream(); reqStream.Write(arrB, 0, arrB.Length); reqStream.Close(); UpdateHelper.SaveResponceToFile(filename, request); } catch { return(""); } return(filename); }
private void u_removePluginButton_Click(object sender, EventArgs e) { PreferenceConnector callback = PreferenceConnector.SharedInstance; if (callback == null) { // Show alert. return; } int index = this.u_pluginComboBox.SelectedIndex; string locale = CultureInfo.CurrentUICulture.Name; if (index > -1 && index < callback.numberOfUnloadableSignedModules()) { string name = callback.localizedNameOfUnloadableSignedModulesAtIndex(index); string message = "Do you really want to unload \"" + name + "\"?"; if (locale.Equals("zh-TW")) { message = "\u60a8\u78ba\u5b9a\u8981\u89e3\u9664\u5b89\u88dd\u300c" + name + "\u300d\u55ce\uff1f"; } else if (locale.Equals("zh-CN")) { message = "\u60a8\u786e\u5b9a\u8981\u89e3\u9664\u5b89\u88c5\u201c" + name + "\u201d\u5417\uff1f"; } DialogResult dialogResult = MessageBox.Show(message, string.Empty, MessageBoxButtons.YesNo); if (dialogResult.Equals(DialogResult.Yes)) { bool result = callback.unloadSignedModuleAtIndex(index); if (result) { string title = "Successfully unloaded the plugin!"; if (locale.Equals("zh-TW")) { title = "\u6210\u529f\u89e3\u9664\u5b89\u88dd"; } else if (locale.Equals("zh-CN")) { title = "\u6210\u529f\u89e3\u9664\u5b89\u88c5"; } message = "Since your software is changed, we have to quit the preference program"; if (locale.Equals("zh-TW")) { message = "\u56e0\u70ba\u60a8\u7684\u8f38\u5165\u6cd5\u7cfb\u7d71\u8a2d\u5b9a\u5df2\u7d93\u6539\u8b8a\uff0c\u6211\u5011\u73fe\u5728\u5fc5\u9808\u95dc\u9589\u504f\u597d\u8a2d\u5b9a\u5de5\u5177\u3002"; } else if (locale.Equals("zh-CN")) { message = "\u56e0\u4e3a\u60a8\u7684\u8f93\u5165\u6cd5\u7cfb\u7edf\u8bbe\u5b9a\u5df2\u7ecf\u6539\u53d8\uff0c\u6211\u4eec\u73b0\u5728\u5fc5\u987b\u5173\u95ed\u504f\u597d\u8bbe\u5b9a\u5de5\u5177\u3002"; } MessageBox.Show(message, title); Application.Exit(); } else { string title = "Faild to unload this plugin!"; if (locale.Equals("zh-TW")) { title = "\u7121\u6cd5\u89e3\u9664\u5b89\u88dd\u9019\u500b\u5916\u639b\u7a0b\u5f0f\uff01"; } else if (locale.Equals("zh-CN")) { title = "\u65e0\u6cd5\u89e3\u9664\u5b89\u88c5\u8fd9\u4e2a\u63d2\u4ef6\uff01"; } message = "You may need System Administrator permission."; if (locale.Equals("zh-TW")) { message = "\u5982\u679c\u5728 Windows Vista \u4e0b\uff0c\u60a8\u9700\u8981\u7cfb\u7d71\u7ba1\u7406\u54e1\u6b0a\u9650\uff0c\u624d\u80fd\u522a\u9664\u5916\u639b\u7a0b\u5f0f\u3002"; } else if (locale.Equals("zh-CN")) { message = "\u5982\u679c\u5728 Windows Vista \u4e0b\uff0c\u60a8\u9700\u8981\u7cfb\u7edf\u7ba1\u7406\u5458\u6743\u9650\uff0c\u624d\u80fd\u5220\u9664\u63d2\u4ef6\u3002"; } MessageBox.Show(message, title); } } } }
/// <summary> /// Initialize the state of the user interface by the /// saved preference. /// </summary> private void InitUI() { string buffer; this.m_generalDictionary.TryGetValue("ShouldUseTransparentStatusBar", out buffer); if (buffer == "true") { this.u_transparentStatusBarCheckBox.Checked = true; } else { this.u_transparentStatusBarCheckBox.Checked = false; } this.m_generalDictionary.TryGetValue("ShouldUseSystemTray", out buffer); if (buffer == "true") { this.u_minimizeToSystemTrayCheckBox.Checked = true; } else { this.u_minimizeToSystemTrayCheckBox.Checked = false; } this.m_generalDictionary.TryGetValue("KeyboardFormShouldFollowCursor", out buffer); if (buffer == "true") { this.u_chkKeyboardFormShouldFollowCursor.Checked = true; } else { this.u_chkKeyboardFormShouldFollowCursor.Checked = false; } this.m_generalDictionary.TryGetValue("HighlightColor", out buffer); if (buffer == "Green") { this.u_highlightColorComboBox.SelectedIndex = 1; } else if (buffer == "Yellow") { this.u_highlightColorComboBox.SelectedIndex = 2; } else if (buffer == "Red") { this.u_highlightColorComboBox.SelectedIndex = 3; } else if (buffer.StartsWith("Color ")) { this.u_highlightColorComboBox.SelectedIndex = 4; } else { this.u_highlightColorComboBox.SelectedIndex = 0; } this.m_generalDictionary.TryGetValue("BackgroundColor", out buffer); if (buffer == "White") { this.u_backgroundColorComboBox.SelectedIndex = 1; } else if (buffer.StartsWith("Color ")) { this.u_backgroundColorComboBox.SelectedIndex = 2; } else { this.u_backgroundColorComboBox.SelectedIndex = 0; } this.m_generalDictionary.TryGetValue("TextColor", out buffer); if (buffer == "Black") { this.u_textColorComboBox.SelectedIndex = 1; } else if (buffer.StartsWith("Color ")) { this.u_textColorComboBox.SelectedIndex = 2; } else { this.u_textColorComboBox.SelectedIndex = 0; } this.m_generalDictionary.TryGetValue("BackgroundPattern", out buffer); if (buffer == "true") { this.u_backgroundPatternCheckBox.Checked = true; } else { this.u_backgroundPatternCheckBox.Checked = false; } this.m_generalDictionary.TryGetValue("ShouldPlaySoundOnTypingError", out buffer); if (buffer == "true") { this.u_beepCheckBox.Checked = true; } else { this.u_beepCheckBox.Checked = false; } this.m_generalDictionary.TryGetValue("SoundFilename", out buffer); // @zonble // You know what? The information of the media path // (C:\Windows\Media is restored in registry, // and there is no better way to obtain this information! #region Get the media file path. if (IsVistaOrLater) { try { RegistryKey registryKey = Registry.LocalMachine; registryKey = registryKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion", false); if (registryKey != null) { string MediaPathUnexpanded = registryKey.GetValue("MediaPathUnexpanded").ToString(); m_mediaPath = Environment.ExpandEnvironmentVariables(MediaPathUnexpanded); } } catch { } } else if (IsXp) { try { RegistryKey registryKey = Registry.LocalMachine; registryKey = registryKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion", false); if (registryKey != null) { m_mediaPath = registryKey.GetValue("MediaPath").ToString(); } } catch { } } #endregion #region Set the sound list. if (Directory.Exists(m_mediaPath)) { DirectoryInfo dirInfo = new DirectoryInfo(m_mediaPath); FileInfo[] fileInfo = dirInfo.GetFiles("*.wav"); if (fileInfo.Length > 0) { foreach (FileInfo f in fileInfo) { string name = f.Name; u_soundListComboBox.Items.Add(f); if (buffer != "Default") { if (buffer == f.FullName) { this.u_soundListComboBox.Text = name; } } } } else { this.u_radioCustomizedSound.Enabled = false; this.u_soundListComboBox.Enabled = false; this.u_radioDefaultSound.Checked = true; } } else { this.u_radioCustomizedSound.Enabled = false; this.u_soundListComboBox.Enabled = false; this.u_radioDefaultSound.Checked = true; } if (buffer == "Default" || buffer.Length == 0) { this.u_radioDefaultSound.Checked = true; } else { this.u_radioCustomizedSound.Checked = true; } #endregion this.u_pluginComboBox.Enabled = false; this.u_removePluginButton.Enabled = false; PreferenceConnector callback = PreferenceConnector.SharedInstance; if (callback != null) { int count = callback.numberOfUnloadableSignedModules(); if (count > 0) { this.u_pluginComboBox.Enabled = true; for (int i = 0; i < count; i++) { string name = callback.localizedNameOfUnloadableSignedModulesAtIndex(i); this.u_pluginComboBox.Items.Add(name); } } } }
void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { try { if (e.Error.Message.Length > 0) { this.m_isFailed = true; } } catch { } string locale = CultureInfo.CurrentCulture.Name; PreferenceConnector callback = PreferenceConnector.SharedInstance; if (callback == null) { if (locale == "zh-TW") { this.u_labelTitle.Text = "\u767c\u751f\u4e0d\u77e5\u540d\u7684\u932f\u8aa4"; } else { this.u_labelTitle.Text = "Unknown errors happened."; } return; } bool valid = callback.validateFile(m_ActionFilename, m_SignatureFilename); if (valid == false) { if (locale == "zh-TW") { this.u_labelTitle.Text = "\u60a8\u4e0b\u8f09\u7684\u6a94\u6848\u5df2\u7d93\u640d\u6bc0\uff0c\u7121\u6cd5\u7e7c\u7e8c\u5b89\u88dd\u3002"; } else { this.u_labelTitle.Text = "The downloaded file is corruped, unable to continue installation."; } return; } this.u_progressBar.Value = 100; this.u_labelDownload.Visible = false; if (this.m_isFailed == true) { string error; if (locale == "zh-TW") { error = "\u4e0d\u77e5\u540d\u7684\u932f\u8aa4"; } else if (locale == "zh-CN") { error = "\u4e0d\u8be6\u7684\u9519\u8bef"; } else { error = "Unknown error."; } try { error = e.Error.Message; } catch {} if (locale == "zh-TW") { this.u_labelTitle.Text = "\u4e0b\u8f09\u5931\u6557\u3002\u539f\u56e0\u662f\uff1a " + error; } else if (locale == "zh-CN") { this.u_labelTitle.Text = "\u4e0b\u8f7d\u5931\u8d25\uff0c\u539f\u56e0\u662f\uff1a " + error; } else { this.u_labelTitle.Text = "Download failed. Error: " + error; } this.u_btnRetry.Show(); } else { this.m_isComplete = true; if (locale == "zh-TW") { this.u_Btn.Text = "\u7a0d\u5f8c(&L)"; this.u_labelTitle.Text = "\u6210\u529f\u5b8c\u6210\u4e0b\u8f09\uff0c\u8acb\u554f\u60a8\u8981\u7acb\u523b\u5b89\u88dd\u66f4\u65b0\uff0c\u9084\u662f\u7a0d\u5f8c\u5728\u91cd\u65b0\u958b\u6a5f\u4e4b\u5f8c\u5b89\u88dd\uff1f"; } else if (locale == "zh-CN") { this.u_Btn.Text = "\u7a0d\u540e(&L)"; this.u_labelTitle.Text = "\u6210\u529f\u5b8c\u6210\u4e0b\u8f7d\uff0c\u8bf7\u95ee\u60a8\u8981\u7acb\u523b\u5b89\u88c5\u66f4\u65b0\uff0c\u8fd8\u662f\u7a0d\u540e\u5728\u91cd\u65b0\u542f\u52a8\u540e\u5b89\u88c5\uff1f"; } else { this.u_Btn.Text = "&Later"; this.u_labelTitle.Text = "Download complete. Do you want to install now, or installer later after reboot?"; } this.u_btnInstall.Show(); } }