Esempio n. 1
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);
        }
Esempio n. 2
0
        protected override void Load()
        {
            string attribute1       = this.XmlElement.GetAttribute("Title");
            int    stringResourceId = MediaCenterUtil.GetMagicStringResourceID(attribute1);

            if (stringResourceId >= 0)
            {
                string stringResource = ResourceExtensions.GetStringResource(this.Manager.Resources["ehres.dll"], stringResourceId);
                if (stringResource != null)
                {
                    this.originalTitle = stringResource;
                }
            }
            if (this.originalTitle == null)
            {
                this.originalTitle = attribute1;
            }
            this.Title = this.originalTitle;
            string attribute2 = this.XmlElement.GetAttribute("Icon");

            this.images = ((DefaultStartMenuManager)this.Manager).GetImages(attribute2);
            if (this.images == null)
            {
                throw new ApplicationException("Could not find image set \"" + attribute2 + "\".");
            }
            this.SetValue(XmlQuickLink.ImageProperty, (object)this.images["Focus"]);
            this.SetValue(XmlQuickLink.NonFocusImageProperty, (object)this.images["Default"]);
            string attribute3 = this.XmlElement.GetAttribute("Visible");
            bool   result;

            this.IsEnabled       = string.IsNullOrEmpty(attribute3) || bool.TryParse(attribute3, out result) && result;
            this.originalStripID = this.XmlElement.GetAttribute("AppId");
            this.originalStrip   = (DefaultMenuStrip)null;
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        private static FontOverride GetFontOverride(XElement node, string fontName, string fontSize, string fontMC)
        {
            XAttribute xattribute = node.Attribute((XName)fontName);

            if (xattribute == null)
            {
                return((FontOverride)null);
            }
            string str = (string)null;

            switch (xattribute.Value)
            {
            case "Main Font":
                str = "MainFontFace";
                break;

            case "Regular Font":
                str = "RegularFontFace";
                break;

            case "Light Font":
                str = "LightFontFace";
                break;
            }
            FontOverride fontOverride = new FontOverride()
            {
                Name      = fontMC,
                FontClass = str
            };
            int result;

            fontOverride.Size = int.TryParse(MediaCenterUtil.AttributeValue(node, (XName)fontSize), out result) ? result : 20;
            return(fontOverride);
        }
Esempio n. 5
0
        private void AddCategories(RegistryKey key)
        {
            foreach (string name in key.GetSubKeyNames())
            {
                using (RegistryKey key1 = key.OpenSubKey(name))
                {
                    if (key1.SubKeyCount != 0)
                    {
                        this.AddCategories(key1);
                    }
                }
            }
            if (MediaCenterUtil.IsGuid(key.Name.Substring(key.Name.LastIndexOf('\\') + 1)))
            {
                return;
            }
            OemCategory oemCategory1 = (OemCategory)this.RegistrySerialiser.Deserialise(this.CategoryType, key);
            OemCategory oemCategory2 = this.managerCategories[oemCategory1.CategoryPath];

            if (oemCategory2 != null)
            {
                this.RegistrySerialiser.Deserialise((object)oemCategory2, key);
            }
            else
            {
                if (oemCategory1.QuickLinks.Count <= 0)
                {
                    return;
                }
                this.managerCategories.Add(oemCategory1);
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
 internal override void Save(IResourceLibrary ehres)
 {
     foreach (StartMenuObject startMenuObject in (Collection <IQuickLink>) this.quickLinks)
     {
         startMenuObject.Save(ehres);
     }
     MediaCenterUtil.SaveXmlResource(ehres, this.DocumentResourceName, 23, this.xml);
     base.Save(ehres);
 }
Esempio n. 9
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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
 public ImageSource GetNonFocusImage()
 {
     if (this.nonFocusImageResource == null)
     {
         return((ImageSource)null);
     }
     else
     {
         return(MediaCenterUtil.GetImageResource((IResourceLibraryCache)VmcStudioUtil.Application.CommonResources.LibraryCache, this.nonFocusImageResource));
     }
 }
Esempio n. 12
0
        protected override void Load()
        {
            XmlAttribute xmlAttribute1 = this.StartMenuCategoryNode.Attributes["App"];

            this.app = xmlAttribute1 == null ? (string)null : xmlAttribute1.Value;
            XmlAttribute xmlAttribute2 = this.StartMenuCategoryNode.Attributes["AppId"];

            this.appId = xmlAttribute2 == null ? (string)null : xmlAttribute2.Value;
            string uri = this.StartMenuCategoryNode.Attributes["Description"].Value;

            this.Title         = MediaCenterUtil.GetStringResource(this.Manager.Resources, uri, false) ?? uri;
            this.originalTitle = this.Title;
            this.IsEnabled     = true;
            XmlNodeList childNodes = this.QuickLinksNode.ChildNodes;

            for (int index = 0; index < childNodes.Count; ++index)
            {
                bool       flag    = true;
                XmlElement element = childNodes[index] as XmlElement;
                if (element == null)
                {
                    XmlComment comment = childNodes[index] as XmlComment;
                    if (comment != null)
                    {
                        element = MediaCenterUtil.UncommentElement(comment);
                        flag    = element == null;
                    }
                }
                if (element != null)
                {
                    IQuickLink quickLink = (IQuickLink)null;
                    try
                    {
                        quickLink = element.Name == "home:PackageMarkupQuickLink" || element.Name == "home:ExtensiblityPackageQuickLink" || element.Name == "home:DualPackageMarkupQuickLink" ? (IQuickLink) new PackageQuickLink(this.Manager, element) : (!(element.Name == "home:DefaultPartnerQuicklink") ? (IQuickLink) new FijiQuickLink(this.Manager, element) : (IQuickLink) new FijiPartnerQuickLink(this.Manager, element));
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceWarning("Failed to load link. Exception is:\n{0}\nXml for element is:\n{1}", (object)((object)ex).ToString(), (object)element.OuterXml);
                    }
                    if (quickLink != null)
                    {
                        quickLink.BeginInit();
                        int result;
                        if (int.TryParse(element.GetAttribute("Priority"), out result))
                        {
                            quickLink.Priority  = result;
                            quickLink.IsEnabled = flag;
                            this.QuickLinks.Add(quickLink);
                        }
                        quickLink.EndInit();
                    }
                }
            }
        }
Esempio n. 13
0
 private void UpdateAutoImages()
 {
     if (this.Document.Presenter.IsImageAutoGenerated)
     {
         if (this.Document.Presenter.IsInactiveImageAutoGenerated)
         {
             this.Document.Presenter.InactiveImage = null;
         }
         if (this.Document.Presenter.TargetPage != EntryPointPresenter.NoPage)
         {
             this.Document.Presenter.Image = this.Document.Presenter.TargetPage.GetImage();
             if (this.Document.Presenter.IsInactiveImageAutoGenerated)
             {
                 this.Document.Presenter.InactiveImage = this.Document.Presenter.TargetPage.GetNonFocusImage();
             }
         }
         else if (!string.IsNullOrEmpty(this.ExecutionUrlText.Text))
         {
             try
             {
                 this.Document.Presenter.Image = Shell.GenerateThumbnail(this.ExecutionUrlText.Text);
             }
             catch (Exception exception)
             {
                 Trace.TraceError(exception.ToString());
             }
             this.Document.Presenter.InactiveImage = null;
         }
         else if (this.Document.Presenter.Media.Count > 0)
         {
             MediaInfoPresenter presenter = this.Document.Presenter.Media.First <MediaInfoPresenter>();
             if (((MediaType)presenter.MediaInfo.MediaType) != MediaType.Dvd)
             {
                 this.Document.Presenter.Image = presenter.Image;
             }
             else
             {
                 string uri  = "res://ehres!STARTMENU.QUICKLINK.PLAYDVD.FOCUS.PNG";
                 string str2 = "res://ehres!STARTMENU.QUICKLINK.PLAYDVD.NOFOCUS.PNG";
                 this.Document.Presenter.Image = MediaCenterUtil.GetImageResource(VmcStudioUtil.Application.CommonResources.LibraryCache, uri);
                 if (this.Document.Presenter.IsInactiveImageAutoGenerated)
                 {
                     this.Document.Presenter.InactiveImage = MediaCenterUtil.GetImageResource(VmcStudioUtil.Application.CommonResources.LibraryCache, str2);
                 }
             }
         }
         else
         {
             this.Document.Presenter.Image = null;
         }
     }
 }
Esempio n. 14
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);
        }
Esempio n. 15
0
        internal NowPlayingStrip(StartMenuManager smm, XmlElement element)
            : base(smm, element)
        {
            this.BeginInit();
            this.originalTitle = MediaCenterUtil.GetMagicString(this.Manager.Resources, "#SM.NowPlaying.Title", out this.titleResourceID);
            this.Title         = this.originalTitle;
            NowPlayingStrip nowPlayingStrip = this;

            NowPlayingStrip.NowPlayingLinkCollection playingLinkCollection1 = new NowPlayingStrip.NowPlayingLinkCollection();
            playingLinkCollection1.Add((IQuickLink) new NowPlayingQuickLink(smm));
            NowPlayingStrip.NowPlayingLinkCollection playingLinkCollection2 = playingLinkCollection1;
            nowPlayingStrip.links = playingLinkCollection2;
            this.EndInit();
        }
Esempio n. 16
0
        private static void DumpHtmlResource(IResourceLibrary lib, string resource, string path)
        {
            XmlReader   xmlResource = MediaCenterUtil.GetXmlResource(lib, resource, 23);
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(xmlResource);
            StringWriter  stringWriter  = new StringWriter();
            XmlTextWriter xmlTextWriter = new XmlTextWriter((TextWriter)stringWriter)
            {
                Formatting = Formatting.Indented
            };

            xmlDocument.WriteTo((XmlWriter)xmlTextWriter);
            using (StreamWriter text = File.CreateText(Path.Combine(path, resource)))
                text.Write(stringWriter.ToString());
        }
Esempio n. 17
0
 protected override void SaveInternal(IResourceLibrary ehres)
 {
     MediaCenterUtil.StripChildComments(this.StripParentNode);
     foreach (Windows7MenuStrip windows7MenuStrip in this.m_deletedStrips)
     {
         XmlElement startMenuElement = windows7MenuStrip.StartMenuElement;
         if (startMenuElement.ParentNode != null)
         {
             startMenuElement.ParentNode.RemoveChild((XmlNode)startMenuElement);
         }
         this.StartMenuDocument.DocumentElement.RemoveAttribute(string.Format("xmlns:{0}", (object)windows7MenuStrip.StartMenuNamespace));
         ResourceExtensions.Update(ehres.GetResource(windows7MenuStrip.DocumentResourceName, (object)23), (byte[])null);
     }
     this.m_deletedStrips.Clear();
     base.SaveInternal(ehres);
 }
Esempio n. 18
0
        protected override void Load()
        {
            string attribute = this.LinkElement.GetAttribute("Description");

            this.Title           = MediaCenterUtil.GetStringResource(this.Manager.Resources, attribute, false) ?? attribute;
            this.m_originalTitle = this.Title;
            XmlNode firstChild = this.LinkElement.FirstChild;

            if (firstChild == null || !(firstChild.Name == "Image") || firstChild.FirstChild == null)
            {
                return;
            }
            ImageSet imageSet = ImageSet.FromXml(this.Manager.Resources, firstChild.FirstChild as XmlElement);

            this.SetValue(XmlQuickLink.ImageProperty, (object)imageSet["Focus"]);
            this.SetValue(XmlQuickLink.NonFocusImageProperty, (object)imageSet["Default"]);
        }
Esempio n. 19
0
        protected override IMenuStrip CreateMenuStrip(XmlNode node, IResourceLibrary ehres)
        {
            IMenuStrip menuStrip  = (IMenuStrip)null;
            XmlElement xmlElement = node as XmlElement;

            if (xmlElement != null)
            {
                if (xmlElement.Name == "home:NowPlayingApp")
                {
                    menuStrip = (IMenuStrip) new NowPlayingStrip((StartMenuManager)this, xmlElement);
                }
                else if (!(xmlElement.Name == "home:MSOApp"))
                {
                    string attribute = xmlElement.GetAttribute("Uri");
                    if (!string.IsNullOrEmpty(attribute))
                    {
                        XmlReader xmlResource = MediaCenterUtil.GetXmlResource(ehres, attribute, 23);
                        if (xmlResource != null)
                        {
                            XmlDocument doc = new XmlDocument();
                            doc.Load(xmlResource);
                            menuStrip = (IMenuStrip) new DefaultMenuStrip((StartMenuManager)this, doc, xmlElement, attribute);
                        }
                        else
                        {
                            Trace.TraceWarning("Strip {0} points to null resource: {1}", (object)xmlElement.Name, (object)attribute);
                        }
                    }
                    else
                    {
                        Trace.TraceWarning("Unknown application element: {0}", new object[1]
                        {
                            (object)xmlElement.OuterXml
                        });
                    }
                }
            }
            int result;

            if (menuStrip != null && int.TryParse(xmlElement.GetAttribute("Priority"), out result))
            {
                menuStrip.Priority = result;
            }
            return(menuStrip);
        }
Esempio n. 20
0
        private ImageSource GetImage(string resourceUrl)
        {
            ImageSource imageResource;

            if (!this.images.TryGetValue(resourceUrl, out imageResource))
            {
                imageResource            = MediaCenterUtil.GetImageResource((IResourceLibraryCache)this.cache, resourceUrl);
                this.images[resourceUrl] = imageResource;
                if (imageResource == null)
                {
                    Trace.TraceWarning("Could not find image resource: {0}", new object[1]
                    {
                        (object)resourceUrl
                    });
                }
            }
            return(imageResource);
        }
Esempio n. 21
0
 private void StartScreenshotProcess()
 {
     if (!this.IsPreviewing && !this.isStartingPreview)
     {
         this.isStartingPreview = true;
         this.themeManager      = VmcStudioUtil.Application.ThemeManager;
         this.previousThemes    = new List <ThemeSummary>(this.themeManager.AppliedThemes);
         this.themeManager.AppliedThemes.Clear();
         this.themeManager.AppliedThemes.Add(Enumerable.First <ThemeSummary>(this.themeManager.Themes, (Func <ThemeSummary, bool>)(o => (this.ThemeItem.Theme.ID == o.ID))));
         IProgressEnabledOperation operation = this.themeManager.ApplyThemesAsync(true, true);
         operation.Completed += delegate
         {
             Action action2 = null;
             this.mediaCenterProcess = MediaCenterUtil.LaunchMediaCenter(false, true, true);
             this.mediaCenterProcess.EnableRaisingEvents = true;
             this.mediaCenterProcess.Exited  += new EventHandler(this.MediaCenterProcess_Exited);
             base.Dispatcher.ShutdownStarted += new EventHandler(this.Dispatcher_ShutdownStarted);
             IntPtr windowHandle = IntPtr.Zero;
             for (int j = 0; (windowHandle == IntPtr.Zero) && (j < 20); j++)
             {
                 Thread.Sleep(500);
                 windowHandle = MediaCenterUtil.GetMediaCenterWindow();
             }
             if (windowHandle != IntPtr.Zero)
             {
                 if (action2 == null)
                 {
                     action2 = delegate
                     {
                         this.preview = new WindowPreview(this.previewWindow, windowHandle);
                         this.preview.ClientAreaOnly = true;
                         this.preview.IsVisible      = true;
                         this.IsPreviewing           = true;
                         this.isStartingPreview      = false;
                     };
                 }
                 Action method = action2;
                 base.Dispatcher.Invoke(DispatcherPriority.Normal, method);
             }
         };
         VmcStudioUtil.Application.ExclusiveOperation = operation;
     }
 }
Esempio n. 22
0
        internal override void Save(IResourceLibrary ehres)
        {
            XmlNode quickLinksNode = this.QuickLinksNode;

            MediaCenterUtil.StripChildComments(quickLinksNode);
            foreach (XmlQuickLink xmlQuickLink in (Collection <IQuickLink>) this.QuickLinks)
            {
                XmlNode parentNode = xmlQuickLink.XmlElement.ParentNode;
                if (parentNode != null)
                {
                    try
                    {
                        parentNode.RemoveChild((XmlNode)xmlQuickLink.XmlElement);
                    }
                    catch (Exception)
                    {
                    }
                }
                bool flag = true;
                Windows7PartnerQuickLink partnerQuickLink = xmlQuickLink as Windows7PartnerQuickLink;
                if (partnerQuickLink != null)
                {
                    flag = partnerQuickLink.OemQuickLink != null;
                }
                if (flag)
                {
                    if (xmlQuickLink.IsEnabled)
                    {
                        quickLinksNode.AppendChild((XmlNode)xmlQuickLink.XmlElement);
                    }
                    else
                    {
                        XmlComment comment = this.MenuStripDocument.CreateComment(xmlQuickLink.XmlElement.OuterXml);
                        quickLinksNode.AppendChild((XmlNode)comment);
                    }
                }
            }
            if (this.Title != this.m_originalTitle)
            {
                this.StartMenuCategoryNode.Attributes["Description"].Value = this.Title;
            }
            base.Save(ehres);
        }
Esempio n. 23
0
        protected override void OnAfterDeserialise(RegistrySerialiser rs, RegistryKey key)
        {
            List <IQuickLink> list = new List <IQuickLink>();

            foreach (string str in key.GetSubKeyNames())
            {
                if (MediaCenterUtil.IsGuid(str))
                {
                    using (RegistryKey key1 = key.OpenSubKey(str))
                    {
                        OemQuickLink l         = (OemQuickLink)rs.Deserialise(this.Manager.QuickLinkType, key1);
                        OemQuickLink quickLink = this.GetQuickLink(l);
                        if (quickLink != null)
                        {
                            rs.Deserialise((object)quickLink, key1);
                            list.Add((IQuickLink)quickLink);
                        }
                        else if (l.EntryPoint != null)
                        {
                            if (l.Application != null)
                            {
                                list.Add((IQuickLink)l);
                            }
                        }
                    }
                }
            }
            foreach (IQuickLink quickLink in list)
            {
                if (!this.categoryQuickLinks.Contains(quickLink))
                {
                    int index = 0;
                    while (index < this.categoryQuickLinks.Count && quickLink.Priority >= this.categoryQuickLinks[index].Priority)
                    {
                        ++index;
                    }
                    this.categoryQuickLinks.Insert(index, quickLink);
                }
            }
            this.categoryName = key.Name.Substring(key.Name.LastIndexOf("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Extensibility\\Categories") + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Extensibility\\Categories".Length + 1);
            base.OnAfterDeserialise(rs, key);
        }
Esempio n. 24
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);
        }
