private void OKBtn_Click(object sender, EventArgs e) { try { bool updatesAvailable = false; foreach (ListViewItem it in listView1.Items) { GXAddIn addIn = it.Tag as GXAddIn; if (addIn.State == AddInStates.Available || addIn.State == AddInStates.Update) { updatesAvailable = true; } //If user has select items to download do not notify. else if (addIn.State == AddInStates.Download) { updatesAvailable = false; break; } } DialogResult res = DialogResult.Yes; if (updatesAvailable) { res = MessageBox.Show(this, Resources.NewProtocolsDownloadTxt, Resources.NewProtocolsAvailableTxt, MessageBoxButtons.YesNoCancel); if (res != DialogResult.Yes) { this.DialogResult = DialogResult.OK; this.Close(); return; } } //Add downloadable items to the list or they are not shown anymore. foreach (ListViewItem it in listView1.Items) { GXAddIn addIn = it.Tag as GXAddIn; if (addIn.State == AddInStates.Available || addIn.State == AddInStates.Download) { if (addIn.State == AddInStates.Available) { if (res == DialogResult.Yes) { addIn.State = AddInStates.Download; } else if (res == DialogResult.No) { addIn.State = AddInStates.Disabled; } } //Add new Addins. bool exists = false; foreach (var a in AddIns) { if (a.Name == addIn.Name) { exists = true; break; } } if (!exists) { AddIns.Add(addIn); } } } XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = System.Text.Encoding.UTF8; settings.CloseOutput = true; settings.CheckCharacters = false; string path = System.IO.Path.Combine(GXCommon.ProtocolAddInsPath, "updates.xml"); DataContractSerializer x = new DataContractSerializer(typeof(GXAddInList)); using (XmlWriter writer = XmlWriter.Create(path, settings)) { x.WriteObject(writer, AddIns); writer.Close(); } Gurux.Common.GXFileSystemSecurity.UpdateFileSecurity(path); GXUpdateChecker updater = new GXUpdateChecker(); updater.OnProgress += new GXUpdateChecker.ProgressEventHandler(updater_OnProgress); Status = updater.UpdateProtocols(); updater.UpdateApplications(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { GXCommon.ShowError(this, ex); } }