First commit

This commit is contained in:
Nicola Carminati
2019-03-29 18:00:18 +01:00
parent 5940c5daf7
commit 4213c2480f
14 changed files with 1055 additions and 212 deletions
+5 -2
View File
@@ -437,8 +437,11 @@ namespace CMS_Client.View
//Show Nc Window
public static void ShowNcWindow()
{
if (windowstarted)
ShowWindow(ncprocess.MainWindowHandle, SW_SHOWNOACTIVATE);
if (windowstarted)
{
ShowWindow(ncprocess.MainWindowHandle, SW_SHOWNOACTIVATE);
ResizeAndMoveNcWindow(ncWindowX, ncWindowY, ncWindowWidth, ncWindowHeight);
}
}
//Show Prod Window
Binary file not shown.
+5
View File
@@ -299,6 +299,11 @@ public static class ThreadsFunctions
else
// Send through signalR
MessageServices.Current.Publish(SEND_EXPIRED_MAINTENANCES_DATA, null, expiredMaintenances);
//Manage Candies
libraryError = ncHandler.ManageCandies();
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
}
else
RestoreConnection();
+85
View File
@@ -1162,6 +1162,91 @@ namespace Step.NC
return max;
}
public CmsError ManageCandies()
{
CmsError cmsError;
int NcCandy = 0;
int NCMatr, PCMatr;
long NCParam, PCParam,newParam;
bool bNC_OK, bPC_OK;
bool bNC_VALID, bPC_VALID;
String strMachNumber="0";
int machNumber;
bool bRewrite=false;
//Read Machine ID
cmsError = numericalControl.NC_RMachineNumber(ref strMachNumber);
if (cmsError.IsError())
return cmsError;
machNumber = Int32.Parse(strMachNumber);
//Read Data from NC & elaborate it
cmsError = numericalControl.PLC_RCandy(ref NcCandy);
if (cmsError.IsError())
return cmsError;
bNC_OK = CandiesController.getDataFromLincense(NcCandy, out NCMatr, out NCParam);
bNC_VALID = machNumber == NCMatr;
//Read Data from PC
bPC_OK = CandiesController.getPCLincense(out PCMatr, out PCParam);
bPC_VALID = machNumber == PCMatr;
if(bNC_VALID & bPC_VALID)
{
if(PCParam == NCParam)
{
newParam = PCParam + Utils.CandiesController.BASE_TIME;
bRewrite = false;
}
else if(PCParam < NCParam)
{
newParam = PCParam + Utils.CandiesController.BASE_TIME;
bRewrite = true;
}
else
{
newParam = NCParam + Utils.CandiesController.BASE_TIME;
bRewrite = true;
}
}
else if (bNC_VALID)
{
newParam = NCParam + Utils.CandiesController.BASE_TIME;
bRewrite = true;
}
else if (bPC_VALID)
{
newParam = PCParam + Utils.CandiesController.BASE_TIME;
bRewrite = true;
}
else
{
// tutto a zero? immagino sia la prima accensione
if ()
}
Else
'tutto a zero? immagino sia la prima accensione
If nLicReg_X = 0 And nLicCnc_X = 0 Then
nData = BASETIME
bRewrite = True
'ho creato il file? immagino sia la prima accensione con memorie cn sporche
ElseIf nLicReg_X = 0 And bFileCreated Then
bFileCreated = False
nData = BASETIME
bRewrite = True
Else
'a questo punto blocco.. ipotizzo una forzatura
nData = 0
bRewrite = False
End If
End If
}
//DTOScadaModel scada = new DTOScadaModel
//{
// Layers = prodScada.Layers.Select(x => new DTOScadaLayerModel()
+155
View File
@@ -0,0 +1,155 @@
namespace Step.UI
{
partial class PasswordForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Panel1 = new System.Windows.Forms.Panel();
this.TextBox_Password = new System.Windows.Forms.TextBox();
this.Label_NewPassword = new System.Windows.Forms.Label();
this.TableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.OK_Pwd_Button = new System.Windows.Forms.Button();
this.Cancel_Pwd_Button = new System.Windows.Forms.Button();
this.ErrorProvider1 = new System.Windows.Forms.ErrorProvider(this.components);
this.Panel1.SuspendLayout();
this.TableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.ErrorProvider1)).BeginInit();
this.SuspendLayout();
//
// Panel1
//
this.Panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.Panel1.BackColor = System.Drawing.Color.White;
this.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Panel1.Controls.Add(this.TextBox_Password);
this.Panel1.Controls.Add(this.Label_NewPassword);
this.Panel1.Location = new System.Drawing.Point(-6, -2);
this.Panel1.Name = "Panel1";
this.Panel1.Size = new System.Drawing.Size(354, 70);
this.Panel1.TabIndex = 4;
//
// TextBox_Password
//
this.TextBox_Password.Font = new System.Drawing.Font("Tahoma", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TextBox_Password.Location = new System.Drawing.Point(114, 25);
this.TextBox_Password.Name = "TextBox_Password";
this.TextBox_Password.PasswordChar = '*';
this.TextBox_Password.Size = new System.Drawing.Size(186, 26);
this.TextBox_Password.TabIndex = 1;
this.TextBox_Password.UseSystemPasswordChar = true;
this.TextBox_Password.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBox_Password_KeyDown);
//
// Label_NewPassword
//
this.Label_NewPassword.AutoSize = true;
this.Label_NewPassword.Font = new System.Drawing.Font("Tahoma", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Label_NewPassword.Location = new System.Drawing.Point(31, 28);
this.Label_NewPassword.Name = "Label_NewPassword";
this.Label_NewPassword.Size = new System.Drawing.Size(69, 18);
this.Label_NewPassword.TabIndex = 7;
this.Label_NewPassword.Tag = "Password";
this.Label_NewPassword.Text = "Password";
//
// TableLayoutPanel1
//
this.TableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.TableLayoutPanel1.ColumnCount = 2;
this.TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.TableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.TableLayoutPanel1.Controls.Add(this.OK_Pwd_Button, 0, 0);
this.TableLayoutPanel1.Controls.Add(this.Cancel_Pwd_Button, 1, 0);
this.TableLayoutPanel1.Location = new System.Drawing.Point(106, 79);
this.TableLayoutPanel1.Name = "TableLayoutPanel1";
this.TableLayoutPanel1.RowCount = 1;
this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.TableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 46F));
this.TableLayoutPanel1.Size = new System.Drawing.Size(219, 46);
this.TableLayoutPanel1.TabIndex = 3;
//
// OK_Pwd_Button
//
this.OK_Pwd_Button.Anchor = System.Windows.Forms.AnchorStyles.None;
this.OK_Pwd_Button.Location = new System.Drawing.Point(3, 3);
this.OK_Pwd_Button.Name = "OK_Pwd_Button";
this.OK_Pwd_Button.Size = new System.Drawing.Size(103, 39);
this.OK_Pwd_Button.TabIndex = 5;
this.OK_Pwd_Button.Text = "OK";
this.OK_Pwd_Button.Click += new System.EventHandler(this.OK_Pwd_Button_Click);
//
// Cancel_Pwd_Button
//
this.Cancel_Pwd_Button.Anchor = System.Windows.Forms.AnchorStyles.None;
this.Cancel_Pwd_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel_Pwd_Button.Location = new System.Drawing.Point(112, 3);
this.Cancel_Pwd_Button.Name = "Cancel_Pwd_Button";
this.Cancel_Pwd_Button.Size = new System.Drawing.Size(103, 39);
this.Cancel_Pwd_Button.TabIndex = 6;
this.Cancel_Pwd_Button.Tag = "Cancel";
this.Cancel_Pwd_Button.Text = "Cancel";
this.Cancel_Pwd_Button.Click += new System.EventHandler(this.Cancel_Pwd_Button_Click);
//
// ErrorProvider1
//
this.ErrorProvider1.ContainerControl = this;
//
// PasswordForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(337, 137);
this.ControlBox = false;
this.Controls.Add(this.Panel1);
this.Controls.Add(this.TableLayoutPanel1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "PasswordForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Password";
this.Load += new System.EventHandler(this.PasswordForm_Load);
this.Panel1.ResumeLayout(false);
this.Panel1.PerformLayout();
this.TableLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.ErrorProvider1)).EndInit();
this.ResumeLayout(false);
}
#endregion
internal System.Windows.Forms.Panel Panel1;
internal System.Windows.Forms.TextBox TextBox_Password;
internal System.Windows.Forms.Label Label_NewPassword;
internal System.Windows.Forms.TableLayoutPanel TableLayoutPanel1;
internal System.Windows.Forms.Button OK_Pwd_Button;
internal System.Windows.Forms.Button Cancel_Pwd_Button;
internal System.Windows.Forms.ErrorProvider ErrorProvider1;
}
}
+114
View File
@@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Step.UI
{
public partial class PasswordForm : Form
{
public String Matricola;
private DateTime Licenza;
const long BASETIME = 730119; // 1/1/2000
public PasswordForm()
{
InitializeComponent();
}
public void setMatricola(String matr)
{
this.Matricola = matr;
this.Text = "Password - " + this.Matricola;
}
private void Cancel_Pwd_Button_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void OK_Pwd_Button_Click(object sender, EventArgs e)
{
checkPSW(TextBox_Password.Text);
}
private void PasswordForm_Load(object sender, EventArgs e)
{
TextBox_Password.Text = "";
this.ActiveControl = TextBox_Password;
}
private void TextBox_Password_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
checkPSW(TextBox_Password.Text);
}
}
private void checkPSW(String psw)
{
bool bValid = false;
long Parameter;
int Matr, Command;
//Password storica. Serve per abilitare funzionalità particolari
if (psw == "cmsserviceonly")
bValid = true;
else if (Utils.CandiesController.PasswordDecode(psw, out Matr, out Command, out Parameter))
//Controllo la matricola
if (this.Matricola != Matr.ToString())
bValid = false;
else
{
switch (Command)
{
//password del service
case 1: bValid = true;break;
//SET Licenza Temporanea
case 2:
Licenza = new DateTime(Parameter * TimeSpan.TicksPerDay);
bValid = false;
break;
//SET Licenza Illimitata
case 3:
Licenza = new DateTime(0);
bValid = false;
break;
}
bValid = false;
}
else
bValid = false;
if (!bValid)
{
long nLic = Licenza.Ticks / TimeSpan.TicksPerDay;
string szError;
if (nLic == BASETIME)
szError = "Error #H-OO";
else
szError = "Error #H-" + nLic.ToString();
ErrorProvider1.SetError(TextBox_Password, "INVALID PASSWORD" + Environment.NewLine + szError);
}
else
{
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}
}
+123
View File
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ErrorProvider1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
+230 -156
View File
@@ -35,20 +35,29 @@ namespace Step.UI
this.StepNotifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.NotifyIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.StopServerItem = new System.Windows.Forms.ToolStripMenuItem();
this.openUiButton = new MetroFramework.Controls.MetroButton();
this.metroTabControl1 = new MetroFramework.Controls.MetroTabControl();
this.ThreadsInfo = new MetroFramework.Controls.MetroTabPage();
this.LISTThreadStatus = new MetroFramework.Controls.MetroListView();
this.adminMachineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.passwordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.goBackToStandardModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator();
this.resetSpindleHoursToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.TXTstatus = new System.Windows.Forms.TextBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.stopServerButton = new System.Windows.Forms.Button();
this.openUiButton = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.TXTVersion = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.TXTType = new System.Windows.Forms.Label();
this.CHNcConnected = new System.Windows.Forms.CheckBox();
this.label2 = new System.Windows.Forms.Label();
this.TXTMachId = new System.Windows.Forms.Label();
this.LISTThreadStatus = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.stopServerButton = new MetroFramework.Controls.MetroButton();
this.TXTstatus = new MetroFramework.Controls.MetroTextBox();
this.TXTType = new System.Windows.Forms.Label();
this.CHNcConnected = new MetroFramework.Controls.MetroCheckBox();
this.label1 = new System.Windows.Forms.Label();
this.NotifyIconMenu.SuspendLayout();
this.metroTabControl1.SuspendLayout();
this.ThreadsInfo.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// StepNotifyIcon
@@ -63,10 +72,11 @@ namespace Step.UI
// NotifyIconMenu
//
this.NotifyIconMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.StopServerItem});
this.StopServerItem,
this.adminMachineToolStripMenuItem});
this.NotifyIconMenu.Name = "NotifyIconMenu";
this.NotifyIconMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
this.NotifyIconMenu.Size = new System.Drawing.Size(167, 26);
this.NotifyIconMenu.Size = new System.Drawing.Size(167, 48);
//
// StopServerItem
//
@@ -75,184 +85,239 @@ namespace Step.UI
this.StopServerItem.Text = "Close CMS Server";
this.StopServerItem.Click += new System.EventHandler(this.StopServerItem_Click);
//
// openUiButton
// adminMachineToolStripMenuItem
//
this.openUiButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.openUiButton.Location = new System.Drawing.Point(11, 371);
this.openUiButton.Name = "openUiButton";
this.openUiButton.Size = new System.Drawing.Size(151, 42);
this.openUiButton.TabIndex = 1;
this.openUiButton.TabStop = false;
this.openUiButton.Text = "Open CMS-Active Client";
this.openUiButton.UseSelectable = true;
this.openUiButton.Click += new System.EventHandler(this.OpenUiButton_Click);
this.adminMachineToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.passwordToolStripMenuItem,
this.goBackToStandardModeToolStripMenuItem,
this.toolStripSeparator,
this.resetSpindleHoursToolStripMenuItem});
this.adminMachineToolStripMenuItem.Name = "adminMachineToolStripMenuItem";
this.adminMachineToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.adminMachineToolStripMenuItem.Text = "Service";
//
// metroTabControl1
// passwordToolStripMenuItem
//
this.metroTabControl1.Controls.Add(this.ThreadsInfo);
this.metroTabControl1.Location = new System.Drawing.Point(8, 26);
this.metroTabControl1.Name = "metroTabControl1";
this.metroTabControl1.SelectedIndex = 0;
this.metroTabControl1.Size = new System.Drawing.Size(328, 323);
this.metroTabControl1.TabIndex = 7;
this.metroTabControl1.UseSelectable = true;
this.passwordToolStripMenuItem.Name = "passwordToolStripMenuItem";
this.passwordToolStripMenuItem.Size = new System.Drawing.Size(214, 22);
this.passwordToolStripMenuItem.Text = "Password";
this.passwordToolStripMenuItem.Click += new System.EventHandler(this.passwordToolStripMenuItem_Click);
//
// ThreadsInfo
// goBackToStandardModeToolStripMenuItem
//
this.ThreadsInfo.Controls.Add(this.LISTThreadStatus);
this.ThreadsInfo.HorizontalScrollbarBarColor = true;
this.ThreadsInfo.HorizontalScrollbarHighlightOnWheel = false;
this.ThreadsInfo.HorizontalScrollbarSize = 10;
this.ThreadsInfo.Location = new System.Drawing.Point(4, 38);
this.ThreadsInfo.Name = "ThreadsInfo";
this.ThreadsInfo.Size = new System.Drawing.Size(320, 281);
this.ThreadsInfo.TabIndex = 1;
this.ThreadsInfo.Text = "Active Threads Info";
this.ThreadsInfo.VerticalScrollbarBarColor = true;
this.ThreadsInfo.VerticalScrollbarHighlightOnWheel = false;
this.ThreadsInfo.VerticalScrollbarSize = 10;
this.goBackToStandardModeToolStripMenuItem.Name = "goBackToStandardModeToolStripMenuItem";
this.goBackToStandardModeToolStripMenuItem.Size = new System.Drawing.Size(214, 22);
this.goBackToStandardModeToolStripMenuItem.Text = "Go back to standard mode";
this.goBackToStandardModeToolStripMenuItem.Visible = false;
this.goBackToStandardModeToolStripMenuItem.Click += new System.EventHandler(this.goBackToStandardModeToolStripMenuItem_Click);
//
// LISTThreadStatus
// toolStripSeparator
//
this.LISTThreadStatus.Alignment = System.Windows.Forms.ListViewAlignment.Default;
this.LISTThreadStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.LISTThreadStatus.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.LISTThreadStatus.Font = new System.Drawing.Font("Segoe UI", 12F);
this.LISTThreadStatus.FullRowSelect = true;
this.LISTThreadStatus.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.LISTThreadStatus.Location = new System.Drawing.Point(-4, 0);
this.LISTThreadStatus.MultiSelect = false;
this.LISTThreadStatus.Name = "LISTThreadStatus";
this.LISTThreadStatus.OwnerDraw = true;
this.LISTThreadStatus.Scrollable = false;
this.LISTThreadStatus.ShowGroups = false;
this.LISTThreadStatus.Size = new System.Drawing.Size(331, 275);
this.LISTThreadStatus.TabIndex = 2;
this.LISTThreadStatus.UseCompatibleStateImageBehavior = false;
this.LISTThreadStatus.UseSelectable = true;
this.LISTThreadStatus.UseStyleColors = true;
this.LISTThreadStatus.View = System.Windows.Forms.View.Details;
this.toolStripSeparator.Name = "toolStripSeparator";
this.toolStripSeparator.Size = new System.Drawing.Size(211, 6);
this.toolStripSeparator.Visible = false;
//
// columnHeader1
// resetSpindleHoursToolStripMenuItem
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 233;
//
// columnHeader2
//
this.columnHeader2.Text = "Exec. Time";
this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader2.Width = 84;
//
// stopServerButton
//
this.stopServerButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stopServerButton.Location = new System.Drawing.Point(188, 371);
this.stopServerButton.Name = "stopServerButton";
this.stopServerButton.Size = new System.Drawing.Size(151, 42);
this.stopServerButton.TabIndex = 3;
this.stopServerButton.TabStop = false;
this.stopServerButton.Text = "Close Active";
this.stopServerButton.UseSelectable = true;
this.stopServerButton.Click += new System.EventHandler(this.StopServerButton_Click);
this.resetSpindleHoursToolStripMenuItem.Name = "resetSpindleHoursToolStripMenuItem";
this.resetSpindleHoursToolStripMenuItem.Size = new System.Drawing.Size(214, 22);
this.resetSpindleHoursToolStripMenuItem.Text = "Reset Spindle Hours";
this.resetSpindleHoursToolStripMenuItem.Visible = false;
//
// TXTstatus
//
this.TXTstatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
//
//
//
this.TXTstatus.CustomButton.Image = null;
this.TXTstatus.CustomButton.Location = new System.Drawing.Point(324, 2);
this.TXTstatus.CustomButton.Name = "";
this.TXTstatus.CustomButton.Size = new System.Drawing.Size(25, 25);
this.TXTstatus.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
this.TXTstatus.CustomButton.TabIndex = 1;
this.TXTstatus.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
this.TXTstatus.CustomButton.UseSelectable = true;
this.TXTstatus.CustomButton.Visible = false;
this.tableLayoutPanel1.SetColumnSpan(this.TXTstatus, 2);
this.TXTstatus.Enabled = false;
this.TXTstatus.Lines = new string[] {
"..."};
this.TXTstatus.Location = new System.Drawing.Point(-1, 419);
this.TXTstatus.MaxLength = 32767;
this.TXTstatus.Location = new System.Drawing.Point(3, 416);
this.TXTstatus.Name = "TXTstatus";
this.TXTstatus.PasswordChar = '\0';
this.TXTstatus.ReadOnly = true;
this.TXTstatus.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.TXTstatus.SelectedText = "";
this.TXTstatus.SelectionLength = 0;
this.TXTstatus.SelectionStart = 0;
this.TXTstatus.ShortcutsEnabled = true;
this.TXTstatus.Size = new System.Drawing.Size(352, 30);
this.TXTstatus.Size = new System.Drawing.Size(435, 20);
this.TXTstatus.TabIndex = 8;
this.TXTstatus.Text = "...";
this.TXTstatus.UseSelectable = true;
this.TXTstatus.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
this.TXTstatus.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
//
// TXTType
// tableLayoutPanel1
//
this.TXTType.AutoSize = true;
this.TXTType.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TXTType.Location = new System.Drawing.Point(179, 348);
this.TXTType.Name = "TXTType";
this.TXTType.Size = new System.Drawing.Size(51, 13);
this.TXTType.TabIndex = 53;
this.TXTType.Text = "NcType";
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Controls.Add(this.stopServerButton, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.openUiButton, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.TXTstatus, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.LISTThreadStatus, 0, 0);
this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 89F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 54F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(441, 438);
this.tableLayoutPanel1.TabIndex = 58;
//
// CHNcConnected
// stopServerButton
//
this.CHNcConnected.AutoCheck = false;
this.CHNcConnected.ForeColor = System.Drawing.SystemColors.ControlText;
this.CHNcConnected.Location = new System.Drawing.Point(246, 345);
this.CHNcConnected.Name = "CHNcConnected";
this.CHNcConnected.Size = new System.Drawing.Size(81, 20);
this.CHNcConnected.TabIndex = 52;
this.CHNcConnected.Text = "Connected";
this.CHNcConnected.UseSelectable = true;
this.stopServerButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stopServerButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stopServerButton.Location = new System.Drawing.Point(223, 362);
this.stopServerButton.Name = "stopServerButton";
this.stopServerButton.Size = new System.Drawing.Size(215, 48);
this.stopServerButton.TabIndex = 3;
this.stopServerButton.TabStop = false;
this.stopServerButton.Text = "Close Active";
this.stopServerButton.Click += new System.EventHandler(this.StopServerButton_Click);
//
// openUiButton
//
this.openUiButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.openUiButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.openUiButton.Location = new System.Drawing.Point(3, 362);
this.openUiButton.Name = "openUiButton";
this.openUiButton.Size = new System.Drawing.Size(214, 48);
this.openUiButton.TabIndex = 58;
this.openUiButton.TabStop = false;
this.openUiButton.Text = "Open CMS-Active Client";
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel1.SetColumnSpan(this.panel1, 2);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.TXTVersion);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.TXTType);
this.panel1.Controls.Add(this.CHNcConnected);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.TXTMachId);
this.panel1.Location = new System.Drawing.Point(3, 273);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(435, 83);
this.panel1.TabIndex = 9;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 49);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(104, 13);
this.label3.TabIndex = 59;
this.label3.Text = "CMS-Active Version:";
//
// TXTVersion
//
this.TXTVersion.AutoSize = true;
this.TXTVersion.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TXTVersion.Location = new System.Drawing.Point(113, 49);
this.TXTVersion.Name = "TXTVersion";
this.TXTVersion.Size = new System.Drawing.Size(19, 13);
this.TXTVersion.TabIndex = 58;
this.TXTVersion.Text = "---";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(134, 348);
this.label1.Location = new System.Drawing.Point(3, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(44, 13);
this.label1.TabIndex = 54;
this.label1.Text = "Vendor:";
//
// TXTType
//
this.TXTType.AutoSize = true;
this.TXTType.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TXTType.Location = new System.Drawing.Point(48, 24);
this.TXTType.Name = "TXTType";
this.TXTType.Size = new System.Drawing.Size(19, 13);
this.TXTType.TabIndex = 53;
this.TXTType.Text = "---";
//
// CHNcConnected
//
this.CHNcConnected.AutoCheck = false;
this.CHNcConnected.ForeColor = System.Drawing.SystemColors.ControlText;
this.CHNcConnected.Location = new System.Drawing.Point(340, 24);
this.CHNcConnected.Name = "CHNcConnected";
this.CHNcConnected.Size = new System.Drawing.Size(81, 20);
this.CHNcConnected.TabIndex = 52;
this.CHNcConnected.Text = "Connected";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(142, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(63, 13);
this.label2.TabIndex = 57;
this.label2.Text = "Machine Id:";
//
// TXTMachId
//
this.TXTMachId.AutoSize = true;
this.TXTMachId.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TXTMachId.Location = new System.Drawing.Point(240, 24);
this.TXTMachId.Name = "TXTMachId";
this.TXTMachId.Size = new System.Drawing.Size(19, 13);
this.TXTMachId.TabIndex = 56;
this.TXTMachId.Text = "---";
//
// LISTThreadStatus
//
this.LISTThreadStatus.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.tableLayoutPanel1.SetColumnSpan(this.LISTThreadStatus, 2);
this.LISTThreadStatus.Dock = System.Windows.Forms.DockStyle.Fill;
this.LISTThreadStatus.Location = new System.Drawing.Point(3, 3);
this.LISTThreadStatus.Name = "LISTThreadStatus";
this.LISTThreadStatus.Size = new System.Drawing.Size(435, 264);
this.LISTThreadStatus.TabIndex = 59;
this.LISTThreadStatus.UseCompatibleStateImageBehavior = false;
this.LISTThreadStatus.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Thread Name";
this.columnHeader1.Width = 328;
//
// columnHeader2
//
this.columnHeader2.Text = "Time";
this.columnHeader2.Width = 78;
//
// ServerControlWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(350, 449);
this.Controls.Add(this.label1);
this.Controls.Add(this.TXTType);
this.Controls.Add(this.CHNcConnected);
this.Controls.Add(this.TXTstatus);
this.Controls.Add(this.stopServerButton);
this.Controls.Add(this.metroTabControl1);
this.Controls.Add(this.openUiButton);
this.ClientSize = new System.Drawing.Size(465, 462);
this.Controls.Add(this.tableLayoutPanel1);
this.ForeColor = System.Drawing.SystemColors.ControlText;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(2);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ServerControlWindow";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.AeroShadow;
this.ShowInTaskbar = false;
this.Theme = MetroFramework.MetroThemeStyle.Default;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ServerControlWindow_FormClosing);
this.Load += new System.EventHandler(this.ServerControlWindow_Load);
this.NotifyIconMenu.ResumeLayout(false);
this.metroTabControl1.ResumeLayout(false);
this.ThreadsInfo.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
@@ -260,16 +325,25 @@ namespace Step.UI
private System.Windows.Forms.NotifyIcon StepNotifyIcon;
private System.Windows.Forms.ContextMenuStrip NotifyIconMenu;
private System.Windows.Forms.ToolStripMenuItem StopServerItem;
private MetroFramework.Controls.MetroButton openUiButton;
private MetroFramework.Controls.MetroTabControl metroTabControl1;
private MetroFramework.Controls.MetroButton stopServerButton;
private MetroFramework.Controls.MetroTabPage ThreadsInfo;
private MetroFramework.Controls.MetroListView LISTThreadStatus;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private MetroFramework.Controls.MetroTextBox TXTstatus;
private Label TXTType;
private MetroFramework.Controls.MetroCheckBox CHNcConnected;
private System.Windows.Forms.TextBox TXTstatus;
private ToolStripMenuItem adminMachineToolStripMenuItem;
private ToolStripMenuItem passwordToolStripMenuItem;
private TableLayoutPanel tableLayoutPanel1;
private Button stopServerButton;
private Button openUiButton;
private Panel panel1;
private Label label3;
private Label TXTVersion;
private Label label1;
private Label TXTType;
private CheckBox CHNcConnected;
private Label label2;
private Label TXTMachId;
private ListView LISTThreadStatus;
private ColumnHeader columnHeader1;
private ColumnHeader columnHeader2;
private ToolStripMenuItem goBackToStandardModeToolStripMenuItem;
private ToolStripSeparator toolStripSeparator;
private ToolStripMenuItem resetSpindleHoursToolStripMenuItem;
}
}
+103 -29
View File
@@ -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);
}
}
}
+14 -9
View File
@@ -34,15 +34,7 @@
<ApplicationIcon>Resources\CMS_Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
<HintPath>..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.dll</HintPath>
</Reference>
<Reference Include="MetroFramework.Design, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
<HintPath>..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Design.dll</HintPath>
</Reference>
<Reference Include="MetroFramework.Fonts, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
<HintPath>..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Fonts.dll</HintPath>
</Reference>
<Reference Include="CMS_CORE_Library, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
@@ -63,6 +55,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PasswordForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PasswordForm.Designer.cs">
<DependentUpon>PasswordForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -87,6 +85,9 @@
<None Include="readme.md" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="PasswordForm.resx">
<DependentUpon>PasswordForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -107,6 +108,10 @@
<Project>{631375DD-06D3-49BB-8130-D9DDB34C429D}</Project>
<Name>Step.Model</Name>
</ProjectReference>
<ProjectReference Include="..\Step.NC\Step.NC.csproj">
<Project>{b2366b08-96bd-4f6b-b748-b45089b87a14}</Project>
<Name>Step.NC</Name>
</ProjectReference>
<ProjectReference Include="..\Step.Utils\Step.Utils.csproj">
<Project>{cbeb631b-abfa-4042-9779-c0060b0dfefe}</Project>
<Name>Step.Utils</Name>
+1 -15
View File
@@ -28,18 +28,6 @@
/// </summary>
private void InitializeComponent()
{
this.metroProgressSpinner = new MetroFramework.Controls.MetroProgressSpinner();
this.statusLabel = new MetroFramework.Controls.MetroLabel();
this.SuspendLayout();
//
// metroProgressSpinner
//
this.metroProgressSpinner.Location = new System.Drawing.Point(120, 224);
this.metroProgressSpinner.Maximum = 100;
this.metroProgressSpinner.Name = "metroProgressSpinner";
this.metroProgressSpinner.Size = new System.Drawing.Size(110, 110);
this.metroProgressSpinner.TabIndex = 0;
this.metroProgressSpinner.UseSelectable = true;
//
// statusLabel
//
@@ -57,7 +45,6 @@
this.AutoSize = true;
this.BackColor = System.Drawing.Color.Black;
this.Controls.Add(this.statusLabel);
this.Controls.Add(this.metroProgressSpinner);
this.Name = "OpeningLayer";
this.Size = new System.Drawing.Size(350, 565);
this.Load += new System.EventHandler(this.OpeningLayer_Load);
@@ -68,7 +55,6 @@
#endregion
private MetroFramework.Controls.MetroProgressSpinner metroProgressSpinner;
private MetroFramework.Controls.MetroLabel statusLabel;
private System.Windows.Forms.Label statusLabel;
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ namespace Step.UI.Views
{
for (int i = 0; i <= 100; i++)
{
metroProgressSpinner.Value = i;
//metroProgressSpinner.Value = i;
if (i == 100)
i = 0;
+218
View File
@@ -0,0 +1,218 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Step.Utils
{
public static class CandiesController
{
private const String BASE36 = "4K6IJZL1M27PQRSNOVWXTU80FGH39ABCDEY5";
private const String BASE10 = "0431786295";
private const String KEY_NAME = "HKEY_LOCAL_MACHINE\\SOFTWARE\\CMS\\ACTIVE";
private const String KEY_VALUE_NAME = "cil";
private const int BASE_TIME = 730119; // 1/1/2000
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region PUBLIC_METHODS
// Decodifica password esportando i dati. Ereditata da CMS-Control
public static bool PasswordDecode(String Password, out int Matricola, out int Command, out long Parameter)
{
String szVal;
int nChk = 0;
Matricola = 0;
Command = 0;
Parameter = 0;
try
{
szVal = AlgoritmoService_Back(Password).ToString();
for (int i = 0; i <= szVal.Length - 1 - 1; i++)
{
nChk += (int)char.GetNumericValue(szVal[i]);
}
//inserita password con checksum errato
if (szVal.Last() != nChk.ToString().Last())
return false;
Matricola = Int16.Parse(szVal.Substring(1, 5));
Command = Int16.Parse(szVal.Substring(0, 1));
Parameter = long.Parse(szVal.Substring(6, szVal.Length - 6 - 1));
}
catch (Exception e)
{
return false;
}
return true;
}
// Lettura della licenza da registro. Ereditata da CMS-Control
public static bool getPCLincense(out int Matricola, out long Parameter)
{
string szLicReg_X = String.Empty;
int nLicReg_X = 0;
Matricola = 0;
Parameter = 0;
//Leggo nel Registro
Licenza_Registry_RW(false, ref szLicReg_X);
nLicReg_X = Int32.Parse(szLicReg_X);
return getDataFromLincense(nLicReg_X, out Matricola, out Parameter);
}
// Scrittura della licenza nel registro. Ereditata da CMS-Control
public static void setPCLincense(int Matricola, long Parameter)
{
int nLic;
int days;
if (Parameter > BASE_TIME)
days = (int) (Parameter - BASE_TIME);
else if (Parameter > Int32.MaxValue)
days = Int32.MaxValue;
else
days = 0;
nLic = (Matricola << 16) + days;
string Licenza = AlgoritmoLicence(nLic);
Licenza_Registry_RW(true, ref Licenza);
}
public static bool getDataFromLincense(int Lincence, out int Matricola,out long Parameter)
{
Matricola = 0;
Parameter = 0;
if (Lincence == 0)
return false;
long szLic = AlgoritmoLicence_Back(Lincence.ToString());
Parameter = szLic & 0xFFFF;
Matricola = (int) ((szLic >> 16) & 0xFFFF);
if (Matricola > 0)
return true;
else
return false;
}
#endregion
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region PRIVATE_METHODS
private static long AlgoritmoService_Back(String val)
{
//Base36ToDec
long lVal = 0;
int ChrPos;
const int BASE = 36;
val = val.ToUpper();
while (val.Length > 0)
{
lVal = lVal * BASE;
ChrPos = BASE36.IndexOf(Left(val, 1));
if (ChrPos >= 0)
lVal = lVal + ChrPos;
val = Mid(val, 2);
}
return lVal;
}
private static long AlgoritmoLicence_Back(String val)
{
long lVal = 0;
int ChrPos;
const int BASE = 10;
val = val.ToUpper();
while (val.Length > 0)
{
lVal = lVal * BASE;
ChrPos = BASE10.IndexOf(Left(val, 1));
if (ChrPos >= 0)
lVal = lVal + ChrPos;
val = Mid(val, 2);
}
return lVal;
}
private static string AlgoritmoLicence(int lVal)
{
String sVal = "";
while(lVal >= 10)
{
sVal = sVal + AlgoritmoLicence(lVal/10);
lVal = lVal - 10 * (lVal/10);
}
sVal = sVal + Mid(BASE10, lVal + 1, 1);
return sVal;
}
private static string Left(string value, int size)
{
if (string.IsNullOrEmpty(value))
return value;
size = (size >= value.Length ? value.Length : size);
string newValue = value.Substring(0, size);
return newValue;
}
private static string Mid(string value, int index)
{
if (string.IsNullOrEmpty(value))
return value;
index = index - 1;
if (index >= value.Length)
return "";
string newValue = value.Substring(index);
return newValue;
}
private static string Mid(string value, int index,int lenght)
{
value = Mid(value, index);
if (lenght <= value.Length)
value = value.Substring(0, lenght);
return value;
}
private static void Licenza_Registry_RW(bool bWrite, ref string Licenza)
{
Object objLicence;
//KEY_NAME
if (bWrite)
Registry.SetValue(KEY_NAME, KEY_VALUE_NAME, Licenza, RegistryValueKind.String);
objLicence = Registry.GetValue(KEY_NAME, KEY_VALUE_NAME,0);
if (objLicence == null) objLicence = 0;
Licenza = objLicence.ToString();
}
#endregion
}
}
+1
View File
@@ -68,6 +68,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CandiesController.cs" />
<Compile Include="ExceptionManager.cs" />
<Compile Include="LanguageController.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />