protected void AdjustForLayoutCapabilities(PrintingOptions po) { if (po == null) { throw new ArgumentNullException(nameof(po)); } PrintLayout pl = PrintLayout.LayoutForType(po.Layout); pnlIncludeImages.Visible = pl.SupportsImages; if (!pl.SupportsImages) { ckIncludeImages.Checked = m_options.IncludeImages = false; } pnlOptionalColumns.Visible = pl.SupportsOptionalColumns; }
protected void RefreshLogbookData() { MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name); PrintingOptions printingOptions = PrintOptions1.Options; mvLayouts.ActiveViewIndex = (int)printingOptions.Layout; List <LogbookEntryDisplay> lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntry.QueryCommand(mfbSearchForm1.Restriction, fAsc: true), pf.UserName, string.Empty, SortDirection.Ascending, pf.UsesHHMM, pf.UsesUTCDateOfFlight); IPrintingTemplate pt = ActiveTemplate; PrintLayout pl = PrintLayout.LayoutForType(printingOptions.Layout, CurrentUser); bool fCanIncludeImages = pl.SupportsImages; List <int> lstPropsToExclude = new List <int>(printingOptions.ExcludedPropertyIDs); string szPropSeparator = printingOptions.PropertySeparatorText; // set up properties per flight, and compute rough lineheight foreach (LogbookEntryDisplay led in lstFlights) { // Fix up properties according to the printing options List <CustomFlightProperty> lstProps = new List <CustomFlightProperty>(led.CustomProperties); lstProps.RemoveAll(cfp => lstPropsToExclude.Contains(cfp.PropTypeID)); led.CustomProperties = lstProps.ToArray(); led.CustPropertyDisplay = CustomFlightProperty.PropListDisplay(lstProps, pf.UsesHHMM, szPropSeparator); if (printingOptions.IncludeImages) { led.PopulateImages(true); } led.RowHeight = pl.RowHeight(led); } Master.PrintingCSS = pl.CSSPath.ToAbsoluteURL(Request).ToString(); pt.BindPages(LogbookPrintedPage.Paginate(lstFlights, printingOptions.FlightsPerPage, printingOptions.OptionalColumns), CurrentUser, printingOptions.IncludeImages, !SuppressFooter, printingOptions.OptionalColumns); pnlResults.Visible = true; }
protected void RefreshLogbookData() { MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name); PrintingOptions printingOptions = PrintOptions1.Options; mvLayouts.ActiveViewIndex = (int)printingOptions.Layout; List <LogbookEntryDisplay> lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntry.QueryCommand(mfbSearchForm1.Restriction, fAsc: true), pf.UserName, string.Empty, SortDirection.Ascending, pf.UsesHHMM, pf.UsesUTCDateOfFlight); IPrintingTemplate pt = ActiveTemplate; PrintLayout pl = PrintLayout.LayoutForType(printingOptions.Layout, CurrentUser); bool fCanIncludeImages = pl.SupportsImages; // Exclude both excluded properties and properties that have been moved to their own columns HashSet <int> lstPropsToExclude = new HashSet <int>(printingOptions.ExcludedPropertyIDs); HashSet <int> lstPropsInOwnColumns = new HashSet <int>(); foreach (OptionalColumn oc in printingOptions.OptionalColumns) { if (oc.ColumnType == OptionalColumnType.CustomProp) { lstPropsInOwnColumns.Add(oc.IDPropType); } } string szPropSeparator = printingOptions.PropertySeparatorText; // set up properties per flight, and compute rough lineheight foreach (LogbookEntryDisplay led in lstFlights) { // Fix up properties according to the printing options List <CustomFlightProperty> lstProps = new List <CustomFlightProperty>(led.CustomProperties); // And fix up model as well. switch (printingOptions.DisplayMode) { case PrintingOptions.ModelDisplayMode.Full: break; case PrintingOptions.ModelDisplayMode.Short: led.ModelDisplay = led.ShortModelName; break; case PrintingOptions.ModelDisplayMode.ICAO: led.ModelDisplay = led.FamilyName; break; } // Remove from the total property set all explicitly excluded properties... lstProps.RemoveAll(cfp => lstPropsToExclude.Contains(cfp.PropTypeID)); // ...and then additionally exclude from the display any that's in its own column to avoid redundancy. lstProps.RemoveAll(cfp => lstPropsInOwnColumns.Contains(cfp.PropTypeID)); led.CustPropertyDisplay = CustomFlightProperty.PropListDisplay(lstProps, pf.UsesHHMM, szPropSeparator); if (printingOptions.IncludeImages) { led.PopulateImages(true); } if (!printingOptions.IncludeSignatures) { led.CFISignatureState = LogbookEntryBase.SignatureState.None; } led.RowHeight = pl.RowHeight(led); } Master.PrintingCSS = pl.CSSPath.ToAbsoluteURL(Request).ToString(); pt.BindPages(LogbookPrintedPage.Paginate(lstFlights, printingOptions), CurrentUser, printingOptions, !SuppressFooter); pnlResults.Visible = true; }