From 870ecd64a42ad146b7e405c73b4a6a8d393abc59 Mon Sep 17 00:00:00 2001 From: Eugene Wang Date: Mon, 15 Feb 2016 19:33:22 -0500 Subject: [PATCH] Exposes actual EndXferJob value during transfer ready event. May help #56. --- samples/Sample.WPF/MainWindow.xaml.cs | 19 ++++++++++++++++++- samples/Sample.WPF/Sample.WPF.csproj | 14 +++++++------- samples/Sample.WPF/app.config | 2 +- samples/Sample.WPF/packages.config | 6 +++--- src/NTwain/Data/TwainTypesExtended.cs | 2 +- src/NTwain/Internals/TransferLogic.cs | 2 +- src/NTwain/Properties/VersionInfo.cs | 4 ++-- src/NTwain/TransferReadyEventArgs.cs | 16 ++++++++++++---- 8 files changed, 45 insertions(+), 20 deletions(-) diff --git a/samples/Sample.WPF/MainWindow.xaml.cs b/samples/Sample.WPF/MainWindow.xaml.cs index e58ebb9..55b8aa0 100644 --- a/samples/Sample.WPF/MainWindow.xaml.cs +++ b/samples/Sample.WPF/MainWindow.xaml.cs @@ -1,4 +1,5 @@ using GalaSoft.MvvmLight.Messaging; +using ModernWPF; using ModernWPF.Controls; using ModernWPF.Messages; using NTwain; @@ -29,7 +30,7 @@ namespace Sample.WPF if (!DesignerProperties.GetIsInDesignMode(this)) { _twainVM = this.DataContext as TwainVM; - + _twainVM.PropertyChanged += _twainVM_PropertyChanged; Messenger.Default.Register(this, m => m.HandleIt()); Messenger.Default.Register(this, msg => { @@ -47,6 +48,22 @@ namespace Sample.WPF }); } } + + private void _twainVM_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == "State") + { + if (_twainVM.State == 5) + { + ModernTheme.ApplyTheme(ModernTheme.Theme.Light, Accent.Orange); + } + else if (_twainVM.State == 4) + { + ModernTheme.ApplyTheme(ModernTheme.Theme.Light, Accent.Green); + } + } + } + protected override void OnClosing(CancelEventArgs e) { e.Cancel = _twainVM.State > 4; diff --git a/samples/Sample.WPF/Sample.WPF.csproj b/samples/Sample.WPF/Sample.WPF.csproj index 5774039..26cd224 100644 --- a/samples/Sample.WPF/Sample.WPF.csproj +++ b/samples/Sample.WPF/Sample.WPF.csproj @@ -47,12 +47,12 @@ ..\..\packages\CommonWin32.2.0.5.6\lib\net35-Client\CommonWin32.dll True - - ..\..\packages\MvvmLightLibs.5.1.1.0\lib\net40\GalaSoft.MvvmLight.dll + + ..\..\packages\MvvmLightLibs.5.2.0.0\lib\net40\GalaSoft.MvvmLight.dll True - - ..\..\packages\MvvmLightLibs.5.1.1.0\lib\net40\GalaSoft.MvvmLight.Extras.dll + + ..\..\packages\MvvmLightLibs.5.2.0.0\lib\net40\GalaSoft.MvvmLight.Extras.dll True @@ -70,11 +70,11 @@ ..\..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll - ..\..\packages\ModernWPF.1.3.4\lib\net40-Client\ModernWPF.dll + ..\..\packages\ModernWPF.1.3.9\lib\net40-Client\ModernWPF.dll True - ..\..\packages\ModernWPF.Mvvm.0.7.3\lib\net40-Client\ModernWPF.Mvvm.dll + ..\..\packages\ModernWPF.Mvvm.0.7.5\lib\net40-Client\ModernWPF.Mvvm.dll True @@ -82,7 +82,7 @@ - ..\..\packages\MvvmLightLibs.5.1.1.0\lib\net40\System.Windows.Interactivity.dll + ..\..\packages\MvvmLightLibs.5.2.0.0\lib\net40\System.Windows.Interactivity.dll True diff --git a/samples/Sample.WPF/app.config b/samples/Sample.WPF/app.config index 3c171a9..2ef4980 100644 --- a/samples/Sample.WPF/app.config +++ b/samples/Sample.WPF/app.config @@ -9,7 +9,7 @@ - + diff --git a/samples/Sample.WPF/packages.config b/samples/Sample.WPF/packages.config index aa6d429..3f5f135 100644 --- a/samples/Sample.WPF/packages.config +++ b/samples/Sample.WPF/packages.config @@ -4,7 +4,7 @@ - - - + + + \ No newline at end of file diff --git a/src/NTwain/Data/TwainTypesExtended.cs b/src/NTwain/Data/TwainTypesExtended.cs index 6899666..a10831c 100644 --- a/src/NTwain/Data/TwainTypesExtended.cs +++ b/src/NTwain/Data/TwainTypesExtended.cs @@ -2129,7 +2129,7 @@ namespace NTwain.Data /// than None. If this is not 0, the application should expect more data /// from the driver according to CapJobControl settings. /// - public uint EndOfJob { get { return _eOJ; } } + public EndXferJob EndOfJob { get { return (EndXferJob)_eOJ; } } } diff --git a/src/NTwain/Internals/TransferLogic.cs b/src/NTwain/Internals/TransferLogic.cs index 0c3638d..a3a0340 100644 --- a/src/NTwain/Internals/TransferLogic.cs +++ b/src/NTwain/Internals/TransferLogic.cs @@ -49,7 +49,7 @@ namespace NTwain.Internals { #region raise xfer ready - var preXferArgs = new TransferReadyEventArgs(session.CurrentSource, pending.Count, pending.EndOfJob == 0); ; + var preXferArgs = new TransferReadyEventArgs(session.CurrentSource, pending.Count, pending.EndOfJob); ; session.SafeSyncableRaiseEvent(preXferArgs); #endregion diff --git a/src/NTwain/Properties/VersionInfo.cs b/src/NTwain/Properties/VersionInfo.cs index 19d11c9..c257785 100644 --- a/src/NTwain/Properties/VersionInfo.cs +++ b/src/NTwain/Properties/VersionInfo.cs @@ -1,6 +1,6 @@ using System.Reflection; -[assembly: AssemblyCopyright("Copyright \x00a9 Yin-Chun Wang 2012-2015")] +[assembly: AssemblyCopyright("Copyright \x00a9 Yin-Chun Wang 2012-2016")] [assembly: AssemblyCompany("Yin-Chun Wang")] [assembly: AssemblyVersion(NTwain.VersionInfo.Release)] @@ -23,7 +23,7 @@ namespace NTwain /// /// The build release version number. /// - public const string Build = "3.3.7"; // change this for each nuget release + public const string Build = "3.3.8"; // change this for each nuget release } diff --git a/src/NTwain/TransferReadyEventArgs.cs b/src/NTwain/TransferReadyEventArgs.cs index 6bf4344..1059371 100644 --- a/src/NTwain/TransferReadyEventArgs.cs +++ b/src/NTwain/TransferReadyEventArgs.cs @@ -13,12 +13,12 @@ namespace NTwain /// /// The source. /// The pending count. - /// if set to true then it's the end of job. - public TransferReadyEventArgs(DataSource source, int pendingCount, bool endOfJob) + /// + public TransferReadyEventArgs(DataSource source, int pendingCount, EndXferJob endOfJobFlag) { DataSource = source; PendingTransferCount = pendingCount; - EndOfJob = endOfJob; + EndOfJobFlag = endOfJobFlag; } /// @@ -46,7 +46,15 @@ namespace NTwain /// Gets a value indicating whether current transfer signifies an end of job in TWAIN world. /// /// true if transfer is end of job; otherwise, false. - public bool EndOfJob { get; private set; } + public bool EndOfJob { get { return EndOfJobFlag != EndXferJob.None; } } + + /// + /// Gets the end of job flag value for this transfer (if job control is enabled). + /// + /// + /// The end of job flag. + /// + public EndXferJob EndOfJobFlag { get; private set; } /// /// Gets the known pending transfer count. This may not be appilicable