private void BuildList() { // // // m_strThemeFolder = RscKnownFolders.GetSystemPath("Theme"); RscStore store = new RscStore(); string[] fldrs = RscSort.OrderBy(store.GetFolderNames(m_strThemeFolder, "*.*")); string sFldrs = "Default"; foreach (string fldr in fldrs) { switch (fldr) { case "Current": case "Default": //Special folders... break; default: sFldrs += "|" + fldr; break; } } fldrs = sFldrs.Split('|'); // // // // string [] astrKeys = new String [2]; astrKeys[0] = "Bk001_portrait"; astrKeys[1] = "Bk001_landscape"; // // // // int iCount = fldrs.Length; for (int i = 0; i < iCount; i++) { string fldr = fldrs[i]; Theme thm = new Theme(); m_a.Add(thm); foreach (string sImage in astrKeys) { ThemeImg thmimg = new ThemeImg(fldr, sImage); thm.m_a.Add(thmimg); } } // // // }
private void CopyImage(int iPos) { if (m_a.Count == 0) { return; } int iY = (iPos / m_a[0].m_a.Count); int iX = iPos % m_a[0].m_a.Count; //m_AppFrame.SetStatusText( iY.ToString() + " | " + iX.ToString() ); ThemeImg thi = m_a[iY].m_a[iX]; if (!thi.Checked) { return; } if (thi.FullPath.Length == 0) { return; } //m_AppFrame.SetStatusText( thi.FullPath ); RscStore store = new RscStore(); string sPath; sPath = m_strThemeFolder + "\\" + "Current" + "\\" + thi.Image + ".png"; if (store.FileExists(sPath)) { store.DeleteFile(sPath); } sPath = m_strThemeFolder + "\\" + "Current" + "\\" + thi.Image + ".jpg"; if (store.FileExists(sPath)) { store.DeleteFile(sPath); } string sPathTrg = thi.FullPath; sPathTrg = sPathTrg.Replace("\\" + thi.Name + "\\", "\\" + "Current" + "\\"); store.CopyFile(thi.FullPath, sPathTrg); }
private void CopyImage(int iPos) { if (m_a.Count == 0) { return; } int iY = (iPos / m_iCX); // + 1; int iX = iPos % m_iCX; //m_AppFrame.SetStatusText( iY.ToString() + " | " + iX.ToString() ); ThemeImg thi = m_a[iY].m_a[iX]; if (!thi.Checked) { return; } if (thi.FullPath.Length == 0) { return; } //m_AppFrame.SetStatusText( thi.FullPath ); RscStore store = new RscStore(); string sPath; sPath = m_strThemeFolder + "\\" + "Current" + "\\" + thi.Image + ".png"; if (store.FileExists(sPath)) { store.DeleteFile(sPath); } sPath = m_strThemeFolder + "\\" + "Current" + "\\" + thi.Image + ".jpg"; if (store.FileExists(sPath)) { store.DeleteFile(sPath); } string sPathTrg = thi.FullPath; sPathTrg = sPathTrg.Replace("\\" + thi.Name + "\\", "\\" + "Current" + "\\"); store.CopyFile(thi.FullPath, sPathTrg); if (iY == 0) { int iPos2 = thi.FullPath.LastIndexOf('\\'); if (iPos2 >= 0) { string sSrc = thi.FullPath.Substring(0, iPos2 + 1); sSrc += "ThemeColors.xml"; if (store.FileExists(sSrc)) { string sTrg = sSrc.Replace("\\" + thi.Name + "\\", "\\" + "Current" + "\\"); if (store.FileExists(sTrg)) { store.DeleteFile(sTrg); } store.CopyFile(sSrc, sTrg); } } } }
private void BuildList() { // // // m_strThemeFolder = RscKnownFolders.GetSystemPath("Theme"); RscStore store = new RscStore(); string[] fldrs = RscSort.OrderBy(store.GetFolderNames(m_strThemeFolder, "*.*")); string sFldrs = "Default"; foreach (string fldr in fldrs) { switch (fldr) { case "Current": case "Default": //Special folders... break; default: { string sPathPre = m_strThemeFolder + "\\" + fldr + "\\" + "Theme"; bool bFullTheme = false; //There are WallPaper only folders!!! if (store.FileExists(sPathPre + ".png")) { bFullTheme = true; } if (store.FileExists(sPathPre + ".jpg")) { bFullTheme = true; } if (bFullTheme) { sFldrs += "|" + fldr; } break; } } } fldrs = sFldrs.Split('|'); // // // // var listOfImageResources = new StringBuilder(); //var asm = Assembly.GetExecutingAssembly(); //MessageBox.Show( asm.FullName ); // // NOT WORKS: //var asm = Assembly.LoadFrom("RscLib.dll"); //var asm = Assembly.Load("Microsoft.Phone.Media.Extended, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e"); var asm = Assembly.Load("Lib_Rsc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); var mrn = asm.GetManifestResourceNames(); foreach (var resource in mrn) { var rm = new ResourceManager(resource.Replace(".resources", ""), asm); try { var NOT_USED = rm.GetStream("app.xaml"); // without getting a stream, next statement doesn't work - bug? var rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, false, true); var enumerator = rs.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Key.ToString().StartsWith("images/")) { listOfImageResources.AppendLine( RscEncode.UrlEncodingToString(enumerator.Key.ToString()) ); } } } catch (MissingManifestResourceException) { // Ignore any other embedded resources (they won't contain app.xaml) } } string str = listOfImageResources.ToString(); string [] astrDelims = new String [1]; astrDelims[0] = "\r\n"; string [] astrKeys = RscSort.OrderBy(str.Split(astrDelims, StringSplitOptions.RemoveEmptyEntries)); // // // // int iCount = astrKeys.Length; for (int i = -1; i < iCount; i++) { string sImage; if (i == -1) { sImage = "Theme"; } else { string sTmp = astrKeys[i]; int iPos1 = sTmp.LastIndexOf('/'); if (iPos1 < 0) { iPos1 = -1; } int iPos2 = sTmp.LastIndexOf('.'); if (iPos2 < 0) { iPos2 = sTmp.Length; } sImage = sTmp.Substring(iPos1 + 1, iPos2 - (iPos1 + 1)); } string [] astrFldrLst; string sName; int iPos; Theme thm = new Theme(); m_a.Add(thm); foreach (string fldr in fldrs) { ThemeImg thmimg = new ThemeImg(fldr, sImage); thm.m_a.Add(thmimg); string sPath; sPath = m_strThemeFolder + "\\" + thmimg.Name + "\\" + thmimg.Image + ".png"; if (store.FileExists(sPath)) { astrFldrLst = store.GetFileNames(m_strThemeFolder + "\\" + thmimg.Name, thmimg.Image + ".png"); sName = ""; if (astrFldrLst.Length == 1) { sName = astrFldrLst[0]; } if (sName.Length > 0) { iPos = sName.LastIndexOf('.'); if (iPos >= 0) { //FIX: Orig value of thmimg.Image (Key) is LOWERCASE!!! thmimg.Image = sName.Substring(0, iPos); sPath = m_strThemeFolder + "\\" + thmimg.Name + "\\" + sName; } } thmimg.FullPath = sPath; } else { sPath = m_strThemeFolder + "\\" + thmimg.Name + "\\" + thmimg.Image + ".jpg"; if (store.FileExists(sPath)) { astrFldrLst = store.GetFileNames(m_strThemeFolder + "\\" + thmimg.Name, thmimg.Image + ".jpg"); sName = ""; if (astrFldrLst.Length == 1) { sName = astrFldrLst[0]; } if (sName.Length > 0) { iPos = sName.LastIndexOf('.'); if (iPos >= 0) { //FIX: Orig value of thmimg.Image (Key) is LOWERCASE!!! thmimg.Image = sName.Substring(0, iPos); sPath = m_strThemeFolder + "\\" + thmimg.Name + "\\" + sName; } } thmimg.FullPath = sPath; } else { thmimg.FullPath = ""; //Not found... } } } } // // // // if (m_a.Count == 0) { m_iCX = 0; } else { m_iCX = m_a[0].m_a.Count; } // // // }