Esempio n. 1
0
        /// <summary>
        /// Load system fonts and create previews of them
        /// </summary>
        /// <returns>Total number of fonts loaded</returns>
        public int LoadSystemFonts()
        {
            FontCollection fc = new InstalledFontCollection();
            int fontCount = 0;

            foreach (FontFamily f in fc.Families)
            {
                fontCount++;

                try
                {
                    FontStyle fs = FontStyle.Strikeout;
                    foreach (FontStyle fos in Enum.GetValues(typeof(FontStyle)))
                    {

                        if (fs == FontStyle.Strikeout && fos != FontStyle.Strikeout)
                        {
                            if (f.IsStyleAvailable(fos))
                            {
                                fs = fos;
                            }
                        }
                    }
                    Font fo = new Font(f, 38f, fs);
                    FamilyViewer fv = new FamilyViewer();
                    fv.PreviewFont = fo;
                    this.AddItem(fv);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("Problem displaying " + f.Name);
                }
            }
            return fontCount;
        }
Esempio n. 2
0
 /// <summary>
 /// Add an item to the FamilyGrid
 /// </summary>
 /// <remarks>Also stores the vertical position of the control in famPositions</remarks>
 /// <param name="f">FamilyViewer control to add</param>
 private void AddItem(FamilyViewer f)
 {
     String fn = f.Family;
     Controls.Add(f);
     famPositions.Add(fn,Controls[Controls.IndexOf(f)].Top);
 }