static void Main() { var current = Process.GetCurrentProcess(); var v = Process.GetProcessesByName(current.ProcessName); if (v.Length > 1) { foreach (Process proc in v) { if (proc.Id == current.Id) continue; //ShowWindow(proc.MainWindowHandle, 9 /* SW_RESTORE */); SetForegroundWindow(proc.MainWindowHandle); return; } } var setting = new UserSetting(); setting.Load(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(setting)); setting.Save(); }
/* ----------------------------------------------------------------- */ /// SaveSetting /* ----------------------------------------------------------------- */ private void SaveSetting(string path) { UserSetting setting = new UserSetting(); foreach (KeyValuePair<string, ScheduleItem> item in this._schedule) { if (item.Key == DEFAULT_SETTING_NAME) setting.DefaultSetting = item.Value; else setting.Schedule.Add(item.Value); } setting.Save(path); }
/* ----------------------------------------------------------------- */ /// constructor /* ----------------------------------------------------------------- */ public MainForm(UserSetting setting) { InitializeComponent(); this._setting = setting; this.Initialize(); }