From d92af8452acdde8595e16c379e8a17cd5d3efdbe Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 15 Dec 2019 17:35:09 +0200 Subject: Added support for chromium touch enabled on PPC. Implemented real Cef Installer. --- .../BoundsObjects/KeyboardHandler.cs | 51 ++++++++++++++++------ .../Tango.PPC.Browser/Views/BrowserView.xaml | 5 ++- .../Tango.PPC.Browser/Views/BrowserView.xaml.cs | 4 ++ .../CefInstaller.cs | 25 +++++------ .../Tango.PPC.Packages.CefInstaller.csproj | 2 + 5 files changed, 57 insertions(+), 30 deletions(-) (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/BoundsObjects/KeyboardHandler.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/BoundsObjects/KeyboardHandler.cs index 50df8ae0c..3c608a518 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/BoundsObjects/KeyboardHandler.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/BoundsObjects/KeyboardHandler.cs @@ -6,6 +6,7 @@ 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; @@ -14,28 +15,52 @@ 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) { - Application.Current.Dispatcher.BeginInvoke(new Action(() => + if (DateTime.Now > _lastTime.AddMilliseconds(1000)) { - switch (inputType) + _lastTime = DateTime.Now; + + Application.Current.Dispatcher.BeginInvoke(new Action(async () => { - case "search": - KeyboardHelper.OpenKeyboard(KeyboardActionKeyMode.Go); - break; - default: - KeyboardHelper.OpenKeyboard(KeyboardActionKeyMode.Next); - break; - } - })); + 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() { - Application.Current.Dispatcher.BeginInvoke(new Action(() => + if (DateTime.Now > _lastTime.AddMilliseconds(1000)) { - KeyboardHelper.CloseKeyboard(); - })); + _lastTime = DateTime.Now; + + Application.Current.Dispatcher.BeginInvoke(new Action(() => + { + KeyboardHelper.CloseKeyboard(); + })); + } } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Views/BrowserView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Views/BrowserView.xaml index 6e2076c98..ce28d660e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Views/BrowserView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Views/BrowserView.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.PPC.Browser.ViewModels" xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" + xmlns:experimental="clr-namespace:CefSharp.Wpf.Experimental;assembly=CefSharp.Wpf" xmlns:global="clr-namespace:Tango.PPC.Browser" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:keyboard="clr-namespace:Tango.Touch.Keyboard;assembly=Tango.Touch" @@ -15,7 +16,7 @@ - + @@ -54,7 +55,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Views/BrowserView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Views/BrowserView.xaml.cs index cdba301ed..e7fe1ca27 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Views/BrowserView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Views/BrowserView.xaml.cs @@ -34,6 +34,8 @@ namespace Tango.PPC.Browser.Views { public event EventHandler AddressChanged; + public static BrowserView Instance { get; set; } + public BrowserView() { try @@ -51,6 +53,8 @@ namespace Tango.PPC.Browser.Views InitializeComponent(); + Instance = this; + TangoIOC.Default.Register(this); Helpers.BoundObjectsHelper.RegisterAllBoundObjects(Browser, Dispatcher); diff --git a/Software/Visual_Studio/PPC/Packages/Tango.PPC.Packages.CefInstaller/CefInstaller.cs b/Software/Visual_Studio/PPC/Packages/Tango.PPC.Packages.CefInstaller/CefInstaller.cs index 61a4077fe..62a1d5717 100644 --- a/Software/Visual_Studio/PPC/Packages/Tango.PPC.Packages.CefInstaller/CefInstaller.cs +++ b/Software/Visual_Studio/PPC/Packages/Tango.PPC.Packages.CefInstaller/CefInstaller.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO.Compression; using System.Linq; using System.Reflection; using System.Text; @@ -21,35 +22,29 @@ namespace Tango.PPC.Packages.CefInstaller { LogManager.Log("Downloading cef binaries..."); - var tempFolder = TemporaryManager.CreateFolder(); var zipFile = TemporaryManager.CreateImaginaryFile(); try { - for (int i = 0; i < 100; i++) + using (AutoFileDownloader downloader = new AutoFileDownloader("https://tangostorage.blob.core.windows.net/resources/CefSharpOutput.zip", "https://tango.azureedge.net/resources/CefSharpOutput.zip", zipFile)) { - context.ReportProgress("Downloading cef binaries...", false, i, 100); - Thread.Sleep(100); - } + downloader.Progress += (x, e) => + { + context.ReportProgress("Downloading cef binaries...", false, e.Current, e.Total); + }; - //using (AutoFileDownloader downloader = new AutoFileDownloader("", "", zipFile)) - //{ - // downloader.Progress += (x, e) => - // { - // context.ReportProgress("Downloading cef binaries...", false, e.Current, e.Total); - // }; + downloader.Download().GetAwaiter().GetResult(); + } - // downloader.Download().GetAwaiter().GetResult(); - //} + ZipFile.ExtractToDirectory(zipFile, context.ApplicationManager.StartPath); } catch (Exception ex) { - LogManager.Log(ex, "Error downloading cef."); + LogManager.Log(ex, "Error installing cef binaries."); throw; } finally { - tempFolder.Delete(); zipFile.Delete(); } diff --git a/Software/Visual_Studio/PPC/Packages/Tango.PPC.Packages.CefInstaller/Tango.PPC.Packages.CefInstaller.csproj b/Software/Visual_Studio/PPC/Packages/Tango.PPC.Packages.CefInstaller/Tango.PPC.Packages.CefInstaller.csproj index 42f996079..4cab8bab9 100644 --- a/Software/Visual_Studio/PPC/Packages/Tango.PPC.Packages.CefInstaller/Tango.PPC.Packages.CefInstaller.csproj +++ b/Software/Visual_Studio/PPC/Packages/Tango.PPC.Packages.CefInstaller/Tango.PPC.Packages.CefInstaller.csproj @@ -33,6 +33,8 @@ + + -- cgit v1.3.1