diff --git a/Client.Config/ConfigController.cs b/Client.Config/ConfigController.cs
index f8fda9d8..7134a890 100644
--- a/Client.Config/ConfigController.cs
+++ b/Client.Config/ConfigController.cs
@@ -72,14 +72,8 @@ namespace Client.Config
IconBase64 = ExtractBase64Icon(x.Element("Path").Value),
Id = SoftwareId++.ToString()
}
- ).ToArray();
-
+ ).ToArray();
-
- // Read ARGS Config
- if (!String.IsNullOrWhiteSpace(Arguments.Url))
- Config.ConnectionConfig.Url = ValidateArgumentUrl(Arguments.Url);
-
}
private static void ValidationHandler(object sender, ValidationEventArgs e)
diff --git a/Client.Utils/Arguments.cs b/Client.Utils/Arguments.cs
deleted file mode 100644
index 919970a4..00000000
--- a/Client.Utils/Arguments.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Client.Utils
-{
- public static class Arguments
- {
- public static String Url { get; set; }
- }
-}
diff --git a/Client.Utils/Client.Utils.csproj b/Client.Utils/Client.Utils.csproj
index 40e6f5ee..38fb5273 100644
--- a/Client.Utils/Client.Utils.csproj
+++ b/Client.Utils/Client.Utils.csproj
@@ -41,7 +41,6 @@
-
diff --git a/Client/Browser_Tools/BrowserJSObject.cs b/Client/Browser_Tools/BrowserJSObject.cs
index 5bc58f5c..aa9aebd6 100644
--- a/Client/Browser_Tools/BrowserJSObject.cs
+++ b/Client/Browser_Tools/BrowserJSObject.cs
@@ -1,4 +1,8 @@
-using Client.Config;
+using Chromium;
+using Chromium.Remote;
+using Chromium.Remote.Event;
+using Chromium.WebBrowser;
+using Client.Config;
using Client.Config.SubModels;
using CMS_Client.View;
using Newtonsoft.Json;
@@ -16,7 +20,7 @@ using static Client.Utils.Constants;
namespace CMS_Client.Browser_Tools
{
- public class BrowserJSObject
+ public class BrowserJSObject : JSObject
{
//The first letter of All PUBLIC Variables and Methods must be Lower-Case (CEF Settings)
@@ -28,6 +32,21 @@ namespace CMS_Client.Browser_Tools
public BrowserJSObject(MainForm f)
{
mainForm = f;
+
+ AddFunction("minimizeForm").Execute += minimizeForm;
+ AddFunction("maximizeForm").Execute += maximizeForm;
+ AddFunction("closeForm").Execute += closeForm;
+ AddFunction("forceStepFocus").Execute += forceStepFocus;
+
+ AddFunction("setNcWindowState").Execute += setNcWindowState;
+ AddFunction("getNcWindowState").Execute += getNcWindowState;
+ AddFunction("getScreenBase64").Execute += getScreenBase64;
+ AddFunction("getChromiumVersion").Execute += getChromiumVersion;
+ AddFunction("getClientID").Execute += getClientID;
+ AddFunction("getConfiguredProcesses").Execute += getConfiguredProcesses;
+ AddFunction("startNewProcess").Execute += startNewProcess;
+ AddFunction("openOrStartProcess").Execute += openOrStartProcess;
+
}
#endregion
@@ -36,7 +55,7 @@ namespace CMS_Client.Browser_Tools
#region FORM_BEHAVIOUR_METHODS
//Minimize Main Window
- public void minimizeForm()
+ public void minimizeForm(object sender, CfrV8HandlerExecuteEventArgs e)
{
//Invoke method if is needed or call the method in STD mode
if (mainForm.InvokeRequired)
@@ -53,7 +72,7 @@ namespace CMS_Client.Browser_Tools
//Maximize Main Window
- public void maximizeForm()
+ public void maximizeForm(object sender, CfrV8HandlerExecuteEventArgs e)
{
//Invoke method if is needed or call the method in STD mode
if (mainForm.InvokeRequired)
@@ -70,7 +89,7 @@ namespace CMS_Client.Browser_Tools
//Close Main Window
- public void closeForm()
+ public void closeForm(object sender, CfrV8HandlerExecuteEventArgs e)
{
//If the mainform is disposed do nothing
if (mainForm.IsDisposed)
@@ -93,23 +112,27 @@ namespace CMS_Client.Browser_Tools
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region NC_BEHAVIOUR_METHODS
- public void setNcWindowState(int stato)
+ public void setNcWindowState(object sender, CfrV8HandlerExecuteEventArgs e)
{
- NcWindow.SetState((NcState)stato);
+ if (e.Arguments.Count() == 0)
+ return;
+
+ NcWindow.SetState((NcState) e.Arguments[0].IntValue );
if (NcWindow.State == NcState.SHOW)
mainForm.ShowNCWindow();
else
mainForm.HideNCWindow();
}
- public int getNcWindowState()
- {
- return (int) NcWindow.State;
+
+ public void getNcWindowState(object sender, CfrV8HandlerExecuteEventArgs e)
+ {
+ e.SetReturnValue((int) NcWindow.State);
}
- public string getScreenBase64()
+ public void getScreenBase64(object sender, CfrV8HandlerExecuteEventArgs e)
{
- return NcWindow.NcCapture;
+ e.SetReturnValue(NcWindow.NcCapture);
}
#endregion
@@ -117,9 +140,9 @@ namespace CMS_Client.Browser_Tools
#region CHROMIUM_METHODS
//Get the Version of Chromium
- public String getChromiumVersion()
+ public void getChromiumVersion(object sender, CfrV8HandlerExecuteEventArgs e)
{
- return "";
+ e.SetReturnValue(CfxRuntime.GetChromeVersion());
}
#endregion
@@ -128,12 +151,12 @@ namespace CMS_Client.Browser_Tools
#region STEP_METHODS
//Get the ID of STEP Client
- public ushort getClientID()
+ public void getClientID(object sender, CfrV8HandlerExecuteEventArgs e)
{
- return Config.ConnectionConfig.Id;
+ e.SetReturnValue((int) Config.ConnectionConfig.Id);
}
- public void forceStepFocus()
+ public void forceStepFocus(object sender, CfrV8HandlerExecuteEventArgs e)
{
Debug.WriteLine("Forced");
NcWindow.ForceStepFocus();
@@ -145,19 +168,23 @@ namespace CMS_Client.Browser_Tools
#region PROCESSES_METHODS
//Read all configured processes
- public String getConfiguredProcesses()
+ public void getConfiguredProcesses(object sender, CfrV8HandlerExecuteEventArgs e)
{
- return JsonConvert.SerializeObject(Config.ExtSoftwaresConfig);
+ e.SetReturnValue(JsonConvert.SerializeObject(Config.ExtSoftwaresConfig));
}
//Start a new process
- public void startNewProcess(String id)
+ public void startNewProcess(object sender, CfrV8HandlerExecuteEventArgs e)
{
+ if (e.Arguments.Count() == 0)
+ return;
+ String id = e.Arguments[0].StringValue;
+
Software sft = Config.ExtSoftwaresConfig.FirstOrDefault(X => X.Id == id);
- if(sft != null)
+ if (sft != null)
{
Process.Start(sft.Path, sft.Arguments);
}
@@ -166,10 +193,14 @@ namespace CMS_Client.Browser_Tools
//Open the last window or Start a new process
- public void openOrStartProcess(String id)
+ public void openOrStartProcess(object sender, CfrV8HandlerExecuteEventArgs e)
{
+ if (e.Arguments.Count() == 0)
+ return;
+ String id = e.Arguments[0].StringValue;
+
Software sft = Config.ExtSoftwaresConfig.FirstOrDefault(X => X.Id == id);
-
+
if (sft != null)
{
Process[] p = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(sft.Path)).OrderByDescending(X => X.StartTime).ToArray();
diff --git a/Client/Program.cs b/Client/Program.cs
index 8dad91d2..875232d8 100644
--- a/Client/Program.cs
+++ b/Client/Program.cs
@@ -39,7 +39,9 @@ namespace CMS_Client
//Check the first argument -> Url
if (args.Count() > 0)
{
- Arguments.Url = args[0];
+ // Read ARGS Config
+ if (!String.IsNullOrWhiteSpace(args[0]))
+ Config.ConnectionConfig.Url = args[0];
}
diff --git a/Client/View/MainForm.cs b/Client/View/MainForm.cs
index c36af342..ea1a56db 100644
--- a/Client/View/MainForm.cs
+++ b/Client/View/MainForm.cs
@@ -9,6 +9,7 @@ using Chromium.WebBrowser;
using Chromium.Event;
using Chromium.WebBrowser.Event;
using System.Diagnostics;
+using CMS_Client.Browser_Tools;
namespace CMS_Client.View
{
@@ -160,10 +161,15 @@ namespace CMS_Client.View
//Initialize the Browser-Component
private void InitializeBrowser()
{
+ //Add Custom object to browser
+ Browser.GlobalObject.Add(Constants.BROWSER_JS_OBJ_NAME, new BrowserJSObject(this));
+
+ //Add all Handlers
Browser.DisplayHandler.OnTitleChange += BrowserTitleChanged;
Browser.LoadHandler.OnLoadingStateChange += BrowserLoadsChanged;
Browser.LoadHandler.OnLoadError += BrowserLoadsError;
Browser.KeyboardHandler.OnKeyEvent += BrowserKeyPress;
+ Browser.ContextMenuHandler.OnBeforeContextMenu += BrowserContextMenu;
}
#endregion
@@ -176,7 +182,7 @@ namespace CMS_Client.View
{
//Set the Load-Error global variable to TRUE
LoadingError.Error = true;
- //LoadingError.ErrorInfo = e.ErrorCode.GetTypeCode() + " - " + e.ErrorText;
+ LoadingError.ErrorInfo = e.ErrorCode.GetTypeCode() + " - " + e.ErrorText;
//write the error in the Title Bar
SetWindowTitle(LoadingError.ErrorInfo);
@@ -247,17 +253,23 @@ namespace CMS_Client.View
//Work only if is a Developer mode
if (Config.ClientConfig.DeveloperMode)
{
- if (e.Event.WindowsKeyCode == (int)Keys.F12)
- ShowDevTools();
-
- if (e.Event.WindowsKeyCode == (int)Keys.F5)
- Browser.Browser.ReloadIgnoreCache();
-
if (e.Event.WindowsKeyCode == (int)Keys.F1)
Browser.Browser.GoBack();
if (e.Event.WindowsKeyCode == (int)Keys.F2)
Browser.Browser.GoForward();
+
+ if (e.Event.WindowsKeyCode == (int)Keys.F5)
+ Browser.Browser.ReloadIgnoreCache();
+
+ if (e.Event.WindowsKeyCode == (int)Keys.F10)
+ ShowChromeVersion();
+
+ if (e.Event.WindowsKeyCode == (int)Keys.F11)
+ ShowChromeGPU();
+
+ if (e.Event.WindowsKeyCode == (int)Keys.F12)
+ ShowDevTools();
}
//Work everytime
@@ -265,7 +277,7 @@ namespace CMS_Client.View
Browser.Browser.ReloadIgnoreCache();
}
- }
+ }
@@ -279,11 +291,62 @@ namespace CMS_Client.View
windowInfo.X = 1120;
windowInfo.Y = 0;
windowInfo.Width = 800;
- windowInfo.Height = 1080;
+ windowInfo.Height = 1080;
//Show Dev Window
Browser.BrowserHost.ShowDevTools(windowInfo, new CfxClient(), new CfxBrowserSettings(), null);
}
+
+
+
+ //Show Chrome GPU Window
+ private void ShowChromeGPU()
+ {
+ int w=1600, h=800;
+
+ //Setup Window
+ CfxWindowInfo windowInfo = new CfxWindowInfo();
+ windowInfo.Style = (WindowStyle.WS_OVERLAPPEDWINDOW | WindowStyle.WS_POPUP | WindowStyle.WS_CLIPCHILDREN | WindowStyle.WS_CLIPSIBLINGS | WindowStyle.WS_VISIBLE);
+ windowInfo.ParentWindow = MainHandle;
+ windowInfo.WindowName = Application.ProductName + " | CEF Graphic Tools";
+ windowInfo.X = (Screen.PrimaryScreen.Bounds.Width / 2) - (w / 2);
+ windowInfo.Y = (Screen.PrimaryScreen.Bounds.Height / 2) - (h / 2);
+ windowInfo.Width = w;
+ windowInfo.Height = h;
+
+ //Show Window
+ CfxBrowserHost.CreateBrowser(windowInfo, new CfxClient(), "chrome://gpu/", ChromiumWebBrowser.DefaultBrowserSettings, null);
+ }
+
+
+
+ //Show Chrome Version Window
+ private void ShowChromeVersion()
+ {
+ int w = 1600, h = 800;
+
+ //Setup Window
+ CfxWindowInfo windowInfo = new CfxWindowInfo();
+ windowInfo.Style = (WindowStyle.WS_OVERLAPPEDWINDOW | WindowStyle.WS_POPUP | WindowStyle.WS_CLIPCHILDREN | WindowStyle.WS_CLIPSIBLINGS | WindowStyle.WS_VISIBLE);
+ windowInfo.ParentWindow = MainHandle;
+ windowInfo.WindowName = Application.ProductName + " | CEF Chromium-Version Tools";
+ windowInfo.X = (Screen.PrimaryScreen.Bounds.Width / 2) - (w / 2);
+ windowInfo.Y = (Screen.PrimaryScreen.Bounds.Height / 2) - (h / 2);
+ windowInfo.Width = w;
+ windowInfo.Height = h;
+
+ //Show Window
+ CfxBrowserHost.CreateBrowser(windowInfo, new CfxClient(), "chrome://version/", ChromiumWebBrowser.DefaultBrowserSettings, null);
+ }
+
+
+
+ //Override default Browser Context Menu
+ private void BrowserContextMenu(object sender, CfxOnBeforeContextMenuEventArgs e)
+ {
+ e.Model.Clear();
+ }
+
#endregion
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////