mirror of
https://github.com/soukoku/ntwain.git
synced 2025-10-26 12:03:06 +08:00
Initial internal loop idea that compiles.
This commit is contained in:
@@ -68,12 +68,7 @@ namespace Tester.WPF
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
|
||||
var hwnd = new WindowInteropHelper(this).Handle;
|
||||
|
||||
// this line is unnecessary if using twain 2 dsm but doesn't hurt to use it
|
||||
HwndSource.FromHwnd(hwnd).AddHook(_twainVM.PreFilterMessage);
|
||||
|
||||
var rc = _twainVM.OpenManager(hwnd);
|
||||
var rc = _twainVM.OpenManager();
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
SrcList.ItemsSource = _twainVM.GetSources().Select(s => new DSVM { DS = s });
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Tester.WPF
|
||||
/// <summary>
|
||||
/// Wraps the twain session as a view model for databinding.
|
||||
/// </summary>
|
||||
class TwainVM : TwainSessionWPF
|
||||
class TwainVM : TwainSession
|
||||
{
|
||||
public TwainVM()
|
||||
: base(TWIdentity.CreateFromAssembly(DataGroups.Image | DataGroups.Audio, Assembly.GetEntryAssembly()))
|
||||
@@ -87,15 +87,18 @@ namespace Tester.WPF
|
||||
|
||||
protected override void OnDataTransferred(DataTransferredEventArgs e)
|
||||
{
|
||||
if (e.NativeData != IntPtr.Zero)
|
||||
App.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
Image = e.NativeData.GetWPFBitmap();
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(e.FileDataPath))
|
||||
{
|
||||
var img = new BitmapImage(new Uri(e.FileDataPath));
|
||||
Image = img;
|
||||
}
|
||||
if (e.NativeData != IntPtr.Zero)
|
||||
{
|
||||
Image = e.NativeData.GetWPFBitmap();
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(e.FileDataPath))
|
||||
{
|
||||
var img = new BitmapImage(new Uri(e.FileDataPath));
|
||||
Image = img;
|
||||
}
|
||||
}));
|
||||
base.OnDataTransferred(e);
|
||||
}
|
||||
|
||||
@@ -113,7 +116,7 @@ namespace Tester.WPF
|
||||
this.CapSetImageXferMech(XferMech.File);
|
||||
}
|
||||
|
||||
var rc = EnableSource(SourceEnableMode.NoUI, false, hwnd, SynchronizationContext.Current);
|
||||
var rc = EnableSource(SourceEnableMode.NoUI, false, hwnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user