private void SetUpImagesForRow(LogbookEntryDisplay le, GridViewRow row) { // Bind to images. Controls_mfbImageList mfbIl = (Controls_mfbImageList)row.FindControl("mfbilFlights"); if (!SuppressImages) { // Flight images mfbIl.Key = le.FlightID.ToString(CultureInfo.InvariantCulture); mfbIl.Refresh(); if (!le.FlightImages.Any()) // populate images, so that flight coloring can work { foreach (MyFlightbook.Image.MFBImageInfo mfbii in mfbIl.Images.ImageArray) { le.FlightImages.Add(mfbii); } } // wire up images if (mfbIl.Images.ImageArray.Count > 0 || le.Videos.Count > 0) { row.FindControl("pnlImagesHover").Visible = true; } else { row.FindControl("pnlFlightImages").Visible = false; } Aircraft ac = AircraftForUser.Find(a => a.AircraftID == le.AircraftID); string szInstTypeDescription = ac == null ? string.Empty : AircraftInstance.ShortNameForInstanceType(ac.InstanceType); ((Label)row.FindControl("lblInstanceTypeDesc")).Text = szInstTypeDescription; // And aircraft // for efficiency, see if we've already done this tail number; re-use if already done if (!m_dictAircraftHoverIDs.ContainsKey(le.AircraftID)) { if (ac != null) { mfbilAircraft.DefaultImage = ac.DefaultImage; } mfbilAircraft.Key = le.AircraftID.ToString(CultureInfo.InvariantCulture); mfbilAircraft.Refresh(); // cache the attributes string - there's a bit of computation involved in it. string szAttributes = ((Label)row.FindControl("lblModelAttributes")).Text.EscapeHTML(); // and the image table. m_dictAircraftHoverIDs[le.AircraftID] = szInstTypeDescription + " " + szAttributes + mfbilAircraft.AsHTMLTable(); } row.FindControl("plcTail").Controls.Add(new LiteralControl(m_dictAircraftHoverIDs[le.AircraftID])); } }
public void gvFlightLogs_RowDataBound(Object sender, GridViewRowEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (e.Row.RowType == DataControlRowType.Footer) { int cCols = e.Row.Cells.Count; for (int i = cCols - 1; i >= 1; i--) { e.Row.Cells.RemoveAt(i); } e.Row.Cells[0].ColumnSpan = cCols; } else if (e.Row.RowType == DataControlRowType.Pager) { ((Label)e.Row.FindControl("lblNumFlights")).Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.NumberOfFlights, CachedData.Count()); } else if (e.Row.RowType == DataControlRowType.DataRow) { LogbookEntryDisplay le = (LogbookEntryDisplay)e.Row.DataItem; // Wire up the drop-menu. We have to do this here because it is an iNamingContainer and can't access the gridviewrow Controls_popmenu popup = (Controls_popmenu)e.Row.FindControl("popmenu1"); ((Controls_mfbMiniFacebook)popup.FindControl("mfbMiniFacebook")).FlightEntry = le; ((Controls_mfbTweetThis)popup.FindControl("mfbTweetThis")).FlightToTweet = le; ((LinkButton)popup.FindControl("lnkReverse")).CommandArgument = ((LinkButton)popup.FindControl("lnkClone")).CommandArgument = le.FlightID.ToString(CultureInfo.InvariantCulture); ((LinkButton)popup.FindControl("lnkSendFlight")).CommandArgument = le.FlightID.ToString(CultureInfo.InvariantCulture); ((HyperLink)popup.FindControl("lnkEditThisFlight")).NavigateUrl = EditPath(le.FlightID); HyperLink h = (HyperLink)popup.FindControl("lnkRequestSignature"); h.Visible = le.CanRequestSig; h.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/RequestSigs.aspx?id={0}", le.FlightID); // fix the ID of the delete button to prevent replay attacks string szDelID = String.Format(CultureInfo.InvariantCulture, "lnkDel{0}", le.FlightID); LinkButton lbDelete = (LinkButton)e.Row.FindControl("lnkDelete"); lbDelete.ID = szDelID; // If the host wants notifications of deletions, register full postback. if (ItemDeleted != null) { ScriptManager.GetCurrent(Page).RegisterPostBackControl(lbDelete); } ((AjaxControlToolkit.ConfirmButtonExtender)e.Row.FindControl("ConfirmButtonExtender1")).TargetControlID = szDelID; // Bind to images. Controls_mfbImageList mfbIl = (Controls_mfbImageList)e.Row.FindControl("mfbilFlights"); if (!SuppressImages) { // Flight images mfbIl.Key = le.FlightID.ToString(CultureInfo.InvariantCulture); mfbIl.Refresh(); // wire up images if (mfbIl.Images.ImageArray.Count > 0 || le.Videos.Count > 0) { e.Row.FindControl("pnlImagesHover").Visible = true; } else { e.Row.FindControl("pnlFlightImages").Visible = false; } Aircraft ac = AircraftForUser.Find(a => a.AircraftID == le.AircraftID); string szInstTypeDescription = ac == null ? string.Empty : AircraftInstance.ShortNameForInstanceType(ac.InstanceType); ((Label)e.Row.FindControl("lblInstanceTypeDesc")).Text = szInstTypeDescription; // And aircraft // for efficiency, see if we've already done this tail number; re-use if already done if (!m_dictAircraftHoverIDs.ContainsKey(le.AircraftID)) { if (ac != null) { mfbilAircraft.DefaultImage = ac.DefaultImage; } mfbilAircraft.Key = le.AircraftID.ToString(CultureInfo.InvariantCulture); mfbilAircraft.Refresh(); // cache the attributes string - there's a bit of computation involved in it. string szAttributes = ((Label)e.Row.FindControl("lblModelAttributes")).Text.EscapeHTML(); // and the image table. m_dictAircraftHoverIDs[le.AircraftID] = szInstTypeDescription + " " + szAttributes + mfbilAircraft.AsHTMLTable(); } e.Row.FindControl("plcTail").Controls.Add(new LiteralControl(m_dictAircraftHoverIDs[le.AircraftID])); } // Set style for the row HtmlGenericControl divDate = (HtmlGenericControl)e.Row.FindControl("divDateAndRoute"); switch (le.RowType) { case LogbookEntryDisplay.LogbookRowType.Flight: if (le.IsPageBreak) { e.Row.CssClass = e.Row.CssClass + " pageBreakRow"; } break; case LogbookEntryDisplay.LogbookRowType.RunningTotal: e.Row.CssClass = "runningTotalRow"; divDate.Visible = false; break; case LogbookEntryDisplay.LogbookRowType.Subtotal: e.Row.CssClass = (le.IsPageBreak) ? "subtotalRowPageBreak" : "subtotalRow"; divDate.Visible = false; break; } } }
public void gvFlightLogs_RowDataBound(Object sender, GridViewRowEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (e.Row.RowType == DataControlRowType.Footer) { int cCols = e.Row.Cells.Count; for (int i = cCols - 1; i >= 1; i--) { e.Row.Cells.RemoveAt(i); } e.Row.Cells[0].ColumnSpan = cCols; } else if (e.Row.RowType == DataControlRowType.DataRow) { LogbookEntryDisplay le = (LogbookEntryDisplay)e.Row.DataItem; // Wire up the drop-menu. We have to do this here because it is an iNamingContainer and can't access the gridviewrow Controls_mfbFlightContextMenu cm = (Controls_mfbFlightContextMenu)e.Row.FindControl("popmenu1").FindControl("mfbFlightContextMenu"); string szEditContext = EditContextParams; cm.EditTargetFormatString = (EditPageUrlFormatString == null) ? string.Empty : (EditPageUrlFormatString + (String.IsNullOrEmpty(szEditContext) ? string.Empty : (EditPageUrlFormatString.Contains("?") ? "&" : "?" + szEditContext))); cm.Flight = le; if (Pilot != null && Pilot.AchievementStatus == MyFlightbook.Achievements.Achievement.ComputeStatus.UpToDate) { Repeater rptBadges = (Repeater)e.Row.FindControl("rptBadges"); if (CachedBadgesByFlight.ContainsKey(le.FlightID)) { IEnumerable <Badge> badges = CachedBadgesByFlight[le.FlightID]; if (badges != null) { rptBadges.DataSource = badges; rptBadges.DataBind(); } } } // Bind to images. Controls_mfbImageList mfbIl = (Controls_mfbImageList)e.Row.FindControl("mfbilFlights"); if (!SuppressImages) { // Flight images mfbIl.Key = le.FlightID.ToString(CultureInfo.InvariantCulture); mfbIl.Refresh(); // wire up images if (mfbIl.Images.ImageArray.Count > 0 || le.Videos.Count() > 0) { e.Row.FindControl("pnlImagesHover").Visible = true; } else { e.Row.FindControl("pnlFlightImages").Visible = false; } Aircraft ac = AircraftForUser.Find(a => a.AircraftID == le.AircraftID); string szInstTypeDescription = ac == null ? string.Empty : AircraftInstance.ShortNameForInstanceType(ac.InstanceType); ((Label)e.Row.FindControl("lblInstanceTypeDesc")).Text = szInstTypeDescription; // And aircraft // for efficiency, see if we've already done this tail number; re-use if already done if (!m_dictAircraftHoverIDs.ContainsKey(le.AircraftID)) { if (ac != null) { mfbilAircraft.DefaultImage = ac.DefaultImage; } mfbilAircraft.Key = le.AircraftID.ToString(CultureInfo.InvariantCulture); mfbilAircraft.Refresh(); // cache the attributes string - there's a bit of computation involved in it. string szAttributes = ((Label)e.Row.FindControl("lblModelAttributes")).Text.EscapeHTML(); // and the image table. m_dictAircraftHoverIDs[le.AircraftID] = szInstTypeDescription + " " + szAttributes + mfbilAircraft.AsHTMLTable(); } e.Row.FindControl("plcTail").Controls.Add(new LiteralControl(m_dictAircraftHoverIDs[le.AircraftID])); } // Set style for the row HtmlGenericControl divDate = (HtmlGenericControl)e.Row.FindControl("divDateAndRoute"); switch (le.RowType) { case LogbookEntryDisplay.LogbookRowType.Flight: if (le.IsPageBreak) { e.Row.CssClass = e.Row.CssClass + " pageBreakRow"; } break; case LogbookEntryDisplay.LogbookRowType.RunningTotal: e.Row.CssClass = "runningTotalRow"; divDate.Visible = false; break; case LogbookEntryDisplay.LogbookRowType.Subtotal: e.Row.CssClass = (le.IsPageBreak) ? "subtotalRowPageBreak" : "subtotalRow"; divDate.Visible = false; break; } } }