From 5fdb4170c92072fa5a3ee32a779bea2ed83b8ef0 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 12 Dec 2019 13:00:45 +0200 Subject: Added more functionality to browser module. --- .../Tango.PPC.Browser/ViewModels/BrowserViewVM.cs | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs new file mode 100644 index 000000000..f24301257 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs @@ -0,0 +1,101 @@ +using CefSharp; +using CefSharp.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.PPC.Browser.ViewContracts; +using Tango.PPC.Common; +using Tango.Touch.Keyboard; + +namespace Tango.PPC.Browser.ViewModels +{ + /// + /// Represents the main view VM and entry point for . + /// + /// + public class BrowserViewVM : PPCViewModel + { + private String _address; + public String Address + { + get { return _address; } + set { _address = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand GoCommand { get; set; } + + public BrowserViewVM() + { + if (!DesignMode) + { + try + { + var settings = new CefSettings(); + settings.BrowserSubprocessPath = @"x86\CefSharp.BrowserSubprocess.exe"; + settings.UserAgent = "Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"; + + Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null); + } + catch (Exception ex) + { + //Log Here Not Throw! + throw; + } + } + + GoCommand = new RelayCommand(Go); + } + + public override void OnViewAttached() + { + base.OnViewAttached(); + View.AddressChanged += View_AddressChanged; + } + + private void View_AddressChanged(object sender, string address) + { + Address = address; + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + KeyboardView.Default.OutputMode = KeyboardOutputMode.Windows; + } + + public override void OnNavigatedFrom() + { + base.OnNavigatedFrom(); + KeyboardView.Default.OutputMode = KeyboardOutputMode.Wpf; + } + + public override Task OnNavigateBackRequest() + { + if (View.CanGoBack()) + { + View.GoBack(); + return Task.FromResult(false); + } + else + { + return Task.FromResult(true); + } + } + + /// + /// Called when the application has been started + /// + public override void OnApplicationStarted() + { + + } + + private void Go() + { + View.NavigateTo(Address); + } + } +} -- cgit v1.3.1 From 85e27ca4c292329a894a49ed950912285465fa2e Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 12 Dec 2019 23:03:21 +0200 Subject: Embedded browser module in technician instead of menu. Implemented browser module navigation support. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes .../PPC/Modules/Tango.PPC.Browser/BrowserModule.cs | 12 ------- .../Navigation/BrowserNavigationRequest.cs | 19 +++++++++++ .../Tango.PPC.Browser/Tango.PPC.Browser.csproj | 1 + .../Tango.PPC.Browser/ViewModels/BrowserViewVM.cs | 35 ++++++++++++++++++++- .../Tango.PPC.Browser/Views/BrowserView.xaml | 6 ++-- .../Tango.PPC.Browser/Views/BrowserView.xaml.cs | 23 ++++++++------ .../Tango.PPC.Technician/Images/browser.png | Bin 0 -> 2539 bytes .../Tango.PPC.Technician.csproj | 7 +++++ .../ViewModels/CatalogViewVM.cs | 23 +++++++++++++- .../Tango.PPC.Technician/Views/CatalogView.xaml | 12 +++++++ .../Tango.PPC.Technician/Views/PackagesView.xaml | 2 +- 13 files changed, 113 insertions(+), 27 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Navigation/BrowserNavigationRequest.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/browser.png (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index f7ef63b2d..6e83bb088 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 080be181d..1fab4f80d 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/BrowserModule.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/BrowserModule.cs index 4da2f4f98..cd8372277 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/BrowserModule.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/BrowserModule.cs @@ -83,18 +83,6 @@ namespace Tango.PPC.Browser } } - public override void OnTechnicianEntered() - { - base.OnTechnicianEntered(); - IsVisibleInMenu = true; - } - - public override void OnTechnicianExited() - { - base.OnTechnicianExited(); - IsVisibleInMenu = false; - } - /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Navigation/BrowserNavigationRequest.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Navigation/BrowserNavigationRequest.cs new file mode 100644 index 000000000..a8becf251 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Navigation/BrowserNavigationRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Browser.Navigation +{ + public class BrowserNavigationRequest + { + public String Address { get; set; } + public bool DisplayAddressBar { get; set; } + + public BrowserNavigationRequest() + { + DisplayAddressBar = true; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Tango.PPC.Browser.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Tango.PPC.Browser.csproj index c799887a2..58d525c32 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Tango.PPC.Browser.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/Tango.PPC.Browser.csproj @@ -89,6 +89,7 @@ + Code diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs index f24301257..9f66bb6a6 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs @@ -6,8 +6,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; +using Tango.PPC.Browser.Navigation; using Tango.PPC.Browser.ViewContracts; using Tango.PPC.Common; +using Tango.PPC.Common.Navigation; using Tango.Touch.Keyboard; namespace Tango.PPC.Browser.ViewModels @@ -16,8 +18,10 @@ namespace Tango.PPC.Browser.ViewModels /// Represents the main view VM and entry point for . /// /// - public class BrowserViewVM : PPCViewModel + public class BrowserViewVM : PPCViewModel, INavigationObjectReceiver { + private bool _isFromObject; + private String _address; public String Address { @@ -25,10 +29,19 @@ namespace Tango.PPC.Browser.ViewModels set { _address = value; RaisePropertyChangedAuto(); } } + private bool _displayAddressBar; + public bool DisplayAddressBar + { + get { return _displayAddressBar; } + set { _displayAddressBar = value; RaisePropertyChangedAuto(); } + } + public RelayCommand GoCommand { get; set; } public BrowserViewVM() { + DisplayAddressBar = true; + if (!DesignMode) { try @@ -64,6 +77,13 @@ namespace Tango.PPC.Browser.ViewModels { base.OnNavigatedTo(); KeyboardView.Default.OutputMode = KeyboardOutputMode.Windows; + + if (!_isFromObject) + { + DisplayAddressBar = true; + } + + _isFromObject = false; } public override void OnNavigatedFrom() @@ -97,5 +117,18 @@ namespace Tango.PPC.Browser.ViewModels { View.NavigateTo(Address); } + + public void OnNavigatedToWithObject(BrowserNavigationRequest obj) + { + _isFromObject = true; + + DisplayAddressBar = obj.DisplayAddressBar; + + if (obj.Address != null) + { + Address = obj.Address; + Go(); + } + } } } 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 5c62d6915..6e2076c98 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 @@ -13,7 +13,7 @@ d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:BrowserViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.BrowserViewVM}" Background="{StaticResource TangoPrimaryBackgroundBrush}"> - + @@ -54,12 +54,12 @@ - + Page Not Found - + The page at '' could not be reached. 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 aeb1b5c41..e3f4c29e3 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 @@ -110,11 +110,11 @@ namespace Tango.PPC.Browser.Views { if (Browser.Address != address) { - Uri uri; + String uri; if (ValidHttpURL(address, out uri)) { - Browser.Address = uri.ToString(); + Browser.Address = uri; } else { @@ -127,15 +127,20 @@ namespace Tango.PPC.Browser.Views } } - public static bool ValidHttpURL(string s, out Uri resultURI) + public static bool ValidHttpURL(string s, out string result) { - if (!Regex.IsMatch(s, @"^https?:\/\/", RegexOptions.IgnoreCase)) - s = "http://" + s; - - if (Uri.TryCreate(s, UriKind.Absolute, out resultURI)) - return (resultURI.Scheme == Uri.UriSchemeHttp || - resultURI.Scheme == Uri.UriSchemeHttps); + if (Uri.IsWellFormedUriString(s, UriKind.Absolute)) + { + result = s; + return true; + } + else if (s.StartsWith("www.")) + { + result = "http://" + s; + return true; + } + result = s; return false; } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/browser.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/browser.png new file mode 100644 index 000000000..ebb975b6f Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/browser.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj index e4261334a..e11e34298 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj @@ -173,6 +173,10 @@ {0BE74EEE-22CB-4DBA-B896-793B9E1A3AC0} Tango.PPC.Common + + {f02eaa84-ad59-465b-99a2-4422c13bfb72} + Tango.PPC.Browser + @@ -245,5 +249,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs index 97bae6f5b..ecd2c7b93 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs @@ -4,6 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; +using Tango.PPC.Browser; +using Tango.PPC.Browser.Navigation; +using Tango.PPC.Browser.Views; using Tango.PPC.Common; namespace Tango.PPC.Technician.ViewModels @@ -15,17 +18,23 @@ namespace Tango.PPC.Technician.ViewModels /// public RelayCommand NavigationCommand { get; set; } + /// + /// Gets or sets the browser command. + /// + public RelayCommand BrowserCommand { get; set; } + /// /// Initializes a new instance of the class. /// public CatalogViewVM() { NavigationCommand = new RelayCommand(NavigateToView); + BrowserCommand = new RelayCommand(OpenBrowserModule); } public override void OnApplicationStarted() { - + } /// @@ -36,5 +45,17 @@ namespace Tango.PPC.Technician.ViewModels { NavigationManager.NavigateTo(view); } + + /// + /// Opens the browser module. + /// + private void OpenBrowserModule() + { + NavigationManager.NavigateWithObject(new BrowserNavigationRequest() + { + Address = "https://twine-s.com/", + DisplayAddressBar = true, + }, true); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml index b0a86d938..b8c74c374 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml @@ -104,6 +104,18 @@ + + + + + + Browser + + Open the browser module and navigate the web. + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/PackagesView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/PackagesView.xaml index f4708448c..a7944497b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/PackagesView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/PackagesView.xaml @@ -26,7 +26,7 @@ - +