First commit
This commit is contained in:
+103
-29
@@ -1,9 +1,12 @@
|
||||
using Step.Model;
|
||||
using Step.Model.DTOModels;
|
||||
using Step.NC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using TeamDev.SDK.MVVM;
|
||||
@@ -12,15 +15,20 @@ using static Step.Model.Constants;
|
||||
|
||||
namespace Step.UI
|
||||
{
|
||||
public partial class ServerControlWindow : MetroFramework.Forms.MetroForm
|
||||
public partial class ServerControlWindow : Form
|
||||
{
|
||||
private bool ncStatus = false;
|
||||
private bool isUpdatingThreads = false;
|
||||
private List<RegistrationInfo> MVVMListeners;
|
||||
private static ServerControlWindow ctrlwindow = null;
|
||||
PasswordForm PswForm;
|
||||
|
||||
public ServerControlWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeComponent();
|
||||
|
||||
if (ServerStartupConfig.AutoOpenCmsClient)
|
||||
this.Opacity = 0;
|
||||
|
||||
//Begin the update
|
||||
LISTThreadStatus.BeginUpdate();
|
||||
@@ -29,7 +37,14 @@ namespace Step.UI
|
||||
//Add all items
|
||||
LISTThreadStatus.Items.Add(new ListViewItem(new string[] { "TryNcConnection", "---" }));
|
||||
//End the update
|
||||
LISTThreadStatus.EndUpdate();
|
||||
LISTThreadStatus.EndUpdate();
|
||||
|
||||
Version v = Assembly.GetEntryAssembly().GetName().Version;
|
||||
DateTime buildDate = new DateTime(2000, 1, 1).AddDays(v.Build).AddSeconds(v.Revision * 2);
|
||||
this.Text = "CMS-Active Control Window";
|
||||
TXTVersion.Text = "V" + v + " ("+ buildDate.ToString("d") + ")";
|
||||
|
||||
PswForm = new PasswordForm();
|
||||
|
||||
if (NcConfig != null && NcConfig.NcVendor != null)
|
||||
TXTType.Text = NcConfig.NcVendor;
|
||||
@@ -39,10 +54,32 @@ namespace Step.UI
|
||||
MessageServices.Current.Subscribe(SHOW_MSG_UI, (a, b) =>
|
||||
{
|
||||
Invoke((MethodInvoker)delegate () { Focus(); MessageBox.Show(a.ToString()); });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
private static ServerControlWindow ctrlwindow = null;
|
||||
}
|
||||
|
||||
|
||||
private void ServerControlWindow_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (!_closing)
|
||||
{
|
||||
e.Cancel = true;
|
||||
this.Opacity = 0;
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ServerControlWindow_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (ServerStartupConfig.AutoOpenCmsClient)
|
||||
{
|
||||
BeginInvoke(new MethodInvoker(delegate
|
||||
{
|
||||
Hide();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
{ // Open WinForm
|
||||
@@ -73,15 +110,6 @@ namespace Step.UI
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -96,10 +124,15 @@ namespace Step.UI
|
||||
}
|
||||
|
||||
private void NotifyIcon_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Show();
|
||||
this.TopMost = true;
|
||||
this.TopMost = false;
|
||||
{
|
||||
if((e as MouseEventArgs).Button == MouseButtons.Left)
|
||||
{
|
||||
Show();
|
||||
this.Opacity = 1;
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
this.TopMost = true;
|
||||
this.TopMost = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void StopServerItem_Click(object sender, EventArgs e)
|
||||
@@ -198,19 +231,34 @@ namespace Step.UI
|
||||
});
|
||||
}
|
||||
|
||||
if (ncStatus)
|
||||
if (ncStatus)
|
||||
{
|
||||
NcHandler nc = new NcHandler();
|
||||
DTONcGenericDataModel model;
|
||||
nc.Connect();
|
||||
nc.GetNcGenericData(out model);
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
StepNotifyIcon.Icon = Properties.Resources.CMS_Icon;
|
||||
});
|
||||
TXTMachId.Text = model.CmsMachineIdNumber;
|
||||
CHNcConnected.Checked = true;
|
||||
PswForm.setMatricola(model.CmsMachineIdNumber);
|
||||
passwordToolStripMenuItem.Enabled = true;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
StepNotifyIcon.Icon = Properties.Resources.CMS_Disconnected;
|
||||
TXTMachId.Text = "---";
|
||||
CHNcConnected.Checked = false;
|
||||
passwordToolStripMenuItem.Enabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
//Other type
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
CHNcConnected.Checked = ncStatus;
|
||||
});
|
||||
}),
|
||||
// Threads status handler
|
||||
MessageServices.Current.Subscribe(SEND_THREADS_STATUS, (a, b) =>
|
||||
@@ -229,7 +277,7 @@ namespace Step.UI
|
||||
LISTThreadStatus.Items.Clear();
|
||||
//Add all items
|
||||
foreach (KeyValuePair<string, String> Thr in Threads)
|
||||
LISTThreadStatus.Items.Add(new ListViewItem(new string[] { Thr.Key, Thr.Value }));
|
||||
LISTThreadStatus.Items.Add(new ListViewItem(new String[]{Thr.Key,Thr.Value }));
|
||||
//End the update
|
||||
LISTThreadStatus.EndUpdate();
|
||||
isUpdatingThreads = false;
|
||||
@@ -245,6 +293,32 @@ namespace Step.UI
|
||||
if (p.Length > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void adminMachineToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void passwordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult dr = PswForm.ShowDialog();
|
||||
if (dr == DialogResult.OK)
|
||||
{
|
||||
resetSpindleHoursToolStripMenuItem.Visible = true;
|
||||
goBackToStandardModeToolStripMenuItem.Visible = true;
|
||||
toolStripSeparator.Visible = true;
|
||||
passwordToolStripMenuItem.Enabled = false;
|
||||
MessageBox.Show("Machine Unlocked for administrator use", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void goBackToStandardModeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
resetSpindleHoursToolStripMenuItem.Visible = false;
|
||||
goBackToStandardModeToolStripMenuItem.Visible = false;
|
||||
toolStripSeparator.Visible = false;
|
||||
passwordToolStripMenuItem.Enabled = true;
|
||||
MessageBox.Show("Machine Locked for standard use", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user