Example #1
0
        /// <summary>
        /// Handles the New 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_New(object sender, ExecutedRoutedEventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Databox file (*.dbx)|*.dbx|All files|*.*";
            if (sfd.ShowDialog() == true)
            {
                ClearEntries();
                ClearTags();
                Databox      = new DataBoxLibrary.DataBox(System.IO.Path.GetFileName(sfd.FileName));
                Databox.Path = System.IO.Path.GetDirectoryName(sfd.FileName);
                DisplayFileName();
            }
        }
Example #2
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));
             }
         }
     }
 }
Example #3
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();
            }
        }
Example #4
0
 private void CommandBinding_Close(object sender, ExecutedRoutedEventArgs e)
 {
     imgStatus.Source = null;
     DisplayFileName();
     databox = null;
 }
Example #5
0
 /// <summary>
 /// Clears the entries.
 /// </summary>
 public void ClearEntries()
 {
     Databox = null;
     sbMainView.Children.Clear();
 }