mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-20 01:22:16 +01:00
Copy File After Converting
This commit is contained in:
1 parent
3b42c75c27
commit
45ec5ea1c7
5 files changed
+59
-2
No files matched your search
@@ -8,6 +8,9 @@ namespace FileConverter.ConversionJobs
|
||||
using System.Windows.Input;
|
||||
|
||||
using FileConverter.Diagnostics;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
using System.Threading;
|
||||
using FileConverter.Services;
|
||||
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
|
||||
@@ -445,6 +448,15 @@ namespace FileConverter.ConversionJobs
|
||||
this.State = ConversionState.Done;
|
||||
this.UserState = Properties.Resources.ConversionStateDone;
|
||||
Debug.Log("Conversion Done!");
|
||||
|
||||
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
|
||||
// Copy the output file to the clipboard using Task
|
||||
if (settingsService.Settings.CheckCopyFileAfterConverting)
|
||||
{
|
||||
Thread clipboardThread = new Thread(CopyFileToClipboard);
|
||||
clipboardThread.SetApartmentState(ApartmentState.STA);
|
||||
clipboardThread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ConversionFailed(string exitingMessage)
|
||||
@@ -526,5 +538,19 @@ namespace FileConverter.ConversionJobs
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void CopyFileToClipboard()
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Windows.Forms.Clipboard.SetFileDropList(new System.Collections.Specialized.StringCollection { OutputFilePath });
|
||||
Debug.Log("Output file copied to the clipboard: '{0}'", OutputFilePath);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.Log("Can't copy file '{0}' to the clipboard.", OutputFilePath);
|
||||
Debug.Log("An exception has been thrown: {0}.", exception.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -19,7 +19,7 @@ namespace FileConverter.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Resources {
|
||||
@@ -321,6 +321,15 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Copy File After Converting.
|
||||
/// </summary>
|
||||
public static string CopyFileAfterConverting {
|
||||
get {
|
||||
return ResourceManager.GetString("CopyFileAfterConverting", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to New folder.
|
||||
/// </summary>
|
||||
|
||||
@@ -592,4 +592,7 @@ use maj for uppercase version</value>
|
||||
<data name="ErrorCantLoadSettings" xml:space="preserve">
|
||||
<value>Can't load file converter user settings. Do you want to fall back to default settings ?</value>
|
||||
</data>
|
||||
<data name="CopyFileAfterConverting" xml:space="preserve">
|
||||
<value>Copy File After Converting</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -22,7 +22,8 @@ namespace FileConverter
|
||||
private bool checkUpgradeAtStartup = true;
|
||||
private CultureInfo applicationLanguage;
|
||||
private int maximumNumberOfSimultaneousConversions;
|
||||
|
||||
private bool checkCopyFileAfterConverting = false;
|
||||
|
||||
public ConversionPreset GetPresetFromName(string presetName)
|
||||
{
|
||||
return this.conversionPresets.FirstOrDefault(match => match.FullName == presetName);
|
||||
@@ -207,6 +208,20 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public bool CheckCopyFileAfterConverting
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.checkCopyFileAfterConverting;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.checkCopyFileAfterConverting = value;
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
public void OnDeserializationComplete()
|
||||
{
|
||||
this.DurationBetweenEndOfConversionsAndApplicationExit = System.Math.Max(0, System.Math.Min(10, this.DurationBetweenEndOfConversionsAndApplicationExit));
|
||||
|
||||
@@ -371,6 +371,7 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Grid.Row="0" Grid.Column="0" Content="{x:Static project:Resources.Language}" HorizontalAlignment="Right" Margin="0,0,5,0"/>
|
||||
@@ -398,6 +399,9 @@
|
||||
|
||||
<Label Grid.Row="4" Grid.Column="0" Content="{x:Static project:Resources.AutomaticallyCheckForUpdates}" HorizontalAlignment="Right" Margin="0,0,5,0"/>
|
||||
<CheckBox Grid.Row="4" Grid.Column="1" IsChecked="{Binding Settings.CheckUpgradeAtStartup, Mode=TwoWay}" Margin="0,5,0,5" />
|
||||
|
||||
<Label Grid.Row="5" Grid.Column="0" Content="{x:Static project:Resources.CopyFileAfterConverting}" HorizontalAlignment="Right" Margin="0,0,5,0"/>
|
||||
<CheckBox Grid.Row="5" Grid.Column="1" x:Name="CopyFileAfterConvertingCheckBox" IsChecked="{Binding Settings.CheckCopyFileAfterConverting, Mode=TwoWay}" Margin="0,5,0,5" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
|
||||
Reference in new issue
Block a user