/// <summary> /// Shows the form as a modal dialog and displays a software update to the user. /// </summary> /// <param name="updateInfo">Software update info to display.</param> /// <param name="owner">Window owner. Can be <c>null</c>.</param> /// <returns><c>true</c> if the the user asked to ignore this update.</returns> public bool ShowUpdate(SoftwareUpdateInfo updateInfo, IWin32Window owner) { if (updateInfo == null) { throw new ArgumentNullException(nameof(updateInfo)); } // Initialize our controls. if (owner == null) { StartPosition = FormStartPosition.CenterScreen; } SoftwareUpdateTitleLbl.Text = updateInfo.Name; updateUrl = updateInfo.Url; SoftwareUpdatesTooltip.SetToolTip(SoftwareUpdateUrlLinkLbl, updateUrl); if (updateInfo.ReleaseNotes != null && updateInfo.ReleaseNotes.Count != 0) { string innerHtml; if (updateInfo.ReleaseNotes.Count == 1) { innerHtml = updateInfo.ReleaseNotes[0]; } else { StringBuilder htmlBuilder = new StringBuilder(); htmlBuilder.Append("<ul>"); foreach (string note in updateInfo.ReleaseNotes) { htmlBuilder.AppendFormat("<li>{0}</li>", note); } htmlBuilder.Append("</ul>"); innerHtml = htmlBuilder.ToString(); } ReleaseNotesWebBrowser.DocumentText = string.Format(CultureInfo.InvariantCulture, ReleaseNotesHTMLFormat, innerHtml); } // Display the form. ignoreUpdate = false; ShowDialog(owner); // Return whether user ignored the update. return(ignoreUpdate); }
/// <summary> /// Shows the form as a modal dialog and displays a software update to the user. /// </summary> /// <param name="updateInfo">Software update info to display.</param> /// <param name="owner">Window owner. Can be <c>null</c>.</param> /// <returns><c>true</c> if the the user asked to ignore this update.</returns> public bool ShowUpdate(SoftwareUpdateInfo updateInfo, IWin32Window owner) { Debug.Assert(updateInfo != null); // Initialize our controls. if (owner == null) { this.StartPosition = FormStartPosition.CenterScreen; } SoftwareUpdateTitleLbl.Text = updateInfo.Name; updateUrl = updateInfo.Url; SoftwareUpdatesTooltip.SetToolTip(SoftwareUpdateUrlLinkLbl, updateUrl); if (updateInfo.ReleaseNotes != null && updateInfo.ReleaseNotes.Length != 0) { string innerHtml; if (updateInfo.ReleaseNotes.Length == 1) { innerHtml = updateInfo.ReleaseNotes[0]; } else { StringBuilder htmlBuilder = new StringBuilder(); htmlBuilder.Append("<ul>"); foreach (string note in updateInfo.ReleaseNotes) { htmlBuilder.AppendFormat("<li>{0}</li>", note); } htmlBuilder.Append("</ul>"); innerHtml = htmlBuilder.ToString(); } ReleaseNotesWebBrowser.DocumentText = String.Format(RELEASE_NOTES_HTML_FORMAT, innerHtml); } // Display the form. ignoreUpdate = false; ShowDialog(owner); // Return whether user ignored the update. return(ignoreUpdate); }
private void updateWorker(DoWorkEventArgs workEventArgs) { try { Symbol.RFID3.UpdateStatus updateStatus; if (m_AppForm.m_ReaderType == READER_TYPE.MC) { if (update_CB.SelectedIndex == 0) { // Do Radio Firmware Update m_AppForm.m_ReaderMgmt.RadioFirmwareUpdate.Update(location_TB.Text); } else { // Do Radio Config Update m_AppForm.m_ReaderMgmt.RadioConfigUpdate.Update(location_TB.Text); } } else { SoftwareUpdateInfo info = new SoftwareUpdateInfo( location_TB.Text, username_TB.Text, password_TB.Text); m_AppForm.m_ReaderMgmt.SoftwareUpdate.Update(info); } uint updatePercent = 0; while (updatePercent < 100) { try { if (this.m_AppForm.m_ReaderType == READER_TYPE.MC) { if (this.update_CB.SelectedIndex == 1) { updateStatus = m_AppForm.m_ReaderMgmt.RadioFirmwareUpdate.UpdateStatus; } else { updateStatus = m_AppForm.m_ReaderMgmt.RadioConfigUpdate.UpdateStatus; } } else { updateStatus = m_AppForm.m_ReaderMgmt.SoftwareUpdate.UpdateStatus; } updatePercent = updateStatus.Percentage; m_percentage = (int)updatePercent; m_updateDesc = updateStatus.UpdateInfo; DisplayUpdateStatus(); Thread.Sleep(1000); } catch (InvalidOperationException ioe) { workEventArgs.Result = "UpdateStatus failed " + ioe.ToString(); break; } catch (InvalidUsageException iue) { workEventArgs.Result = "UpdateStatus failed " + iue.ToString(); break; } catch (OperationFailureException ofe) { workEventArgs.Result = ofe.StatusDescription; break; } catch (Exception ex) { workEventArgs.Result = ex.Message.ToString(); break; } } if (updatePercent == 100) { workEventArgs.Result = "Update Completed"; } } catch (OperationFailureException ex) { workEventArgs.Result = ex.VendorMessage; } }