Esempio n. 1
0
        public static void RemoveCurrencyNonIncluded(UpdateDropDownList ddl, Kraken.Currency[] currency)
        {
            if (ddl == null || ddl.Items == null || ddl.Items.Count <= 0 || currency == null || currency.Length <= 0)
            {
                return;
            }

            var list = currency.ToList();

            for (int i = 0; i < ddl.Items.Count; i++)
            {
                var nvalue = Kraken.ToCurrency(ddl.Items[i].Value);
                if (nvalue == null || !nvalue.HasValue)
                {
                    continue;
                }

                var value = nvalue.Value;

                if (!currency.Contains(value))
                {
                    ddl.Items.RemoveAt(i);
                    RemoveCurrencyNonIncluded(ddl, currency);
                    return;
                }
            }
        }
Esempio n. 2
0
        public static void Select(this UpdateDropDownList uddl, Fundings fundings)
        {
            if (uddl == null || uddl.Items == null || fundings == null)
            {
                return;
            }

            ListItem item = fundings.ToListItem();

            if (item != null)
            {
                uddl.SelectValue(item.Value);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Adds assets to DropDownList
        /// </summary>
        /// <param name="ddl"></param>
        /// <param name="assets"></param>
        public static void AddAssets(UpdateDropDownList ddl, Kraken.Asset[] assets)
        {
            if (ddl == null || ddl.Items == null || assets == null || assets.Length <= 0)
            {
                return;
            }

            foreach (var v in assets)
            {
                ListItem item = new ListItem();
                item.Text  = v.GetEnumDescription();
                item.Value = v.GetEnumName();
                ddl.Items.Add(item);
            }
        }
Esempio n. 4
0
        public static void RemoveAsset(UpdateDropDownList ddl, Kraken.Asset?asset)
        {
            if (ddl == null || ddl.Items == null || ddl.Items.Count <= 0 || asset == null || !asset.HasValue)
            {
                return;
            }

            for (int i = 0; i < ddl.Items.Count; i++)
            {
                if (asset.Value == Kraken.ToAsset(ddl.Items[i].Value))
                {
                    ddl.Items.RemoveAt(i);
                    RemoveAsset(ddl, asset);
                    return;
                }
            }
        }
Esempio n. 5
0
        public static int GetAssetIndex(UpdateDropDownList ddl, Kraken.Asset?asset, int defaultIndex = -1)
        {
            if (ddl == null || ddl.Items == null || ddl.Items.Count <= 0 || asset == null || !asset.HasValue)
            {
                return(-1);
            }

            for (int i = 0; i < ddl.Items.Count; i++)
            {
                if (asset.Value == Kraken.ToAsset(ddl.Items[i].Value))
                {
                    return(i);
                }
            }

            return(defaultIndex);
        }
Esempio n. 6
0
        public static bool ContainsText(this UpdateDropDownList uddl, string text)
        {
            if (uddl == null || uddl.Items == null)
            {
                return(false);
            }

            for (int i = 0; i < uddl.Items.Count; i++)
            {
                ListItem primary = uddl.Items[i];
                if (primary != null && primary.Text == text)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 7
0
        public static int SelectValue(this UpdateDropDownList uddl, string value)
        {
            if (uddl == null || uddl.Items == null)
            {
                return(-1);
            }

            for (int i = 0; i < uddl.Items.Count; i++)
            {
                ListItem primary = uddl.Items[i];
                if (primary != null && primary.Value == value)
                {
                    uddl.SelectedIndex = i;
                    return(i);
                }
            }

            return(-1);
        }
Esempio n. 8
0
        public static Fundings[] AddItems(this UpdateDropDownList uddl, Fundings[] fundings)
        {
            List <Fundings> added = new List <Fundings>();

            if (uddl == null || fundings == null)
            {
                return(added.ToArray());
            }

            uddl.Items.Clear();

            foreach (Fundings funding in fundings)
            {
                ListItem item = funding.ToListItem();
                if (item != null)
                {
                    uddl.Items.Add(item);
                    added.Add(funding.Copy());
                }
            }

            return(added.ToArray());
        }