Beispiel #1
0
        public IconOverviewDataContext()
        {
            this
            .ToObservable(p => p.SearchTerm)
            .Throttle(TimeSpan.FromMilliseconds(500))
            .Select(term => term?.Trim())
            .DistinctUntilChanged()
            .Select(term => term?.ToLower(CultureInfo.CurrentCulture))
            //.Select(filterString => FilterItems(filterString))
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(result =>
            {
                if (string.IsNullOrEmpty(result))
                {
                    Icons.RemoveFilter();
                }
                else
                {
                    Icons.Filter(icon => icon.Name.ToLower().Contains(result));
                }
            }
                       );

            // Icon size calculator
            calc      = new IconSizeCalculator();
            SpanCount = calc.GetItemsPerRowDefault();

            var x = Observable.FromEvent <ListViewItemInfo>(
                evt => calc.ItemInfoChanged += evt,
                evt => calc.ItemInfoChanged -= evt
                ).Subscribe(info =>
            {
                FontSize  = info.FontSize;
                SpanCount = info.ItemsPerRow;
            }
                            );

            var fontSet = FontIconProvider.GetAllIcons(FontFamilies.FontAwesomeSolid);

            Icons = new BindingCollection <FontIcon>(fontSet.Icons);
            //_ = Icons.Fill(fontSet.Icons);
        }