How do I use the
Glide.CalibrationSettings
and I want to save and restore it. I do not want to calibrate every time I start up.
There is no good example I could find.
using GHI.Glide;
using GHI.Glide.Display;
using GHI.Glide.UI;
using Microsoft.SPOT;
using System.Threading;
namespace TouchLogger
{
public class MicGlide
{
private static Window window;
private static CalibrationWindow calibrationWindow;
const int CAL_POINTS = 5;
public void Init()
{
CalibrationSettings cal = new Glide.CalibrationSettings();
cal.SX = new short[CAL_POINTS] { 240, 48, 48, 432, 432 };
cal.SY = new short[CAL_POINTS] { 136, 26, 246, 246, 26 };
cal.CX = new short[CAL_POINTS] { 478, 189, 169, 781, 790 };
cal.CY = new short[CAL_POINTS] { 481, 238, 741, 767, 231 };
window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window));
GlideTouch.Initialize();
var Button = (Button)window.GetChildByName("Button");
Button.TapEvent += OnTap;
var Text = (PasswordBox)window.GetChildByName("Text");
Text.TapEvent += OnTap;
calibrationWindow = new CalibrationWindow(false, false);
calibrationWindow.CloseEvent += OnCalClose;
if (GlideTouch.Calibrated == false)
{
Glide.MainWindow = calibrationWindow;
}
else
{
Glide.MainWindow = window;
}
while (Glide.MainWindow == calibrationWindow)
{
Thread.Sleep(100);
}
//Thread.Sleep(-1);
}
private static void OnTap1(object sender)
{
Debug.Print("Button tapped.");
}
private static void OnTap(object sender)
{
Glide.MainWindow = calibrationWindow;
}
private static void OnCalClose(object sender)
{
Glide.MainWindow = window;
}
}
}