private void checkBoxCopySubject_Checked(object sender, RoutedEventArgs e) { if (this.initializing) { return; } StaticHelper.SetApplicationSetting("CopySubjectToClipboard", this.checkBoxCopySubject.IsChecked.ToString()); }
private void checkBoxAutoUpdate_Unchecked(object sender, RoutedEventArgs e) { if (this.initializing) { return; } StaticHelper.SetApplicationSetting("AutoUpdate", this.checkBoxAutoUpdate.IsChecked.ToString()); }
private void checkBoxCallMailto_Checked(object sender, RoutedEventArgs e) { if (this.initializing) { return; } StaticHelper.SetApplicationSetting("CallMailtoProtocol", this.checkBoxCallMailto.IsChecked.ToString()); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { StaticHelper.SetApplicationSetting("MasterEmailAccount", this.textBoxMasterEmailAccount.Text); }
public static bool CheckForMenuXmlUpdates() { LogMessage(MessageType.Info, "Checking for Menu content updates"); try { DirectoryInfo installationPath = GetInstallationPath(); XmlSerializer deserializer = new XmlSerializer(typeof(ButtonConfiguration)); // Iterate over Add-ins found DirectoryInfo buttonRoot = new DirectoryInfo(Path.Combine(installationPath.FullName, "Buttons")); DirectoryInfo[] buttons = buttonRoot.GetDirectories(); foreach (FileInfo file in buttons.Select(button => new FileInfo(Path.Combine(button.FullName, "config.xml")))) { // open the configuration file for the button ButtonConfiguration buttonConfig; using (FileStream buttonStream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read)) { buttonConfig = (ButtonConfiguration)deserializer.Deserialize(buttonStream); } // if an onlineUrl is present, then we look for an update if (!string.IsNullOrEmpty(buttonConfig.onlineUrl)) { string currentMenu; using (TextReader tr = new StreamReader(Path.Combine(file.DirectoryName, @"button.xml"))) { currentMenu = tr.ReadToEnd(); } using (var client = GetPreconfiguredWebClient()) { // check if we need to update the whole button or just look for structure updates. if (!UpgradeButton(buttonConfig, file)) { Stream myStream = client.OpenRead(buttonConfig.onlineUrl); if (myStream != null) { using (StreamReader sr = new StreamReader(myStream)) { string latestMenu = sr.ReadToEnd(); if (latestMenu != currentMenu) { FileInfo f = new FileInfo(Path.Combine(file.DirectoryName, @"button.xml")); // First make sure the file is writable. FileAttributes fileAttributes = File.GetAttributes(f.FullName); // If readonly attribute is set, reset it. if ((fileAttributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { File.SetAttributes(f.FullName, fileAttributes ^ FileAttributes.ReadOnly); } using (TextWriter tw = new StreamWriter(f.FullName)) { LogMessage(MessageType.Info, "Updating menu with online updates"); tw.Write(latestMenu); } } } } } } } } StaticHelper.SetApplicationSetting("LastUpdateCheckDate", DateTime.Now.ToString()); } catch (Exception ex) { LogMessage(MessageType.Error, "Update check failed." + ex.Message); return(false); } return(true); }