Click here to Skip to main content
15,892,643 members
Articles / Multimedia / GDI+

Digitizer interface in C# using VBTablet

Rate me:
Please Sign up or sign in to vote.
4.28/5 (12 votes)
4 Dec 2009CPOL3 min read 61.8K   2.4K   25  
Digitzer device interface using VBTablet in C#.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using VBTablet;

namespace DigitizerInterface
{
    public partial class Form1 : Form
    {
        public  Tablet Digitizer;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {

                // On Error GoTo errorload
                Digitizer = new Tablet(); //Actually create the tablet object
                sldGranularity.Value = 2; //Set packet granularity value
                //that uses a tablet attribute. Remember not everyone has _your_ tablet.
                Digitizer.UnavailableIsError = false;

                //Tablet.hWnd = frmMain.DefInstance.Handle
                prgX.Maximum = Digitizer.Context.OutputExtentX - Digitizer.Context.OutputOriginX;
                prgY.Maximum = Digitizer.Context.OutputExtentY - Digitizer.Context.OutputOriginY;
                prgZ.Maximum = Digitizer.Context.OutputExtentZ - Digitizer.Context.OutputOriginZ;

                prgPressure.Maximum = (int)Digitizer.Device.NormalPressure.get_Max(true);
                prgTangentPressure.Maximum = (int)Digitizer.Device.TangentPressure.get_Max(true);
            }

            catch (Exception  ex)
            {

                MessageBox.Show(ex.Message);
            }
            
            
      }

        private void cmdConnect_Click(object sender, EventArgs e)
        {
            IntPtr Hwnd;
            bool IsDigitizingContext=false;
            string ContextID = "FirstContext";
            Connect.Enabled = false;
            Enable.Enabled = true;
            Hwnd = this.Handle;
            Digitizer.hWnd = Hwnd;
            
            Disconnect.Enabled = true;
            Digitizer.AddContext(ContextID, ref IsDigitizingContext);
            Digitizer.SelectContext(ref ContextID);
            Digitizer.Connected = true;
            Digitizer.Context.QueueSize = 32;//Set queue size to a reasonable value
        }

        private void Enable_Click(object sender, EventArgs e)
        {
            Disable.Enabled = true;
        }

        private void Disconnect_Click(object sender, EventArgs e)
        {
            string RemoveCOntextID = "FirstContext";
            Digitizer.RemoveContext(ref RemoveCOntextID);
            Disable.Enabled = false;
            Enable.Enabled = false;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions