e043ae2181
Added Javascript TestPage in wwwroot
131 lines
4.0 KiB
C#
131 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
using Step.Model;
|
|
using TeamDev.SDK.MVVM;
|
|
using static Step.Config.StartupConfig;
|
|
using static Step.Utils.Constants;
|
|
|
|
namespace Step.UI
|
|
{
|
|
public partial class ServerControlWindow : Form
|
|
{
|
|
String HomePageUI;
|
|
String TestJSPageUI;
|
|
|
|
public ServerControlWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
HomePageUI = "http://localhost:" + ServerConfig.ServerPort.ToString() + "/index.html";
|
|
TestJSPageUI = "http://localhost:" + ServerConfig.ServerPort.ToString() + "/Testjavascript//index.html";
|
|
MessageServices.Current.Subscribe(SEND_MESSAGE, (a, b) =>
|
|
{
|
|
// Cast object to ErrorMessageModel
|
|
ErrorMessageModel message = (ErrorMessageModel)a;
|
|
// If error has a fatal level, icon must be error
|
|
message.errorLevel = message.errorLevel > (int)ERROR_LEVEL.ERROR ? (int)ERROR_LEVEL.ERROR : message.errorLevel;
|
|
// Open BalloonTip with data
|
|
StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon)message.errorLevel);
|
|
});
|
|
}
|
|
|
|
private static ServerControlWindow ctrlwindow = null;
|
|
|
|
public static void Start()
|
|
{ // Open WinForm
|
|
Thread th = new Thread(() =>
|
|
{
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
ctrlwindow = new ServerControlWindow();
|
|
Application.Run(ctrlwindow);
|
|
});
|
|
|
|
th.SetApartmentState(ApartmentState.STA);
|
|
th.Start();
|
|
}
|
|
|
|
public static void Stop()
|
|
{ // Close WinForm
|
|
if (ctrlwindow != null)
|
|
{
|
|
ctrlwindow.Invoke((ThreadStart)delegate ()
|
|
{
|
|
ctrlwindow._closing = true;
|
|
ctrlwindow.Close();
|
|
ctrlwindow = null;
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
private bool _closing = false;
|
|
|
|
// Avoid closing the window
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
{
|
|
if (!_closing)
|
|
{
|
|
e.Cancel = true;
|
|
Hide();
|
|
}
|
|
}
|
|
|
|
private void OpenUiButton_Click(object sender, EventArgs e)
|
|
{
|
|
//Open CMS Client
|
|
StartCMSClient(HomePageUI);
|
|
}
|
|
|
|
private void StopServerButton_Click(object sender, EventArgs e)
|
|
{
|
|
// Send message to listeners and close server
|
|
MessageServices.Current.Publish("StopServer");
|
|
}
|
|
|
|
private void NotifyIcon_Click(object sender, EventArgs e)
|
|
{
|
|
this.Show();
|
|
this.TopMost = true;
|
|
this.TopMost = false;
|
|
}
|
|
|
|
private void StopServerItem_Click(object sender, EventArgs e)
|
|
{
|
|
MessageServices.Current.Publish("StopServer");
|
|
}
|
|
|
|
|
|
private void StartCMSClient(string url)
|
|
{
|
|
//Setup the Path Variable
|
|
String CMSClientPath = "";
|
|
|
|
//Check if the system is 64/32 bit
|
|
if (Environment.Is64BitOperatingSystem && File.Exists(Environment.CurrentDirectory + @"\Client\x64\CMS_Client.exe"))
|
|
CMSClientPath = Environment.CurrentDirectory + @"\Client\x64\CMS_Client.exe";
|
|
|
|
else if (File.Exists(Environment.CurrentDirectory + @"\Client\x86\CMS_Client.exe"))
|
|
CMSClientPath = Environment.CurrentDirectory + @"\Client\x86\CMS_Client.exe";
|
|
|
|
if(!String.IsNullOrEmpty(CMSClientPath))
|
|
Process.Start(CMSClientPath, url);
|
|
else
|
|
MessageBox.Show("CMS_Client.Exe not found");
|
|
|
|
}
|
|
|
|
private void TestJSButton_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
StartCMSClient(TestJSPageUI);
|
|
}
|
|
}
|
|
}
|