mirror of
https://github.com/soukoku/ntwain.git
synced 2025-05-03 04:27:46 +08:00
Added error handling to wpf example.
This commit is contained in:
parent
78d0a94bd2
commit
dc41cebc18
@ -20,6 +20,8 @@ using CommonWin32;
|
||||
using System.Threading;
|
||||
using ModernWPF.Controls;
|
||||
using System.Reflection;
|
||||
using System.ComponentModel;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
|
||||
namespace Tester.WPF
|
||||
{
|
||||
@ -44,6 +46,13 @@ namespace Tester.WPF
|
||||
|
||||
_twainVM = new TwainVM();
|
||||
this.DataContext = _twainVM;
|
||||
if (!DesignerProperties.GetIsInDesignMode(this))
|
||||
{
|
||||
Messenger.Default.Register<DialogMessage>(this, msg =>
|
||||
{
|
||||
ModernMessageBox.Show(this, msg.Content, msg.Caption, msg.Button, msg.Icon, msg.DefaultResult);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
|
@ -44,6 +44,15 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\CommonWin32.2.0.4\lib\net35-Client\CommonWin32.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="GalaSoft.MvvmLight.Extras.WPF4">
|
||||
<HintPath>..\..\packages\MvvmLightLibs.4.3.31.1\lib\net40\GalaSoft.MvvmLight.Extras.WPF4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="GalaSoft.MvvmLight.WPF4">
|
||||
<HintPath>..\..\packages\MvvmLightLibs.4.3.31.1\lib\net40\GalaSoft.MvvmLight.WPF4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Practices.ServiceLocation">
|
||||
<HintPath>..\..\packages\CommonServiceLocator.1.2\lib\portable-windows8+net40+sl5+windowsphone8\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ModernWPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c99d0cfbea7491ef, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\ModernWPF.1.1.41.2\lib\net40-Client\ModernWPF.dll</HintPath>
|
||||
@ -51,6 +60,9 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\MvvmLightLibs.4.3.31.1\lib\net40\System.Windows.Interactivity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -10,6 +10,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using CommonWin32;
|
||||
using System.Threading;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
|
||||
namespace Tester.WPF
|
||||
{
|
||||
@ -42,6 +43,29 @@ namespace Tester.WPF
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTransferError(TransferErrorEventArgs e)
|
||||
{
|
||||
if (e.Exception != null)
|
||||
{
|
||||
Messenger.Default.Send(new DialogMessage(e.Exception.Message, null)
|
||||
{
|
||||
Caption = "Transfer Error Exception",
|
||||
Icon = System.Windows.MessageBoxImage.Error,
|
||||
Button = System.Windows.MessageBoxButton.OK
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Messenger.Default.Send(new DialogMessage(string.Format("Return Code: {0}\nCondition Code: {1}", e.ReturnCode, e.SourceStatus.ConditionCode), null)
|
||||
{
|
||||
Caption = "Transfer Error",
|
||||
Icon = System.Windows.MessageBoxImage.Error,
|
||||
Button = System.Windows.MessageBoxButton.OK
|
||||
});
|
||||
}
|
||||
base.OnTransferError(e);
|
||||
}
|
||||
|
||||
protected override void OnTransferReady(TransferReadyEventArgs e)
|
||||
{
|
||||
// set it up to use file xfer
|
||||
|
@ -1,3 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" /></startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="CommonServiceLocator" version="1.2" targetFramework="net40-Client" />
|
||||
<package id="CommonWin32" version="2.0.4" targetFramework="net40-Client" />
|
||||
<package id="ModernWPF" version="1.1.41.2" targetFramework="net40-Client" />
|
||||
<package id="MvvmLightLibs" version="4.3.31.1" targetFramework="net40-Client" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user