Esempio n. 25
0
        protected override void Load()
        {
            int resourceID;

            this.Title         = MediaCenterUtil.GetMagicString(this.Manager.Resources, this.AppElement.GetAttribute("Title"), out resourceID);
            this.originalTitle = this.Title;
            string attribute = this.AppElement.GetAttribute("Visible");

            this.IsEnabled = string.IsNullOrEmpty(attribute) || Convert.ToBoolean(attribute);
            XmlNodeList childNodes = this.AppElement.ChildNodes;

            for (int index = 0; index < childNodes.Count; ++index)
            {
                XmlElement element = childNodes[index] as XmlElement;
                if (element != null)
                {
                    IQuickLink quickLink = (IQuickLink)null;
                    try
                    {
                        quickLink = !(element.Name == "home:PackageMarkupQuickLink") ? (!(element.Name == "home:PartnerQuickLink") ? (IQuickLink) new DefaultQuickLink(this.Manager, element) : (IQuickLink) new DefaultPartnerQuickLink(this.Manager, element)) : (IQuickLink) new DefaultPackageQuickLink(this.Manager, element);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceWarning("Failed to load link. Exception is:\n{0}\nXml for element is:\n{0}", (object)((object)ex).ToString(), (object)element.OuterXml);
                    }
                    if (quickLink != null)
                    {
                        quickLink.BeginInit();
                        int result;
                        if (int.TryParse(element.GetAttribute("Priority"), out result))
                        {
                            quickLink.Priority = result;
                            this.QuickLinks.Add(quickLink);
                        }
                        quickLink.EndInit();
                    }
                }
            }
        }
