diff --git a/02_Windows_App/Perun_v1/00_Config/App.config b/02_Windows_App/Perun_v1/00_Config/App.config
index 7aeb785..2c593bb 100644
--- a/02_Windows_App/Perun_v1/00_Config/App.config
+++ b/02_Windows_App/Perun_v1/00_Config/App.config
@@ -35,7 +35,13 @@
False
-
+
+ 1
+
+
+ 1
+
+
3306
diff --git a/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs b/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs
index c2640a1..6955a34 100644
--- a/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs
+++ b/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs
@@ -180,36 +180,36 @@ public class DatabaseController
switch (Int32.Parse(TCPFrameType))
{
case 1:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Connected players: " + TCPFrame.payload["c_players"], 1,0,"1");
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "Connected players: " + TCPFrame.payload["c_players"], 1,0,"1");
break;
case 2:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Mission: \"" + TCPFrame.payload["mission"]["name"]+"\""+ ", time:" + TCPFrame.payload["mission"]["modeltime"], 1, 0, "2");
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "Mission: \"" + TCPFrame.payload["mission"]["name"]+"\""+ ", time:" + TCPFrame.payload["mission"]["modeltime"], 1, 0, "2");
break;
case 3:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Slots data updated", 1, 0, "3");
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "Slots data updated", 1, 0, "3");
break;
case 50:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Player's \""+ TCPFrame.payload.player + "\" chat message saved", 1, 0, "50");
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "Player's \""+ TCPFrame.payload.player + "\" chat message saved", 1, 0, "50");
break;
case 51:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Game event: \""+ TCPFrame.payload.log_content +"\"", 1, 0, "51");
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "Game event: \""+ TCPFrame.payload.log_content +"\"", 1, 0, "51");
break;
case 52:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Player's \""+ TCPFrame.payload.stat_name + "\" stats saved", 1, 0, "52");
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "Player's \""+ TCPFrame.payload.stat_name + "\" stats saved", 1, 0, "52");
break;
case 53:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Player \""+ TCPFrame.payload.login_name + "\" logged in", 1, 0, "53");
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "Player \""+ TCPFrame.payload.login_name + "\" logged in", 1, 0, "53");
break;
case 100:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "SRS data send", 1,0,"100");
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "SRS data send", 1,0,"100");
break;
case 101:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "LotATC data send", 1,0,"101");
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "LotATC data send", 1,0,"101");
break;
case -1:
break;
default:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Data send", 1,0, TCPFrameType);
+ PerunHelper.LogDebug(ref Globals.AppLogHistory, "Data send", 1,0, TCPFrameType);
break;
}
@@ -218,7 +218,7 @@ public class DatabaseController
{
// General exception found
Console.WriteLine(a_ex.ToString());
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - error: " + a_ex.Message,1,1, TCPFrameType);
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR MySQL - error: " + a_ex.Message,1,1, TCPFrameType);
Globals.ErrorsGame++;
DatabaseStatus = false;
ReturnValue = 0;
@@ -229,25 +229,25 @@ public class DatabaseController
switch (m_ex.Number)
{
case 1042: // Unable to connect to any of the specified MySQL hosts (Check Server,Port)
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - unable to connect, error: " + m_ex.Message,1,1, TCPFrameType);
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR MySQL - unable to connect, error: " + m_ex.Message,1,1, TCPFrameType);
DatabaseStatus = false;
ReturnValue = 0;
break;
case 0: // Access denied (Check DB name,username,password)
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - access denied, error: " + m_ex.Message,1,1, TCPFrameType);
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR MySQL - access denied, error: " + m_ex.Message,1,1, TCPFrameType);
DatabaseStatus = false;
ReturnValue = 0;
break;
case 1064: // Incorrect query
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - query: " + SQLQueryTxt, 1, 1, TCPFrameType);
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - error: " + m_ex.Message, 1, 1, TCPFrameType);
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR MySQL - query: " + SQLQueryTxt, 1, 1, TCPFrameType);
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR MySQL - error: " + m_ex.Message, 1, 1, TCPFrameType);
DatabaseStatus = true; // True as connection is not broken
ReturnValue = 1; // Return a value to remove this query from quae
break;
default:
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - error id: " + m_ex.Number,1,1, TCPFrameType);
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - query: " + SQLQueryTxt, 1, 1, TCPFrameType);
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - error: " + m_ex.Message,1,1, TCPFrameType);
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR MySQL - error id: " + m_ex.Number,1,1, TCPFrameType);
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR MySQL - query: " + SQLQueryTxt, 1, 1, TCPFrameType);
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR MySQL - error: " + m_ex.Message,1,1, TCPFrameType);
DatabaseStatus = false;
ReturnValue = 0;
break;
@@ -260,7 +260,7 @@ public class DatabaseController
}
catch (ArgumentException x_ex)
{
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - unable to connect, error: " + x_ex.Message,1,1, TCPFrameType);
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR MySQL - unable to connect, error: " + x_ex.Message,1,1, TCPFrameType);
ReturnValue = 0;
Globals.ErrorsGame++;
}
diff --git a/02_Windows_App/Perun_v1/01_Classes/LogController.cs b/02_Windows_App/Perun_v1/01_Classes/LogController.cs
index 98b2a5a..fc8ca61 100644
--- a/02_Windows_App/Perun_v1/01_Classes/LogController.cs
+++ b/02_Windows_App/Perun_v1/01_Classes/LogController.cs
@@ -3,9 +3,47 @@ using System.IO;
class LogController
{
- // TBD - done via https://stackoverflow.com/questions/20185015/how-to-write-log-file-in-c
- public static void WriteLog(string strLog)
+ private static LogController _instance = new LogController();
+
+ public static LogController instance
{
+ get
+ {
+ return _instance;
+ }
+ }
+
+ public int level
+ {
+ get;
+ set;
+ }
+
+ public void LogError(string strLog)
+ {
+ this.WriteLog(0, strLog);
+ }
+
+ public void LogWarning(string strLog)
+ {
+ this.WriteLog(1, strLog);
+ }
+
+ public void LogInfo(string strLog)
+ {
+ this.WriteLog(2, strLog);
+ }
+
+ public void LogDebug(string strLog)
+ {
+ this.WriteLog(3, strLog);
+ }
+
+ // TBD - done via https://stackoverflow.com/questions/20185015/how-to-write-log-file-in-c
+ public void WriteLog(int logLevel, string strLog)
+ {
+ if (logLevel > this.level) return;
+
StreamWriter LogStreamWriter;
FileStream LogFileStream = null;
DirectoryInfo LogDirectoryInfo = null;
diff --git a/02_Windows_App/Perun_v1/01_Classes/PerunHelper.cs b/02_Windows_App/Perun_v1/01_Classes/PerunHelper.cs
index 1f96346..9ec1bfa 100644
--- a/02_Windows_App/Perun_v1/01_Classes/PerunHelper.cs
+++ b/02_Windows_App/Perun_v1/01_Classes/PerunHelper.cs
@@ -5,7 +5,27 @@ using System.Text.RegularExpressions;
internal class PerunHelper
{
- public static void AddLog(ref string[] arrLogHistory, string strEntryToAdd, int intDirection = 0, int intMarker = 0, string strType = " ", bool bSkipGui = false)
+ public static void LogError(ref string[] arrLogHistory, string strEntryToAdd, int intDirection = 0, int intMarker = 0, string strType = " ", bool bSkipGui = false)
+ {
+ AddLog(0, ref arrLogHistory, strEntryToAdd, intDirection, intMarker, strType, bSkipGui);
+ }
+
+ public static void LogWarning(ref string[] arrLogHistory, string strEntryToAdd, int intDirection = 0, int intMarker = 0, string strType = " ", bool bSkipGui = false)
+ {
+ AddLog(1, ref arrLogHistory, strEntryToAdd, intDirection, intMarker, strType, bSkipGui);
+ }
+
+ public static void LogInfo(ref string[] arrLogHistory, string strEntryToAdd, int intDirection = 0, int intMarker = 0, string strType = " ", bool bSkipGui = false)
+ {
+ AddLog(2, ref arrLogHistory, strEntryToAdd, intDirection, intMarker, strType, bSkipGui);
+ }
+
+ public static void LogDebug(ref string[] arrLogHistory, string strEntryToAdd, int intDirection = 0, int intMarker = 0, string strType = " ", bool bSkipGui = false)
+ {
+ AddLog(3, ref arrLogHistory, strEntryToAdd, intDirection, intMarker, strType, bSkipGui);
+ }
+
+ private static void AddLog(int logLevel, ref string[] arrLogHistory, string strEntryToAdd, int intDirection = 0, int intMarker = 0, string strType = " ", bool bSkipGui = false)
{
// Declare values
string LogDirection;
@@ -48,7 +68,7 @@ internal class PerunHelper
Globals.AppUpdateGUI = true;
}
// Add the entry to log file
- LogController.WriteLog(DateTime.Now.ToString("yyyy-MM-dd ") + " " + DateTime.Now.ToString("HH:mm:ss") + " | Instance: "+ Globals.AppInstanceID + " | " + LogMarker + " | "+ LogDirection + " | "+ strType + " | " + strEntryToAdd);
+ LogController.instance.WriteLog(logLevel, DateTime.Now.ToString("yyyy-MM-dd ") + " " + DateTime.Now.ToString("HH:mm:ss") + " | Instance: "+ Globals.AppInstanceID + " | " + LogMarker + " | "+ LogDirection + " | "+ strType + " | " + strEntryToAdd);
}
public static string GetAppVersion(string strBeginning)
@@ -72,7 +92,7 @@ internal class PerunHelper
if(VersionApp != Globals.VersionDatabase)
{
// Incorrect database version
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR Incorrect database revision : "+ Globals.VersionDatabase, 1, 1, "?");
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR Incorrect database revision : "+ Globals.VersionDatabase, 1, 1, "?");
Globals.ErrorsDatabase++;
ReturnValue = 0;
}
@@ -84,7 +104,7 @@ internal class PerunHelper
if (VersionApp != Globals.VersionDCSHook)
{
// Incorrect dcs script version
- PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR Incorrect DCS hook revision : " + Globals.VersionDCSHook, 2, 1, "?");
+ PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR Incorrect DCS hook revision : " + Globals.VersionDCSHook, 2, 1, "?");
Globals.ErrorsGame++;
ReturnValue = 0;
}
diff --git a/02_Windows_App/Perun_v1/01_Classes/TCPController.cs b/02_Windows_App/Perun_v1/01_Classes/TCPController.cs
index a92dfb6..a64cde3 100644
--- a/02_Windows_App/Perun_v1/01_Classes/TCPController.cs
+++ b/02_Windows_App/Perun_v1/01_Classes/TCPController.cs
@@ -126,7 +126,7 @@ public class TCPController
if (Int32.Parse(strRawTCPFrameType) != 0)
{
// Add to mySQL send buffer (find first empty slot)
- PerunHelper.AddLog(ref arrGUILogHistory, "Packet received" , 2,0, strRawTCPFrameType,true);
+ PerunHelper.LogDebug(ref arrGUILogHistory, "Packet received" , 2,0, strRawTCPFrameType,true);
bool AddedDataToBuffer = false;
for (int i = 0; i < arrMySQLSendBuffer.Length - 1; i++)
{
@@ -139,12 +139,12 @@ public class TCPController
}
if (!AddedDataToBuffer)
{
- PerunHelper.AddLog(ref arrGUILogHistory, "ERROR package was dropped", 1, 1, strRawTCPFrameType);
+ PerunHelper.LogError(ref arrGUILogHistory, "ERROR package was dropped", 1, 1, strRawTCPFrameType);
}
} else
{
// Keep alive
- PerunHelper.AddLog(ref arrGUILogHistory, "Keep-alive received", 2,0,"0",true);
+ PerunHelper.LogDebug(ref arrGUILogHistory, "Keep-alive received", 2,0,"0",true);
}
}
else
@@ -156,7 +156,7 @@ public class TCPController
{
Globals.ErrorsGame++;
Console.WriteLine(e.ToString());
- PerunHelper.AddLog(ref arrGUILogHistory, "ERROR while message parsing , error: " + e.Message,2,1,"?");
+ PerunHelper.LogError(ref arrGUILogHistory, "ERROR while message parsing , error: " + e.Message,2,1,"?");
bTCPConnectionOnline = false;
}
@@ -168,7 +168,7 @@ public class TCPController
catch (SocketException e)
{
Console.WriteLine(e.ToString());
- PerunHelper.AddLog(ref arrGUILogHistory, "TCP ERROR cannot check connection, error: " + e.Message,2,1,"?");
+ PerunHelper.LogError(ref arrGUILogHistory, "TCP ERROR cannot check connection, error: " + e.Message,2,1,"?");
}
}
@@ -182,7 +182,7 @@ public class TCPController
{
Globals.ErrorsGame++;
Console.WriteLine(e.ToString());
- PerunHelper.AddLog(ref arrGUILogHistory, "TCP error - connection closed or port in use, error: " + e.Message,1,1,"?");
+ PerunHelper.LogError(ref arrGUILogHistory, "TCP error - connection closed or port in use, error: " + e.Message,1,1,"?");
bTCPConnectionOnline = false;
}
diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs
index eb8535b..f305c27 100644
--- a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs
+++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs
@@ -34,6 +34,9 @@
this.con_Button_Listen_ON = new System.Windows.Forms.Button();
this.con_Button_Listen_OFF = new System.Windows.Forms.Button();
this.con_GroupBox_1 = new System.Windows.Forms.GroupBox();
+ this.label15 = new System.Windows.Forms.Label();
+ this.cboLogLevel = new System.Windows.Forms.ComboBox();
+ this.con_Button_Add_Marker = new System.Windows.Forms.Button();
this.tim_GUI = new System.Windows.Forms.Timer(this.components);
this.con_GroupBox_2 = new System.Windows.Forms.GroupBox();
this.label6 = new System.Windows.Forms.Label();
@@ -76,8 +79,8 @@
this.con_img_srs = new System.Windows.Forms.PictureBox();
this.con_img_dcs = new System.Windows.Forms.PictureBox();
this.con_img_db = new System.Windows.Forms.PictureBox();
- this.con_Button_Add_Marker = new System.Windows.Forms.Button();
this.TIM_Autostart = new System.Windows.Forms.Timer(this.components);
+ this.chkCloseToTray = new System.Windows.Forms.CheckBox();
this.con_GroupBox_1.SuspendLayout();
this.con_GroupBox_2.SuspendLayout();
this.con_GroupBox_3.SuspendLayout();
@@ -95,7 +98,7 @@
this.con_List_Received.FormattingEnabled = true;
this.con_List_Received.Items.AddRange(new object[] {
"Not connected"});
- this.con_List_Received.Location = new System.Drawing.Point(11, 19);
+ this.con_List_Received.Location = new System.Drawing.Point(8, 44);
this.con_List_Received.Name = "con_List_Received";
this.con_List_Received.Size = new System.Drawing.Size(307, 134);
this.con_List_Received.TabIndex = 0;
@@ -123,14 +126,56 @@
//
// con_GroupBox_1
//
+ this.con_GroupBox_1.Controls.Add(this.label15);
+ this.con_GroupBox_1.Controls.Add(this.cboLogLevel);
this.con_GroupBox_1.Controls.Add(this.con_List_Received);
- this.con_GroupBox_1.Location = new System.Drawing.Point(12, 434);
+ this.con_GroupBox_1.Controls.Add(this.con_Button_Add_Marker);
+ this.con_GroupBox_1.Location = new System.Drawing.Point(12, 412);
this.con_GroupBox_1.Name = "con_GroupBox_1";
- this.con_GroupBox_1.Size = new System.Drawing.Size(324, 162);
+ this.con_GroupBox_1.Size = new System.Drawing.Size(324, 184);
this.con_GroupBox_1.TabIndex = 4;
this.con_GroupBox_1.TabStop = false;
this.con_GroupBox_1.Text = "Data log";
//
+ // label15
+ //
+ this.label15.AutoSize = true;
+ this.label15.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label15.Location = new System.Drawing.Point(9, 21);
+ this.label15.Name = "label15";
+ this.label15.Size = new System.Drawing.Size(50, 13);
+ this.label15.TabIndex = 22;
+ this.label15.Text = "Log level";
+ //
+ // cboLogLevel
+ //
+ this.cboLogLevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cboLogLevel.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F);
+ this.cboLogLevel.FormattingEnabled = true;
+ this.cboLogLevel.Items.AddRange(new object[] {
+ "Error",
+ "Warning",
+ "Info",
+ "Debug"});
+ this.cboLogLevel.Location = new System.Drawing.Point(65, 18);
+ this.cboLogLevel.Name = "cboLogLevel";
+ this.cboLogLevel.Size = new System.Drawing.Size(102, 20);
+ this.cboLogLevel.TabIndex = 23;
+ this.cboLogLevel.SelectedIndexChanged += new System.EventHandler(this.cboLogLevel_SelectedIndexChanged);
+ //
+ // con_Button_Add_Marker
+ //
+ this.con_Button_Add_Marker.Enabled = false;
+ this.con_Button_Add_Marker.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.con_Button_Add_Marker.Location = new System.Drawing.Point(229, 17);
+ this.con_Button_Add_Marker.Name = "con_Button_Add_Marker";
+ this.con_Button_Add_Marker.Size = new System.Drawing.Size(86, 20);
+ this.con_Button_Add_Marker.TabIndex = 21;
+ this.con_Button_Add_Marker.Text = "Add log marker";
+ this.con_Button_Add_Marker.UseVisualStyleBackColor = true;
+ this.con_Button_Add_Marker.Click += new System.EventHandler(this.con_Button_Add_Marker_Click);
+ //
// tim_GUI
//
this.tim_GUI.Interval = 200;
@@ -394,7 +439,7 @@
this.label9.AutoSize = true;
this.label9.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label9.Location = new System.Drawing.Point(21, 396);
+ this.label9.Location = new System.Drawing.Point(20, 393);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(61, 13);
this.label9.TabIndex = 1;
@@ -405,7 +450,7 @@
this.label10.AutoSize = true;
this.label10.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label10.Location = new System.Drawing.Point(117, 396);
+ this.label10.Location = new System.Drawing.Point(88, 393);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(39, 13);
this.label10.TabIndex = 14;
@@ -416,7 +461,7 @@
this.label11.AutoSize = true;
this.label11.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label11.Location = new System.Drawing.Point(205, 396);
+ this.label11.Location = new System.Drawing.Point(149, 393);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(32, 13);
this.label11.TabIndex = 15;
@@ -427,7 +472,7 @@
this.label12.AutoSize = true;
this.label12.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label12.Location = new System.Drawing.Point(282, 396);
+ this.label12.Location = new System.Drawing.Point(198, 393);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(49, 13);
this.label12.TabIndex = 16;
@@ -437,9 +482,9 @@
//
this.con_Button_Reset_Flags.Enabled = false;
this.con_Button_Reset_Flags.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.con_Button_Reset_Flags.Location = new System.Drawing.Point(224, 414);
+ this.con_Button_Reset_Flags.Location = new System.Drawing.Point(266, 362);
this.con_Button_Reset_Flags.Name = "con_Button_Reset_Flags";
- this.con_Button_Reset_Flags.Size = new System.Drawing.Size(114, 20);
+ this.con_Button_Reset_Flags.Size = new System.Drawing.Size(61, 36);
this.con_Button_Reset_Flags.TabIndex = 17;
this.con_Button_Reset_Flags.Text = "Reset error flags";
this.con_Button_Reset_Flags.UseVisualStyleBackColor = true;
@@ -478,7 +523,7 @@
//
// con_img_lotATC
//
- this.con_img_lotATC.Location = new System.Drawing.Point(292, 362);
+ this.con_img_lotATC.Location = new System.Drawing.Point(207, 362);
this.con_img_lotATC.Name = "con_img_lotATC";
this.con_img_lotATC.Size = new System.Drawing.Size(29, 28);
this.con_img_lotATC.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -487,7 +532,7 @@
//
// con_img_srs
//
- this.con_img_srs.Location = new System.Drawing.Point(207, 362);
+ this.con_img_srs.Location = new System.Drawing.Point(150, 362);
this.con_img_srs.Name = "con_img_srs";
this.con_img_srs.Size = new System.Drawing.Size(29, 28);
this.con_img_srs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -496,7 +541,7 @@
//
// con_img_dcs
//
- this.con_img_dcs.Location = new System.Drawing.Point(122, 362);
+ this.con_img_dcs.Location = new System.Drawing.Point(93, 362);
this.con_img_dcs.Name = "con_img_dcs";
this.con_img_dcs.Size = new System.Drawing.Size(29, 28);
this.con_img_dcs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -506,39 +551,42 @@
// con_img_db
//
this.con_img_db.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
- this.con_img_db.Location = new System.Drawing.Point(37, 362);
+ this.con_img_db.Location = new System.Drawing.Point(36, 362);
this.con_img_db.Name = "con_img_db";
this.con_img_db.Size = new System.Drawing.Size(29, 28);
this.con_img_db.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.con_img_db.TabIndex = 10;
this.con_img_db.TabStop = false;
//
- // con_Button_Add_Marker
- //
- this.con_Button_Add_Marker.Enabled = false;
- this.con_Button_Add_Marker.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.con_Button_Add_Marker.Location = new System.Drawing.Point(12, 414);
- this.con_Button_Add_Marker.Name = "con_Button_Add_Marker";
- this.con_Button_Add_Marker.Size = new System.Drawing.Size(114, 20);
- this.con_Button_Add_Marker.TabIndex = 21;
- this.con_Button_Add_Marker.Text = "Add log marker";
- this.con_Button_Add_Marker.UseVisualStyleBackColor = true;
- this.con_Button_Add_Marker.Click += new System.EventHandler(this.con_Button_Add_Marker_Click);
- //
// TIM_Autostart
//
this.TIM_Autostart.Interval = 500;
+ this.TIM_Autostart.Tick += new System.EventHandler(this.TIM_Autostart_Tick);
+ //
+ // chkCloseToTray
+ //
+ this.chkCloseToTray.AutoSize = true;
+ this.chkCloseToTray.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
+ this.chkCloseToTray.Checked = true;
+ this.chkCloseToTray.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.chkCloseToTray.Location = new System.Drawing.Point(236, 7);
+ this.chkCloseToTray.Name = "chkCloseToTray";
+ this.chkCloseToTray.Size = new System.Drawing.Size(98, 17);
+ this.chkCloseToTray.TabIndex = 24;
+ this.chkCloseToTray.Text = "Minimize to tray";
+ this.chkCloseToTray.UseVisualStyleBackColor = true;
+ this.chkCloseToTray.Validated += new System.EventHandler(this.chkCloseToTray_Validated);
//
// form_Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(349, 653);
- this.Controls.Add(this.con_Button_Add_Marker);
+ this.ClientSize = new System.Drawing.Size(346, 652);
+ this.Controls.Add(this.chkCloseToTray);
+ this.Controls.Add(this.con_Button_Reset_Flags);
this.Controls.Add(this.label14);
this.Controls.Add(this.label13);
this.Controls.Add(this.con_img_logo);
- this.Controls.Add(this.con_Button_Reset_Flags);
this.Controls.Add(this.label12);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
@@ -565,6 +613,7 @@
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.form_Main_FormClosing);
this.Load += new System.EventHandler(this.form_Main_Load);
this.con_GroupBox_1.ResumeLayout(false);
+ this.con_GroupBox_1.PerformLayout();
this.con_GroupBox_2.ResumeLayout(false);
this.con_GroupBox_2.PerformLayout();
this.con_GroupBox_3.ResumeLayout(false);
@@ -578,10 +627,7 @@
((System.ComponentModel.ISupportInitialize)(this.con_img_db)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
- // TIM_Autostart
- //
- this.TIM_Autostart.Tick += new System.EventHandler(this.TIM_Autostart_Tick);
- //
+
}
#endregion
@@ -634,6 +680,9 @@
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Button con_Button_Add_Marker;
private System.Windows.Forms.Timer TIM_Autostart;
+ private System.Windows.Forms.Label label15;
+ private System.Windows.Forms.ComboBox cboLogLevel;
+ private System.Windows.Forms.CheckBox chkCloseToTray;
}
}
diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs
index b0a4fed..64cbe1e 100644
--- a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs
+++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs
@@ -54,7 +54,7 @@ namespace Perun_v1
}
}
}
-
+
if (args.Length > 3)
{
// Get argument DCS SRS file path
@@ -90,7 +90,7 @@ namespace Perun_v1
if (args[5] != "-1")
{
TIM_Autostart.Enabled = true;
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Autostart parameter provided", 0, 1);
+ PerunHelper.LogInfo(ref Globals.AppLogHistory, "Autostart parameter provided", 0, 1);
}
}
}
@@ -124,6 +124,8 @@ namespace Perun_v1
con_check_3rd_srs.Checked = Properties.Settings.Default.OTHER_SRS_USE;
con_txt_dcs_server_port.Text = Properties.Settings.Default.DCS_Server_Port.ToString();
con_txt_dcs_instance.Text = Properties.Settings.Default.DCS_Instance.ToString();
+ cboLogLevel.SelectedIndex = Properties.Settings.Default.LOG_LEVEL;
+ chkCloseToTray.Checked = Properties.Settings.Default.CLOSE_TO_TRAY;
}
private void form_Main_SaveSettings()
@@ -142,6 +144,8 @@ namespace Perun_v1
Properties.Settings.Default.OTHER_SRS_USE = con_check_3rd_srs.Checked;
Properties.Settings.Default.DCS_Server_Port = Int32.Parse(con_txt_dcs_server_port.Text);
Properties.Settings.Default.DCS_Instance = Int32.Parse(con_txt_dcs_instance.Text);
+ Properties.Settings.Default.LOG_LEVEL = cboLogLevel.SelectedIndex;
+ Properties.Settings.Default.CLOSE_TO_TRAY = chkCloseToTray.Checked;
Properties.Settings.Default.Save();
}
@@ -165,6 +169,7 @@ namespace Perun_v1
con_check_3rd_srs.Enabled = false;
con_txt_dcs_server_port.Enabled = false;
con_txt_dcs_instance.Enabled = false;
+ cboLogLevel.Enabled = true;
}
private void form_Main_SetControlsToDisconnected()
@@ -186,6 +191,7 @@ namespace Perun_v1
con_check_3rd_srs.Enabled = true;
con_txt_dcs_server_port.Enabled = true;
con_txt_dcs_instance.Enabled = true;
+ cboLogLevel.Enabled = true;
}
@@ -212,7 +218,7 @@ namespace Perun_v1
DatabaseConnection.DatabaseConnectionString = "server=" + con_txt_mysql_server.Text + ";user=" + con_txt_mysql_username.Text + ";database=" + con_txt_mysql_database.Text + ";port=" + con_txt_mysql_port.Text + ";password=" + con_txt_mysql_password.Text;
// Start listening
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Opening connections", 0, 1);
+ PerunHelper.LogInfo(ref Globals.AppLogHistory, "Opening connections", 0, 1);
TCPServer.Create(Int32.Parse(con_txt_dcs_server_port.Text), ref Globals.AppLogHistory, ref DatabaseSendBuffer);
TCPServer.thrTCPListener = new Thread(TCPServer.StartListen);
TCPServer.thrTCPListener.Start();
@@ -233,7 +239,7 @@ namespace Perun_v1
{
// Stop listening
// Prepare GUI
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Closing connections", 0, 1);
+ PerunHelper.LogInfo(ref Globals.AppLogHistory, "Closing connections", 0, 1);
con_Button_Listen_OFF.Enabled = false;
Tim_GUI_Tick(null, null);
this.Refresh();
@@ -251,7 +257,7 @@ namespace Perun_v1
}
catch (Exception ex)
{
- PerunHelper.AddLog(ref Globals.AppLogHistory, "TCP ERROR, error: " + ex.Message, 2, 1, "?");
+ PerunHelper.LogError(ref Globals.AppLogHistory, "TCP ERROR, error: " + ex.Message, 2, 1, "?");
Console.WriteLine(ex.ToString());
}
@@ -269,7 +275,7 @@ namespace Perun_v1
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
// Display information about closed connections
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Connections closed", 0, 1);
+ PerunHelper.LogInfo(ref Globals.AppLogHistory, "Connections closed", 0, 1);
Tim_GUI_Tick(null, null);
// Set title bar
@@ -374,7 +380,13 @@ namespace Perun_v1
if (e.CloseReason == CloseReason.UserClosing && !AppCanClose)
{
e.Cancel = true;
- form_Main_SendToTray(); // Send app to system tray
+ if (Properties.Settings.Default.CLOSE_TO_TRAY)
+ {
+ form_Main_SendToTray(); // Send app to system tray
+ } else
+ {
+ con_Button_Quit_Click(sender, e);
+ }
}
}
@@ -558,12 +570,12 @@ namespace Perun_v1
ExtSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + ExtSRSJson + "'}";
ExtSRSUseDefault = false;
- PerunHelper.AddLog(ref Globals.AppLogHistory, "SRS data loaded", 3, 0, "100", true);
+ PerunHelper.LogInfo(ref Globals.AppLogHistory, "SRS data loaded", 3, 0, "100", true);
ExtSRSStatus = true;
}
catch (Exception exc_srs)
{
- PerunHelper.AddLog(ref Globals.AppLogHistory, "SRS data ERROR , error: " + exc_srs.Message, 3, 1, "100");
+ PerunHelper.LogError(ref Globals.AppLogHistory, "SRS data ERROR , error: " + exc_srs.Message, 3, 1, "100");
ExtSRSStatus = false;
Globals.ErrorsSRS++;
}
@@ -592,12 +604,12 @@ namespace Perun_v1
ExtLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + ExtLotATCJson + "'}";
ExtLotATCUseDefault = false;
- PerunHelper.AddLog(ref Globals.AppLogHistory, "LotATC data loaded", 3, 0, "101", true);
+ PerunHelper.LogInfo(ref Globals.AppLogHistory, "LotATC data loaded", 3, 0, "101", true);
ExtLotATCStatus = true;
}
catch (Exception exc_lotatc)
{
- PerunHelper.AddLog(ref Globals.AppLogHistory, "LotATC data ERROR, error: " + exc_lotatc.Message, 3, 1, "101");
+ PerunHelper.LogError(ref Globals.AppLogHistory, "LotATC data ERROR, error: " + exc_lotatc.Message, 3, 1, "101");
ExtLotATCStatus = false;
Globals.ErrorsLotATC++;
}
@@ -639,7 +651,7 @@ namespace Perun_v1
Globals.AppForceIconReload = true;
// Add information
- PerunHelper.AddLog(ref Globals.AppLogHistory, "Resetted error counter", 0, 1);
+ PerunHelper.LogInfo(ref Globals.AppLogHistory, "Resetted error counter", 0, 1);
}
else if (dialogResult == DialogResult.No)
{
@@ -651,7 +663,7 @@ namespace Perun_v1
private void con_Button_Add_Marker_Click(object sender, EventArgs e)
{
// Added user marker
- PerunHelper.AddLog(ref Globals.AppLogHistory, "User Marker", 0, 1);
+ PerunHelper.LogInfo(ref Globals.AppLogHistory, "User Marker", 0, 1);
}
private void TIM_Autostart_Tick(object sender, EventArgs e)
@@ -660,5 +672,15 @@ namespace Perun_v1
TIM_Autostart.Enabled = false; // Disable timer
con_Button_Listen_ON_Click(sender,e); // Simulate button click
}
+
+ private void cboLogLevel_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ LogController.instance.level = cboLogLevel.SelectedIndex;
+ }
+
+ private void chkCloseToTray_Validated(object sender, EventArgs e)
+ {
+ Properties.Settings.Default.CLOSE_TO_TRAY = chkCloseToTray.Checked;
+ }
}
}
diff --git a/02_Windows_App/Perun_v1/Properties/Settings.Designer.cs b/02_Windows_App/Perun_v1/Properties/Settings.Designer.cs
index 778c811..b9fbc32 100644
--- a/02_Windows_App/Perun_v1/Properties/Settings.Designer.cs
+++ b/02_Windows_App/Perun_v1/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace Perun_v1.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -154,5 +154,29 @@ namespace Perun_v1.Properties {
this["DCS_Instance"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("1")]
+ public int LOG_LEVEL {
+ get {
+ return ((int)(this["LOG_LEVEL"]));
+ }
+ set {
+ this["LOG_LEVEL"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool CLOSE_TO_TRAY {
+ get {
+ return ((bool)(this["CLOSE_TO_TRAY"]));
+ }
+ set {
+ this["CLOSE_TO_TRAY"] = value;
+ }
+ }
}
}
diff --git a/02_Windows_App/Perun_v1/Properties/Settings.settings b/02_Windows_App/Perun_v1/Properties/Settings.settings
index 37e5157..6b42f22 100644
--- a/02_Windows_App/Perun_v1/Properties/Settings.settings
+++ b/02_Windows_App/Perun_v1/Properties/Settings.settings
@@ -35,5 +35,11 @@
1
+
+ 1
+
+
+ True
+
\ No newline at end of file
diff --git a/02_Windows_App/Perun_v1/app.config b/02_Windows_App/Perun_v1/app.config
index 02494be..7c8c8c2 100644
--- a/02_Windows_App/Perun_v1/app.config
+++ b/02_Windows_App/Perun_v1/app.config
@@ -40,6 +40,12 @@
1
+
+ 1
+
+
+ True
+