From c8ba0e08fcd114edb8bca7c4c94b1689feca25e3 Mon Sep 17 00:00:00 2001 From: Jones-HM <93740747+Jones-HM@users.noreply.github.com> Date: Sun, 26 Nov 2023 02:29:08 +0400 Subject: [PATCH] Added Logs --- QVMEditor/QVMEditorForm.cs | 356 ++++++++++++++++++++++++++++++------- 1 file changed, 290 insertions(+), 66 deletions(-) diff --git a/QVMEditor/QVMEditorForm.cs b/QVMEditor/QVMEditorForm.cs index 94cdb09..83b7876 100644 --- a/QVMEditor/QVMEditorForm.cs +++ b/QVMEditor/QVMEditorForm.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Drawing; using System.Windows.Forms; using System.IO; @@ -58,7 +58,10 @@ public QVMEditorForm() } private void QVMEditorForm_Load(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: QVMEditorForm_Load()"); + QUtils.AddLog("QVMEditorForm_Load param sender = " + sender); + QUtils.AddLog("QVMEditorForm_Load param e = " + e); + // BASIC CONFIG scintilla.Dock = DockStyle.Fill; @@ -86,11 +89,15 @@ private void QVMEditorForm_Load(object sender, EventArgs e) // init hotkeys InitHotkeys(); + QUtils.AddLog("Exiting method: QVMEditorForm_Load()"); } private void scriptViewerText_MouseDoubleClick(object sender, MouseEventArgs e) - { + { QUtils.AddLog("Entering method: scriptViewerText_MouseDoubleClick()"); + QUtils.AddLog("scriptViewerText_MouseDoubleClick param sender = " + sender); + QUtils.AddLog("scriptViewerText_MouseDoubleClick param e = " + e); + string objectType = ((Scintilla)sender).SelectedText; string objectInfo = String.Empty; @@ -110,6 +117,7 @@ private void scriptViewerText_MouseDoubleClick(object sender, MouseEventArgs e) if (showDialog == DialogResult.Yes) { QUtils.ShowInputDialog(ref modelInput); + QUtils.AddLog("Exiting method: scriptViewerText_MouseDoubleClick()"); } //Save the input model to model data. @@ -167,13 +175,17 @@ private void scriptViewerText_MouseDoubleClick(object sender, MouseEventArgs e) } private void InitTextSelectionColors(bool darkMode) - { + { QUtils.AddLog("Entering method: InitTextSelectionColors()"); + QUtils.AddLog("InitTextSelectionColors param darkMode = " + darkMode); + if (darkMode) scintilla.SetSelectionBackColor(true, IntToColor(0x0078D7)); //For Dark Mode. else scintilla.SetSelectionBackColor(true, IntToColor(0x97C6EB)); //For Light Mode. + QUtils.AddLog("Exiting method: InitTextSelectionColors()"); } private void InitHotkeys() - { + { QUtils.AddLog("Entering method: InitHotkeys()"); + // register the hotkeys with the form HotKeyManager.AddHotKey(this, OpenSearch, Keys.F, true); HotKeyManager.AddHotKey(this, OpenReplaceDialog, Keys.R, true); @@ -189,11 +201,14 @@ private void InitHotkeys() scintilla.ClearCmdKey(Keys.Control | Keys.H); scintilla.ClearCmdKey(Keys.Control | Keys.L); scintilla.ClearCmdKey(Keys.Control | Keys.U); + QUtils.AddLog("Exiting method: InitHotkeys()"); } private void InitSyntaxColoring() - { + { QUtils.AddLog("Entering method: InitSyntaxColoring()"); + AutomaticThemeStyle(); + QUtils.AddLog("Exiting method: InitSyntaxColoring()"); } @@ -231,7 +246,8 @@ private void InitSyntaxColoring() private const bool CODEFOLDING_CIRCULAR = true; private void InitNumberMargin() - { + { QUtils.AddLog("Entering method: InitNumberMargin()"); + scintilla.Styles[Style.LineNumber].BackColor = IntToColor(BACK_COLOR); scintilla.Styles[Style.LineNumber].ForeColor = IntToColor(FORE_COLOR); @@ -245,10 +261,12 @@ private void InitNumberMargin() nums.Mask = 0; scintilla.MarginClick += TextArea_MarginClick; + QUtils.AddLog("Exiting method: InitNumberMargin()"); } private void InitBookmarkMargin() - { + { QUtils.AddLog("Entering method: InitBookmarkMargin()"); + var margin = scintilla.Margins[BOOKMARK_MARGIN]; margin.Width = 20; margin.Sensitive = true; @@ -260,10 +278,12 @@ private void InitBookmarkMargin() marker.SetBackColor(IntToColor(0xFF003B)); marker.SetForeColor(IntToColor(0x000000)); marker.SetAlpha(100); + QUtils.AddLog("Exiting method: InitBookmarkMargin()"); } private void InitCodeFolding() - { + { QUtils.AddLog("Entering method: InitCodeFolding()"); + scintilla.SetFoldMarginColor(true, IntToColor(BACK_COLOR)); scintilla.SetFoldMarginHighlightColor(true, IntToColor(BACK_COLOR)); @@ -283,6 +303,7 @@ private void InitCodeFolding() { scintilla.Markers[i].SetForeColor(IntToColor(BACK_COLOR)); // styles for [+] and [-] scintilla.Markers[i].SetBackColor(IntToColor(FORE_COLOR)); // styles for [+] and [-] + QUtils.AddLog("Exiting method: InitCodeFolding()"); } // Configure folding markers with respective symbols @@ -300,7 +321,10 @@ private void InitCodeFolding() } private void TextArea_MarginClick(object sender, MarginClickEventArgs e) - { + { QUtils.AddLog("Entering method: TextArea_MarginClick()"); + QUtils.AddLog("TextArea_MarginClick param sender = " + sender); + QUtils.AddLog("TextArea_MarginClick param e = " + e); + if (e.Margin == BOOKMARK_MARGIN) { // Do we have a marker for this line? @@ -310,6 +334,7 @@ private void TextArea_MarginClick(object sender, MarginClickEventArgs e) { // Remove existing bookmark line.MarkerDelete(BOOKMARK_MARKER); + QUtils.AddLog("Exiting method: TextArea_MarginClick()"); } else { @@ -324,7 +349,8 @@ private void TextArea_MarginClick(object sender, MarginClickEventArgs e) #region Drag & Drop File public void InitDragDropFile() - { + { QUtils.AddLog("Entering method: InitDragDropFile()"); + scintilla.AllowDrop = true; scintilla.DragEnter += delegate (object sender, DragEventArgs e) @@ -333,6 +359,7 @@ public void InitDragDropFile() e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; + QUtils.AddLog("Exiting method: InitDragDropFile()"); }; scintilla.DragDrop += delegate (object sender, DragEventArgs e) { @@ -361,7 +388,8 @@ public void InitDragDropFile() } private void LoadDataFromFile() - { + { QUtils.AddLog("Entering method: LoadDataFromFile()"); + try { var fopenIO = QUtils.ShowOpenFileDlg("Select QVM file",".qvm", "QVM files (*.qvm)|*.qvm|DAT files (*.dat)|*.dat|QSC files (*.qsc)|*.qsc|All files (*.*)|*.*",true); @@ -374,6 +402,7 @@ private void LoadDataFromFile() fileExtension.ToLower() == ".txt") { scintilla.Text = QUtils.LoadFile(fopenIO.FileName); + QUtils.AddLog("Exiting method: LoadDataFromFile()"); } else { @@ -391,88 +420,146 @@ private void LoadDataFromFile() #region Main Menu Commands private void openToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: openToolStripMenuItem_Click()"); + QUtils.AddLog("openToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("openToolStripMenuItem_Click param e = " + e); + LoadDataFromFile(); + QUtils.AddLog("Exiting method: openToolStripMenuItem_Click()"); } private void findToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: findToolStripMenuItem_Click()"); + QUtils.AddLog("findToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("findToolStripMenuItem_Click param e = " + e); + OpenSearch(); + QUtils.AddLog("Exiting method: findToolStripMenuItem_Click()"); } private void findAndReplaceToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: findAndReplaceToolStripMenuItem_Click()"); + QUtils.AddLog("findAndReplaceToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("findAndReplaceToolStripMenuItem_Click param e = " + e); + OpenReplaceDialog(); + QUtils.AddLog("Exiting method: findAndReplaceToolStripMenuItem_Click()"); } private void cutToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: cutToolStripMenuItem_Click()"); + QUtils.AddLog("cutToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("cutToolStripMenuItem_Click param e = " + e); + scintilla.Cut(); + QUtils.AddLog("Exiting method: cutToolStripMenuItem_Click()"); } private void copyToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: copyToolStripMenuItem_Click()"); + QUtils.AddLog("copyToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("copyToolStripMenuItem_Click param e = " + e); + scintilla.Copy(); + QUtils.AddLog("Exiting method: copyToolStripMenuItem_Click()"); } private void pasteToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: pasteToolStripMenuItem_Click()"); + QUtils.AddLog("pasteToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("pasteToolStripMenuItem_Click param e = " + e); + scintilla.Paste(); + QUtils.AddLog("Exiting method: pasteToolStripMenuItem_Click()"); } private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: selectAllToolStripMenuItem_Click()"); + QUtils.AddLog("selectAllToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("selectAllToolStripMenuItem_Click param e = " + e); + scintilla.SelectAll(); + QUtils.AddLog("Exiting method: selectAllToolStripMenuItem_Click()"); } private void selectLineToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: selectLineToolStripMenuItem_Click()"); + QUtils.AddLog("selectLineToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("selectLineToolStripMenuItem_Click param e = " + e); + Line line = scintilla.Lines[scintilla.CurrentLine]; scintilla.SetSelection(line.Position + line.Length, line.Position); + QUtils.AddLog("Exiting method: selectLineToolStripMenuItem_Click()"); } private void indentSelectionToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: indentSelectionToolStripMenuItem_Click()"); + QUtils.AddLog("indentSelectionToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("indentSelectionToolStripMenuItem_Click param e = " + e); + Indent(); + QUtils.AddLog("Exiting method: indentSelectionToolStripMenuItem_Click()"); } private void outdentSelectionToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: outdentSelectionToolStripMenuItem_Click()"); + QUtils.AddLog("outdentSelectionToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("outdentSelectionToolStripMenuItem_Click param e = " + e); + Outdent(); + QUtils.AddLog("Exiting method: outdentSelectionToolStripMenuItem_Click()"); } private void wordWrapToolStripMenuItem1_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: wordWrapToolStripMenuItem1_Click()"); + QUtils.AddLog("wordWrapToolStripMenuItem1_Click param sender = " + sender); + QUtils.AddLog("wordWrapToolStripMenuItem1_Click param e = " + e); + // toggle word wrap wordWrapItem.Checked = !wordWrapItem.Checked; scintilla.WrapMode = wordWrapItem.Checked ? WrapMode.Word : WrapMode.None; + QUtils.AddLog("Exiting method: wordWrapToolStripMenuItem1_Click()"); } private void indentGuidesToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: indentGuidesToolStripMenuItem_Click()"); + QUtils.AddLog("indentGuidesToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("indentGuidesToolStripMenuItem_Click param e = " + e); + // toggle indent guides indentGuidesItem.Checked = !indentGuidesItem.Checked; scintilla.IndentationGuides = indentGuidesItem.Checked ? IndentView.LookBoth : IndentView.None; + QUtils.AddLog("Exiting method: indentGuidesToolStripMenuItem_Click()"); } private void hiddenCharactersToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: hiddenCharactersToolStripMenuItem_Click()"); + QUtils.AddLog("hiddenCharactersToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("hiddenCharactersToolStripMenuItem_Click param e = " + e); + // toggle view whitespace hiddenCharactersItem.Checked = !hiddenCharactersItem.Checked; scintilla.ViewWhitespace = hiddenCharactersItem.Checked ? WhitespaceMode.VisibleAlways : WhitespaceMode.Invisible; + QUtils.AddLog("Exiting method: hiddenCharactersToolStripMenuItem_Click()"); } private void GotoLine(int lineNumber) - { + { QUtils.AddLog("Entering method: GotoLine()"); + QUtils.AddLog("GotoLine param lineNumber = " + lineNumber); + if (lineNumber > scintilla.Lines.Count) return; scintilla.Lines[lineNumber - 1].Goto(); + QUtils.AddLog("Exiting method: GotoLine()"); } private void goToLineToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: goToLineToolStripMenuItem_Click()"); + QUtils.AddLog("goToLineToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("goToLineToolStripMenuItem_Click param e = " + e); + PanelReplace.Visible = true; if (PanelReplace.Visible) @@ -481,33 +568,54 @@ private void goToLineToolStripMenuItem_Click(object sender, EventArgs e) { int lineNumber = Convert.ToInt32(ReplaceTextBox.Text); GotoLine(lineNumber); + QUtils.AddLog("Exiting method: goToLineToolStripMenuItem_Click()"); } } } private void zoomInToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: zoomInToolStripMenuItem_Click()"); + QUtils.AddLog("zoomInToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("zoomInToolStripMenuItem_Click param e = " + e); + ZoomIn(); + QUtils.AddLog("Exiting method: zoomInToolStripMenuItem_Click()"); } private void zoomOutToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: zoomOutToolStripMenuItem_Click()"); + QUtils.AddLog("zoomOutToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("zoomOutToolStripMenuItem_Click param e = " + e); + ZoomOut(); + QUtils.AddLog("Exiting method: zoomOutToolStripMenuItem_Click()"); } private void zoom100ToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: zoom100ToolStripMenuItem_Click()"); + QUtils.AddLog("zoom100ToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("zoom100ToolStripMenuItem_Click param e = " + e); + ZoomDefault(); + QUtils.AddLog("Exiting method: zoom100ToolStripMenuItem_Click()"); } private void collapseAllToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: collapseAllToolStripMenuItem_Click()"); + QUtils.AddLog("collapseAllToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("collapseAllToolStripMenuItem_Click param e = " + e); + scintilla.FoldAll(FoldAction.Contract); + QUtils.AddLog("Exiting method: collapseAllToolStripMenuItem_Click()"); } private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: expandAllToolStripMenuItem_Click()"); + QUtils.AddLog("expandAllToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("expandAllToolStripMenuItem_Click param e = " + e); + scintilla.FoldAll(FoldAction.Expand); + QUtils.AddLog("Exiting method: expandAllToolStripMenuItem_Click()"); } @@ -516,25 +624,32 @@ private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) #region Indent / Outdent private void Indent() - { + { QUtils.AddLog("Entering method: Indent()"); + // we use this hack to send "Shift+Tab" to scintilla, since there is no known API to indent, // although the indentation function exists. Pressing TAB with the editor focused confirms this. GenerateKeystrokes("{TAB}"); + QUtils.AddLog("Exiting method: Indent()"); } private void Outdent() - { + { QUtils.AddLog("Entering method: Outdent()"); + // we use this hack to send "Shift+Tab" to scintilla, since there is no known API to outdent, // although the indentation function exists. Pressing Shift+Tab with the editor focused confirms this. GenerateKeystrokes("+{TAB}"); + QUtils.AddLog("Exiting method: Outdent()"); } private void GenerateKeystrokes(string keys) - { + { QUtils.AddLog("Entering method: GenerateKeystrokes()"); + QUtils.AddLog("GenerateKeystrokes param keys = " + keys); + HotKeyManager.Enable = false; scintilla.Focus(); SendKeys.Send(keys); HotKeyManager.Enable = true; + QUtils.AddLog("Exiting method: GenerateKeystrokes()"); } #endregion @@ -542,18 +657,24 @@ private void GenerateKeystrokes(string keys) #region Zoom private void ZoomIn() - { + { QUtils.AddLog("Entering method: ZoomIn()"); + scintilla.ZoomIn(); + QUtils.AddLog("Exiting method: ZoomIn()"); } private void ZoomOut() - { + { QUtils.AddLog("Entering method: ZoomOut()"); + scintilla.ZoomOut(); + QUtils.AddLog("Exiting method: ZoomOut()"); } private void ZoomDefault() - { + { QUtils.AddLog("Entering method: ZoomDefault()"); + scintilla.Zoom = 0; + QUtils.AddLog("Exiting method: ZoomDefault()"); } @@ -565,7 +686,8 @@ private void ZoomDefault() bool ReplaceIsOpen = false; private void OpenSearch() - { + { QUtils.AddLog("Entering method: OpenSearch()"); + SearchManager.SearchBox = SearchTextBox; SearchManager.TextArea = scintilla; @@ -579,6 +701,7 @@ private void OpenSearch() SearchTextBox.Text = SearchManager.LastSearch; SearchTextBox.Focus(); SearchTextBox.SelectAll(); + QUtils.AddLog("Exiting method: OpenSearch()"); }); } else @@ -592,45 +715,73 @@ private void OpenSearch() } private void CloseSearchPanel(Panel panel, ref bool panelIsOpen) - { + { QUtils.AddLog("Entering method: CloseSearchPanel()"); + QUtils.AddLog("CloseSearchPanel param panel = " + panel); + QUtils.AddLog("CloseSearchPanel param panelIsOpen = " + panelIsOpen); + if (panelIsOpen) { panelIsOpen = false; InvokeIfNeeded(delegate () { panel.Visible = false; + QUtils.AddLog("Exiting method: CloseSearchPanel()"); }); } } private void BtnClearSearch_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: BtnClearSearch_Click()"); + QUtils.AddLog("BtnClearSearch_Click param sender = " + sender); + QUtils.AddLog("BtnClearSearch_Click param e = " + e); + CloseSearchPanel(PanelSearch, ref SearchIsOpen); + QUtils.AddLog("Exiting method: BtnClearSearch_Click()"); } private void BtnCloseReplace_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: BtnCloseReplace_Click()"); + QUtils.AddLog("BtnCloseReplace_Click param sender = " + sender); + QUtils.AddLog("BtnCloseReplace_Click param e = " + e); + CloseSearchPanel(PanelReplace, ref ReplaceIsOpen); + QUtils.AddLog("Exiting method: BtnCloseReplace_Click()"); } private void BtnPrevSearch_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: BtnPrevSearch_Click()"); + QUtils.AddLog("BtnPrevSearch_Click param sender = " + sender); + QUtils.AddLog("BtnPrevSearch_Click param e = " + e); + SearchManager.Find(false, false); + QUtils.AddLog("Exiting method: BtnPrevSearch_Click()"); } private void BtnNextSearch_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: BtnNextSearch_Click()"); + QUtils.AddLog("BtnNextSearch_Click param sender = " + sender); + QUtils.AddLog("BtnNextSearch_Click param e = " + e); + SearchManager.Find(true, false); + QUtils.AddLog("Exiting method: BtnNextSearch_Click()"); } private void TxtSearch_TextChanged(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: TxtSearch_TextChanged()"); + QUtils.AddLog("TxtSearch_TextChanged param sender = " + sender); + QUtils.AddLog("TxtSearch_TextChanged param e = " + e); + SearchManager.Find(true, true); + QUtils.AddLog("Exiting method: TxtSearch_TextChanged()"); } private void TxtSearch_KeyDown(object sender, KeyEventArgs e) - { + { QUtils.AddLog("Entering method: TxtSearch_KeyDown()"); + QUtils.AddLog("TxtSearch_KeyDown param sender = " + sender); + QUtils.AddLog("TxtSearch_KeyDown param e = " + e); + if (HotKeyManager.IsHotkey(e, Keys.Enter)) { SearchManager.Find(true, false); + QUtils.AddLog("Exiting method: TxtSearch_KeyDown()"); } if (HotKeyManager.IsHotkey(e, Keys.Enter, true) || HotKeyManager.IsHotkey(e, Keys.Enter, false, true)) { @@ -639,10 +790,14 @@ private void TxtSearch_KeyDown(object sender, KeyEventArgs e) } private void ReplaceTextBox_KeyDown(object sender, KeyEventArgs e) - { + { QUtils.AddLog("Entering method: ReplaceTextBox_KeyDown()"); + QUtils.AddLog("ReplaceTextBox_KeyDown param sender = " + sender); + QUtils.AddLog("ReplaceTextBox_KeyDown param e = " + e); + if (HotKeyManager.IsHotkey(e, Keys.Enter)) { OpenReplaceDialog(); + QUtils.AddLog("Exiting method: ReplaceTextBox_KeyDown()"); } } @@ -651,7 +806,8 @@ private void ReplaceTextBox_KeyDown(object sender, KeyEventArgs e) #region Find & Replace Dialog private void OpenReplaceDialog() - { + { QUtils.AddLog("Entering method: OpenReplaceDialog()"); + SearchManager.SearchBox = SearchTextBox; SearchManager.TextArea = scintilla; @@ -664,6 +820,7 @@ private void OpenReplaceDialog() SearchTextBox.Text = SearchManager.LastSearch; SearchTextBox.Focus(); SearchTextBox.SelectAll(); + QUtils.AddLog("Exiting method: OpenReplaceDialog()"); }); } else @@ -684,15 +841,21 @@ private void OpenReplaceDialog() #region Utils public static Color IntToColor(int rgb) - { + { QUtils.AddLog("Entering method: IntToColor()"); + QUtils.AddLog("IntToColor param rgb = " + rgb); + return Color.FromArgb(255, (byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb); + QUtils.AddLog("Exiting method: IntToColor()"); } public void InvokeIfNeeded(Action action) - { + { QUtils.AddLog("Entering method: InvokeIfNeeded()"); + QUtils.AddLog("InvokeIfNeeded param action = " + action); + if (this.InvokeRequired) { this.BeginInvoke(action); + QUtils.AddLog("Exiting method: InvokeIfNeeded()"); } else { @@ -708,7 +871,10 @@ public void InvokeIfNeeded(Action action) #region Themes private void DarkThemeStyle(string fontName, int fontSize) - { + { QUtils.AddLog("Entering method: DarkThemeStyle()"); + QUtils.AddLog("DarkThemeStyle param fontName = " + fontName); + QUtils.AddLog("DarkThemeStyle param fontSize = " + fontSize); + // Configure the default style scintilla.StyleResetDefault(); scintilla.Styles[Style.Default].Font = fontName; @@ -736,10 +902,14 @@ private void DarkThemeStyle(string fontName, int fontSize) scintilla.Styles[Style.Cpp.GlobalClass].ForeColor = IntToColor(0x48A8EE); scintilla.Lexer = Lexer.Cpp; + QUtils.AddLog("Exiting method: DarkThemeStyle()"); } private void LightThemeStyle(string fontName, int fontSize) - { + { QUtils.AddLog("Entering method: LightThemeStyle()"); + QUtils.AddLog("LightThemeStyle param fontName = " + fontName); + QUtils.AddLog("LightThemeStyle param fontSize = " + fontSize); + // Configuring the default style with properties // we have common to every lexer style saves time. scintilla.StyleResetDefault(); @@ -763,10 +933,14 @@ private void LightThemeStyle(string fontName, int fontSize) scintilla.Styles[Style.Lua.Operator].ForeColor = Color.Purple; scintilla.Styles[Style.Lua.Preprocessor].ForeColor = Color.Maroon; scintilla.Lexer = Lexer.Lua; + QUtils.AddLog("Exiting method: LightThemeStyle()"); } private void ClassicThemeStyle(string fontName, int fontSize) - { + { QUtils.AddLog("Entering method: ClassicThemeStyle()"); + QUtils.AddLog("ClassicThemeStyle param fontName = " + fontName); + QUtils.AddLog("ClassicThemeStyle param fontSize = " + fontSize); + // Reset the styles scintilla.StyleResetDefault(); scintilla.Styles[Style.Default].Font = fontName; @@ -787,6 +961,7 @@ private void ClassicThemeStyle(string fontName, int fontSize) { scintilla.Markers[i].SetForeColor(SystemColors.ControlLightLight); scintilla.Markers[i].SetBackColor(SystemColors.ControlDark); + QUtils.AddLog("Exiting method: ClassicThemeStyle()"); } // Style the folder markers @@ -833,11 +1008,13 @@ public static bool IsNight(DateTime from, DateTime to) => (to > from) && (from.Hour < 6 || to.Hour < 6 || to > from.Date.AddDays(1)); private void AutomaticThemeStyle() - { + { QUtils.AddLog("Entering method: AutomaticThemeStyle()"); + if (IsNight(DateTime.Now, DateTime.Now.AddHours(6))) { DarkThemeStyle(fontName, fontSize); InitTextSelectionColors(true); + QUtils.AddLog("Exiting method: AutomaticThemeStyle()"); } else { @@ -847,51 +1024,82 @@ private void AutomaticThemeStyle() } private void automaticToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: automaticToolStripMenuItem_Click()"); + QUtils.AddLog("automaticToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("automaticToolStripMenuItem_Click param e = " + e); + AutomaticThemeStyle(); + QUtils.AddLog("Exiting method: automaticToolStripMenuItem_Click()"); } private void darkToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: darkToolStripMenuItem_Click()"); + QUtils.AddLog("darkToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("darkToolStripMenuItem_Click param e = " + e); + DarkThemeStyle(fontName, fontSize); InitTextSelectionColors(true); + QUtils.AddLog("Exiting method: darkToolStripMenuItem_Click()"); } private void lightToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: lightToolStripMenuItem_Click()"); + QUtils.AddLog("lightToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("lightToolStripMenuItem_Click param e = " + e); + LightThemeStyle(fontName, fontSize); InitTextSelectionColors(false); + QUtils.AddLog("Exiting method: lightToolStripMenuItem_Click()"); } private void classicToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: classicToolStripMenuItem_Click()"); + QUtils.AddLog("classicToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("classicToolStripMenuItem_Click param e = " + e); + ClassicThemeStyle(fontName, fontSize); InitTextSelectionColors(false); + QUtils.AddLog("Exiting method: classicToolStripMenuItem_Click()"); } #endregion #region Font private void smallToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: smallToolStripMenuItem_Click()"); + QUtils.AddLog("smallToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("smallToolStripMenuItem_Click param e = " + e); + fontSize = 10; + QUtils.AddLog("Exiting method: smallToolStripMenuItem_Click()"); } private void mediumToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: mediumToolStripMenuItem_Click()"); + QUtils.AddLog("mediumToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("mediumToolStripMenuItem_Click param e = " + e); + fontSize = 14; + QUtils.AddLog("Exiting method: mediumToolStripMenuItem_Click()"); } private void largeToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: largeToolStripMenuItem_Click()"); + QUtils.AddLog("largeToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("largeToolStripMenuItem_Click param e = " + e); + fontSize = 18; + QUtils.AddLog("Exiting method: largeToolStripMenuItem_Click()"); } #endregion #region CoreMethods private void scriptViewerText_CharAdded(object sender, CharAddedEventArgs e) - { + { QUtils.AddLog("Entering method: scriptViewerText_CharAdded()"); + QUtils.AddLog("scriptViewerText_CharAdded param sender = " + sender); + QUtils.AddLog("scriptViewerText_CharAdded param e = " + e); + // Find the word start var currentPos = scintilla.CurrentPosition; var wordStartPos = scintilla.WordStartPosition(currentPos, true); @@ -903,12 +1111,16 @@ private void scriptViewerText_CharAdded(object sender, CharAddedEventArgs e) if (!scintilla.AutoCActive) { scintilla.AutoCShow(word, QUtils.keywords); + QUtils.AddLog("Exiting method: scriptViewerText_CharAdded()"); } } } private void saveToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: saveToolStripMenuItem_Click()"); + QUtils.AddLog("saveToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("saveToolStripMenuItem_Click param e = " + e); + string scriptFileQvm = scriptFilePathAbsolute + "\\" + fileNameLabel.Text; string scriptFileQsc = fileNameLabel.Text.Replace(QUtils.qvmFile, QUtils.qscFile); string scriptData = scintilla.Text; @@ -919,16 +1131,23 @@ private void saveToolStripMenuItem_Click(object sender, EventArgs e) { QUtils.FileIODelete(scriptFileQsc); QUtils.AddLog("File saved successfully"); + QUtils.AddLog("Exiting method: saveToolStripMenuItem_Click()"); } } private void exitToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: exitToolStripMenuItem_Click()"); + QUtils.AddLog("exitToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("exitToolStripMenuItem_Click param e = " + e); + Environment.Exit(0); + QUtils.AddLog("Exiting method: exitToolStripMenuItem_Click()"); } private void DecompileQVM(string fileName) - { + { QUtils.AddLog("Entering method: DecompileQVM()"); + QUtils.AddLog("DecompileQVM param fileName = " + fileName); + QUtils.AddLog("Decompiling file: " + fileName); QCompiler.DecompileFile(fileName, QUtils.appOutPath); QUtils.AddLog("Decompiling done"); @@ -937,16 +1156,21 @@ private void DecompileQVM(string fileName) fileNameLabel.Text = Path.GetFileNameWithoutExtension(fileName) + QUtils.qvmFile; scintilla.Text = QUtils.LoadFile(scriptFilePath); QUtils.AddLog("Files path are {scriptFilePath} {fileNameLabel.Text}"); + QUtils.AddLog("Exiting method: DecompileQVM()"); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) - { + { QUtils.AddLog("Entering method: aboutToolStripMenuItem_Click()"); + QUtils.AddLog("aboutToolStripMenuItem_Click param sender = " + sender); + QUtils.AddLog("aboutToolStripMenuItem_Click param e = " + e); + string infoMsg = "Project IGI QVM Editor is tool to Edit QVM File in IGI 1 & IGI 2\n" + "Developed by: Haseeb Mir\n" + "App/Language: C# (.NET 4.0) / GUI.\n" + "Credits/Thanks: Artiom (QCompiler), Dark (UI/Tools).\n" + "Application Version: v" + QUtils.appVersion + "\n"; QUtils.ShowInfo(infoMsg); + QUtils.AddLog("Exiting method: aboutToolStripMenuItem_Click()"); } #endregion