public NemonicContext(NemonicForm form, bool startup = false) { Forms = new Dictionary <string, JsonObject>(); #if (!DEBUG) try #endif { if (File.Exists(ReStartPath)) { string json = File.ReadAllText(ReStartPath); JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; List <JsonObject> objects = JsonConvert.DeserializeObject <List <JsonObject> >(json, settings); if (startup && objects.Count < 1) { throw new ApplicationException("No need to start program"); } foreach (JsonObject obj in objects) { Memo memo = obj as Memo; NemonicForm fm = new NemonicForm(path: memo.path); this.OpenNew(fm); fm.Location = new Point(memo.x, memo.y); this.Forms.Add(memo.path, memo); } } } #if (!DEBUG) catch (Exception e) { File.Delete(NemonicContext.ReStartPath); } #endif if (Application.OpenForms.Count == 0) { if (startup) { throw new ApplicationException("No need to start program"); } else { form.FormClosed += OnFormClosed; form.Show(); } } }
public void OpenNew(NemonicForm form) { form.FormClosed += OnFormClosed; form.Show(); }