示例#1
0
        private void OnLoad(object sender, RoutedEventArgs e)
        {
            GroupedIcons.Source = VKIcons;
            int count = 0;
            ResourceDictionary iconsdict = App.Current.Resources.MergedDictionaries[3];
            var q = (from i in iconsdict select i).ToList();

            foreach (var i in q)
            {
                if (i.Key is string k && k.Length > 6 && k.Substring(0, 4) == "Icon" && i.Value is DataTemplate v)
                {
                    double s = 0;
                    if (!Double.TryParse(k.Substring(4, 2), out s))
                    {
                        return;
                    }

                    IconItem icon = new IconItem(v, s, k);

                    var gq = from g in VKIcons where g.Size == s select g;
                    if (gq.Count() == 0)
                    {
                        IconGroup ig = new IconGroup(s, new ObservableCollection <IconItem> {
                            icon
                        });
                        int idx = VKIcons.ToList().BinarySearch(ig);
                        if (idx < 0)
                        {
                            idx = ~idx;
                        }
                        VKIcons.Insert(idx, ig);
                    }
                    else if (gq.Count() == 1)
                    {
                        IconGroup ig  = gq.First();
                        int       idx = ig.ToList().BinarySearch(icon);
                        if (idx < 0)
                        {
                            idx = ~idx;
                        }
                        ig.Insert(idx, icon);
                    }
                    count++;
                }
            }
            Debug.WriteLine($"Icons count: {count}");
        }
示例#2
0
        private async void ShowIconInfo(object sender, ItemClickEventArgs e)
        {
            IconItem icon = e.ClickedItem as IconItem;

            await new MessageDialog("", icon.Name).ShowAsync();
        }