public static void Main(string[] args) { #if DEBUG // args = new String[] { "-nogui" }; #endif if (ApplicationHelper.IsAlreadyRunning()) { return; } StartupManager manager = new StartupManager(); manager.Load(); List <StartupItem> startupItems = new List <StartupItem>(manager.GetItems()); if (args.Length == 0) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm frm = new MainForm(manager); frm.PopulateListView(startupItems); Application.Run(frm); } else if (args.Length == 1 && args[0].Equals("-startup")) { int currentOffset = 0; foreach (StartupItem item in startupItems) { Thread.Sleep((item.Offset - currentOffset) * 1000); ProcessStartInfo processInfo = new ProcessStartInfo(); processInfo.FileName = "cmd"; processInfo.Arguments = CommandFormat(item.Item, item.WindowState, item.Arguments); processInfo.WindowStyle = ProcessWindowStyle.Hidden; string workingDirectory = item.WorkingDirectory; if (workingDirectory == "" || string.IsNullOrEmpty(workingDirectory)) { workingDirectory = Environment.SystemDirectory; } processInfo.WorkingDirectory = workingDirectory; Process.Start(processInfo); currentOffset = item.Offset; } } }
public MainForm(StartupManager manager) { this.manager = manager; InitializeComponent(); title = ConfigurationManager.AppSettings["Title"]; Text = title; // Customise the ListView listViewItems.Columns.Add("Program", -2); listViewItems.Columns.Add("Offset"); listViewItems.Columns.Add("Working Directory"); listViewItems.Columns.Add("Arguments"); listViewItems.Columns.Add("State"); UpdateUI(); }