/// <summary> /// Processes command line of this program. /// Returns true if this instance must exit: 1. If finds previous program instance; then sends the command line to it if need. 2. If incorrect command line. /// </summary> public static bool OnProgramStarted(string[] a) { string s = null; int cmd = 0; bool activateWnd = true; if (a.Length > 0) { //AOutput.Write(a); for (int i = 0; i < a.Length; i++) { if (a[i].Starts('-')) { a[i] = a[i].ReplaceAt(0, 1, "/"); } if (a[i].Starts('/')) { a[i] = a[i].Lower(); } } s = a[0]; if (s.Starts('/')) { for (int i = 0; i < a.Length; i++) { s = a[i]; switch (s) { case "/test": if (++i < a.Length) { TestArg = a[i]; } break; case "/v": StartVisible = true; break; default: ADialog.ShowError("Unknown command line parameter", s); return(true); } //rejected: /h start hidden. Not useful. } } else //one or more files { if (a.Length == 1 && FilesModel.IsWorkspaceDirectory(s)) { switch (cmd = ADialog.Show("Workspace", s, "1 Open|2 Import|0 Cancel", footerText: FilesModel.GetSecurityInfo("v|"))) { case 1: WorkspaceDirectory = s; break; case 2: _importWorkspace = s; break; } } else { cmd = 3; _importFiles = a; } } } //single instance s_mutex = new Mutex(true, "Au.Mutex.1", out bool createdNew); if (createdNew) { return(false); } var w = AWnd.FindFast(null, "Au.Editor.Msg", true); if (!w.Is0) { if (activateWnd) { AWnd wMain = (AWnd)w.Send(Api.WM_USER); if (!wMain.Is0) { try { wMain.Activate(); } catch (Exception ex) { ADebug.Print(ex); } } } switch (cmd) { case 3: //import files s = string.Join("\0", a); break; } if (cmd != 0) { AWnd.More.CopyDataStruct.SendString(w, cmd, s); } } return(true); }