Esempio n. 1
0
    public void AddPictures(Object sender, GridViewRowEventArgs e)
    {
        if (e != null && e.Row.RowType == DataControlRowType.DataRow)
        {
            Aircraft ac = (Aircraft)e.Row.DataItem;

            // Refresh the images
            if (!IsAdminMode)
            {
                ((Controls_mfbHoverImageList)e.Row.FindControl("mfbHoverThumb")).Refresh();
            }

            // Show aircraft capabilities too.
            Controls_popmenu popup = (Controls_popmenu)e.Row.FindControl("popmenu1");
            ((RadioButtonList)popup.FindControl("rblRole")).SelectedValue = ac.RoleForPilot.ToString();
            ((CheckBox)popup.FindControl("ckShowInFavorites")).Checked    = !ac.HideFromSelection;

            ((Label)popup.FindControl("lblOptionHeader")).Text = String.Format(CultureInfo.CurrentCulture, Resources.Aircraft.optionHeader, ac.DisplayTailnumber);

            if (!IsAdminMode)
            {
                List <LinkedString> lst = new List <LinkedString>();

                if (ac.Stats != null)
                {
                    lst.Add(ac.Stats.UserStatsDisplay);
                }
                MakeModel mm = MakeModel.GetModel(ac.ModelID);
                if (mm != null)
                {
                    if (!String.IsNullOrEmpty(mm.FamilyName))
                    {
                        lst.Add(new LinkedString(ModelQuery.ICAOPrefix + mm.FamilyName));
                    }

                    foreach (string sz in mm.AttributeList(ac.AvionicsTechnologyUpgrade, ac.GlassUpgradeDate))
                    {
                        lst.Add(new LinkedString(sz));
                    }
                }

                Repeater rpt = (Repeater)e.Row.FindControl("rptAttributes");
                rpt.DataSource = lst;
                rpt.DataBind();
            }

            if (IsAdminMode)
            {
                HyperLink lnkRegistration = (HyperLink)e.Row.FindControl("lnkRegistration");
                string    szURL           = ac.LinkForTailnumberRegistry();
                lnkRegistration.Visible     = szURL.Length > 0;
                lnkRegistration.NavigateUrl = szURL;
            }
        }
    }
Esempio n. 2
0
    protected void rptTemplates_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }

        Controls_popmenu            pop = (Controls_popmenu)e.Item.FindControl("popmenu");
        PersistablePropertyTemplate pt  = (PersistablePropertyTemplate)e.Item.DataItem;

        pop.FindControl("imgbtnEdit").Visible = pop.FindControl("lnkEditTemplate").Visible = pt.IsMutable;
        ((AjaxControlToolkit.ConfirmButtonExtender)(pop.FindControl("confirmDeleteTemplate"))).ConfirmText = String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.TemplateDeleteConfirm, pt.Name);
    }
 protected void gvSchedSummary_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException(nameof(e));
     }
     if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow)
     {
         ScheduledEvent   se  = (ScheduledEvent)e.Row.DataItem;
         Controls_popmenu pop = (Controls_popmenu)e.Row.FindControl("popmenu");
         ((HyperLink)pop.FindControl("lnkDownloadICS")).NavigateUrl    = String.Format(CultureInfo.InvariantCulture, "~/Member/IcalAppt.aspx?c={0}&sid={1}", ClubID, se.ID);
         ((HyperLink)pop.FindControl("lnkDownloadYahoo")).NavigateUrl  = String.Format(CultureInfo.InvariantCulture, "~/Member/IcalAppt.aspx?c={0}&sid={1}&fmt=Y", ClubID, se.ID);
         ((HyperLink)pop.FindControl("lnkDownloadGoogle")).NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/IcalAppt.aspx?c={0}&sid={1}&fmt=G", ClubID, se.ID);
     }
 }
    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;
            }
        }
    }