aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2019-12-12 13:00:45 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2019-12-12 13:00:45 +0200
commit5fdb4170c92072fa5a3ee32a779bea2ed83b8ef0 (patch)
tree231e9b316e3b1f30c815d9bcec5d8b7815625201 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels
parent217fcb79fa32f858a06d8200697ddee7c5da625a (diff)
downloadTango-5fdb4170c92072fa5a3ee32a779bea2ed83b8ef0.tar.gz
Tango-5fdb4170c92072fa5a3ee32a779bea2ed83b8ef0.zip
Added more functionality to browser module.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/BrowserViewVM.cs101
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/MainViewVM.cs56
2 files changed, 101 insertions, 56 deletions
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
+{
+ /// <summary>
+ /// Represents the main view VM and entry point for <see cref="Synchronization.MyModule"/>.
+ /// </summary>
+ /// <seealso cref="Tango.PPC.Common.PPCViewModel" />
+ public class BrowserViewVM : PPCViewModel<IBrowserView>
+ {
+ 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<bool> OnNavigateBackRequest()
+ {
+ if (View.CanGoBack())
+ {
+ View.GoBack();
+ return Task.FromResult(false);
+ }
+ else
+ {
+ return Task.FromResult(true);
+ }
+ }
+
+ /// <summary>
+ /// Called when the application has been started
+ /// </summary>
+ public override void OnApplicationStarted()
+ {
+
+ }
+
+ private void Go()
+ {
+ View.NavigateTo(Address);
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/MainViewVM.cs
deleted file mode 100644
index afea97f73..000000000
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Browser/ViewModels/MainViewVM.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using CefSharp;
-using CefSharp.Wpf;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.PPC.Common;
-using Tango.Touch.Keyboard;
-
-namespace Tango.PPC.Browser.ViewModels
-{
- /// <summary>
- /// Represents the main view VM and entry point for <see cref="Synchronization.MyModule"/>.
- /// </summary>
- /// <seealso cref="Tango.PPC.Common.PPCViewModel" />
- public class MainViewVM : PPCViewModel
- {
- public MainViewVM()
- {
- 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;
- }
- }
-
- public override void OnNavigatedTo()
- {
- base.OnNavigatedTo();
- KeyboardView.Default.OutputMode = KeyboardOutputMode.Windows;
- }
-
- public override void OnNavigatedFrom()
- {
- base.OnNavigatedFrom();
- KeyboardView.Default.OutputMode = KeyboardOutputMode.Wpf;
- }
-
- /// <summary>
- /// Called when the application has been started
- /// </summary>
- public override void OnApplicationStarted()
- {
-
- }
- }
-}