Beispiel #1
0
    private bool fHasBeenSetUp = false; // have we already been initialized for the user?

    protected void SetUpForUser()
    {
        if (fHasBeenSetUp)
        {
            return;
        }

        if (String.IsNullOrEmpty(Username))
        {
            Username = Page.User.Identity.Name;
        }

        UserAircraft ua = new UserAircraft(Username);

        Aircraft[] rgac       = ua.GetAircraftForUser();
        Aircraft[] rgacActive = Array.FindAll(rgac, aircraft => !aircraft.HideFromSelection);

        // Hide inactive aircraft unless
        // (a) all aircraft are active, or
        // (b) the current query references inactive aircraft
        // (c) pnlshowAllAircraft is invisible (indicating that it has been clicked)
        bool fShowAll = !pnlShowAllAircraft.Visible || rgacActive.Length == rgac.Length || Array.Exists(Restriction.AircraftList, ac => ac.HideFromSelection);

        if (fShowAll)
        {
            pnlShowAllAircraft.Visible = false;
        }
        cklAircraft.DataSource = fShowAll ? rgac : rgacActive;
        cklAircraft.DataBind();

        cklMakes.DataSource = MakeModel.ModelsForAircraft(rgac);
        cklMakes.DataBind();

        cklCatClass.DataSource = CategoryClass.CategoryClasses();
        cklCatClass.DataBind();

        CustomPropertyType[]      rgCpt = CustomPropertyType.GetCustomPropertyTypes(Username);
        List <CustomPropertyType> al    = new List <CustomPropertyType>();

        foreach (CustomPropertyType cpt in rgCpt)
        {
            if (cpt.IsFavorite)
            {
                al.Add(cpt);
            }
        }

        if (al.Count == 0)
        {
            pnlCustomProps.Visible = CustomPropsHeader.Visible = false;
        }
        else
        {
            cklCustomProps.DataSource = al;
            cklCustomProps.DataBind();
        }
        fHasBeenSetUp = true;
    }
    private void InitForm()
    {
        if (!m_fNeedsInit)
        {
            return;
        }

        m_fNeedsInit = false;

        foreach (CustomCurrencyTimespanType t in Enum.GetValues(typeof(CustomCurrencyTimespanType)))
        {
            cmbMonthsDays.Items.Add(new ListItem(t.DisplayString(), t.ToString()));
        }

        UserAircraft           ua    = new UserAircraft(Page.User.Identity.Name);
        IEnumerable <Aircraft> lstAc = ua.GetAircraftForUser();

        lstAircraft.DataSource = lstAc;
        lstAircraft.DataBind();

        List <ListItem> lstCurrencyEvents = new List <ListItem>();

        foreach (var value in Enum.GetValues(typeof(CustomCurrency.CustomCurrencyEventType)))
        {
            lstCurrencyEvents.Add(new ListItem(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(CustomCurrency.EventTypeLabel(1, (CustomCurrency.CustomCurrencyEventType)value)), ((int)value).ToString(CultureInfo.CurrentCulture)));
        }

        lstCurrencyEvents.Sort(delegate(ListItem a, ListItem b) { return(a.Text.CompareCurrentCultureIgnoreCase(b.Text)); });
        foreach (ListItem li in lstCurrencyEvents)
        {
            cmbEventTypes.Items.Add(li);
        }

        lstModels.DataSource = MakeModel.ModelsForAircraft(lstAc);
        lstModels.DataBind();

        IEnumerable <CategoryClass> rgCatClass = CategoryClass.CategoryClasses();

        cmbCatClass.DataSource = rgCatClass;
        cmbCatClass.DataBind();

        // Get the categories (as opposed to catclass); this is something of a hack, but it avoids an extra DB call
        Dictionary <string, string> dictCategories = new Dictionary <string, string>();

        foreach (CategoryClass cc in rgCatClass)
        {
            dictCategories[cc.Category] = cc.Category;
        }
        List <string> lst = new List <string>(dictCategories.Keys);

        lst.Sort();
        foreach (string category in lst)
        {
            cmbCategory.Items.Add(new ListItem(category, category));
        }
    }
    protected void SetUpForUser()
    {
        if (fHasBeenSetUp)
        {
            return;
        }

        if (String.IsNullOrEmpty(Username))
        {
            Username = Page.User.Identity.Name;
        }

        UserAircraft           ua         = new UserAircraft(Username);
        IEnumerable <Aircraft> rgac       = ua.GetAircraftForUser();
        IEnumerable <Aircraft> rgacActive = ua.FindMatching(aircraft => !aircraft.HideFromSelection);

        // Hide inactive aircraft unless
        // (a) all aircraft are active, or
        // (b) the current query references inactive aircraft
        // (c) pnlshowAllAircraft is invisible (indicating that it has been clicked)
        bool fShowAll = !pnlShowAllAircraft.Visible || rgacActive.Count() == rgac.Count() || Restriction.AircraftList.FirstOrDefault(ac => ac.HideFromSelection) != null;

        if (fShowAll)
        {
            pnlShowAllAircraft.Visible = false;
        }
        cklAircraft.DataSource = fShowAll ? rgac : rgacActive;
        cklAircraft.DataBind();
        ckAllAircraft.Visible = cklAircraft.Items.Count > 4;

        cklMakes.DataSource = MakeModel.ModelsForAircraft(rgac);
        cklMakes.DataBind();
        ckAllMakes.Visible = cklMakes.Items.Count > 4;

        cklCatClass.DataSource = CategoryClass.CategoryClasses();
        cklCatClass.DataBind();

        SetUpPropertiesForUser(false);

        fHasBeenSetUp = true;
    }
