public string GetAdCount(IRibbonControl control) { var journal = control.Journal(); return journal == null ? "(N/A)" : journal.Ads.Count.ToString(CultureInfo.CurrentCulture); }
public string GetWomensSeats(IRibbonControl control) { if (!Program.WasInitialized) return "(N/A)"; var journal = control.Journal(); if (journal == null) return "(N/A)"; return Program.Current.Statistics[journal.Year].WomensSeats.ToString("n0", CultureInfo.CurrentCulture); }
public bool IsJournal(IRibbonControl control) { return control.Journal() != null; }
public string GetTotalPledged(IRibbonControl control) { if (!Program.WasInitialized) return "(N/A)"; var journal = control.Journal(); if (journal == null) return "(N/A)"; return Program.Current.Statistics[journal.Year].TotalPledged.ToString("c", CultureInfo.CurrentCulture); }
public void InsertAd(IRibbonControl control, string selectedId, int selectedIndex) { var jp = control.Journal(); if (!jp.ConfirmModification()) return; var typeName = selectedId.Substring("Insert".Length); jp.CreateAd(Names.AdTypes.First(t => t.Name == typeName)).Shape.ForceSelect(); }
public void DeleteAd(IRibbonControl control) { string message; var ad = control.CurrentAd(); if (ad == null) return; if (!control.Journal().ConfirmModification()) return; if (ad.Row.Payments.Any()) message = String.Format(CultureInfo.CurrentCulture, "Are you sure you want to delete this ad?\r\nThe ad's {0:c} in payments will not be deleted.\r\nYou should probably delete them first.", ad.Row.Payments.Sum(p => p.Amount)); else if (ad.Row.Pledges.Any()) message = String.Format(CultureInfo.CurrentCulture, "Are you sure you want to delete this ad?\r\nThe ad's {0:c} in pledges will not be deleted.\r\nYou should probably delete them first.", ad.Row.Pledges.Sum(p => p.Amount)); else message = "Are you sure you want to delete this ad?"; if (Dialog.Warn(message)) ad.Delete(); }
public void SavePdfTypes(IRibbonControl control) { using (var dialog = new FolderBrowserDialog { Description = "Export PDFs by ad type", ShowNewFolderButton = true }) { if (dialog.ShowDialog(new ArbitraryWindow((IntPtr)control.Window().HWND)) == DialogResult.Cancel) return; var ranges = new List<PageRange>(); var presentation = control.Journal().Presentation; for (int i = 1; i <= presentation.Slides.Count; i++) { var currentType = presentation.Slides[i].CustomLayout.Name; if (ranges.Count == 0 || ranges.Last().Type != currentType) ranges.Add(new PageRange { Type = currentType, Start = i, End = i }); else ranges.Last().End = i; } for (int i = 0; i < ranges.Count; i++) { var range = ranges[i]; presentation.ExportAsFixedFormat( Path.Combine(dialog.SelectedPath, $"{i:00} - {range.Type} " + (range.Start == range.End ? $"(Page {range.Start}).pdf" : $"(Pages {range.Start} - {range.End}).pdf")), PpFixedFormatType.ppFixedFormatTypePDF, PpFixedFormatIntent.ppFixedFormatIntentPrint, PrintRange: presentation.PrintOptions.Ranges.Add(range.Start, range.End), RangeType: PpPrintRangeType.ppPrintSlideRange); } } }
public void SavePdf(IRibbonControl control) { using (var dialog = new SaveFileDialog { Filter = "PDF Files (*.pdf)|*.pdf", FileName = Path.ChangeExtension(control.Journal().Presentation.FullName, ".pdf"), Title = "Export PDF" }) { if (dialog.ShowDialog(new ArbitraryWindow((IntPtr)control.Window().HWND)) == DialogResult.Cancel) return; control.Journal().Presentation.ExportAsFixedFormat(dialog.FileName, PpFixedFormatType.ppFixedFormatTypePDF, PpFixedFormatIntent.ppFixedFormatIntentPrint, RangeType: control.Id == "SavePdfSlide" ? PpPrintRangeType.ppPrintCurrent : PpPrintRangeType.ppPrintAll); } }
public void ShowImportForm(IRibbonControl control) { if (!control.Journal().ConfirmModification()) return; AppFramework.LoadTables(EmailAddress.Schema, ImportedPayment.Schema); Program.Current.MefContainer.Value .GetExport<Billing.PaymentImport.ImportForm>() .SetPledgeTypes(Names.JournalPledgeType) .RequirePledge() .SetCreationCallback(control.Journal().ImportAd) .SetJournalMode(control.Journal().Year) .Show(new ArbitraryWindow((IntPtr)control.Window().HWND)); }
public void ShowGrid(IRibbonControl control) { new Forms.AdsGridForm(control.Journal()).Show(Globals.ThisAddIn.Application.Window()); }
public void ShowCharts(IRibbonControl control) { new Forms.ChartsForm(control.Journal().Year).Show(Globals.ThisAddIn.Application.Window()); }
public void ShowWarningsForm(IRibbonControl control) { new Forms.WarningsForm(control.Journal()).Show(Globals.ThisAddIn.Application.Window()); }
public void ShowDetailPane(IRibbonControl control) { var window = control.Window(); var jp = control.Journal(); // CustomTaskPanes cannot be reused; I need to create a new one. Globals.ThisAddIn.CustomTaskPanes.Add(new AdPane(jp), "Ad Details", jp.Presentation.Windows[1]).Visible = true; }