-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
112 changed files
with
9,219 additions
and
2,872 deletions.
There are no files selected for viewing
733 changes: 733 additions & 0 deletions
733
Plugins/Luna/Controllers/FormEditorCtrl/AutoCompleteCtrl.cs
Large diffs are not rendered by default.
Oops, something went wrong.
376 changes: 211 additions & 165 deletions
376
Plugins/Luna/Controllers/TabEditorCtrl.cs → .../Controllers/FormEditorCtrl/ButtonCtrl.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
using Luna.Resources.Langs; | ||
using Luna.Services; | ||
using System.Windows.Forms; | ||
|
||
namespace Luna.Controllers.FormEditorCtrl | ||
{ | ||
internal sealed class MenuCtrl | ||
{ | ||
Views.WinForms.FormEditor formEditor; | ||
ButtonCtrl editorCtrl; | ||
private readonly ToolStripMenuItem miNewWindow; | ||
private readonly ToolStripMenuItem miShowMgr; | ||
private readonly ToolStripMenuItem miLoad; | ||
private readonly ToolStripMenuItem miSaveAs; | ||
private readonly ToolStripMenuItem miExit; | ||
private readonly ToolStripMenuItem miLoadClrLib; | ||
|
||
private readonly ToolStripStatusLabel smiLbClrLib; | ||
private readonly ComboBox cboxScriptName; | ||
|
||
public MenuCtrl( | ||
Views.WinForms.FormEditor formEditor, | ||
|
||
ButtonCtrl editorCtrl, | ||
ToolStripMenuItem miNewWindow, | ||
ToolStripMenuItem miShowMgr, | ||
ToolStripMenuItem miLoad, | ||
ToolStripMenuItem miSaveAs, | ||
ToolStripMenuItem miExit, | ||
|
||
ToolStripMenuItem miLoadClrLib, | ||
|
||
|
||
ToolStripStatusLabel smiLbClrLib, | ||
|
||
|
||
ComboBox cboxScriptName) | ||
{ | ||
this.editorCtrl = editorCtrl; | ||
this.miNewWindow = miNewWindow; | ||
this.miShowMgr = miShowMgr; | ||
this.miLoad = miLoad; | ||
this.miSaveAs = miSaveAs; | ||
this.miExit = miExit; | ||
this.miLoadClrLib = miLoadClrLib; | ||
|
||
this.smiLbClrLib = smiLbClrLib; | ||
|
||
this.cboxScriptName = cboxScriptName; | ||
this.formEditor = formEditor; | ||
} | ||
|
||
public void Run( | ||
Services.FormMgrSvc formMgrService, | ||
Services.Settings settings) | ||
{ | ||
InitControls(settings); | ||
BindEvents(formMgrService); | ||
} | ||
|
||
#region private method | ||
private void InitControls(Settings settings) | ||
{ | ||
miLoadClrLib.Checked = settings.isLoadClrLib; | ||
smiLbClrLib.Enabled = settings.isLoadClrLib; | ||
} | ||
|
||
private void BindEvents(FormMgrSvc formMgrService) | ||
{ | ||
miShowMgr.Click += (s, a) => formMgrService.ShowFormMain(); | ||
|
||
miLoadClrLib.Click += (s, a) => | ||
{ | ||
var enable = !miLoadClrLib.Checked; | ||
miLoadClrLib.Checked = enable; | ||
smiLbClrLib.Enabled = enable; | ||
editorCtrl.isLoadClrLib = 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; | ||
} | ||
}; | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Luna.Resources.Langs; | ||
using System.Windows.Forms; | ||
|
||
namespace Luna.Controllers.FormMainCtrl | ||
{ | ||
internal class TabOptionsCtrl | ||
{ | ||
private readonly CheckBox chkLoadClrLib; | ||
private readonly CheckBox chkEnableCodeAnalyze; | ||
private readonly Button btnSaveOptions; | ||
|
||
public TabOptionsCtrl( | ||
CheckBox chkLoadClrLib, | ||
CheckBox chkEnableCodeAnalyze, | ||
Button btnSaveOptions) | ||
{ | ||
this.chkLoadClrLib = chkLoadClrLib; | ||
this.chkEnableCodeAnalyze = chkEnableCodeAnalyze; | ||
this.btnSaveOptions = btnSaveOptions; | ||
} | ||
|
||
Services.Settings settings; | ||
public void Run(Services.Settings settings) | ||
{ | ||
this.settings = settings; | ||
InitControls(); | ||
BindEvents(); | ||
} | ||
|
||
public bool IsChanged() | ||
{ | ||
if (chkLoadClrLib.Checked != settings.isLoadClrLib | ||
|| chkEnableCodeAnalyze.Checked != settings.isEnableAdvanceAutoComplete) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
#region private methods | ||
void BindEvents() | ||
{ | ||
btnSaveOptions.Click += (s, a) => | ||
{ | ||
if (IsChanged()) | ||
{ | ||
settings.isLoadClrLib = chkLoadClrLib.Checked; | ||
settings.isEnableAdvanceAutoComplete = chkEnableCodeAnalyze.Checked; | ||
} | ||
VgcApis.Misc.UI.MsgBox(I18N.Done); | ||
}; | ||
} | ||
|
||
void InitControls() | ||
{ | ||
chkLoadClrLib.Checked = settings.isLoadClrLib; | ||
chkEnableCodeAnalyze.Checked = settings.isEnableAdvanceAutoComplete; | ||
} | ||
#endregion | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.