private void Export(AbstractExportWorker exportWorker)
{
var activationState = Protection.GetLicenseStatus();
if (activationState == Protection.ActivationState.TrialExpired || activationState == Protection.ActivationState.Unlicensed)
{
DisplayActivationOptions(null, null);
return;
}
string projectFileName = "";
if (exportWorker.SupportsLaunchingByExtension())
{
projectFileName = Path.Combine(Path.GetTempPath(), "My highlights - " + string.Format(CultureInfo.CurrentCulture, "{0:yyyy-MM-dd_hh-mm-ss-tt}",
DateTime.Now) + exportWorker.GetProjectFileExtension());
}
else
{
using (var saveFileDialog = new SaveFileDialog())
{
saveFileDialog.Title = "Save project file";
saveFileDialog.FileName = exportWorker.GetProjectFilename();
saveFileDialog.DefaultExt = exportWorker.GetProjectFileExtension();
saveFileDialog.InitialDirectory = MainModel.GetMyVideosDirectory();
saveFileDialog.Filter = exportWorker.GetSaveDialogFilter();
if (saveFileDialog.ShowDialog() == DialogResult.OK)
projectFileName = saveFileDialog.FileName;
else
return;
}
}
if (exportWorker.ExportHighlightsToFile(projectFileName))
{
if (exportWorker.SupportsLaunchingByExtension())
{
using (new HourGlass())
{
var p = new Process();
p.StartInfo.FileName = projectFileName;
try
{
p.Start();
p.WaitForInputIdle();
}
catch (Exception ex)
{
Logger.Error("Error running {0}: {1}", projectFileName, ex);
if (MessageBox.Show("Unfortunately we had trouble opening your highlights in " + exportWorker.AppName + "." + Environment.NewLine + Environment.NewLine +
"Can you tell us about this on our Support Center?", "Error exporting", MessageBoxButtons.YesNo, MessageBoxIcon.Error)
== DialogResult.Yes)
{
BrowserHelper.LaunchBrowser("http://support.highlighthunter.com", "ErrorExporting");
}
}
}
}
else
{
MessageBox.Show("Export was successful! Follow these steps to proceed:" + Environment.NewLine + Environment.NewLine +
exportWorker.LaunchAppMessage(), "Export successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
if (MessageBox.Show("Unfortunately we had trouble opening your highlights in " + exportWorker.AppName + "." + Environment.NewLine + Environment.NewLine +
"Can you tell us about this on our Support Center?", "Error exporting", MessageBoxButtons.YesNo, MessageBoxIcon.Error)
== DialogResult.Yes)
{
BrowserHelper.LaunchBrowser("http://support.highlighthunter.com", "ErrorExporting");
}
}
if (Properties.Settings.Default.HasExportedHighlights == false)
{
if (AnalyticsHelper.FireEvent("First export"))
{
Properties.Settings.Default.HasExportedHighlights = true;
Properties.Settings.Default.Save();
}
}
}