Hello,
Is that possible to add a command argument to set UCCNC windows title (useful with multiple instances of UCCNC)
// ================================================================================================
// System Info v1.1
// ================================================================================================
string header = "UCCNC - ";
string version = AS3.Getfield(902);
string profile = AS3.Getfield(900);
string device = AS3.Getfield(907);
string filename = exec.Getgcodefilename(); // AS3.Getfield(895);
profile = profile.Replace(":", ": ");
if (filename == "-") filename = "";
header += version + " - " + profile + " - " + device + " - File: " + filename;
if (++counter == 20)
{
counter = 0;
if (exec.mainform.Text != header)
exec.mainform.Text = header;
}
// ================================================================================================
#Events
// ================================================================================================
int counter = 0;
// ================================================================================================
string[] args = Environment.GetCommandLineArgs();
if (args.Length > 0)
for (int i = 0; i < args.Length; i++)
if ((args[i].Trim().ToUpper() == "/TITLE") && (i < args.Length - 1))
exec.mainform.Text = args[i + 1];
string[] args = Environment.GetCommandLineArgs();
// test all commands (add it in a bat file then run it)
// C:\UCCNC\UCCNC.exe /TITLE "title 1" /SLEEP_FOR_TESTS 2000 /TITLE "title 2" /WINDOW_MAXIMIZED /POPUP_FOR_TESTS "Window should be maximized" /WINDOW_ON_TOP /POPUP_FOR_TESTS "Window should be on top" /WINDOW_ON_BOTTOM /POPUP_FOR_TESTS "Window should be on bottom" /WINDOW_ON_LEFT /POPUP_FOR_TESTS "Window should be on left" /WINDOW_ON_RIGHT /POPUP_FOR_TESTS "Window should be on right" /WINDOW_ON_TOP_LEFT /POPUP_FOR_TESTS "Window should be on top left" /WINDOW_ON_TOP_RIGHT /POPUP_FOR_TESTS "Window should be on top right" /WINDOW_ON_BOTTOM_LEFT /POPUP_FOR_TESTS "Window should be on bottom left" /WINDOW_ON_BOTTOM_RIGHT /POPUP_FOR_TESTS "Window should be on bottom right"
//MessageBox.Show("Test " + args.Length);
if (args.Length > 0)
{
for (int i = 0; i < args.Length; i++)
{
string command = args[i].Trim().ToUpper();
if ((command == "/TITLE") && (i < args.Length - 1))
{
//MessageBox.Show("TITLE = " + args[i + 1]);
exec.mainform.Text = args[i + 1];
i++;
}
else if (command == "/WINDOW_MAXIMIZED")
{
exec.mainform.WindowState = FormWindowState.Maximized;
}
else if (command == "/WINDOW_ON_TOP")
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
rect.Height = rect.Height / 2;
exec.mainform.Bounds = rect;
exec.mainform.Location = new Point(0, 0);
}
else if (command == "/WINDOW_ON_BOTTOM")
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
rect.Height = rect.Height / 2;
exec.mainform.Bounds = rect;
exec.mainform.Location = new Point(0, rect.Height);
}
else if (command == "/WINDOW_ON_LEFT")
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
rect.Width = rect.Width / 2;
exec.mainform.Bounds = rect;
exec.mainform.Location = new Point(0, 0);
}
else if (command == "/WINDOW_ON_RIGHT")
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
rect.Width = rect.Width / 2;
exec.mainform.Bounds = rect;
exec.mainform.Location = new Point(rect.Width, 0);
}
else if (command == "/WINDOW_ON_TOP_LEFT")
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
rect.Height = rect.Height / 2;
rect.Width = rect.Width / 2;
exec.mainform.Bounds = rect;
exec.mainform.Location = new Point(0, 0);
}
else if (command == "/WINDOW_ON_TOP_RIGHT")
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
rect.Height = rect.Height / 2;
rect.Width = rect.Width / 2;
exec.mainform.Bounds = rect;
exec.mainform.Location = new Point(rect.Width, 0);
}
else if (command == "/WINDOW_ON_BOTTOM_LEFT")
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
rect.Height = rect.Height / 2;
rect.Width = rect.Width / 2;
exec.mainform.Bounds = rect;
exec.mainform.Location = new Point(0, rect.Height);
}
else if (command == "/WINDOW_ON_BOTTOM_RIGHT")
{
Rectangle rect = Screen.PrimaryScreen.WorkingArea;
exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
rect.Height = rect.Height / 2;
rect.Width = rect.Width / 2;
exec.mainform.Bounds = rect;
exec.mainform.Location = new Point(rect.Width, rect.Height);
}
else if ((command == "/SLEEP_FOR_TESTS") && (i < args.Length - 1))
{
System.Threading.Thread.Sleep(Int32.Parse(args[i + 1]));
i++;
}
else if ((command == "/POPUP_FOR_TESTS") && (i < args.Length - 1))
{
MessageBox.Show(args[i + 1]);
i++;
}
}
}
Users browsing this forum: No registered users and 2 guests