e043ae2181
Added Javascript TestPage in wwwroot
150 lines
4.3 KiB
C#
150 lines
4.3 KiB
C#
using CefSharp;
|
|
using Client.Config;
|
|
using Client.Config.SubModels;
|
|
using CMS_Client.View;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.Drawing.Imaging;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace CMS_Client.Browser_Tools
|
|
{
|
|
public class BrowserJSObject
|
|
{
|
|
//The first letter of All PUBLIC Variables and Methods must be Lower-Case (CEF Settings)
|
|
|
|
private MainForm mainForm;
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
#region CONSTRUCTOR_METHOD
|
|
//Constructor Method
|
|
public BrowserJSObject(MainForm f)
|
|
{
|
|
mainForm = f;
|
|
}
|
|
|
|
#endregion
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
#region FORM_BEHAVIOUR_METHODS
|
|
|
|
//Minimize Main Window
|
|
public void minimizeForm()
|
|
{
|
|
//Invoke method if is needed or call the method in STD mode
|
|
if (mainForm.InvokeRequired)
|
|
mainForm.Invoke((MethodInvoker)delegate () {
|
|
mainForm.WindowState = FormWindowState.Minimized;
|
|
});
|
|
|
|
else
|
|
{
|
|
mainForm.WindowState = FormWindowState.Minimized;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//Maximize Main Window
|
|
public void maximizeForm()
|
|
{
|
|
//Invoke method if is needed or call the method in STD mode
|
|
if (mainForm.InvokeRequired)
|
|
mainForm.Invoke((MethodInvoker)delegate () {
|
|
mainForm.WindowState = FormWindowState.Maximized;
|
|
});
|
|
|
|
else
|
|
{
|
|
mainForm.WindowState = FormWindowState.Maximized;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//Close Main Window
|
|
public void closeForm()
|
|
{
|
|
//If the mainform is disposed do nothing
|
|
if (mainForm.IsDisposed)
|
|
return;
|
|
|
|
//Invoke method if is needed or call the method in STD mode
|
|
if (mainForm.InvokeRequired)
|
|
mainForm.Invoke((MethodInvoker)delegate () {
|
|
mainForm.Close();
|
|
});
|
|
|
|
else
|
|
{
|
|
mainForm.Close();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
#region NC_BEHAVIOUR_METHODS
|
|
|
|
//Move NC Window
|
|
public void moveNcWindow(int X,int Y)
|
|
{
|
|
if (Config.VendorHmiConfig.Enabled)
|
|
NcWindow.MoveNcWindow(X, Y);
|
|
}
|
|
|
|
#endregion
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
#region CHROMIUM_METHODS
|
|
|
|
//Get the Version of Chromium
|
|
public String getChromiumVersion()
|
|
{
|
|
return Cef.ChromiumVersion;
|
|
}
|
|
|
|
#endregion
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
#region STEP_METHODS
|
|
|
|
//Get the ID of STEP Client
|
|
public ushort getClientID()
|
|
{
|
|
return Config.ConnectionConfig.Id;
|
|
}
|
|
|
|
public void forceStepFocus()
|
|
{
|
|
Debug.WriteLine("Forced");
|
|
NcWindow.ForceStepFocus();
|
|
}
|
|
|
|
#endregion
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
#region PROCESSES_METHODS
|
|
public String getAvailableProcess()
|
|
{
|
|
return JsonConvert.SerializeObject(Config.ExtSoftwaresConfig);
|
|
}
|
|
public void startProcess(String Path)
|
|
{
|
|
if(File.Exists(Path))
|
|
Process.Start(Path);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|