static ThemeColorSet getColorSetFromTheme(Stream thmxFile) { XDocument themeDoc = null; StreamResourceInfo thmxSRI = new StreamResourceInfo(thmxFile, null); StreamResourceInfo sri = Application.GetResourceStream(thmxSRI, new Uri(ThmxThemeUri, UriKind.Relative)); //Add the namespace manager NameTable nameTable = new NameTable(); XmlNamespaceManager manager = new XmlNamespaceManager(nameTable); manager.AddNamespace("a", ThmxNamespace); //Create XDocument from thmx stream themeDoc = XDocument.Load(sri.Stream); XDocument xDocTheme = XDocument.Parse(themeDoc.ToString()); //Get RGB Values for the 12 theme colors string dk1 = getRGBFromTheme(xDocTheme, thmx_dk1, true); //Text string dk2 = getRGBFromTheme(xDocTheme, thmx_dk2); //Main Dark Color string lt1 = getRGBFromTheme(xDocTheme, thmx_lt1, true); //Window Background string lt2 = getRGBFromTheme(xDocTheme, thmx_lt2); //Main Light Color string a1 = getRGBFromTheme(xDocTheme, thmx_a1); //Accent1 string a2 = getRGBFromTheme(xDocTheme, thmx_a2); //Accent2 string a3 = getRGBFromTheme(xDocTheme, thmx_a3); //Accent3 string a4 = getRGBFromTheme(xDocTheme, thmx_a4); //Accent4 string a5 = getRGBFromTheme(xDocTheme, thmx_a5); //Accent5 string a6 = getRGBFromTheme(xDocTheme, thmx_a6); //Accent6 string hlink = getRGBFromTheme(xDocTheme, thmx_hlink); //Hyperlink string flink = getRGBFromTheme(xDocTheme, thmx_flink); //Followed Link //Get the two fonts string majFont = getFontFamilyFromTheme(xDocTheme, thmx_majfont); //Heading Font string minFont = getFontFamilyFromTheme(xDocTheme, thmx_minfont);//Body Font ThemeColorSet theme = new ThemeColorSet() { TextBackgroundDark1 = fromHex(dk1), TextBackgroundDark2 = fromHex(dk2), TextBackgroundLight1 = fromHex(lt1), TextBackgroundLight2 = fromHex(lt2), Accent1 = fromHex(a1), Accent2 = fromHex(a2), Accent3 = fromHex(a3), Accent4 = fromHex(a4), Accent5 = fromHex(a5), Accent6 = fromHex(a6), Hyperlink = fromHex(hlink), FollowedHyperlink = fromHex(flink), }; //Color bkStart = fromHex(dk2); //Color bkEnd = fromHex(lt2); //Color text = fromHex(dk1); //Color winBkgd = fromHex(lt1); //Color separator = fromHex(a1); //Color selected = fromHex(flink); //Color mouseOver = fromHex(hlink); //ApplicationColorSet appSet = new ApplicationColorSet() //{ // ChildWindowColorSet = new ChildWindowColorSet() // { // BackgroundStartGradientColor = bkStart, // //BackgroundEndGradientColor = bkEnd, // TitleBarColor = winBkgd, // TitleBarForegroundColor = text, // }, // SidePanelControlColorSet = new SidePanelControlColorSet() // { // BackgroundStartGradientColor = bkStart, // //BackgroundEndGradientColor = bkEnd, // MouseOverFillColor = mouseOver, // SelectedStateFillColor = selected, // SeparatorLineColor = separator, // }, //}; return theme; }
static ThemeColorSet getColorSetFromTheme(Stream thmxFile) { XDocument themeDoc = null; StreamResourceInfo thmxSRI = new StreamResourceInfo(thmxFile, null); StreamResourceInfo sri = Application.GetResourceStream(thmxSRI, new Uri(ThmxThemeUri, UriKind.Relative)); //Add the namespace manager NameTable nameTable = new NameTable(); XmlNamespaceManager manager = new XmlNamespaceManager(nameTable); manager.AddNamespace("a", ThmxNamespace); //Create XDocument from thmx stream themeDoc = XDocument.Load(sri.Stream); XDocument xDocTheme = XDocument.Parse(themeDoc.ToString()); //Get RGB Values for the 12 theme colors string dk1 = getRGBFromTheme(xDocTheme, thmx_dk1, true); //Text string dk2 = getRGBFromTheme(xDocTheme, thmx_dk2); //Main Dark Color string lt1 = getRGBFromTheme(xDocTheme, thmx_lt1, true); //Window Background string lt2 = getRGBFromTheme(xDocTheme, thmx_lt2); //Main Light Color string a1 = getRGBFromTheme(xDocTheme, thmx_a1); //Accent1 string a2 = getRGBFromTheme(xDocTheme, thmx_a2); //Accent2 string a3 = getRGBFromTheme(xDocTheme, thmx_a3); //Accent3 string a4 = getRGBFromTheme(xDocTheme, thmx_a4); //Accent4 string a5 = getRGBFromTheme(xDocTheme, thmx_a5); //Accent5 string a6 = getRGBFromTheme(xDocTheme, thmx_a6); //Accent6 string hlink = getRGBFromTheme(xDocTheme, thmx_hlink); //Hyperlink string flink = getRGBFromTheme(xDocTheme, thmx_flink); //Followed Link //Get the two fonts string majFont = getFontFamilyFromTheme(xDocTheme, thmx_majfont); //Heading Font string minFont = getFontFamilyFromTheme(xDocTheme, thmx_minfont); //Body Font ThemeColorSet theme = new ThemeColorSet() { TextBackgroundDark1 = fromHex(dk1), TextBackgroundDark2 = fromHex(dk2), TextBackgroundLight1 = fromHex(lt1), TextBackgroundLight2 = fromHex(lt2), Accent1 = fromHex(a1), Accent2 = fromHex(a2), Accent3 = fromHex(a3), Accent4 = fromHex(a4), Accent5 = fromHex(a5), Accent6 = fromHex(a6), Hyperlink = fromHex(hlink), FollowedHyperlink = fromHex(flink), }; //Color bkStart = fromHex(dk2); //Color bkEnd = fromHex(lt2); //Color text = fromHex(dk1); //Color winBkgd = fromHex(lt1); //Color separator = fromHex(a1); //Color selected = fromHex(flink); //Color mouseOver = fromHex(hlink); //ApplicationColorSet appSet = new ApplicationColorSet() //{ // ChildWindowColorSet = new ChildWindowColorSet() // { // BackgroundStartGradientColor = bkStart, // //BackgroundEndGradientColor = bkEnd, // TitleBarColor = winBkgd, // TitleBarForegroundColor = text, // }, // SidePanelControlColorSet = new SidePanelControlColorSet() // { // BackgroundStartGradientColor = bkStart, // //BackgroundEndGradientColor = bkEnd, // MouseOverFillColor = mouseOver, // SelectedStateFillColor = selected, // SeparatorLineColor = separator, // }, //}; return(theme); }