/////////////////////////////////////////////////////////////////////////////// // Public Functions... /////////////////////////////////////////////////////////////////////////////// #region Public Functions... /// <summary> /// Init our form, and our TWAIN class. You might want to consider /// moving TWAIN into its own thread, or even running it from a /// separate process, so that the main application is always responsive /// no matter what's going on in the driver... /// </summary> public FormMain() { ContextMenu contextmenu; MenuItem menuitem; // Init our form... InitializeComponent(); // Make sure we cleanup if unexpectedly closed... this.FormClosing += new FormClosingEventHandler(FormMain_FormClosing); // This next bit establishes the rules for the various DSM's on the // various operating systems. // Windows controls... if (TWAINCSToolkit.GetPlatform() == "WINDOWS") { m_checkboxUseTwain32.Enabled = (TWAINCSToolkit.GetMachineWordBitSize() == 32); m_checkboxUseCallbacks.Enabled = true; m_checkboxUseTwain32.Checked = false; m_checkboxUseCallbacks.Checked = true; } // Linux controls... else if (TWAINCSToolkit.GetPlatform() == "LINUX") { m_checkboxUseTwain32.Checked = false; m_checkboxUseCallbacks.Checked = true; m_checkboxUseTwain32.Enabled = false; m_checkboxUseCallbacks.Enabled = false; } // Mac OS X controls... else if (TWAINCSToolkit.GetPlatform() == "MACOSX") { m_checkboxUseTwain32.Checked = false; m_checkboxUseCallbacks.Checked = true; m_checkboxUseTwain32.Enabled = false; m_checkboxUseCallbacks.Enabled = false; } // Autoscroll the text in our output box... m_richtextboxOutput.HideSelection = false; m_richtextboxOutput.SelectionProtected = false; // Init other stuff... m_twaincstoolkit = null; // Init our image controls... InitImage(); // Load our triplet dropdown... this.m_comboboxDG.Items.AddRange(TWAINCSToolkit.GetTwainDg()); this.m_comboboxDAT.Items.AddRange(TWAINCSToolkit.GetTwainDat()); this.m_comboboxMSG.Items.AddRange(TWAINCSToolkit.GetTwainMsg()); // Init our triplet dropdown... AutoDropdown("", "", ""); // Context menu for our value box... contextmenu = new ContextMenu(); menuitem = new MenuItem("Copy"); menuitem.Click += new EventHandler(richtextboxcapability_Copy); contextmenu.MenuItems.Add(menuitem); menuitem = new MenuItem("Paste"); menuitem.Click += new EventHandler(richtextboxcapability_Paste); contextmenu.MenuItems.Add(menuitem); m_richtextboxCapability.ContextMenu = contextmenu; contextmenu = null; // Context menu for our output box... contextmenu = new ContextMenu(); menuitem = new MenuItem("Copy"); menuitem.Click += new EventHandler(richtextboxoutput_Copy); contextmenu.MenuItems.Add(menuitem); menuitem = new MenuItem("Paste"); menuitem.Click += new EventHandler(richtextboxoutput_Paste); contextmenu.MenuItems.Add(menuitem); m_richtextboxOutput.ContextMenu = contextmenu; contextmenu = null; }
/////////////////////////////////////////////////////////////////////////////// // Public Functions... /////////////////////////////////////////////////////////////////////////////// #region Public Functions... /// <summary> /// Init our form, and our TWAIN class. You might want to consider /// moving TWAIN into its own thread, or even running it from a /// separate process, so that the main application is always responsive /// no matter what's going on in the driver... /// </summary> public FormMain() { ContextMenu contextmenu; MenuItem menuitem; // Init our form... InitializeComponent(); // Open the log in our working folder, and say hi... TWAINWorkingGroup.Log.Open("TWAINCSTst", ".", 1); TWAINWorkingGroup.Log.Info("TWAINCSTst v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString()); // Make sure we cleanup if unexpectedly closed... this.FormClosing += new FormClosingEventHandler(FormMain_FormClosing); // This next bit establishes the rules for the various DSM's on the // various operating systems. // Windows controls... if (TWAINCSToolkit.GetPlatform() == "WINDOWS") { // Choose between TWAIN_32 and TWAINDSM, note that we always default // to the open source TWAIN DSM... m_checkboxUseTwain32.Enabled = (TWAINCSToolkit.GetMachineWordBitSize() == 32); m_checkboxUseCallbacks.Enabled = true; m_checkboxUseTwain32.Checked = false; m_checkboxUseCallbacks.Checked = true; } // Linux controls... else if (TWAINCSToolkit.GetPlatform() == "LINUX") { // We don't give the user control between the DSM versions, because // the 64-bit problem is handled as seamlessly as possible... m_checkboxUseTwain32.Enabled = false; m_checkboxUseCallbacks.Enabled = false; m_checkboxUseTwain32.Checked = false; m_checkboxUseCallbacks.Checked = true; } // Mac OS X controls... else if (TWAINCSToolkit.GetPlatform() == "MACOSX") { // Choose between /System/Library/Frameworks/TWAIN.framework and // /Library/Frameworks/TWAINDSM.framework, note that we always default // to the open source TWAIN DSM... m_checkboxUseTwain32.Enabled = true; m_checkboxUseCallbacks.Enabled = false; m_checkboxUseTwain32.Checked = false; m_checkboxUseCallbacks.Checked = true; } // Autoscroll the text in our output box... m_richtextboxOutput.HideSelection = false; m_richtextboxOutput.SelectionProtected = false; // Init other stuff... m_twaincstoolkit = null; // Init our image controls... InitImage(); // Load our triplet dropdown... this.m_comboboxDG.Items.AddRange(TWAINCSToolkit.GetTwainDg()); this.m_comboboxDAT.Items.AddRange(TWAINCSToolkit.GetTwainDat()); this.m_comboboxMSG.Items.AddRange(TWAINCSToolkit.GetTwainMsg()); // Init our triplet dropdown... AutoDropdown("", "", ""); // Context menu for our value box... contextmenu = new ContextMenu(); menuitem = new MenuItem("Copy"); menuitem.Click += new EventHandler(richtextboxcapability_Copy); contextmenu.MenuItems.Add(menuitem); menuitem = new MenuItem("Paste"); menuitem.Click += new EventHandler(richtextboxcapability_Paste); contextmenu.MenuItems.Add(menuitem); m_richtextboxCapability.ContextMenu = contextmenu; contextmenu = null; // Context menu for our output box... contextmenu = new ContextMenu(); menuitem = new MenuItem("Copy"); menuitem.Click += new EventHandler(richtextboxoutput_Copy); contextmenu.MenuItems.Add(menuitem); menuitem = new MenuItem("Paste"); menuitem.Click += new EventHandler(richtextboxoutput_Paste); contextmenu.MenuItems.Add(menuitem); m_richtextboxOutput.ContextMenu = contextmenu; contextmenu = null; // Set the capbility box to our app info... m_richtextboxCapability.Text = "TWAIN Working Group," + "TWAIN Sharp," + "TWAIN Sharp Test App," + "2," + "4," + "0x20000003," + "USA," + "testing...," + "ENGLISH_USA"; }