Пример #1
0
        public static bool PrepareForSave(MediaCenterLibraryCache cache)
        {
            bool flag = true;

            foreach (string path2 in cache.LoadedFiles)
            {
                string str = Path.Combine(cache.SearchPath, path2);
                if (File.Exists(str))
                {
                    VmcStudioUtil.BackupFile(str);
                    if (!VmcStudioUtil.TakeOwnership(str))
                    {
                        throw new VmcStudioException(string.Format("Could not take ownership of {0}.", (object)str));
                    }
                }
                else
                {
                    Trace.TraceWarning("File not found: {0}", new object[1]
                    {
                        (object)str
                    });
                }
            }
            if (!VmcStudioUtil.EnsureMediaCenterClosed(true))
            {
                flag = false;
            }
            return(flag);
        }
Пример #2
0
        public void Apply(IThemeItem themeItem, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
        {
            ColorsThemeItem colorsThemeItem = (ColorsThemeItem)themeItem;

            if (colorsThemeItem.DefaultColors.Count <= 0)
            {
                return;
            }
            IResourceLibrary resourceLibrary1 = readCache[this.ResourceLibraryName];
            IResourceLibrary resourceLibrary2 = writeCache[this.ResourceLibraryName];
            McmlDocument     mcml             = MediaCenterUtil.GetMcml(resourceLibrary1.GetResource(this.ColorsDocumentName, (object)this.ColorsDocumentResourceType));

            foreach (ColorItem colorItem in (Collection <ColorItem>)colorsThemeItem.DefaultColors)
            {
                string          str      = colorItem.ToString();
                PropertyElement property = mcml.Properties().GetProperty(colorItem.Name);
                if (property == null)
                {
                    XElement xelement = new XElement(mcml.DefaultNamespace + "Color", new object[2]
                    {
                        (object)new XAttribute((XName)"Name", (object)colorItem.Name),
                        (object)new XAttribute((XName)"Color", (object)str)
                    });
                    mcml.Xml.Root.Add((object)xelement);
                }
                else
                {
                    property.Value = str;
                }
            }
            MediaCenterUtil.UpdateMcml(resourceLibrary2.GetResource(this.ColorsDocumentName, (object)this.ColorsDocumentResourceType), mcml);
        }
Пример #3
0
        public IEnumerable <ColorItem> GetColors(MediaCenterLibraryCache cache)
        {
            McmlDocument     mcml = MediaCenterUtil.GetMcml(cache[this.ResourceLibraryName].GetResource(this.ColorsDocumentName, (object)this.ColorsDocumentResourceType));
            List <ColorItem> list = new List <ColorItem>();

            foreach (PropertyElement propertyElement in mcml.Properties().ColorProperties())
            {
                string text = propertyElement.Value;
                Color  color;
                if (MediaCenterUtil.TryParseColor(text, out color))
                {
                    list.Add(new ColorItem()
                    {
                        Color = color,
                        Name  = propertyElement.Name
                    });
                }
                else
                {
                    Trace.TraceWarning("Could not parse color \"{0}\" from COLORS.MCML.", new object[1]
                    {
                        (object)text
                    });
                }
            }
            return((IEnumerable <ColorItem>)list);
        }
Пример #4
0
 public ApplyOperation(MediaCenterTheme theme, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
 {
     this.ReadCache   = readCache;
     this.WriteCache  = writeCache;
     this.Theme       = theme;
     this.Description = string.Format("Applying theme {0}", (object)theme.Name);
 }
Пример #5
0
        public void Apply(IThemeItem themeItem, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
        {
            StartMenuThemeItem startMenuThemeItem = (StartMenuThemeItem)themeItem;

            this.UpdateStartMenuCategory(startMenuThemeItem, readCache, writeCache);
            this.UpdateQuickLinks(startMenuThemeItem, readCache, writeCache);
            this.UpdateStartMenuOverlay(startMenuThemeItem, readCache, writeCache);
        }
Пример #6
0
 public void Apply(IThemeItem themeItem, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
 {
     if (!((AnimationsItem)themeItem).IsBackgroundAnimationDisabled)
     {
         return;
     }
     this.DisableBackgroundAnimations(readCache, writeCache);
 }
Пример #7
0
 private void SaveExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
     try
     {
         VmcStudioUtil.Application.CommonResources.CloseResources();
         try
         {
             using (MediaCenterLibraryCache mediaCenterLibraryCache = new MediaCenterLibraryCache(MediaCenterUtil.MediaCenterPath, UnmanagedLibraryAccess.Write))
             {
                 MemoryLibraryCache memoryLibraryCache = new MemoryLibraryCache(1033);
                 VmcStudioUtil.Application.StartMenuManager.Save(memoryLibraryCache);
                 foreach (string current in memoryLibraryCache.Libraries)
                 {
                     mediaCenterLibraryCache.LoadLibrary(current);
                 }
                 VmcStudioUtil.PrepareForSave(mediaCenterLibraryCache);
                 memoryLibraryCache.ApplyTo(mediaCenterLibraryCache);
             }
         }
         finally
         {
             VmcStudioUtil.Application.CommonResources.ResetResources();
         }
     }
     catch (Win32Exception ex)
     {
         if (ex.NativeErrorCode != 5)
         {
             throw;
         }
         Trace.TraceError("Failed to save changes: {0}", new object[]
         {
             ex.ToString()
         });
         System.Windows.MessageBox.Show(AccessDeniedMessage, VmcStudioUtil.ApplicationTitle, MessageBoxButton.OK, MessageBoxImage.Hand);
     }
     catch (UnauthorizedAccessException ex2)
     {
         Trace.TraceError("Failed to save changes: {0}", new object[]
         {
             ex2.ToString()
         });
         System.Windows.MessageBox.Show(AccessDeniedMessage, VmcStudioUtil.ApplicationTitle, MessageBoxButton.OK, MessageBoxImage.Hand);
     }
     catch (VmcStudioException ex3)
     {
         Trace.TraceError("Failed to save changes: {0}", new object[]
         {
             ex3.ToString()
         });
         System.Windows.MessageBox.Show("Failed to save changes:\n" + ex3.ToString(), VmcStudioUtil.ApplicationTitle, MessageBoxButton.OK, MessageBoxImage.Hand);
     }
     finally
     {
         Mouse.OverrideCursor = null;
     }
 }
Пример #8
0
        public void Apply(IThemeItem themeItem, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
        {
            FontsThemeItem   fontsThemeItem   = (FontsThemeItem)themeItem;
            IResourceLibrary resourceLibrary1 = readCache["Microsoft.MediaCenter.Shell.dll"];
            IResourceLibrary resourceLibrary2 = writeCache["Microsoft.MediaCenter.Shell.dll"];
            McmlDocument     mcml1            = MediaCenterUtil.GetMcml(resourceLibrary1.GetResource("FONTNAMES.MCML", (object)this.DocumentResourceType));
            McmlDocument     mcml2            = MediaCenterUtil.GetMcml(resourceLibrary1.GetResource("FONTS.MCML", (object)this.DocumentResourceType));

            foreach (FontClass fontClass in Enumerable.Where <FontClass>((IEnumerable <FontClass>)fontsThemeItem.FontClasses, (Func <FontClass, bool>)(o => o.FontFace != null)))
            {
                string          typefaceName = FontUtilities.GetTypefaceName(themeItem.Theme, fontClass.FontFace);
                PropertyElement property     = mcml1.Properties().GetProperty(fontClass.Name);
                if (property == null)
                {
                    XElement xelement = new XElement(McmlDocument.SystemCoreNamespace + "String", new object[2]
                    {
                        (object)new XAttribute((XName)"Name", (object)fontClass.Name),
                        (object)new XAttribute((XName)"String", (object)typefaceName)
                    });
                    mcml1.Xml.Root.Add((object)xelement);
                }
                else
                {
                    property.Value = typefaceName;
                }
            }
            foreach (XElement xelement in mcml1.Xml.Root.Elements())
            {
                mcml2.Xml.Root.AddFirst((object)xelement);
            }
            MediaCenterUtil.UpdateMcml(resourceLibrary2.GetResource("FONTNAMES.MCML", (object)this.DocumentResourceType), mcml1);
            foreach (FontOverride fontOverride in Enumerable.Where <FontOverride>((IEnumerable <FontOverride>)fontsThemeItem.FontOverrides, (Func <FontOverride, bool>)(o =>
            {
                if (o.FontFace == null)
                {
                    return(o.FontClass != null);
                }
                else
                {
                    return(true);
                }
            })))
            {
                FontElement fontElement = mcml2.Properties().GetProperty(fontOverride.Name) as FontElement;
                if (fontElement == null)
                {
                    XElement xelement = new XElement(mcml2.DefaultNamespace + "Font", (object)new XAttribute((XName)"Name", (object)fontOverride.Name));
                    mcml2.Xml.Root.Add((object)xelement);
                    fontElement = (FontElement)mcml2.Properties().GetProperty(fontOverride.Name);
                }
                McmlUtilities.UpdateFontElement(fontOverride, fontElement, themeItem.Theme);
            }
            foreach (XNode xnode in mcml2.Xml.Root.Elements(mcml2.DefaultNamespace + "Aggregate"))
            {
                xnode.Remove();
            }
            MediaCenterUtil.UpdateMcml(resourceLibrary2.GetResource("FONTS.MCML", (object)this.DocumentResourceType), mcml2);
        }
Пример #9
0
        protected override void DisableBackgroundAnimations(MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
        {
            McmlDocument      mcml = MediaCenterUtil.GetMcml(readCache["Microsoft.MediaCenter.Shell.dll"].GetResource("PAGEBACKGROUND.MCML", (object)23));
            PropertiesElement themeUiProperties = McmlUtilities.GetThemeUIProperties(mcml, "PageBackground");
            PropertyElement   themeProperty     = McmlUtilities.GetThemeProperty(themeUiProperties, "StaticSource");

            McmlUtilities.GetThemeProperty(themeUiProperties, "AnimatedSource").Value = themeProperty.Value;
            MediaCenterUtil.UpdateMcml(writeCache["Microsoft.MediaCenter.Shell.dll"].GetResource("PAGEBACKGROUND.MCML", (object)23), mcml);
        }
Пример #10
0
 public void CloseResources()
 {
     if (this.cache == null)
     {
         return;
     }
     this.cache.Dispose();
     this.cache = (MediaCenterLibraryCache)null;
 }
Пример #11
0
        protected virtual void UpdateStartMenuCategory(StartMenuThemeItem item, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
        {
            McmlDocument      mcml = MediaCenterUtil.GetMcml(readCache["Microsoft.MediaCenter.Shell.dll"].GetResource("STARTMENUCATEGORY.MCML", (object)this.DocumentResourceType));
            PropertiesElement themeUiProperties = McmlUtilities.GetThemeUIProperties(mcml, "StartMenuCategoryView");

            McmlUtilities.UpdateFontElement(item.StripTitleFont, themeUiProperties.GetProperty("Font") as FontElement, item.Theme);
            McmlUtilities.UpdateColorElement(item.FocusedStripTitleColor, themeUiProperties.GetProperty("FocusColor"), item.Theme);
            McmlUtilities.UpdateColorElement(item.NonFocusedStripTitleColor, themeUiProperties.GetProperty("NoFocusColor"), item.Theme);
            MediaCenterUtil.UpdateMcml(writeCache["Microsoft.MediaCenter.Shell.dll"].GetResource("STARTMENUCATEGORY.MCML", (object)this.DocumentResourceType), mcml);
        }
Пример #12
0
 public VmcStudioApp()
 {
     this.Documents = new ObservableCollection <VmcDocument>();
     this.Documents.CollectionChanged += new NotifyCollectionChangedEventHandler(this.Documents_CollectionChanged);
     this.ThemeManager = new ThemeManager(Path.Combine(VmcStudioUtil.ApplicationDataPath, "Themes"));
     using (MediaCenterLibraryCache centerLibraryCache = new MediaCenterLibraryCache(MediaCenterUtil.MediaCenterPath))
         this.StartMenuManager = StartMenuManager.Create((IResourceLibraryCache)centerLibraryCache);
     Application.Current.Resources.Add((object)"StartMenuManager", (object)this.StartMenuManager);
     this.StartMenuManager.CustomCategory = VmcStudioUtil.ApplicationName;
     this.CommonResources = new CommonResourceManager(this);
 }
Пример #13
0
        public void Apply(IThemeItem themeItem, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
        {
            ResourceThemeItem resourceThemeItem = (ResourceThemeItem)themeItem;

            byte[] data = resourceThemeItem.Save(false);
            if (data == null || data.Length <= 0)
            {
                return;
            }
            ResourceExtensions.Update(writeCache[resourceThemeItem.DllName].GetResource(resourceThemeItem.ResourceName, (object)resourceThemeItem.ResourceType), data);
        }
Пример #14
0
        protected virtual void UpdateQuickLinks(StartMenuThemeItem item, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
        {
            McmlDocument      mcml = MediaCenterUtil.GetMcml(readCache["Microsoft.MediaCenter.Shell.dll"].GetResource("STARTMENUQUICKLINK.MCML", (object)this.DocumentResourceType));
            PropertiesElement themeUiProperties = McmlUtilities.GetThemeUIProperties(mcml, "BaseQuickLinkContent");

            McmlUtilities.UpdateFontElement(item.NonFocusedQuickLinkFont, themeUiProperties.GetProperty("Font") as FontElement, item.Theme);
            McmlUtilities.UpdateFontElement(item.FocusedQuickLinkFont, themeUiProperties.GetProperty("FocusFont") as FontElement, item.Theme);
            McmlUtilities.UpdateColorElement(item.FocusedQuickLinkColor, themeUiProperties.GetProperty("FocusColor"), item.Theme);
            McmlUtilities.UpdateColorElement(item.NonFocusedQuickLinkColor, themeUiProperties.GetProperty("NoFocusColor"), item.Theme);
            MediaCenterUtil.UpdateMcml(writeCache["Microsoft.MediaCenter.Shell.dll"].GetResource("STARTMENUQUICKLINK.MCML", (object)this.DocumentResourceType), mcml);
        }
Пример #15
0
        protected virtual void UpdateStartMenuOverlay(StartMenuThemeItem item, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
        {
            McmlDocument      mcml = MediaCenterUtil.GetMcml(readCache["Microsoft.MediaCenter.Shell.dll"].GetResource("STARTMENUOVERLAY.MCML", (object)this.DocumentResourceType));
            PropertiesElement themeUiProperties = McmlUtilities.GetThemeUIProperties(mcml, "StartMenuOverlay");

            if (!string.IsNullOrEmpty(item.StartMenuText))
            {
                themeUiProperties.GetProperty("StartText").Value = item.StartMenuText;
            }
            McmlUtilities.UpdateFontElement(item.StartMenuTextFont, themeUiProperties.GetProperty("StartTextFont") as FontElement, item.Theme);
            McmlUtilities.UpdateColorElement(item.StartMenuTextColor, themeUiProperties.GetProperty("StartTextColor"), item.Theme);
            MediaCenterUtil.UpdateMcml(writeCache["Microsoft.MediaCenter.Shell.dll"].GetResource("STARTMENUOVERLAY.MCML", (object)this.DocumentResourceType), mcml);
        }
Пример #16
0
 public void ResetResources()
 {
     if (this.cache == null)
     {
         this.cache = new MediaCenterLibraryCache();
     }
     this.images.Clear();
     this.colors = null;
     this.fonts  = null;
     foreach (MemberInfo memberInfo in this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
     {
         this.OnPropertyChanged(memberInfo.Name);
     }
 }
Пример #17
0
 public ThemeManager(string themesPath)
 {
     if (themesPath == null)
     {
         throw new ArgumentNullException();
     }
     this.themesPath    = themesPath;
     this.AppliedThemes = new ObservableCollection <ThemeSummary>();
     this.themes        = new ObservableCollection <ThemeSummary>();
     this.Themes        = (IEnumerable <ThemeSummary>) this.themes;
     try
     {
         foreach (string path in Directory.GetDirectories(themesPath))
         {
             try
             {
                 var theme_summary = ThemeSummary.Load(path);
                 if (theme_summary != null)
                 {
                     this.themes.Add(theme_summary);
                 }
             }
             catch (FileNotFoundException)
             {
             }
         }
     }
     catch (DirectoryNotFoundException)
     {
     }
     using (MediaCenterLibraryCache centerLibraryCache = new MediaCenterLibraryCache(MediaCenterUtil.MediaCenterPath))
     {
         foreach (ThemeSummary themeSummary1 in ThemeManager.GetAppliedThemes((IResourceLibraryCache)centerLibraryCache))
         {
             ThemeSummary summary       = themeSummary1;
             ThemeSummary themeSummary2 = Enumerable.FirstOrDefault <ThemeSummary>(this.Themes, (Func <ThemeSummary, bool>)(o => o.ID == summary.ID));
             if (themeSummary2 != null)
             {
                 this.AppliedThemes.Add(themeSummary2);
             }
         }
     }
     this.AppliedThemes.CollectionChanged += (NotifyCollectionChangedEventHandler) delegate
     {
         this.IsDirty = true;
     };
 }
Пример #18
0
        public IEnumerable <FontClass> GetFontClasses(MediaCenterLibraryCache cache)
        {
            XDocument        xdocument  = XDocument.Load(MediaCenterUtil.GetXml(cache["Microsoft.MediaCenter.Shell.dll"].GetResource("FONTNAMES.MCML", (object)this.DocumentResourceType)));
            List <FontClass> list       = new List <FontClass>();
            XNamespace       xnamespace = (XNamespace)"assembly://MSCorLib/System";

            foreach (XElement element in xdocument.Root.Elements(xnamespace + "String"))
            {
                FontFace fontFaceInfo = FontUtilities.GetFontFaceInfo(MediaCenterUtil.AttributeValue(element, (XName)"String"), (MediaCenterTheme)null);
                if (fontFaceInfo != null)
                {
                    list.Add(new FontClass()
                    {
                        FontFace = fontFaceInfo,
                        Name     = MediaCenterUtil.AttributeValue(element, (XName)"Name")
                    });
                }
            }
            return((IEnumerable <FontClass>)list);
        }
Пример #19
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();
 }
Пример #20
0
        public IEnumerable <FontOverride> GetFontOverrides(MediaCenterLibraryCache cache, MediaCenterTheme theme)
        {
            XDocument           xdocument  = XDocument.Load(MediaCenterUtil.GetXml(cache["Microsoft.MediaCenter.Shell.dll"].GetResource("FONTS.MCML", (object)this.DocumentResourceType)));
            string              str1       = string.Format("global://{0}:", (object)"me");
            List <FontOverride> list       = new List <FontOverride>();
            XNamespace          xnamespace = (XNamespace)"http://schemas.microsoft.com/2006/mcml";

            foreach (XElement element in xdocument.Root.Elements(xnamespace + "Font"))
            {
                FontOverride fontOverride = new FontOverride();
                fontOverride.Name = MediaCenterUtil.AttributeValue(element, (XName)"Name");
                string font = MediaCenterUtil.AttributeValue(element, (XName)"FontName");
                if (font.StartsWith(str1))
                {
                    fontOverride.FontClass = font.Substring(str1.Length);
                }
                else
                {
                    fontOverride.FontFace = FontUtilities.GetFontFaceInfo(font, theme);
                }
                if (!string.IsNullOrEmpty(fontOverride.FontClass) || fontOverride.FontFace != null)
                {
                    int result;
                    if (int.TryParse(MediaCenterUtil.AttributeValue(element, (XName)"FontSize"), out result))
                    {
                        fontOverride.Size = result;
                    }
                    string str2 = MediaCenterUtil.AttributeValue(element, (XName)"FontStyle");
                    if (str2 != null)
                    {
                        fontOverride.IsBold   = str2.Contains("Bold");
                        fontOverride.IsItalic = str2.Contains("Italic");
                    }
                    list.Add(fontOverride);
                }
            }
            return((IEnumerable <FontOverride>)list);
        }
Пример #21
0
 public static IEnumerable <ColorItem> GetColors(MediaCenterLibraryCache cache)
 {
     return(ThemeItemBase.CreateApplicator <ColorsThemeItem, ColorsThemeItem.IColorsThemeItemApplicator>().GetColors(cache));
 }
Пример #22
0
 public IDelayedProgressOperation CreateApplyOperation(MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
 {
     return((IDelayedProgressOperation) new MediaCenterTheme.ApplyOperation(this, readCache, writeCache));
 }
Пример #23
0
 public void Apply(MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
 {
     this.Apply(readCache, writeCache, new ProgressEnabledOperation());
 }
Пример #24
0
 public virtual void Apply(MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
 {
     this.Applicator.Apply((IThemeItem)this, readCache, writeCache);
 }
Пример #25
0
 protected override void UpdateStartMenuOverlay(StartMenuThemeItem item, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
 {
 }
Пример #26
0
 public override void Apply(MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
 {
     this.Load();
     base.Apply(readCache, writeCache);
 }
Пример #27
0
 protected void ApplyThemes(ProgressEnabledOperation operation, bool preserveMenu)
 {
     this.OnApplyingThemes(new ApplyThemesEventArgs(operation));
     try
     {
         MediaCenterLibraryCache readCache          = new MediaCenterLibraryCache(VmcStudioUtil.BackupsPath, UnmanagedLibraryAccess.Read);
         MediaCenterLibraryCache writeCache         = new MediaCenterLibraryCache(MediaCenterUtil.MediaCenterPath, UnmanagedLibraryAccess.Write);
         MemoryLibraryCache      memoryLibraryCache = (MemoryLibraryCache)null;
         if (preserveMenu)
         {
             memoryLibraryCache = new MemoryLibraryCache((ushort)1033);
             using (MediaCenterLibraryCache centerLibraryCache = new MediaCenterLibraryCache())
                 StartMenuManager.Create((IResourceLibraryCache)centerLibraryCache).Save((IResourceLibraryCache)memoryLibraryCache, true);
         }
         readCache.LibraryLoading  += (EventHandler <LibraryLoadEventArgs>)((sender, e) => VmcStudioUtil.BackupFile(Path.Combine(MediaCenterUtil.MediaCenterPath, e.FileName)));
         writeCache.LibraryLoading += (EventHandler <LibraryLoadEventArgs>)((sender, e) =>
         {
             string local_0 = VmcStudioUtil.BackupFile(Path.Combine(MediaCenterUtil.MediaCenterPath, e.FileName));
             string local_1 = Path.Combine(writeCache.SearchPath, e.FileName);
             VmcStudioUtil.TakeOwnership(local_1);
             File.Copy(local_0, local_1, true);
             VmcStudioUtil.TakeOwnership(local_1);
         });
         if (Directory.Exists(VmcStudioUtil.BackupsPath))
         {
             foreach (string path in Directory.GetFiles(VmcStudioUtil.BackupsPath))
             {
                 writeCache.LoadLibrary(Path.GetFileName(path));
             }
         }
         int       num = 0;
         int       operationCompleted  = 0;
         Exception applyException      = (Exception)null;
         List <MediaCenterTheme> list1 = Enumerable.ToList <MediaCenterTheme>(Enumerable.Select <ThemeSummary, MediaCenterTheme>((IEnumerable <ThemeSummary>) this.AppliedThemes, (Func <ThemeSummary, MediaCenterTheme>)(o => o.OpenTheme())));
         try
         {
             List <IDelayedProgressOperation> list2 = new List <IDelayedProgressOperation>();
             foreach (MediaCenterTheme mediaCenterTheme in list1)
             {
                 IDelayedProgressOperation applyOperation = mediaCenterTheme.CreateApplyOperation(readCache, writeCache);
                 num += applyOperation.Count;
                 applyOperation.Progress  += (EventHandler <ProgressEventArgs>)((sender, args) => operation.OnProgress(args.Message, args.CurrentIndex + operationCompleted));
                 applyOperation.Abandoned += (EventHandler <ExceptionEventArgs>)((sender, args) => applyException = args.Exception);
                 list2.Add(applyOperation);
             }
             operation.Count = num;
             using (readCache)
             {
                 using (writeCache)
                 {
                     foreach (IDelayedProgressOperation progressOperation in list2)
                     {
                         operation.Description = progressOperation.Description;
                         progressOperation.Start();
                         progressOperation.WaitForCompletion();
                         if (applyException != null)
                         {
                             throw applyException;
                         }
                         operationCompleted += progressOperation.Count;
                     }
                     if (this.AppliedThemes.Count > 0)
                     {
                         IResource resource = writeCache["ehres.dll"].GetResource("VmcStudio.Themes.xml", (object)23);
                         using (MemoryStream memoryStream = new MemoryStream())
                         {
                             new XmlSerializer(typeof(ThemeManager.AppliedThemesDocument)).Serialize((Stream)memoryStream, (object)new ThemeManager.AppliedThemesDocument()
                             {
                                 AppliedThemes = Enumerable.ToArray <ThemeSummary>((IEnumerable <ThemeSummary>) this.AppliedThemes)
                             });
                             memoryStream.Flush();
                             ResourceExtensions.Update(resource, memoryStream.GetBuffer());
                         }
                     }
                     if (memoryLibraryCache != null)
                     {
                         memoryLibraryCache.ApplyTo((IResourceLibraryCache)writeCache);
                     }
                 }
             }
             this.IsDirty = false;
         }
         finally
         {
             foreach (MediaCenterTheme mediaCenterTheme in list1)
             {
                 mediaCenterTheme.Dispose();
             }
         }
     }
     catch (Exception ex)
     {
         Trace.TraceError(((object)ex).ToString());
         operation.OnAbandoned(ex);
         throw;
     }
     operation.OnCompleted();
 }
Пример #28
0
 public static IEnumerable <FontOverride> GetFontOverrides(MediaCenterLibraryCache cache, MediaCenterTheme theme)
 {
     return(ThemeItemBase.CreateApplicator <FontsThemeItem, FontsThemeItem.IFontsThemeItemApplicator>().GetFontOverrides(cache, theme));
 }
Пример #29
0
        public static string CreateSupportPackage()
        {
            string path2 = Guid.NewGuid().ToString();
            string str1  = Path.Combine(Path.GetTempPath(), path2);

            Trace.TraceInformation("Creating support package...");
            Directory.CreateDirectory(str1);
            try
            {
                File.Copy(VmcStudioUtil.LogFilePath, Path.Combine(str1, Path.GetFileName(VmcStudioUtil.LogFilePath)));
                string path1 = Path.Combine(VmcStudioUtil.ApplicationDataPath, "Logs");
                if (Directory.Exists(path1))
                {
                    FileUtil.CopyTo(new DirectoryInfo(path1), Path.Combine(str1, "Logs"), true);
                }
                using (StreamWriter text = File.CreateText(Path.Combine(str1, "info.txt")))
                {
                    text.WriteLine("Support package ID: {0}", (object)path2);
                    text.WriteLine("{1} Version: {0}", (object)Assembly.GetEntryAssembly().GetName().Version, (object)VmcStudioUtil.ApplicationName);
                    FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(MediaCenterUtil.MediaCenterPath, "ehshell.exe"));
                    text.WriteLine("Media Center Version: {0}", (object)versionInfo.ProductVersion);
                    text.WriteLine("Date/Time: {0}", (object)DateTime.Now);
                    text.WriteLine("User preferred language: {0}", (object)LanguageUtils.GetUserDefaultUILanguage());
                    text.WriteLine("System default language: {0}", (object)LanguageUtils.GetSystemDefaultUILanguage());
                    text.WriteLine();
                    try
                    {
                        text.WriteLine("Dumping registry...");
                        string str2 = Path.Combine(str1, "Registry");
                        Directory.CreateDirectory(str2);
                        using (RegistryKey key1 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Extensibility"))
                        {
                            using (RegistryKey key2 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Extensibility"))
                            {
                                using (RegistryKey key3 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Start Menu"))
                                {
                                    using (RegistryKey key4 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Start Menu"))
                                    {
                                        VmcStudioUtil.DumpRegistry(key1, Path.Combine(str2, "HKEY_LOCAL_MACHINE Extensibility.txt"));
                                        VmcStudioUtil.DumpRegistry(key2, Path.Combine(str2, "HKEY_CURRENT_USER Extensibility.txt"));
                                        VmcStudioUtil.DumpRegistry(key3, Path.Combine(str2, "HKEY_LOCAL_MACHINE Start Menu.txt"));
                                        VmcStudioUtil.DumpRegistry(key4, Path.Combine(str2, "HKEY_CURRENT_USER Start Menu.txt"));
                                    }
                                }
                            }
                        }
                        text.WriteLine("Success!");
                    }
                    catch (Exception ex)
                    {
                        text.WriteLine(((object)ex).ToString());
                    }
                    text.WriteLine();
                    try
                    {
                        text.WriteLine("Dumping resources...");
                        string path3 = Path.Combine(str1, "Resources");
                        Directory.CreateDirectory(path3);
                        using (MediaCenterLibraryCache centerLibraryCache = new MediaCenterLibraryCache(MediaCenterUtil.MediaCenterPath))
                        {
                            IResourceLibrary lib = centerLibraryCache["ehres.dll"];
                            VmcStudioUtil.DumpHtmlResource(lib, "STARTMENU.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.ACTIVITIES.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.MUSIC.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.PICTURES.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.SPORTS.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.TV.XML", path3);
                            UnmanagedLibrary unmanagedLibrary = lib as UnmanagedLibrary;
                            if (unmanagedLibrary != null)
                            {
                                text.WriteLine("ehres.dll MUI languages: {0}", (object)VmcStudioUtil.ArrayToString(unmanagedLibrary.GetMUI().Languages));
                            }
                            text.WriteLine("STARTMENU.XML languages: {0}", (object)VmcStudioUtil.ArrayToString(lib.GetResource("STARTMENU.XML", (object)23).Languages));
                        }
                        text.WriteLine("Success!");
                    }
                    catch (Exception ex)
                    {
                        text.WriteLine(((object)ex).ToString());
                    }
                }
                string str3 = Path.Combine(VmcStudioUtil.UserPath, "Support Packages");
                if (!Directory.Exists(str3))
                {
                    Directory.CreateDirectory(str3);
                }
                string str4 = Path.Combine(str3, string.Format("Media Center Studio Support {0}.zip", (object)path2));
                new FastZip().CreateZip(str4, str1, true, (string)null);
                Trace.WriteLine("Support package successfully created at {0}", str4);
                return(str4);
            }
            finally
            {
                Directory.Delete(str1, true);
            }
        }
Пример #30
0
 public static IEnumerable <FontClass> GetFontClasses(MediaCenterLibraryCache cache)
 {
     return(ThemeItemBase.CreateApplicator <FontsThemeItem, FontsThemeItem.IFontsThemeItemApplicator>().GetFontClasses(cache));
 }