Esempio n. 26
0
        private void StartMediaCenter(object sender, ExecutedRoutedEventArgs e)
        {
            ThreadStart start = delegate
            {
                Process process = MediaCenterUtil.LaunchMediaCenter(new ProcessStartInfo
                {
                    UseShellExecute       = false,
                    RedirectStandardError = true
                }, false, false, false);
                process.ErrorDataReceived += delegate(object s, DataReceivedEventArgs args)
                {
                    Trace.TraceError("Media Center Error: " + args.Data);
                };
                process.BeginErrorReadLine();
                process.WaitForExit();
            };

            new Thread(start)
            {
                IsBackground = true
            }.Start();
        }
Esempio n. 27
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);
        }
Esempio n. 28
0
 public override string ToString()
 {
     return(MediaCenterUtil.ColorToString(this.Color));
 }
Esempio n. 29
0
        public MediaCenterFXTheme(string file)
            : base(file, FileMode.Open)
        {
            FontsThemeItem fonts = new FontsThemeItem();

            fonts.BeginInit();
            ColorsThemeItem colorsThemeItem = new ColorsThemeItem();

            colorsThemeItem.BeginInit();
            StartMenuThemeItem startMenuThemeItem = new StartMenuThemeItem();

            startMenuThemeItem.BeginInit();
            this.ThemeItems.Add((IThemeItem)startMenuThemeItem);
            AnimationsItem animationsItem = new AnimationsItem();

            animationsItem.BeginInit();
            this.ThemeItems.Add((IThemeItem)animationsItem);
            foreach (ZipEntry entry in this.ZipFile)
            {
                if (entry.IsFile)
                {
                    ResourceThemeItem resourceThemeItem = (ResourceThemeItem)null;
                    string            str = entry.Name.ToUpper();
                    switch (Path.GetExtension(str))
                    {
                    case ".PNG":
                        if (str == "CUSTOM.THEMESHOT.PNG")
                        {
                            this.MainScreenshot = (BitmapSource)BitmapDecoder.Create(this.ZipFile.GetInputStream(entry), BitmapCreateOptions.None, BitmapCacheOption.OnLoad).Frames[0];
                            break;
                        }
                        else
                        {
                            resourceThemeItem = (ResourceThemeItem) new ImageResourceThemeItem("ehres.dll", str, (Func <ResourceThemeItem, byte[]>)(themeItem => ZippedTheme.ReadZipEntry(this.ZipFile, this.zipEntries[(IThemeItem)themeItem])));
                            break;
                        }

                    case ".TTF":
                        this.fontEntries.Add(entry);
                        break;
                    }
                    if (resourceThemeItem != null)
                    {
                        this.zipEntries[(IThemeItem)resourceThemeItem] = entry;
                        this.ThemeItems.Add((IThemeItem)resourceThemeItem);
                    }
                }
            }
            ZipEntry entry1 = this.ZipFile.GetEntry("Theme.xml");

            if (entry1 == null)
            {
                throw new InvalidDataException("Could not find Theme.xml.");
            }
            XDocument xdocument = XDocument.Load((XmlReader) new XmlTextReader(this.ZipFile.GetInputStream(entry1)));

            if (xdocument.Root != null)
            {
                foreach (XElement xelement in xdocument.Root.Elements())
                {
                    switch (xelement.Name.LocalName)
                    {
                    case "Biography":
                        this.Name     = MediaCenterUtil.AttributeValue(xelement, (XName)"Name");
                        this.Author   = MediaCenterUtil.AttributeValue(xelement, (XName)"Author");
                        this.Version  = new Version(MediaCenterUtil.AttributeValue(xelement, (XName)"Version"));
                        this.Comments = MediaCenterUtil.AttributeValue(xelement, (XName)"Comments");
                        continue;

                    case "Sounds":
                        using (IEnumerator <XAttribute> enumerator = xelement.Attributes().GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                XAttribute             current           = enumerator.Current;
                                string                 localName         = current.Name.LocalName;
                                ZipEntry               entry2            = this.ZipFile.GetEntry(current.Value);
                                SoundResourceThemeItem resourceThemeItem = new SoundResourceThemeItem("ehres.dll", localName, (Func <ResourceThemeItem, byte[]>)(themeItem => ZippedTheme.ReadZipEntry(this.ZipFile, this.zipEntries[(IThemeItem)themeItem])));
                                this.zipEntries[(IThemeItem)resourceThemeItem] = entry2;
                                this.ThemeItems.Add((IThemeItem)resourceThemeItem);
                            }
                            continue;
                        }

                    case "MainFonts":
                        using (IEnumerator <XAttribute> enumerator = xelement.Attributes().GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                XAttribute current   = enumerator.Current;
                                FontClass  fontClass = new FontClass()
                                {
                                    Name = current.Name.LocalName
                                };
                                fontClass.FontFace = FontUtilities.GetFontFaceInfo(current.Value, (MediaCenterTheme)this);
                                if (fontClass.FontFace != null)
                                {
                                    fonts.FontClasses.Add(fontClass);
                                }
                            }
                            continue;
                        }

                    case "FontsOverrides":
                        MediaCenterFXTheme.AddFontOverride(fonts, xelement, "FontDialogC", "DialogCSize", "DialogContent");
                        MediaCenterFXTheme.AddFontOverride(fonts, xelement, "FontButton", "SizeButton", "ButtonText");
                        MediaCenterFXTheme.AddFontOverride(fonts, xelement, "FontDialogT", "DialogTSize", "DialogTitle");
                        MediaCenterFXTheme.AddFontOverride(fonts, xelement, "FontThumbnail", "ThumbnailSize", "ThumbnailButtonText");
                        MediaCenterFXTheme.AddFontOverride(fonts, xelement, "FontVolume", "VolumeSize", "VolumeText");
                        MediaCenterFXTheme.AddFontOverride(fonts, xelement, "FontBackground", "SizeBackground", "BackgroundTitleText");
                        continue;

                    case "MainColors":
                        using (IEnumerator <XAttribute> enumerator = xelement.Attributes().GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                XAttribute current = enumerator.Current;
                                Color      color;
                                if (this.TryParseColor(current.Value, out color))
                                {
                                    colorsThemeItem.DefaultColors.Add(new ColorItem()
                                    {
                                        Color = color,
                                        Name  = current.Name.LocalName
                                    });
                                }
                                else
                                {
                                    Trace.TraceWarning("Could not parse color value for {0} \"{1}\" in theme file {2}.", (object)current.Name, (object)current.Value, (object)file);
                                }
                            }
                            continue;
                        }

                    case "StartMenu":
                        startMenuThemeItem.StripTitleFont = this.GetFontOverride(MediaCenterUtil.AttributeValue(xelement, (XName)"FontFace"), MediaCenterUtil.AttributeValue(xelement, (XName)"FontSize"));
                        Color color1;
                        if (this.TryParseColor(MediaCenterUtil.AttributeValue(xelement, (XName)"FocusColor"), out color1))
                        {
                            startMenuThemeItem.FocusedStripTitleColor = new ColorReference()
                            {
                                Color = new Color?(color1)
                            }
                        }
                        ;
                        Color color2;
                        if (this.TryParseColor(MediaCenterUtil.AttributeValue(xelement, (XName)"NoFocusColor"), out color2))
                        {
                            startMenuThemeItem.NonFocusedStripTitleColor = new ColorReference()
                            {
                                Color = new Color?(color2)
                            };
                            continue;
                        }
                        else
                        {
                            continue;
                        }

                    case "QuickLink":
                        startMenuThemeItem.FocusedQuickLinkFont    = this.GetFontOverride(MediaCenterUtil.AttributeValue(xelement, (XName)"SelectedFontFace"), MediaCenterUtil.AttributeValue(xelement, (XName)"SelectedFontSize"));
                        startMenuThemeItem.NonFocusedQuickLinkFont = this.GetFontOverride(MediaCenterUtil.AttributeValue(xelement, (XName)"NonSelectedFontFace"), MediaCenterUtil.AttributeValue(xelement, (XName)"NonSelectedFontSize"));
                        if (startMenuThemeItem.FocusedQuickLinkFont.Size == 0)
                        {
                            startMenuThemeItem.FocusedQuickLinkFont.Size = startMenuThemeItem.NonFocusedQuickLinkFont.Size;
                        }
                        if (startMenuThemeItem.NonFocusedQuickLinkFont.Size == 0)
                        {
                            startMenuThemeItem.NonFocusedQuickLinkFont.Size = startMenuThemeItem.FocusedQuickLinkFont.Size;
                        }
                        Color color3;
                        if (this.TryParseColor(MediaCenterUtil.AttributeValue(xelement, (XName)"SelectedColor"), out color3))
                        {
                            startMenuThemeItem.FocusedQuickLinkColor = new ColorReference()
                            {
                                Color = new Color?(color3)
                            }
                        }
                        ;
                        Color color4;
                        if (this.TryParseColor(MediaCenterUtil.AttributeValue(xelement, (XName)"NonSelectedColor"), out color4))
                        {
                            startMenuThemeItem.NonFocusedQuickLinkColor = new ColorReference()
                            {
                                Color = new Color?(color4)
                            };
                            continue;
                        }
                        else
                        {
                            continue;
                        }

                    case "StartText":
                        startMenuThemeItem.StartMenuText     = MediaCenterUtil.AttributeValue(xelement, (XName)"String");
                        startMenuThemeItem.StartMenuTextFont = this.GetFontOverride(MediaCenterUtil.AttributeValue(xelement, (XName)"FontFace"), MediaCenterUtil.AttributeValue(xelement, (XName)"FontSize"));
                        Color color5;
                        if (this.TryParseColor(MediaCenterUtil.AttributeValue(xelement, (XName)"Color"), out color5))
                        {
                            startMenuThemeItem.StartMenuTextColor = new ColorReference()
                            {
                                Color = new Color?(color5)
                            };
                            continue;
                        }
                        else
                        {
                            continue;
                        }

                    case "MainBackgroundAnimation":
                        string str = MediaCenterUtil.AttributeValue(xelement, (XName)"BackgroundAnimationDisabled");
                        animationsItem.IsBackgroundAnimationDisabled = str != null && bool.Parse(str);
                        continue;

                    default:
                        continue;
                    }
                }
            }
            this.ID = this.Name;
            fonts.EndInit();
            colorsThemeItem.EndInit();
            startMenuThemeItem.EndInit();
            animationsItem.EndInit();
            this.FontsItem  = fonts;
            this.ColorsItem = colorsThemeItem;
        }
