aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/ThreadLoading
Path not found
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Tango.PPC.Browser.Attributes;
using Tango.PPC.Browser.Views;
using Tango.PPC.Common.Helpers;
using Tango.Touch.Keyboard;

namespace Tango.PPC.Browser.BoundsObjects
{
    [BoundObject("keyboard", "keyboard.js")]
    public class KeyboardHandler
    {
        private DateTime _lastTime;

        public KeyboardHandler()
        {
            _lastTime = DateTime.Now;
        }

        public void openKeyboard(String inputType)
        {
            if (DateTime.Now > _lastTime.AddMilliseconds(1000))
            {
                _lastTime = DateTime.Now;

                Application.Current.Dispatcher.BeginInvoke(new Action(async () =>
                {
                    switch (inputType)
                    {
                        case "search":
                            KeyboardHelper.OpenKeyboard(KeyboardActionKeyMode.Go);
                            break;
                        default:
                            KeyboardHelper.OpenKeyboard(KeyboardActionKeyMode.Next);
                            break;
                    }


                    await Task.Delay(50);
                    BrowserView.Instance.btnGo.Focus();
                    await Task.Delay(50);
                    BrowserView.Instance.Browser.Focus();
                    Debug.WriteLine("Focus");
                }));
            }
        }

        public void closeKeyboard()
        {
            if (DateTime.Now > _lastTime.AddMilliseconds(1000))
            {
                _lastTime = DateTime.Now;

                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    KeyboardHelper.CloseKeyboard();
                }));
            }
        }
    }
}