Initial internal loop idea that compiles.

This commit is contained in:
soukoku
2014-04-14 19:04:48 -04:00
parent 04ee0baf75
commit 320dfb2175
13 changed files with 231 additions and 611 deletions

View File

@@ -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 });

View File

@@ -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);
}
}
}