This project has moved. For the latest updates, please go here.

Using Saraff in WPF

Jan 13, 2014 at 5:49 AM
Hello! I want use Saraff in my WPF-application, can i do this? And if yes when how? Because in InitializeComponent i don't see this line "this.components = new System.ComponentModel.Container();", therefore i can't initialize Saraff variable. Thx.
Coordinator
Jan 13, 2014 at 3:38 PM
Edited Jan 13, 2014 at 3:41 PM
Hello, DyGer.
Yes. Saraff.Twain.NET can use in WPF-application. The following example shows how to do it.
namespace WpfApplication1 {

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow:Window {
        private Twain32 _twain=new Twain32();

        public MainWindow() {
            InitializeComponent();
            this._twain.OpenDSM();
            this._twain.AcquireCompleted+=new EventHandler(_AcquireCompleted);
        }

        protected override void OnClosing(System.ComponentModel.CancelEventArgs e) {
            base.OnClosing(e);
            this._twain.Dispose();
        }

        private void _AcquireCompleted(object sender,EventArgs e) {
            this._twain.GetImage(0).Save(@"c:\scanimage.jpg",ImageFormat.Jpeg);
        }

        private void selectDSButton_Click(object sender,RoutedEventArgs e) {
            this._twain.CloseDataSource();
            this._twain.SelectSource();
        }

        private void acquireButton_Click(object sender,RoutedEventArgs e) {
            this._twain.Acquire();
        }

    }
}
Marked as answer by DyGer on 1/16/2014 at 11:21 PM
Jan 16, 2014 at 4:24 AM
Thanks man, it's really work!