Beispiel #1
0
 public static WalletVM FromFile(string fileName, string password)
 {
     try
     {
         List <byte> myBytes = new List <byte>();
         using (IsolatedStorageFile myFile = IsolatedStorageFile.GetUserStoreForApplication())
         {
             using (IsolatedStorageFileStream ifs = myFile.OpenFile(fileName, FileMode.Open))
             {
                 using (MemoryStream ms = new MemoryStream())
                 {
                     ifs.CopyTo(ms);
                     WalletVM retVal = DeSerializeFromXML <WalletVM>(AES.Decrypt(ms.ToArray(), password));
                     retVal.BindItemEvents();
                     retVal.ResetChanges();
                     return(retVal);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Corrupt file or wrong password", "Loading File Failed", MessageBoxButton.OK);
         return(null);
     }
 }
Beispiel #2
0
        internal static WalletVM OpenCommand()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = Properties.Settings.Default.LastSaveFolder;
            dialog.DefaultExt       = "wlt";
            dialog.Filter           = "Wallet files (*.wlt)|*.wlt|All files (*.*)|*.*";
            if (dialog.ShowDialog().Value)
            {
                if (dialog.CheckFileExists)
                {
                    PasswordDialog dialog1 = new PasswordDialog();
                    if (dialog1.ShowDialog().Value)
                    {
                        if (!string.IsNullOrWhiteSpace(dialog1.Password))
                        {
                            WalletVM wallet = FromFile(dialog.FileName, dialog1.Password);
                            if (wallet != null)
                            {
                                Properties.Settings.Default.LastSaveFolder = dialog.InitialDirectory;
                                Properties.Settings.Default.Save();

                                wallet._fullPath = dialog.FileName;
                                wallet.FileName  = dialog.SafeFileName;
                                wallet.Password  = dialog1.Password;
                                wallet.BindItemEvents();
                                wallet.ResetChanges();
                            }
                            return(wallet);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        internal void NewWalletCommand()
        {
            if (string.IsNullOrEmpty(_password))
            {
                MessageBox.Show("Please enter a password", "Password can't be empty", MessageBoxButton.OK);
                return;
            }

            CloudWallet.ViewModels.WalletVM myWallet = new ViewModels.WalletVM()
            {
                FileName = "MyCloudWallet" + _walletFiles.Count.ToString() + ".wlt", Password = _password
            };
            App.MyWalletFile          = null;
            App.MyWallet              = myWallet;
            myWallet.OnSaveCompleted += myWallet_OnSaveCompleted;
            myWallet.AddCommand();
            myWallet.SaveFile();
            this.IsBusy = true;
        }