예제 #1
0
        private PdfCreatorSettings LoadDefaultUserSettings(PdfCreatorSettings defaultSettings, DefaultProfileBuilder profileBuilder,
                                                           IStorage regStorage)
        {
            var defaultUserStorage = new RegistryStorage(RegistryHive.Users,
                                                         @".DEFAULT\" + _installationPathProvider.SettingsRegistryPath);

            var data = Data.CreateDataStorage();

            defaultUserStorage.SetData(data);

            // Store default settings and then load the machine defaults from HKEY_USERS\.DEFAULT to give them prefrence
            defaultSettings.StoreValues(data, "");
            defaultUserStorage.ReadData("", false);

            // And then load the combined settings with default user overriding our defaults
            var settings = profileBuilder.CreateEmptySettings(regStorage);

            settings.ReadValues(data, "");

            return(settings);
        }
예제 #2
0
        private void SaveSettings(string userId, string uri, string password)
        {
            INameValueStore storage = new RegistryStorage();

            try
            {
                if (String.IsNullOrEmpty(password))
                {
                    storage.Delete(uri, "UserName");
                    storage.Delete(uri, "Password");
                }
                else
                {
                    storage.Write(uri, "UserName", userId);
                    storage.Write(uri, "Password", Encryption.CurrentUser.Encrypt(password));
                }
            }
            catch
            {
            }
        }
예제 #3
0
        private static bool IsSupportedRuntimeVersion()
        {
            //https://msdn.microsoft.com/en-us/library/hh925568
            const int minSupportedRelease = 460798;

            if (RegistryStorage.Load(name: "DoVersionCheck") == "False")
            {
                return(true);
            }
            using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"))
            {
                if (key?.GetValue("Release") != null)
                {
                    var releaseKey = (int)key.GetValue("Release");
                    if (releaseKey >= minSupportedRelease)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #4
0
파일: Form1.cs 프로젝트: youlun/rp-checker
        private void Form1_Load(object sender, EventArgs e)
        {
            UpdateText();

            var saved = ToolKits.String2Point(RegistryStorage.Load(@"Software\RPChecker", "location"));

            if (saved != new Point(-32000, -32000))
            {
                Location = saved;
            }
            this.NormalizePosition();
            RegistryStorage.RegistryAddCount(@"Software\RPChecker\Statistics", @"Count");

            cbFPS.SelectedIndex     = 0;
            cbVpyFile.SelectedIndex = 0;
            var current = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);

            cbVpyFile.Items.AddRange(current.GetFiles("*.vpy").ToArray <object>());
            btnAnalyze.Enabled = false;

            Updater.Utils.CheckUpdateWeekly("RPChecker");
        }
예제 #5
0
        private IStorage BuildMigrationStorage()
        {
            var storage = new RegistryStorage(RegistryHive.CurrentUser, InstallationPathProvider.SettingsRegistryPath, true);

            return(_migrationStorageFactory.GetMigrationStorage(storage, CreatorAppSettings.ApplicationSettingsVersion, _settingsBackup));
        }
예제 #6
0
        public static async Task <KeyValuePair <string, BDMVGroup> > GetChapterAsync(string location)
        {
            var list      = new BDMVGroup();
            var bdmvTitle = string.Empty;
            var path      = Path.Combine(location, "BDMV", "PLAYLIST");

            if (!Directory.Exists(path))
            {
                throw new FileNotFoundException("Blu-Ray disc structure not found.");
            }

            var metaPath = Path.Combine(location, "BDMV", "META", "DL");

            if (Directory.Exists(metaPath))
            {
                var xmlFile = Directory.GetFiles(metaPath).FirstOrDefault(file => file.ToLower().EndsWith(".xml"));
                if (xmlFile != null)
                {
                    var xmlText = File.ReadAllText(xmlFile);
                    var title   = Regex.Match(xmlText, @"<di:name>(?<title>[^<]*)</di:name>");
                    if (title.Success)
                    {
                        bdmvTitle = title.Groups["title"].Value;
                        OnLog?.Invoke($"Disc Title: {bdmvTitle}");
                    }
                }
            }

            var eac3toPath = RegistryStorage.Load(name: "eac3toPath");

            if (string.IsNullOrEmpty(eac3toPath) || !File.Exists(eac3toPath))
            {
                eac3toPath = Notification.InputBox("请输入eac3to的地址", "注意不要带上多余的引号", "C:\\eac3to\\eac3to.exe");
                if (string.IsNullOrEmpty(eac3toPath))
                {
                    return(new KeyValuePair <string, BDMVGroup>(bdmvTitle, list));
                }
                RegistryStorage.Save(name: "eac3toPath", value: eac3toPath);
            }
            var workingPath = Directory.GetParent(location).FullName;

            location = location.Substring(location.LastIndexOf('\\') + 1);
            var text = (await TaskAsync.RunProcessAsync(eac3toPath, $"\"{location}\"", workingPath)).ToString();

            if (text.Contains("HD DVD / Blu-Ray disc structure not found."))
            {
                OnLog?.Invoke(text);
                throw new Exception("May be the path is too complex or directory contains nonAscii characters");
            }
            OnLog?.Invoke("\r\nDisc Info:\r\n" + text);

            foreach (Match match in RDiskInfo.Matches(text))
            {
                var index = match.Groups["idx"].Value;
                var mpls  = match.Groups["mpls"].Value;
                var time  = match.Groups["dur"].Value;
                if (string.IsNullOrEmpty(time))
                {
                    time = match.Groups["dur2"].Value;
                }
                var file = match.Groups["fn"].Value;
                if (string.IsNullOrEmpty(file))
                {
                    file = match.Groups["fn2"].Value;
                }
                OnLog?.Invoke($"+ {index}) {mpls} -> [{file}] - [{time}]");

                list.Add(new ChapterInfo
                {
                    Duration    = TimeSpan.Parse(time),
                    SourceIndex = index,
                    SourceName  = file,
                });
            }
            var toBeRemove  = new List <ChapterInfo>();
            var chapterPath = Path.Combine(workingPath, "chapters.txt");
            var logPath     = Path.Combine(workingPath, "chapters - Log.txt");

            foreach (var current in list)
            {
                text = (await TaskAsync.RunProcessAsync(eac3toPath, $"\"{location}\" {current.SourceIndex})", workingPath)).ToString();
                if (!text.Contains("Chapters"))
                {
                    toBeRemove.Add(current);
                    continue;
                }
                text = (await TaskAsync.RunProcessAsync(eac3toPath, $"\"{location}\" {current.SourceIndex}) chapters.txt", workingPath)).ToString();
                if (!text.Contains("Creating file \"chapters.txt\"...") && !text.Contains("Done!"))
                {
                    OnLog?.Invoke(text);
                    throw new Exception("Error creating chapters file.");
                }
                current.Chapters = OgmData.GetChapterInfo(File.ReadAllBytes(chapterPath).GetUTFString()).Chapters;
                if (current.Chapters.First().Name != string.Empty)
                {
                    continue;
                }
                var chapterName = ChapterName.GetChapterName();
                current.Chapters.ForEach(chapter => chapter.Name = chapterName());
            }
            toBeRemove.ForEach(item => list.Remove(item));
            if (File.Exists(chapterPath))
            {
                File.Delete(chapterPath);
            }
            if (File.Exists(logPath))
            {
                File.Delete(logPath);
            }
            return(new KeyValuePair <string, BDMVGroup>(bdmvTitle, list));
        }
예제 #7
0
 public SettingsHost()
 {
     Storage = new RegistryStorage("Software\\Sitecore\\Sitecore.Rocks.VisualStudio\\");
     Options = new Options("Windows");
 }
예제 #8
0
 private void FrmLoadFiles_FormClosing(object sender, FormClosingEventArgs e)
 {
     RegistryStorage.Save(Location.ToString(), @"Software\RPChecker", "LoadLocation");
 }
예제 #9
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Updater.Utils.SoftwareName   = "AutoTorrentInspection";
            Updater.Utils.RepoName       = "vcb-s/Auto-Torrent-Inspection";
            Updater.Utils.CurrentVersion = Assembly.GetExecutingAssembly().GetName().Version;
            Logger.StoreLogMessages      = true;
            Logger.LoggerHandlerManager.AddHandler(new DebugConsoleLoggerHandler());

            if (!IsSupportedRuntimeVersion())
            {
                var ret = Notification.ShowInfo("需要 .Net4.8 或以上版本以保证所有功能正常运作,是否不再提示?");
                System.Diagnostics.Process.Start("https://dotnet.microsoft.com/download/dotnet-framework");
                if (ret == DialogResult.Yes)
                {
                    RegistryStorage.Save("False", name: "DoVersionCheck");
                }
            }
            if (!File.Exists("config.json"))
            {
                Logger.Log("Extract default config file to current directory");
                File.WriteAllText("config.json", new Configuration().ToString());
            }
            else
            {
                try
                {
                    var           updateConfigFile = false;
                    Configuration config, defaultConfig;
                    using (var input = new StreamReader("config.json"))
                    {
                        config        = JSON.Deserialize <Configuration>(input);
                        defaultConfig = new Configuration();
                        if (defaultConfig.Version > config.Version)
                        {
                            updateConfigFile = true;
                        }
                    }
                    if (updateConfigFile)
                    {
                        File.WriteAllText("config.json", config.ToString());
                        Logger.Log($"Update the config file version from {config.Version}->{defaultConfig.Version}");
                    }
                }
                catch (Exception e)
                {
                    Logger.Log(e);
                    Notification.ShowError("无法读取配置文件", e);
                }
#if DEBUG
                File.WriteAllText("config.json", new Configuration().ToString());
                Logger.Log("Config file is now up to date");
#endif
            }
            if (args.Length == 0)
            {
                Application.Run(new Form1());
            }
            else
            {
                var argsFull = string.Join(" ", args);
                //argsFull = "\"" + argsFull + "\"";
                Application.Run(new Form1(argsFull));
            }
        }
예제 #10
0
파일: Form1.cs 프로젝트: youlun/rp-checker
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     _coreProcess.Kill();
     RegistryStorage.Save(Location.ToString(), @"Software\RPChecker", "Location");
 }
예제 #11
0
        private IStorage BuildStorage()
        {
            var storage = new RegistryStorage(RegistryHive.CurrentUser, InstallationPathProvider.SettingsRegistryPath, true);

            return(storage);
        }
 public VisualStudioSettingsHost()
 {
     Storage = new RegistryStorage(@"Software\\Sitecore\\Sitecore.Rocks.VisualStudio\\");
     Options = SitecorePackage.Instance.Options;
 }