Пример #1
0
        /// <summary>
        /// Methode for try connexion with password
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnOpenExistingButtonClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenArchiveButton.Visibility = Visibility.Hidden;
                LoadingLabel.Visibility      = Visibility.Visible;

                DataEncrypter.Decrypt(((Archive)ListArchive.SelectedItem).OwnerEncrypted, ExistingArchivePassphrase.Password);

                SettingsProvider.getInstance().PassPhrase    = ExistingArchivePassphrase.Password;
                SettingsProvider.getInstance().LoadedArchive = NoteEncryptCSManager.GetInstance().GetArchive(((Archive)ListArchive.SelectedItem).Name, ExistingArchivePassphrase.Password);

                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                this.Close();
            }
            catch (Exception exc)
            {
                //display a message invalid password
                OpenArchiveButton.Visibility = Visibility.Visible;
                LoadingLabel.Visibility      = Visibility.Hidden;
                ExistingArchivePassphrase.Clear();
                MessageBox.Show("Unable to decrypt archive, check your password and try again", "Fatal error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
        public void OnDeleteArchiveButtonClicked(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("We won't be able to revert this operation...", "Are you really sure ?", MessageBoxButton.OKCancel, MessageBoxImage.Warning);

            if (result == MessageBoxResult.OK)
            {
                NoteEncryptCSManager.GetInstance().DeleteArchive(SettingsProvider.getInstance().LoadedArchive);
                ConnexionWindow connectWindow = new ConnexionWindow();
                connectWindow.Show();
                SettingsProvider.getInstance().PassPhrase = "";
                this.Close();
            }
            else if (result == MessageBoxResult.Cancel)
            {
                MessageBox.Show("I think that's a good decision.", "Yeah man !");
            }
        }
Пример #3
0
        public ConnexionWindow()
        {
            RoutedCommand firstSettings = new RoutedCommand();

            firstSettings.InputGestures.Add(new KeyGesture(Key.Enter, ModifierKeys.Alt));
            CommandBindings.Add(new CommandBinding(firstSettings, OnOpenExistingButtonClicked));

            InitializeComponent();
            Title = "Connexion";
            IDatabaseInitializer <DataBaseContext> init = new CreateDatabaseIfNotExists <DataBaseContext>();

            //IDatabaseInitializer<DataBaseContext> init = new DropCreateDatabaseAlways<DataBaseContext>();
            //IDatabaseInitializer<DataBaseContext> init = new DropCreateDatabaseIfModelChanges<DataBaseContext>();
            Database.SetInitializer(init);
            init.InitializeDatabase(new DataBaseContext());

            ListArchive.ItemsSource   = NoteEncryptCSManager.GetInstance().GetArchives();
            ListArchive.SelectedIndex = 0;
        }
Пример #4
0
        private void OnNewButtonClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                string archiveName = NewArchiveName.Text;
                string passphrase  = NewArchivePassword.Password;
                NoteEncryptCSManager.GetInstance().CreateArchive(archiveName, passphrase);
                ListArchive.ItemsSource   = NoteEncryptCSManager.GetInstance().GetArchives();
                ListArchive.SelectedIndex = ListArchive.Items.Count - 1;

                NewArchiveName.Clear();
                NewArchivePassword.Clear();
            }
            catch (Exception exc)
            {
                NewArchivePassword.Clear();
                //display a message invalid password
                MessageBox.Show("Cannot create new archive.", "Fatal error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }