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");
            switch (ac.RoleForPilot)
            {
            case Aircraft.PilotRole.None:
                ((RadioButton)popup.FindControl("rbRoleNone")).Checked = true;
                break;

            case Aircraft.PilotRole.CFI:
                ((RadioButton)popup.FindControl("rbRoleCFI")).Checked = true;
                break;

            case Aircraft.PilotRole.SIC:
                ((RadioButton)popup.FindControl("rbRoleSIC")).Checked = true;
                break;

            case Aircraft.PilotRole.PIC:
                ((RadioButton)popup.FindControl("rbRolePIC")).Checked = true;
                break;
            }
            ((CheckBox)popup.FindControl("ckShowInFavorites")).Checked = !ac.HideFromSelection;
            ((CheckBox)popup.FindControl("ckAddNameAsPIC")).Checked    = ac.CopyPICNameWithCrossfill;

            ((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();
            }

            Controls_mfbSelectTemplates selectTemplates = (Controls_mfbSelectTemplates)popup.FindControl("mfbSelectTemplates");
            foreach (int i in ac.DefaultTemplates)
            {
                selectTemplates.AddTemplate(i);
            }

            selectTemplates.Refresh();

            if (IsAdminMode)
            {
                HyperLink lnkRegistration = (HyperLink)e.Row.FindControl("lnkRegistration");
                string    szURL           = ac.LinkForTailnumberRegistry();
                lnkRegistration.Visible     = szURL.Length > 0;
                lnkRegistration.NavigateUrl = szURL;
            }
        }
    }
Example #2
0
        public void gvAircraft_OnRowDataBound(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.
                Control     popup      = e.Row.FindControl("popmenu1");
                RadioButton rbRoleNone = (RadioButton)popup.FindControl("rbRoleNone");
                RadioButton rbRoleCFI  = (RadioButton)popup.FindControl("rbRoleCFI");
                RadioButton rbRoleSIC  = (RadioButton)popup.FindControl("rbRoleSIC");
                RadioButton rbRolePIC  = (RadioButton)popup.FindControl("rbRolePIC");

                switch (ac.RoleForPilot)
                {
                case Aircraft.PilotRole.None:
                    rbRoleNone.Checked = true;
                    break;

                case Aircraft.PilotRole.CFI:
                    rbRoleCFI.Checked = true;
                    break;

                case Aircraft.PilotRole.SIC:
                    rbRoleSIC.Checked = true;
                    break;

                case Aircraft.PilotRole.PIC:
                    rbRolePIC.Checked = true;
                    break;
                }

                CheckBox ckIsFavorite = (CheckBox)popup.FindControl("ckShowInFavorites");
                ckIsFavorite.Checked = !ac.HideFromSelection;
                ckIsFavorite.Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:toggleFavorite({0},this.checked,'{1}');", ac.AircraftID, ResolveClientUrl("~/Member/Aircraft.aspx/SetActive"));
                CheckBox ckAddName = (CheckBox)popup.FindControl("ckAddNameAsPIC");
                ckAddName.Checked = ac.CopyPICNameWithCrossfill;
                ckAddName.Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:document.getElementById(\"{0}\").click();", rbRolePIC.ClientID);  // clicking the "Add Name" checkbox should effectively click the PIC checkbox.

                rbRoleNone.Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:setRole({0},\"{1}\",false,document.getElementById(\"{2}\"),\"{3}\");", ac.AircraftID, Aircraft.PilotRole.None.ToString(), ckAddName.ClientID, ResolveClientUrl("~/Member/Aircraft.aspx/SetRole"));
                rbRoleCFI.Attributes["onclick"]  = String.Format(CultureInfo.InvariantCulture, "javascript:setRole({0},\"{1}\",false,document.getElementById(\"{2}\"),\"{3}\");", ac.AircraftID, Aircraft.PilotRole.CFI.ToString(), ckAddName.ClientID, ResolveClientUrl("~/Member/Aircraft.aspx/SetRole"));
                rbRoleSIC.Attributes["onclick"]  = String.Format(CultureInfo.InvariantCulture, "javascript:setRole({0},\"{1}\",false,document.getElementById(\"{2}\"),\"{3}\");", ac.AircraftID, Aircraft.PilotRole.SIC.ToString(), ckAddName.ClientID, ResolveClientUrl("~/Member/Aircraft.aspx/SetRole"));
                rbRolePIC.Attributes["onclick"]  = String.Format(CultureInfo.InvariantCulture, "javascript:setRole({0},\"{1}\",document.getElementById(\"{2}\").checked, document.getElementById(\"{3}\"),\"{4}\");", ac.AircraftID, Aircraft.PilotRole.PIC.ToString(), ckAddName.ClientID, ckAddName.ClientID, ResolveClientUrl("~/Member/Aircraft.aspx/SetRole"));

                ((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();
                }

                Controls_mfbSelectTemplates selectTemplates = (Controls_mfbSelectTemplates)popup.FindControl("mfbSelectTemplates");
                foreach (int i in ac.DefaultTemplates)
                {
                    selectTemplates.AddTemplate(i);
                }

                selectTemplates.Refresh();

                if (IsAdminMode)
                {
                    HyperLink lnkRegistration = (HyperLink)e.Row.FindControl("lnkRegistration");
                    string    szURL           = ac.LinkForTailnumberRegistry();
                    lnkRegistration.Visible     = szURL.Length > 0;
                    lnkRegistration.NavigateUrl = szURL;
                }
            }
        }