Beispiel #4
0
    private void InitForm()
    {
        if (!m_fNeedsInit)
        {
            return;
        }

        m_fNeedsInit = false;

        List <TimespanType> lstTst = new List <TimespanType>();

        foreach (TimespanType t in Enum.GetValues(typeof(TimespanType)))
        {
            lstTst.Add(t);
        }
        // Move sliding months up - we don't want an alphabetical sort.  Want days/calendar months/sliding months, then everything else.
        lstTst.RemoveAll(tst => tst == TimespanType.Days || tst == TimespanType.CalendarMonths || tst == TimespanType.SlidingMonths);
        lstTst.InsertRange(0, new TimespanType[] { TimespanType.Days, TimespanType.CalendarMonths, TimespanType.SlidingMonths });
        foreach (TimespanType t in lstTst)
        {
            cmbMonthsDays.Items.Add(new ListItem(t.DisplayString().Substring(0, 1).ToUpper(CultureInfo.CurrentCulture) + t.DisplayString().Substring(1), t.ToString()));
        }

        UserAircraft           ua    = new UserAircraft(Page.User.Identity.Name);
        IEnumerable <Aircraft> lstAc = ua.GetAircraftForUser();

        lstAircraft.DataSource = lstAc;
        lstAircraft.DataBind();

        List <ListItem> lstCurrencyEvents = new List <ListItem>();

        foreach (var value in Enum.GetValues(typeof(CustomCurrency.CustomCurrencyEventType)))
        {
            lstCurrencyEvents.Add(new ListItem(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(CustomCurrency.EventTypeLabel(1, (CustomCurrency.CustomCurrencyEventType)value)), ((int)value).ToString(CultureInfo.CurrentCulture)));
        }

        lstCurrencyEvents.Sort(delegate(ListItem a, ListItem b) { return(a.Text.CompareCurrentCultureIgnoreCase(b.Text)); });
        foreach (ListItem li in lstCurrencyEvents)
        {
            cmbEventTypes.Items.Add(li);
        }

        lstModels.DataSource = MakeModel.ModelsForAircraft(lstAc);
        lstModels.DataBind();

        IEnumerable <CategoryClass> rgCatClass = CategoryClass.CategoryClasses();

        cmbCatClass.DataSource = rgCatClass;
        cmbCatClass.DataBind();

        List <CustomPropertyType> lstCpt = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name));

        lstCpt.RemoveAll(cpt => !cpt.IsFavorite);
        lstProps.DataSource = lstCpt;
        lstProps.DataBind();

        // Get the categories (as opposed to catclass); this is something of a hack, but it avoids an extra DB call
        Dictionary <string, string> dictCategories = new Dictionary <string, string>();

        foreach (CategoryClass cc in rgCatClass)
        {
            dictCategories[cc.Category] = cc.Category;
        }
        List <string> lst = new List <string>(dictCategories.Keys);

        lst.Sort();
        foreach (string category in lst)
        {
            cmbCategory.Items.Add(new ListItem(category, category));
        }
    }