Example #1
0
        public bool Save()
        {
            Global.DownloadFolder = StringValue(Settings.download_folder) ?? "hitomi_downloaded";
            Global.FileEn         = BoolValue(Settings.file_encrypt) ?? false;
            Global.AutoFileEn     = BoolValue(Settings.download_file_encrypt) ?? false;
            Global.EncryptTitle   = BoolValue(Settings.encrypt_title) ?? false;
            Global.RandomTitle    = BoolValue(Settings.random_title) ?? false;
            if (Global.DownloadFolder == "")
            {
                Global.DownloadFolder = "hitomi_downloaded";
            }
            string path = encrypt ? Global.Config.encryptpath : Global.Config.path;

            byte[] bytes = Encoding.UTF8.GetBytes(config.ToString());
            if (encrypt)
            {
                bytes = FileEncrypt.Encrypt(bytes, Global.Password);
            }
            File.WriteAllBytes(path, bytes);
            return(true);
        }
Example #2
0
        public bool Save()
        {
            if (Global.MainWindow != null)
            {
                Visibility visibility = Visibility.Visible;
                if (config.password.Get <string>() == null || config.file_encrypt.Get <bool>() == false)
                {
                    visibility = Visibility.Collapsed;
                }
                Global.MainWindow.Encrypt.Visibility = visibility;
                Global.MainWindow.Decrypt.Visibility = visibility;
            }
            string path = encrypt ? Global.Config.encryptpath : Global.Config.path;

            byte[] bytes = Encoding.UTF8.GetBytes(ToJObject().ToString());//JObject.FromObject(config).ToString());
            if (encrypt)
            {
                bytes = FileEncrypt.Encrypt(bytes, Global.Password);
            }
            File.WriteAllBytes(path, bytes);
            return(true);
        }