public async Task Initialize(Page page)
        {
            _page    = page;
            _tsc2046 = await Tsc2046.GetDefaultAsync();

            try
            {
                await _tsc2046.LoadCalibrationAsync(CalibrationFilename);
            }
            catch (System.IO.FileNotFoundException)
            {
                await CalibrateTouch(); // Initiate calibration if we don't have a calibration on file
            }
            catch (UnauthorizedAccessException)
            {
                // No access to documents folder
                await new Windows.UI.Popups.MessageDialog("Make sure the application manifest specifies access to the documents folder and declares the file type association for the calibration file.", "Configuration Error").ShowAsync();
                throw;
            }
            // Load up the touch processor and listen for touch events
            _processor               = new TouchPanels.TouchProcessor(_tsc2046);
            _processor.PointerDown  += Processor_PointerDown;
            _processor.PointerMoved += Processor_PointerMoved;
            _processor.PointerUp    += Processor_PointerUp;
        }
Example #2
0
        public LcdCalibrationView(Tsc2046 device)
        {
            this._device = device;

            this.InitializeComponent();
            this.Loaded += (s, e) => _loaded.SetResult(true);
        }
Example #3
0
        private async void Init()
        {
            tsc2046 = await Tsc2046.GetDefaultAsync().ConfigureAwait(true);

            if (!tsc2046.IsCalibrated)
            {
                try
                {
                    await tsc2046.LoadCalibrationAsync(CalibrationFilename).ConfigureAwait(true);
                }
                catch (FileNotFoundException)
                {
                    await CalibrateTouch().ConfigureAwait(true); //Initiate calibration
                }
                catch (UnauthorizedAccessException)
                {
                    //No access to documents folder
                    await new Windows.UI.Popups.MessageDialog("Make sure the application " +
                                                              "manifest specifies access to the documents folder and declares the " +
                                                              "file type association for the calibration file.",
                                                              "Configuration Error").ShowAsync();
                    throw;
                }
            }
            //Load up the touch processor and listen for touch events
            if (processor == null)
            {
                processor               = new TouchPanels.TouchProcessor(tsc2046);
                processor.PointerDown  += Processor_PointerDown;
                processor.PointerMoved += Processor_PointerMoved;
                processor.PointerUp    += Processor_PointerUp;
            }
        }
Example #4
0
        private async Task CalibrateTouch(Tsc2046 touchDevice)
        {
            var calibration = await TouchPanels.UI.LcdCalibrationView.CalibrateScreenAsync(touchDevice);

            touchDevice.SetCalibration(calibration.A, calibration.B, calibration.C, calibration.D, calibration.E, calibration.F);

            await touchDevice.SaveCalibrationAsync(CalibrationFileName);
        }
Example #5
0
        public async Task InitializeAsync()
        {
            if (!_isInitialized)
            {
                _isInitialized = true;

                if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.IoT")
                {
                    _tsc2046 = await InitializeTouchControllerAsync();

                    _processor = InitializeTouchProcessor(_tsc2046);
                }
            }
        }
Example #6
0
        private async Task <Tsc2046> InitializeTouchControllerAsync()
        {
            var tsc2046 = await Tsc2046.GetDefaultAsync();

            try
            {
                await tsc2046.LoadCalibrationAsync(CalibrationFileName);
            }
            catch (System.IO.FileNotFoundException)
            {
                await CalibrateTouch(tsc2046);
            }

            return(tsc2046);
        }