Fix tool manager Osai update functions
Fix UI
This commit is contained in:
@@ -42,7 +42,7 @@ namespace Step.UI
|
||||
|
||||
MessageServices.Current.Subscribe(SHOW_MSG_UI, (a, b) =>
|
||||
{
|
||||
this.Invoke((MethodInvoker)delegate () { this.Focus(); MessageBox.Show(a.ToString()); });
|
||||
Invoke((MethodInvoker)delegate () { Focus(); MessageBox.Show(a.ToString()); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,122 +139,92 @@ namespace Step.UI
|
||||
|
||||
private void InitializeMessageListeners()
|
||||
{
|
||||
MVVMListeners = new List<RegistrationInfo>();
|
||||
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_MESSAGE, (a, b) =>
|
||||
MVVMListeners = new List<RegistrationInfo>
|
||||
{
|
||||
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;
|
||||
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
// Open BalloonTip with data
|
||||
StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon)message.ErrorLevel);
|
||||
|
||||
//ShowMessage on UI
|
||||
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message;
|
||||
});
|
||||
}));
|
||||
|
||||
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) =>
|
||||
{
|
||||
bool newNcStatus = (bool)a;
|
||||
|
||||
if (ncStatus != newNcStatus)
|
||||
});
|
||||
}),
|
||||
// NC status handler
|
||||
MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) =>
|
||||
{
|
||||
ncStatus = newNcStatus;
|
||||
string title = "NC not connected";
|
||||
string message = "Check NC connection";
|
||||
ToolTipIcon toolTipIcon = ToolTipIcon.Error;
|
||||
bool newNcStatus = (bool)a;
|
||||
|
||||
if (ncStatus == true)
|
||||
if (ncStatus != newNcStatus)
|
||||
{
|
||||
title = "Nc connection established";
|
||||
message = "Comunication started";
|
||||
toolTipIcon = ToolTipIcon.Info;
|
||||
}
|
||||
ncStatus = newNcStatus;
|
||||
string title = "NC not connected";
|
||||
string message = "Check NC connection";
|
||||
ToolTipIcon toolTipIcon = ToolTipIcon.Error;
|
||||
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
if (ncStatus)
|
||||
{
|
||||
StepNotifyIcon.ShowBalloonTip(1000, title, message, toolTipIcon);
|
||||
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + title;
|
||||
});
|
||||
}
|
||||
title = "Nc connection established";
|
||||
message = "Comunication started";
|
||||
toolTipIcon = ToolTipIcon.Info;
|
||||
}
|
||||
|
||||
if (ncStatus)
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
StepNotifyIcon.Icon = Properties.Resources.Step_Icon;
|
||||
});
|
||||
else
|
||||
{
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
TXTName.Text = "";
|
||||
TXTNcSerial.Text = "";
|
||||
TXTCMSMach.Text = "";
|
||||
TXTSftVers.Text = "";
|
||||
TXTNCProc.Text = "";
|
||||
TXTTime.Text = "";
|
||||
TXTLang.Text = "";
|
||||
StepNotifyIcon.Icon = Properties.Resources.Step_Disconnected;
|
||||
// Show balloon with new status
|
||||
StepNotifyIcon.ShowBalloonTip(1000, title, message, toolTipIcon);
|
||||
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + title;
|
||||
});
|
||||
}
|
||||
|
||||
//Other type
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
CHNcConnected.Checked = ncStatus;
|
||||
});
|
||||
}));
|
||||
if (ncStatus)
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
StepNotifyIcon.Icon = Properties.Resources.Step_Icon;
|
||||
});
|
||||
|
||||
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_THREADS_STATUS, (a, b) =>
|
||||
{
|
||||
//Other type
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
if (!isUpdatingThreads)
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
isUpdatingThreads = true;
|
||||
Dictionary<String, String> Threads = new Dictionary<String, String>((Dictionary<String, String>)a);
|
||||
CHNcConnected.Checked = ncStatus;
|
||||
});
|
||||
}),
|
||||
// Threads status handler
|
||||
MessageServices.Current.Subscribe(SEND_THREADS_STATUS, (a, b) =>
|
||||
{
|
||||
//Other type
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
if (!isUpdatingThreads)
|
||||
{
|
||||
isUpdatingThreads = true;
|
||||
Dictionary<String, String> Threads = new Dictionary<String, String>((Dictionary<String, String>)a);
|
||||
//Begin the update
|
||||
LISTThreadStatus.BeginUpdate();
|
||||
//clear the List
|
||||
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;
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_GENERIC_DATA, (a, b) =>
|
||||
{
|
||||
DTONcGenericDataModel data = (DTONcGenericDataModel)a;
|
||||
|
||||
//Other type
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
TXTName.Text = data.NcModel;
|
||||
TXTNcSerial.Text = data.SerialNumber;
|
||||
TXTCMSMach.Text = data.CmsMachineIdNumber;
|
||||
TXTSftVers.Text = data.NcSoftwareVersion;
|
||||
TXTNCProc.Text = data.ProcessNumber.ToString();
|
||||
TXTLang.Text = data.Language;
|
||||
TXTTime.Text = data.DateTime.ToShortDateString() + " " + data.DateTime.ToShortTimeString();
|
||||
});
|
||||
}));
|
||||
isUpdatingThreads = false;
|
||||
}
|
||||
});
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user