private void BindEvents(FormMgrSvc formMgrService) { miShowMgr.Click += (s, a) => formMgrService.ShowFormMain(); miLoadClrLib.Click += (s, a) => { var enable = !miLoadClrLib.Checked; UpdateClrControlsEanbledState(enable); }; miNewWindow.Click += (s, a) => formMgrService.CreateNewEditor(); // event handling miExit.Click += (s, a) => VgcApis.Misc.UI.CloseFormIgnoreError(formEditor); miLoad.Click += (s, a) => { if (editorCtrl.IsChanged() && !VgcApis.Misc.UI.Confirm(I18N.DiscardUnsavedChanges)) { return; } var cf = VgcApis.Misc.UI.ReadFileFromDialog(VgcApis.Models.Consts.Files.LuaExt); var script = cf.Item1; var filename = cf.Item2; if (script == null) { return; } cboxScriptName.Text = @""; editorCtrl.SetCurFileName(filename); editorCtrl.SetCurrentEditorContent(script); editorCtrl.SetScriptCache(script); }; miSaveAs.Click += (s, a) => { var script = editorCtrl.GetCurrentEditorContent(); var err = VgcApis.Misc.UI.ShowSaveFileDialog( VgcApis.Models.Consts.Files.LuaExt, script, out var filename); switch (err) { case VgcApis.Models.Datas.Enums.SaveFileErrorCode.Success: if (string.IsNullOrEmpty(cboxScriptName.Text)) { editorCtrl.SetCurFileName(filename); editorCtrl.SetScriptCache(script); } VgcApis.Misc.UI.MsgBoxAsync(I18N.Done); break; case VgcApis.Models.Datas.Enums.SaveFileErrorCode.Fail: VgcApis.Misc.UI.MsgBoxAsync(I18N.WriteFileFail); break; } }; }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { var cs = luaCoreCtrl.GetCoreSettings(); formMgrSvc.CreateNewEditor(cs); }