Ejemplo n.º 1
0
 /// <summary>
 /// Creates an instance of XLToolbox.Csv.CsvExportViewModel and wires up the
 /// message events to display a progress bar and error message as needed.
 /// </summary>
 static Csv.CsvExportViewModel CreateCsvExportViewModel(Xl.Range range)
 {
     Csv.CsvExportViewModel vm = Csv.CsvExportViewModel.FromLastUsed();
     vm.Range = range;
     vm.ShowProgressMessage.Sent += (sender, args) =>
     {
         args.Content.CancelButtonText       = Strings.Cancel;
         args.Content.Caption                = Strings.ExportCsvFile;
         args.Content.CompletedMessage.Sent += (sender2, args2) =>
         {
             args.Content.CloseViewCommand.Execute(null);
         };
         args.Content.InjectInto <Bovender.Mvvm.Views.ProcessView>().ShowInForm();
     };
     vm.ProcessFinishedMessage.Sent += (sender, args) =>
     {
         if (args.Content.Exception != null)
         {
             Logger.Info("Received ProcessFinishedMessage with exception");
             Bovender.Mvvm.Actions.ProcessCompletedAction action = new ProcessCompletedAction(
                 args.Content, Strings.CsvExportFailed, Strings.CsvExportFailed, Strings.Close);
             action.Invoke(args);
         }
     };
     return(vm);
 }
Ejemplo n.º 2
0
 internal static void Exporter_ProcessFinished_Sent(object sender, MessageArgs <ProcessMessageContent> e)
 {
     if (e.Content.Exception != null)
     {
         Logger.Info("Exporter_ProcessFinished_Sent: Received ProcessFinishedMessage with exception, informing user");
         Bovender.Mvvm.Actions.ProcessCompletedAction action = new ProcessCompletedAction(
             e.Content, Strings.ExportFailed, Strings.ExportFailedMessage, Strings.Close);
         action.Invoke(e);
     }
     else
     {
         Logger.Info("Exporter_ProcessFinished_Sent: Exporter process has finished");
     }
 }