Esempio n. 30
0
        protected override IMenuStrip CreateMenuStrip(XmlNode node, IResourceLibrary ehres)
        {
            XmlElement startMenuTargetElement = node as XmlElement;
            bool       flag = true;

            if (startMenuTargetElement == null)
            {
                XmlComment comment = node as XmlComment;
                if (comment != null)
                {
                    startMenuTargetElement = MediaCenterUtil.UncommentElement(comment);
                    flag = startMenuTargetElement == null;
                }
            }
            IMenuStrip menuStrip = (IMenuStrip)null;

            if (startMenuTargetElement != null)
            {
                XmlElement xmlElement = startMenuTargetElement;
                if (startMenuTargetElement.Name == "home:ConstrainedCategory" || startMenuTargetElement.Name == "constraints:ConstrainedItem")
                {
                    startMenuTargetElement = (XmlElement)startMenuTargetElement.FirstChild.FirstChild;
                }
                if (startMenuTargetElement.Name == "home:NowPlayingStartMenuCategory")
                {
                    menuStrip = (IMenuStrip) new NowPlayingStrip((StartMenuManager)this, xmlElement);
                }
                else if (!(startMenuTargetElement.Name == "home:MSOStartMenuCategory"))
                {
                    string attribute1 = startMenuTargetElement.GetAttribute("StartMenuCategory");
                    if (!string.IsNullOrEmpty(attribute1) && attribute1.StartsWith("global://"))
                    {
                        int num = attribute1.IndexOf(':', "global://".Length);
                        if (num >= 0)
                        {
                            string str        = attribute1.Substring("global://".Length, num - "global://".Length);
                            string attribute2 = this.StartMenuDocument.DocumentElement.GetAttribute("xmlns:" + str);
                            if (!string.IsNullOrEmpty(attribute2))
                            {
                                string    resourceName;
                                XmlReader xmlResource = MediaCenterUtil.GetXmlResource(this.Resources, attribute2, out resourceName);
                                if (xmlResource != null)
                                {
                                    XmlDocument doc = new XmlDocument();
                                    doc.Load(xmlResource);
                                    Windows7MenuStrip windows7MenuStrip = new Windows7MenuStrip((StartMenuManager)this, doc, xmlElement, startMenuTargetElement, resourceName);
                                    windows7MenuStrip.StartMenuNamespace = str;
                                    windows7MenuStrip.IsEnabled          = flag;
                                    menuStrip = (IMenuStrip)windows7MenuStrip;
                                }
                                else
                                {
                                    Trace.TraceWarning("Strip {0} points to null resource: {1}", (object)startMenuTargetElement.Name, (object)attribute2);
                                }
                            }
                            else
                            {
                                Trace.TraceWarning("Could not find namespace \"{0}\". Element: {1}", (object)str, (object)startMenuTargetElement.OuterXml);
                            }
                        }
                        else
                        {
                            Trace.TraceWarning("Invalid StartMenuCategory value \"{0}\". Element: {1}", (object)attribute1, (object)startMenuTargetElement.OuterXml);
                        }
                    }
                    else
                    {
                        Trace.TraceWarning("Unknown application element: {0}", new object[1]
                        {
                            (object)startMenuTargetElement.OuterXml
                        });
                    }
                }
            }
            int result;

            if (menuStrip != null && int.TryParse(startMenuTargetElement.GetAttribute("Priority"), out result))
            {
                menuStrip.Priority = result;
            }
            return(menuStrip);
        }