From 2afdaf4ad39af3f32c9975cf718a38ae521e1c1c Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Mon, 15 Jul 2019 16:50:54 -0700 Subject: [PATCH] Implement Extension Script Info debug feature --- SourceGenWPF/MainController.cs | 58 ++++++++++-------- SourceGenWPF/SourceGenWPF.csproj | 7 +++ SourceGenWPF/Tools/WpfGui/ShowText.xaml | 34 +++++++++++ SourceGenWPF/Tools/WpfGui/ShowText.xaml.cs | 70 ++++++++++++++++++++++ SourceGenWPF/WpfGui/MainWindow.xaml | 13 ++-- SourceGenWPF/WpfGui/MainWindow.xaml.cs | 14 +++-- 6 files changed, 161 insertions(+), 35 deletions(-) create mode 100644 SourceGenWPF/Tools/WpfGui/ShowText.xaml create mode 100644 SourceGenWPF/Tools/WpfGui/ShowText.xaml.cs diff --git a/SourceGenWPF/MainController.cs b/SourceGenWPF/MainController.cs index f07c74a..3b56a60 100644 --- a/SourceGenWPF/MainController.cs +++ b/SourceGenWPF/MainController.cs @@ -2984,30 +2984,6 @@ namespace SourceGenWPF { #endif } - public void Debug_Refresh() { - Debug.WriteLine("Reanalyzing..."); - // Call through ApplyChanges so we update the timer task output. - UndoableChange uc = - UndoableChange.CreateDummyChange(UndoableChange.ReanalysisScope.CodeAndData); - ApplyChanges(new ChangeSet(uc), false); -#if false - UpdateMenuItemsAndTitle(); // in case something changed -#endif - } - - public void Debug_ToggleCommentRulers() { - MultiLineComment.DebugShowRuler = !MultiLineComment.DebugShowRuler; - // Don't need to repeat the analysis, but we do want to save/restore the - // selection and top position when the comment fields change size. - UndoableChange uc = - UndoableChange.CreateDummyChange(UndoableChange.ReanalysisScope.DataOnly); - ApplyChanges(new ChangeSet(uc), false); - } - - public void Debug_ToggleKeepAliveHack() { - ScriptManager.UseKeepAliveHack = !ScriptManager.UseKeepAliveHack; - } - #endregion References panel #region Notes panel @@ -3277,11 +3253,43 @@ namespace SourceGenWPF { #region Debug features - public void RunSourceGenerationTests() { + public void Debug_ExtensionScriptInfo() { + string info = mProject.DebugGetLoadedScriptInfo(); + + Tools.WpfGui.ShowText dlg = new Tools.WpfGui.ShowText(mMainWin, info); + dlg.Title = "Loaded Extension Script Info"; + dlg.ShowDialog(); + } + + public void Debug_RunSourceGenerationTests() { Tests.WpfGui.GenTestRunner dlg = new Tests.WpfGui.GenTestRunner(mMainWin); dlg.ShowDialog(); } + public void Debug_Refresh() { + Debug.WriteLine("Reanalyzing..."); + // Call through ApplyChanges so we update the timer task output. + UndoableChange uc = + UndoableChange.CreateDummyChange(UndoableChange.ReanalysisScope.CodeAndData); + ApplyChanges(new ChangeSet(uc), false); +#if false + UpdateMenuItemsAndTitle(); // in case something changed +#endif + } + + public void Debug_ToggleCommentRulers() { + MultiLineComment.DebugShowRuler = !MultiLineComment.DebugShowRuler; + // Don't need to repeat the analysis, but we do want to save/restore the + // selection and top position when the comment fields change size. + UndoableChange uc = + UndoableChange.CreateDummyChange(UndoableChange.ReanalysisScope.DataOnly); + ApplyChanges(new ChangeSet(uc), false); + } + + public void Debug_ToggleKeepAliveHack() { + ScriptManager.UseKeepAliveHack = !ScriptManager.UseKeepAliveHack; + } + #endregion } } diff --git a/SourceGenWPF/SourceGenWPF.csproj b/SourceGenWPF/SourceGenWPF.csproj index 0a2e050..0af819b 100644 --- a/SourceGenWPF/SourceGenWPF.csproj +++ b/SourceGenWPF/SourceGenWPF.csproj @@ -82,6 +82,9 @@ AsciiChart.xaml + + ShowText.xaml + AboutBox.xaml @@ -226,6 +229,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/SourceGenWPF/Tools/WpfGui/ShowText.xaml b/SourceGenWPF/Tools/WpfGui/ShowText.xaml new file mode 100644 index 0000000..1805e0f --- /dev/null +++ b/SourceGenWPF/Tools/WpfGui/ShowText.xaml @@ -0,0 +1,34 @@ + + + + + + + diff --git a/SourceGenWPF/Tools/WpfGui/ShowText.xaml.cs b/SourceGenWPF/Tools/WpfGui/ShowText.xaml.cs new file mode 100644 index 0000000..33c09a5 --- /dev/null +++ b/SourceGenWPF/Tools/WpfGui/ShowText.xaml.cs @@ -0,0 +1,70 @@ +/* + * Copyright 2019 faddenSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Windows; +using System.Windows.Input; + +namespace SourceGenWPF.Tools.WpfGui { + /// + /// Simple text display dialog. Can be modal or modeless. + /// + public partial class ShowText : Window, INotifyPropertyChanged { + /// + /// Text to display in the window. May be updated at any time. Bound to dialog property. + /// + public string DisplayText { + get { return mDisplayText; } + set { + mDisplayText = value; + OnPropertyChanged(); + } + } + private string mDisplayText; + + // INotifyPropertyChanged implementation + public event PropertyChangedEventHandler PropertyChanged; + private void OnPropertyChanged([CallerMemberName] string propertyName = "") { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + + /// + /// Constructor. Pass in an owner for modal dialogs, or null for modeless. + /// + public ShowText(Window owner, string initialText) { + InitializeComponent(); + Owner = owner; + DataContext = this; + + if (owner == null) { + // Modeless dialogs can get lost, so show them in the task bar. + ShowInTaskbar = true; + } + + DisplayText = initialText; + } + + // Catch ESC key. + private void Window_KeyEventHandler(object sender, KeyEventArgs e) { + if (e.Key == Key.Escape) { + Close(); + } + } + } +} diff --git a/SourceGenWPF/WpfGui/MainWindow.xaml b/SourceGenWPF/WpfGui/MainWindow.xaml index 1d51347..5843be0 100644 --- a/SourceGenWPF/WpfGui/MainWindow.xaml +++ b/SourceGenWPF/WpfGui/MainWindow.xaml @@ -56,7 +56,7 @@ limitations under the License. - + Del @@ -159,6 +159,7 @@ limitations under the License. + @@ -180,8 +181,8 @@ limitations under the License. CanExecute="IsProjectOpen" Executed="CopyCmd_Executed"/> - + + - + - + diff --git a/SourceGenWPF/WpfGui/MainWindow.xaml.cs b/SourceGenWPF/WpfGui/MainWindow.xaml.cs index 4043144..9321049 100644 --- a/SourceGenWPF/WpfGui/MainWindow.xaml.cs +++ b/SourceGenWPF/WpfGui/MainWindow.xaml.cs @@ -925,11 +925,6 @@ namespace SourceGenWPF.WpfGui { mMainCtrl.CopyToClipboard(); } - private void DebugSourceGenerationTestsCmd_Executed(object sender, - ExecutedRoutedEventArgs e) { - mMainCtrl.RunSourceGenerationTests(); - } - private void DeleteMlcCmd_Executed(object sender, ExecutedRoutedEventArgs e) { mMainCtrl.DeleteMlc(); } @@ -1113,10 +1108,19 @@ namespace SourceGenWPF.WpfGui { mMainCtrl.UndoChanges(); } + private void Debug_ExtensionScriptInfoCmd_Executed(object sender, ExecutedRoutedEventArgs e) { + mMainCtrl.Debug_ExtensionScriptInfo(); + } + private void Debug_RefreshCmd_Executed(object sender, ExecutedRoutedEventArgs e) { mMainCtrl.Debug_Refresh(); } + private void Debug_SourceGenerationTestsCmd_Executed(object sender, + ExecutedRoutedEventArgs e) { + mMainCtrl.Debug_RunSourceGenerationTests(); + } + private void Debug_ToggleCommentRulersCmd_Executed(object sender, ExecutedRoutedEventArgs e) { mMainCtrl.Debug_ToggleCommentRulers(); }