Exemple #1
0
 private void CommandBinding_Open(object sender, ExecutedRoutedEventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     if(ofd.ShowDialog(this) == true)
     {
         if (DataBoxLibrary.DataBox.IsEncrypted(ofd.FileName))
         {
             PasswordDialogue pd = new PasswordDialogue();
             if (pd.ShowDialog() == true)
             {
                 try
                 {
                     databox = DataBoxLibrary.DataBox.Open(ofd.FileName, pd.Password);
                     DisplayFileName();
                     SetChangeMade(false);
                 }
                 catch (DataBoxLibrary.IncorrectPasswordException ex)
                 {
                     MessageBox.Show("Incorrect Password", "The password was incorrect", MessageBoxButton.OK, MessageBoxImage.Warning);
                     return;
                 }
             }
             else
                 return;
         }
         else
         {
             databox = DataBoxLibrary.DataBox.Open(ofd.FileName);
             DisplayFileName();
             SetChangeMade(false);
         }
         if (databox == null)
             MessageBox.Show("File is not a Data Box file.",
                 "The selected file was not the correct format.",
                 MessageBoxButton.OK,
                 MessageBoxImage.Warning);
         else
         {
             foreach (Entry entry in databox.Entries)
             {
                 if (entry is LinkEntry)
                     sbMainView.Children.Add(new LinkItemControl((LinkEntry)entry));
             }
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Handles the Open event of the CommandBinding control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        private void CommandBinding_Open(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog(this) == true)
            {
                ClearEntries();
                if (DataBoxLibrary.DataBox.IsEncrypted(ofd.FileName))
                {
                    PasswordDialogue pd = new PasswordDialogue();
                    if (pd.ShowDialog() == true)
                    {
                        try
                        {
                            Databox = DataBoxLibrary.DataBox.Open(ofd.FileName, pd.Password);
                            DisplayFileName();
                            SetChangeMade(false);
                        }
                        catch (DataBoxLibrary.IncorrectPasswordException)
                        {
                            MessageBox.Show("Incorrect Password", "The password was incorrect", MessageBoxButton.OK, MessageBoxImage.Warning);
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    Databox = DataBoxLibrary.DataBox.Open(ofd.FileName);
                    DisplayFileName();
                    SetChangeMade(false);
                }
                LoadEntries();
                LoadTags();
            }
        }