Esempio n. 1
0
        public static string BackupFile(string file)
        {
            bool   flag       = false;
            string backupFile = VmcStudioUtil.GetBackupFile(file);

            if (!File.Exists(backupFile))
            {
                Trace.TraceInformation("No backup of {0} exists, creating {1}.", (object)file, (object)backupFile);
                flag = true;
            }
            else
            {
                string fileVersion1 = VmcStudioUtil.GetFileVersion(backupFile);
                string fileVersion2 = VmcStudioUtil.GetFileVersion(file);
                if (fileVersion1 != fileVersion2)
                {
                    Trace.TraceInformation("Version of {0} has changed ({1} to {2}), refreshing backup file {3}.", (object)file, (object)fileVersion1, (object)fileVersion2, (object)backupFile);
                    VmcStudioUtil.TakeOwnership(backupFile);
                    flag = true;
                }
            }
            if (flag)
            {
                Directory.CreateDirectory(Path.GetDirectoryName(backupFile));
                File.Copy(file, backupFile, true);
            }
            return(backupFile);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        private void RestoreDefaultExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            ThemeManager themeManager = VmcStudioUtil.Application.ThemeManager;

            themeManager.AppliedThemes.Clear();
            VmcStudioUtil.RestoreModifiedFiles();
            VmcStudioUtil.Application.StartMenuManager.Reset();
            e.Handled = true;
        }
Esempio n. 4
0
 public static bool TakeOwnership(string file)
 {
     if (VmcStudioUtil.Execute("takeown", "/f \"" + file + "\"") && VmcStudioUtil.Execute("icacls", "\"" + file + "\" /grant *S-1-5-32-545:F"))
     {
         return(VmcStudioUtil.Execute("icacls", "\"" + file + "\" /grant *S-1-5-32-544:F"));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 5
0
 public static bool EnsureMediaCenterClosed(bool verifyBeforeClose)
 {
     if (VmcStudioUtil.EnsureNotRunning("ehshell", verifyBeforeClose))
     {
         return(VmcStudioUtil.EnsureNotRunning("ehtray", false));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 6
0
 public static string GetVideoFile()
 {
     string[] videoFiles = VmcStudioUtil.GetVideoFiles(false);
     if (videoFiles != null)
     {
         return(videoFiles[0]);
     }
     else
     {
         return((string)null);
     }
 }
Esempio n. 7
0
 public static string GetImageFile()
 {
     string[] imageFiles = VmcStudioUtil.GetImageFiles(false);
     if (imageFiles != null)
     {
         return(imageFiles[0]);
     }
     else
     {
         return((string)null);
     }
 }
Esempio n. 8
0
 private static void DumpRegistry(RegistryKey key, TextWriter file)
 {
     if (key == null)
     {
         return;
     }
     file.WriteLine(key.Name);
     foreach (string name in key.GetValueNames())
     {
         file.WriteLine("{0} = {1}", (object)name, key.GetValue(name) ?? (object)string.Empty);
     }
     file.WriteLine();
     foreach (string name in key.GetSubKeyNames())
     {
         using (RegistryKey key1 = key.OpenSubKey(name))
             VmcStudioUtil.DumpRegistry(key1, file);
     }
 }
Esempio n. 9
0
        public static string GetWrapperArgs(string targetFile, string targetArgs, EntryPointCapabilities caps, IEnumerable <Keys> closeKeys, IEnumerable <Keys> killKeys)
        {
            string str = string.Format("/file \"{0}\" /args {1}", (object)targetFile, (object)targetArgs);

            if ((caps & EntryPointCapabilities.DirectX) == EntryPointCapabilities.DirectX)
            {
                str = "/directx " + str;
            }
            string keys1 = VmcStudioUtil.GetKeys(closeKeys);

            if (!string.IsNullOrEmpty(keys1))
            {
                str = string.Format("/closekeys \"{0}\" {1}", (object)keys1, (object)str);
            }
            string keys2 = VmcStudioUtil.GetKeys(killKeys);

            if (!string.IsNullOrEmpty(keys2))
            {
                str = string.Format("/killkeys \"{0}\" {1}", (object)keys2, (object)str);
            }
            return(str);
        }
Esempio n. 10
0
 public static bool RestoreModifiedFiles()
 {
     if (!VmcStudioUtil.EnsureMediaCenterClosed(true))
     {
         return(false);
     }
     VmcStudioUtil.Application.CommonResources.CloseResources();
     try
     {
         foreach (string str in Directory.GetFiles(MediaCenterUtil.MediaCenterPath))
         {
             string backupFile = VmcStudioUtil.GetBackupFile(str);
             if (File.Exists(backupFile))
             {
                 File.Copy(backupFile, str, true);
             }
         }
     }
     finally
     {
         VmcStudioUtil.Application.CommonResources.ResetResources();
     }
     return(true);
 }
Esempio n. 11
0
 private static void DumpRegistry(RegistryKey key, string path)
 {
     using (StreamWriter text = File.CreateText(path))
         VmcStudioUtil.DumpRegistry(key, (TextWriter)text);
 }
Esempio n. 12
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);
            }
        }
Esempio n. 13
0
 public static string[] GetVideoFiles()
 {
     return(VmcStudioUtil.GetVideoFiles(true));
 }
Esempio n. 14
0
        private void CreateSupportPackageExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            string arg = VmcStudioUtil.CreateSupportPackage();

            Process.Start("explorer", string.Format("/select,\"{0}\"", arg));
        }