private FontGroup GetFontGroup(string name, Func<FontDetail, bool> predicate)
 {
     var group = new FontGroup()
     {
         Description = name
     };
     foreach(var f in AllFonts.Where(predicate))
     {
         group.Add(f);
     }
     return group;
 }
예제 #2
0
        private FontGroup GetFontGroup(string name, Func <FontDetail, bool> predicate)
        {
            var group = new FontGroup()
            {
                Description = name
            };

            foreach (var f in AllFonts.Where(predicate))
            {
                group.Add(f);
            }
            group.HasFonts = group.Count > 0;
            return(group);
        }
        public override async Task LoadAsync()
        {
            await base.LoadAsync();

            if (InstalledFonts == null)
            {
                var installedFonts = AllFonts;

                InstalledFonts = new FontGroup();
                InstalledFonts.Description = "Installed Locally";
                InstalledFonts.HasFonts = true;
                foreach (var f in installedFonts)
                {
                    f.Type = "Installed";
                    InstalledFonts.Add(f);
                }
            }

            if (OnlineFonts == null)
            {
                OnlineFonts = new FontGroup();
                OnlineFonts.Description = "Online";
                OnlineFonts.HasFonts = true;
                foreach (var f in await GetOnlineFonts())
                {
                    f.Type = "Online";
                    OnlineFonts.Add(f);
                }

                // load online fonts
                foreach (var font in OnlineFonts)
                {
                    var codes = font.CharacterCodes.Select(c => new FontChar()
                    {
                        Name = c.Key,
                        Char = (char)c.Value,
                        Family = font.Name,
                        Size = 48
                    });
                }
            }

            AllFonts = OnlineFonts.Union(InstalledFonts).ToList();
        }
예제 #4
0
        public override async Task LoadAsync()
        {
            await base.LoadAsync();

            if (InstalledFonts == null)
            {
                var installedFonts = AllFonts;

                InstalledFonts             = new FontGroup();
                InstalledFonts.Description = "Installed Locally";
                InstalledFonts.HasFonts    = true;
                foreach (var f in installedFonts)
                {
                    f.Type = "Installed";
                    InstalledFonts.Add(f);
                }
            }

            if (OnlineFonts == null)
            {
                OnlineFonts             = new FontGroup();
                OnlineFonts.Description = "Online";
                OnlineFonts.HasFonts    = true;
                foreach (var f in await GetOnlineFonts())
                {
                    f.Type = "Online";
                    OnlineFonts.Add(f);
                }

                // load online fonts
                foreach (var font in OnlineFonts)
                {
                    var codes = font.CharacterCodes.Select(c => new FontChar()
                    {
                        Name   = c.Key,
                        Char   = (char)c.Value,
                        Family = font.Name,
                        Size   = 48
                    });
                }
            }

            AllFonts = OnlineFonts.Union(InstalledFonts).ToList();
        }