/// <summary> /// Handles the Executed event of the ExportCommand control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param> private void ExportCommand_Executed(object sender, ExecutedRoutedEventArgs e) { e.Handled = true; var param = e.Parameter as ItemParams; if (param == null) { return; } switch (param.Type) { case ObjectType.Category: var dialog = new SaveFileDialog() { Title = "Create database file", Filter = LocalFileContext.FileFilter, CreatePrompt = false, OverwritePrompt = true }; if (!(dialog.ShowDialog(Application.Current.MainWindow) ?? false)) { return; } var destination = LocalFileContext.CreateDatabase(dialog.FileName); var copier = new ObjectCopier(); copier.Copy(KbContext.CurrentKb, destination, param.IntId); MessageBox.Show("Export finished.", "Export"); break; default: e.Handled = false; break; } }
/// <summary> /// Connects this instance. /// </summary> /// <returns></returns> public KbContext Connect() { try { var filePath = string.IsNullOrEmpty(boxFile.Text) ? AppCore.Settings.LocalDatabasePath : boxFile.Text; if (!File.Exists(filePath)) { MessageBox.Show("File not exist " + filePath); return(null); } var result = LocalFileContext.OpenDatabase(filePath); KnowledgeBase.Core.Properties.Settings.Default.PreviousFile = filePath; return(result); } catch (Exception ex) { ErrorForm.Show("Error connect", ex); return(null); } }