/// <summary>Hides a single update.</summary> /// <param name="hiddenUpdate">The update to hide.</param> public void HideUpdate(Suh hiddenUpdate) { Collection <Suh> hidden = (File.Exists(App.HiddenFile) ? Utilities.Deserialize <Collection <Suh> >(App.HiddenFile) : new Collection <Suh>()) ?? new Collection <Suh>(); hidden.Add(hiddenUpdate); Utilities.Serialize(hidden, App.HiddenFile); }
/// <summary>Shows or Hides the selected update.</summary> /// <param name="sender">The object that called the event.</param> /// <param name="e">The <c>System.Windows.RoutedEventArgs</c> instance containing the event data.</param> void ShowOrHideUpdate(object sender, RoutedEventArgs e) { int appIndex = this.appIndices[this.lvUpdates.SelectedIndex]; var update = this.lvUpdates.SelectedItem as Update; if (update == null) { return; } var hnh = new Suh(update.Name, Core.Applications[appIndex].AppInfo.Publisher, update.Description) { HelpUrl = Core.Applications[appIndex].AppInfo.HelpUrl, InfoUrl = update.InfoUrl, AppUrl = Core.Applications[appIndex].AppInfo.AppUrl, ReleaseDate = update.ReleaseDate, Status = UpdateStatus.Hidden, UpdateSize = Core.GetUpdateSize(update.Files), Importance = update.Importance, }; if (!update.Hidden) { if (WcfService.HideUpdate(hnh)) { update.Hidden = true; update.Selected = false; } } else { if (WcfService.ShowUpdate(hnh)) { update.Hidden = false; } } }
/// <summary>Shows the window and displays the update information.</summary> /// <param name="updateInfo">The update information to display.</param> internal void ShowDialog(Suh updateInfo) { this.DataContext = updateInfo; this.helpUrl = updateInfo.HelpUrl; this.infoUrl = updateInfo.InfoUrl; string updateStatus = updateInfo.Status == UpdateStatus.Failed ? Properties.Resources.Failed.ToLower(CultureInfo.CurrentCulture) : Properties.Resources.Successful.ToLower(CultureInfo.CurrentCulture); this.tbStatus.Text = updateInfo.Status == UpdateStatus.Hidden ? string.Format( CultureInfo.CurrentCulture, Properties.Resources.DownloadSize, Utilities.ConvertFileSize(updateInfo.UpdateSize)) : string.Format( CultureInfo.CurrentCulture, Properties.Resources.InstallationStatus, updateStatus, updateInfo.InstallDate); this.ShowDialog(); return; }
/// <summary>The update to show and remove from hidden updates.</summary> /// <param name="hiddenUpdate">The hidden update to show.</param> public void ShowUpdate(Suh hiddenUpdate) { if (hiddenUpdate == null) { throw new ArgumentNullException("hiddenUpdate"); } Collection <Suh> show = File.Exists(App.HiddenFile) ? Utilities.Deserialize <Collection <Suh> >(App.HiddenFile) : new Collection <Suh>(); if (show == null) { File.Delete(App.HiddenFile); return; } for (int x = 0; x < show.Count; x++) { if (show[x].Importance == hiddenUpdate.Importance && show[x].Status == hiddenUpdate.Status && show[x].UpdateSize == hiddenUpdate.UpdateSize && show[x].HelpUrl == hiddenUpdate.HelpUrl && show[x].InfoUrl == hiddenUpdate.InfoUrl && show[x].AppUrl == hiddenUpdate.AppUrl && show[x].Description[0].Value == hiddenUpdate.Description[0].Value && show[x].Name[0].Value == hiddenUpdate.Name[0].Value) { show.RemoveAt(x); } } if (show.Count == 0) { File.Delete(App.HiddenFile); } else { Utilities.Serialize(show, App.HiddenFile); } }
/// <summary>The update to show and remove from hidden updates.</summary> /// <param name="hiddenUpdate">The hidden update to show.</param> public void ShowUpdate(Suh hiddenUpdate) { if (hiddenUpdate == null) { throw new ArgumentNullException("hiddenUpdate"); } Collection<Suh> show = File.Exists(App.HiddenFile) ? Utilities.Deserialize<Collection<Suh>>(App.HiddenFile) : new Collection<Suh>(); if (show == null) { File.Delete(App.HiddenFile); return; } for (int x = 0; x < show.Count; x++) { if (show[x].Importance == hiddenUpdate.Importance && show[x].Status == hiddenUpdate.Status && show[x].UpdateSize == hiddenUpdate.UpdateSize && show[x].HelpUrl == hiddenUpdate.HelpUrl && show[x].InfoUrl == hiddenUpdate.InfoUrl && show[x].AppUrl == hiddenUpdate.AppUrl && show[x].Description[0].Value == hiddenUpdate.Description[0].Value && show[x].Name[0].Value == hiddenUpdate.Name[0].Value) { show.RemoveAt(x); } } if (show.Count == 0) { File.Delete(App.HiddenFile); } else { Utilities.Serialize(show, App.HiddenFile); } }
/// <summary>Hides a single update.</summary> /// <param name="hiddenUpdate">The update to hide.</param> public void HideUpdate(Suh hiddenUpdate) { Collection<Suh> hidden = (File.Exists(App.HiddenFile) ? Utilities.Deserialize<Collection<Suh>>(App.HiddenFile) : new Collection<Suh>()) ?? new Collection<Suh>(); hidden.Add(hiddenUpdate); Utilities.Serialize(hidden, App.HiddenFile); }