示例#1
0
        /// <summary>
        /// Install the fonts associated with Media Center by default
        /// I realize I should use a private font collection, but it's a pain to
        /// use with WPF etc...  So I install and say, not my problem fool
        /// </summary>
        private static void InstallMediaCenterFonts()
        {
            List <FontFamily> local_ttfs = new List <FontFamily>();
            var font_files = Directory.GetFiles(MediaCenterUtil.MediaCenterPath, "*.ttf");

            foreach (var font_file in font_files)
            {
                var result = FontUtil.InstallFont(font_file);

                var error = Marshal.GetLastWin32Error();
                if (error != 0)
                {
                    Trace.TraceWarning((new Win32Exception(error)).Message);
                }
                else
                {
                    Trace.TraceWarning((result == 0) ? "Font is already installed." :
                                       "Font installed successfully.");
                }
            }
        }
示例#2
0
 protected virtual void Apply(MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache, ProgressEnabledOperation operation)
 {
     try
     {
         if (this.Fonts.Count > 0)
         {
             operation.OnProgress("Installing fonts...", 0);
             foreach (string file in Enumerable.Distinct <string>(Enumerable.Select <FontFamily, string>(Enumerable.Where <FontFamily>((IEnumerable <FontFamily>) this.Fonts, (Func <FontFamily, bool>)(f => !Enumerable.Any <FontFamily>((IEnumerable <FontFamily>)System.Windows.Media.Fonts.SystemFontFamilies, (Func <FontFamily, bool>)(o => FontUtil.GetName(f) == FontUtil.GetName(o))))), (Func <FontFamily, string>)(o => FontUtil.GetFile(o)))))
             {
                 FontUtil.InstallFont(file);
             }
         }
         List <IThemeItem> list = Enumerable.ToList <IThemeItem>(Enumerable.Concat <IThemeItem>((IEnumerable <IThemeItem>) new List <IThemeItem>()
         {
             (IThemeItem)this.FontsItem,
             (IThemeItem)this.ColorsItem
         }, (IEnumerable <IThemeItem>) this.ThemeItems));
         for (int currentIndex = 0; currentIndex < list.Count; ++currentIndex)
         {
             IThemeItem themeItem = list[currentIndex];
             operation.OnProgress(string.Format("Applying {0}...", (object)themeItem.Name), currentIndex);
             try
             {
                 themeItem.Apply(readCache, writeCache);
             }
             catch (ThemeApplicationException ex)
             {
                 Trace.TraceWarning(((object)ex).ToString());
             }
         }
     }
     catch (Exception ex)
     {
         Trace.TraceError(((object)ex).ToString());
         operation.OnAbandoned(ex);
         throw;
     }
     operation.OnCompleted();
 }