internal static void UpdateStats(IDownsizeResponse downsizeResponse = null) { try { _settings.Stat_UsageCounter++; if (downsizeResponse != null) { _settings.Stat_LayoutsDeleted += Convert.ToUInt64(downsizeResponse.CustomLayoutsDeleted); _settings.Stat_MastersDeleted += Convert.ToUInt64(downsizeResponse.MasterSlidesDeleted); } if (!_settings.Coffee_AlreadyBought && _settings.Coffee_HiddenSinceCounter >= Fickles.CoffeeRevealThreshold * _settings.Coffee_HideCounter) { _settings.Ribbon_ShowCoffeeButton = true; _settings.Coffee_HiddenSinceCounter = 0; } _settings.Save(); } catch (Exception) { _settings.Reset(); } }
public async Task <IDownsizeResponse> Downsize(IDownsizePotential potential, IDownsizeResponse downsizeResponse, StatsUpdater updateStat = null) { try { foreach (CustomLayout layout in potential.UnusedLayouts) { layout.Delete(); downsizeResponse.CustomLayoutsDeleted++; } foreach (Master master in potential.UnusedMasters) { master.Delete(); downsizeResponse.MasterSlidesDeleted++; } downsizeResponse.IsSuccess = true; downsizeResponse.ResultMessage = Constants.Messages.SlideMasterDonwsizeSuccess; } catch (Exception e) { downsizeResponse.Exception = e; downsizeResponse.ResultMessage = Constants.Messages.SlideMasterDonwsizeFailed; } updateStat?.Invoke(downsizeResponse); return(await Task.FromResult(downsizeResponse).ConfigureAwait(false)); }
internal static async Task ReportDownsizeStatus(IDownsizeResponse response) { var removedAny = response.CustomLayoutsDeleted > 0 || response.MasterSlidesDeleted > 0; var msgBoxIcon = MessageBoxIcon.Exclamation; if (response.IsSuccess && removedAny) { msgBoxIcon = MessageBoxIcon.Information; } else if (!response.IsSuccess) { msgBoxIcon = MessageBoxIcon.Error; } await Task.FromResult(MessageBox.Show(response.DownsizeResult, caption, MessageBoxButtons.OK, msgBoxIcon)).ConfigureAwait(false); }