private void AdjustForRealOrAnonymous(bool fRealAircraft, bool fIsAnonymous, bool fHasModelSpecified, CountryCodePrefix cc)
        {
            if (fRealAircraft)
            {
                if (fIsAnonymous)
                {
                    lblAnonTailDisplay.Text = m_ac.TailNumber = txtTail.Text = lblReadTail.Text = (fHasModelSpecified) ? Aircraft.AnonymousTailnumberForModel(m_ac.ModelID) : String.Empty;
                    pnlAnonTail.Visible     = (fHasModelSpecified);
                }
                else
                {
                    m_ac.TailNumber = cc.IsSim || cc.IsAnonymous
                        ? cmbCountryCode.SelectedItem.Value
                        : CountryCodePrefix.SetCountryCodeForTail(new CountryCodePrefix(cmbCountryCode.SelectedItem.Text, cmbCountryCode.SelectedValue), txtTail.Text);
                    lblReadTail.Text = txtTail.Text = HttpUtility.HtmlEncode(m_ac.TailNumber);
                }

                mvRealAircraft.SetActiveView(fIsAnonymous ? vwAnonTail : vwRegularTail);
                valTailNumber.Enabled = fIsAnonymous;
                FixFAALink();
            }
            else
            {
                // Sim
                if (fHasModelSpecified)
                {
                    m_ac.TailNumber = Aircraft.SuggestSims(m_ac.ModelID, m_ac.InstanceType)[0].TailNumber;
                }
                vwSimTailDisplay.SetActiveView(fHasModelSpecified ? vwHasModel : vwNoModel);

                lblSimTail.Text = lblReadTail.Text = txtTail.Text = m_ac.TailNumber;
            }
        }
 protected void UpdateMask()
 {
     txtTail.Text = HttpUtility.HtmlEncode(CountryCodePrefix.SetCountryCodeForTail(new CountryCodePrefix(cmbCountryCode.SelectedItem.Text, cmbCountryCode.SelectedValue), txtTail.Text));
 }
    protected void UpdateMask()
    {
        string szCountry = IsRealAircraft ? cmbCountryCode.SelectedValue : hdnSimCountry.Value;

        txtTail.Text = CountryCodePrefix.SetCountryCodeForTail(new CountryCodePrefix(cmbCountryCode.SelectedItem.Text, cmbCountryCode.SelectedValue), txtTail.Text);
    }
    /// <summary>
    /// Shows/hides functionality based on instance type, new/existing, sim, or anonymous.  Does NOT bind any data
    /// </summary>
    protected void AdjustForAircraftType()
    {
        MakeModel mm = MakeModel.GetModel(m_ac.ModelID);

        Boolean           fRealAircraft = IsRealAircraft;
        CountryCodePrefix cc            = CountryCodePrefix.BestMatchCountryCode(m_ac.TailNumber);

        Boolean fIsNew             = m_ac.IsNew;
        Boolean fHasModelSpecified = (m_ac.ModelID > 0);

        Boolean fIsAnonymous = rbRealAnonymous.Checked;

        rbRealRegistered.Enabled = rbRealAnonymous.Enabled = true;
        switch (mm.AllowedTypes)
        {
        case AllowedAircraftTypes.Any:
            break;

        case AllowedAircraftTypes.SimOrAnonymous:
            if (fRealAircraft)
            {
                fIsAnonymous         = true;
                m_ac.TailNumber      = CountryCodePrefix.AnonymousCountry.Prefix;  // so that the selected instance will do anonymous correctly
                SelectedInstanceType = AircraftInstanceTypes.RealAircraft;
            }
            rbRealRegistered.Enabled = false;
            break;

        case AllowedAircraftTypes.SimulatorOnly:
            cc = CountryCodePrefix.SimCountry;
            if (fRealAircraft)
            {
                // migrate to an ATD.
                m_ac.InstanceType = SelectedInstanceType = AircraftInstanceTypes.CertifiedATD;
                fRealAircraft     = false;
            }
            rbRealRegistered.Enabled = rbRealAnonymous.Enabled = false;
            break;
        }

        mvTailnumber.SetActiveView(fRealAircraft ? vwRealAircraft : vwSimTail);

        // Show glass option if this is not, by model, a glass cockpit AND if it's not anonymous
        bool fRealRegistered = fRealAircraft && !fIsAnonymous;

        // All avionics upgrade options are limited to real, registered aircraft.  Beyond that:
        // - Can upgrade to glass if the model is not already glass or TAA (i.e., = steam)
        // - Can upgrade to TAA if the model is not already TAA-only AND this is an airplane (TAA is airplane only).
        // - So we will hide the overall avionics upgrade panel if no upgrade is possible.
        bool fAvionicsGlassvisible = fRealRegistered && mm.AvionicsTechnology == MakeModel.AvionicsTechnologyType.None;
        bool fTAAVisible           = fRealRegistered && mm.AvionicsTechnology != MakeModel.AvionicsTechnologyType.TAA;

        rbAvionicsGlass.Visible = fAvionicsGlassvisible;
        pnlTAA.Visible          = fTAAVisible;
        pnlGlassCockpit.Visible = fAvionicsGlassvisible || fTAAVisible;

        // Sanity check
        if ((rbAvionicsGlass.Checked && !rbAvionicsGlass.Visible) || (rbAvionicsTAA.Checked && !rbAvionicsTAA.Visible))
        {
            AvionicsUpgrade = MakeModel.AvionicsTechnologyType.None;
        }

        rowCountry.Visible     = fRealAircraft && !fIsAnonymous;
        rowMaintenance.Visible = rowCountry.Visible && !fIsNew;

        pnlTrainingDeviceTypes.Visible = fIsNew && !fRealAircraft;

        if (fRealAircraft)
        {
            if (fIsAnonymous)
            {
                lblAnonTailDisplay.Text = m_ac.TailNumber = txtTail.Text = (fHasModelSpecified) ? Aircraft.AnonymousTailnumberForModel(m_ac.ModelID) : String.Empty;
                pnlAnonTail.Visible     = (fHasModelSpecified);
            }
            else
            {
                if (cc.IsSim || cc.IsAnonymous)   // reset tail if switching from sim or anonymous
                {
                    m_ac.TailNumber = txtTail.Text = cmbCountryCode.SelectedItem.Value;
                }
                else
                {
                    m_ac.TailNumber = txtTail.Text = CountryCodePrefix.SetCountryCodeForTail(new CountryCodePrefix(cmbCountryCode.SelectedItem.Text, cmbCountryCode.SelectedValue), txtTail.Text);
                }
            }

            mvRealAircraft.SetActiveView(fIsAnonymous ? vwAnonTail : vwRegularTail);
            valTailNumber.Enabled = fIsAnonymous;
            FixFAALink();
        }
        else
        {
            // Sim
            if (fHasModelSpecified)
            {
                m_ac.TailNumber = Aircraft.SuggestSims(m_ac.ModelID, m_ac.InstanceType)[0].TailNumber;
            }
            vwSimTailDisplay.SetActiveView(fHasModelSpecified ? vwHasModel : vwNoModel);

            lblSimTail.Text = txtTail.Text = m_ac.TailNumber;
        }
    }