mirror of
https://github.com/fadden/6502bench.git
synced 2025-01-16 19:32:31 +00:00
Implement debug info windows
Show analysis timers, show analyzer output, and show undo/redo history. With this change, all main menu items have been ported to WPF.
This commit is contained in:
parent
2afdaf4ad3
commit
b93def6560
@ -68,6 +68,14 @@ namespace SourceGenWPF {
|
||||
/// </summary>
|
||||
private Tools.WpfGui.HexDumpViewer mHexDumpDialog;
|
||||
|
||||
// Debug windows.
|
||||
private Tools.WpfGui.ShowText mShowAnalysisTimersDialog;
|
||||
public bool IsDebugAnalysisTimersOpen { get { return mShowAnalysisTimersDialog != null; } }
|
||||
private Tools.WpfGui.ShowText mShowAnalyzerOutputDialog;
|
||||
public bool IsDebugAnalyzerOutputOpen { get { return mShowAnalyzerOutputDialog != null; } }
|
||||
private Tools.WpfGui.ShowText mShowUndoRedoHistoryDialog;
|
||||
public bool IsDebugUndoRedoHistoryOpen { get { return mShowUndoRedoHistoryDialog != null; } }
|
||||
|
||||
/// <summary>
|
||||
/// This holds any un-owned Windows that we don't otherwise track. It's used for
|
||||
/// hex dump windows of arbitrary files. We need to close them when the main window
|
||||
@ -645,12 +653,12 @@ namespace SourceGenWPF {
|
||||
mProject.PushChangeSet(cs);
|
||||
#if false
|
||||
UpdateMenuItemsAndTitle();
|
||||
#endif
|
||||
|
||||
// If the debug dialog is visible, update it.
|
||||
if (mShowUndoRedoHistoryDialog != null) {
|
||||
mShowUndoRedoHistoryDialog.BodyText = mProject.DebugGetUndoRedoHistory();
|
||||
mShowUndoRedoHistoryDialog.DisplayText = mProject.DebugGetUndoRedoHistory();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -711,12 +719,10 @@ namespace SourceGenWPF {
|
||||
mReanalysisTimer.EndTask("ProjectView.ApplyChanges()");
|
||||
|
||||
//mReanalysisTimer.DumpTimes("ProjectView timers:", mGenerationLog);
|
||||
#if false
|
||||
if (mShowAnalysisTimersDialog != null) {
|
||||
string timerStr = mReanalysisTimer.DumpToString("ProjectView timers:");
|
||||
mShowAnalysisTimersDialog.BodyText = timerStr;
|
||||
mShowAnalysisTimersDialog.DisplayText = timerStr;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Lines may have moved around. Update the selection highlight. It's important
|
||||
// we do it here, and not down in DoRefreshProject(), because at that point the
|
||||
@ -817,11 +823,9 @@ namespace SourceGenWPF {
|
||||
//mGenerationLog.WriteToFile(@"C:\Src\WorkBench\SourceGen\TestData\_log.txt");
|
||||
//mReanalysisTimer.EndTask("Save _log");
|
||||
|
||||
#if false
|
||||
if (mShowAnalyzerOutputDialog != null) {
|
||||
mShowAnalyzerOutputDialog.BodyText = mGenerationLog.WriteToString();
|
||||
mShowAnalyzerOutputDialog.DisplayText = mGenerationLog.WriteToString();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
mReanalysisTimer.StartTask("Generate DisplayList");
|
||||
@ -1097,11 +1101,11 @@ namespace SourceGenWPF {
|
||||
}
|
||||
|
||||
mProject.ResetDirtyFlag();
|
||||
#if false
|
||||
// If the debug dialog is visible, update it.
|
||||
if (mShowUndoRedoHistoryDialog != null) {
|
||||
mShowUndoRedoHistoryDialog.BodyText = mProject.DebugGetUndoRedoHistory();
|
||||
mShowUndoRedoHistoryDialog.DisplayText = mProject.DebugGetUndoRedoHistory();
|
||||
}
|
||||
#if false
|
||||
UpdateMenuItemsAndTitle();
|
||||
#endif
|
||||
|
||||
@ -1126,12 +1130,12 @@ namespace SourceGenWPF {
|
||||
|
||||
// WPF won't exit until all windows are closed, so any unowned windows need
|
||||
// to be cleaned up here.
|
||||
if (mAsciiChartDialog != null) {
|
||||
mAsciiChartDialog.Close();
|
||||
}
|
||||
if (mHexDumpDialog != null) {
|
||||
mHexDumpDialog.Close();
|
||||
}
|
||||
mAsciiChartDialog?.Close();
|
||||
mHexDumpDialog?.Close();
|
||||
mShowAnalysisTimersDialog?.Close();
|
||||
mShowAnalyzerOutputDialog?.Close();
|
||||
mShowUndoRedoHistoryDialog?.Close();
|
||||
|
||||
while (mUnownedWindows.Count > 0) {
|
||||
int count = mUnownedWindows.Count;
|
||||
mUnownedWindows[0].Close();
|
||||
@ -1167,21 +1171,11 @@ namespace SourceGenWPF {
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
// Close modeless dialogs that depend on project.
|
||||
if (mShowUndoRedoHistoryDialog != null) {
|
||||
mShowUndoRedoHistoryDialog.Close();
|
||||
}
|
||||
if (mShowAnalysisTimersDialog != null) {
|
||||
mShowAnalysisTimersDialog.Close();
|
||||
}
|
||||
if (mShowAnalyzerOutputDialog != null) {
|
||||
mShowAnalyzerOutputDialog.Close();
|
||||
}
|
||||
#endif
|
||||
if (mHexDumpDialog != null) {
|
||||
mHexDumpDialog.Close();
|
||||
}
|
||||
mHexDumpDialog?.Close();
|
||||
mShowAnalysisTimersDialog?.Close();
|
||||
mShowAnalyzerOutputDialog?.Close();
|
||||
mShowUndoRedoHistoryDialog?.Close();
|
||||
|
||||
// Discard all project state.
|
||||
if (mProject != null) {
|
||||
@ -2952,12 +2946,12 @@ namespace SourceGenWPF {
|
||||
ApplyChanges(cs, true);
|
||||
#if false
|
||||
UpdateMenuItemsAndTitle();
|
||||
#endif
|
||||
|
||||
// If the debug dialog is visible, update it.
|
||||
if (mShowUndoRedoHistoryDialog != null) {
|
||||
mShowUndoRedoHistoryDialog.BodyText = mProject.DebugGetUndoRedoHistory();
|
||||
mShowUndoRedoHistoryDialog.DisplayText = mProject.DebugGetUndoRedoHistory();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public bool CanRedo() {
|
||||
@ -2976,12 +2970,12 @@ namespace SourceGenWPF {
|
||||
ApplyChanges(cs, false);
|
||||
#if false
|
||||
UpdateMenuItemsAndTitle();
|
||||
#endif
|
||||
|
||||
// If the debug dialog is visible, update it.
|
||||
if (mShowUndoRedoHistoryDialog != null) {
|
||||
mShowUndoRedoHistoryDialog.BodyText = mProject.DebugGetUndoRedoHistory();
|
||||
mShowUndoRedoHistoryDialog.DisplayText = mProject.DebugGetUndoRedoHistory();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion References panel
|
||||
@ -3261,6 +3255,55 @@ namespace SourceGenWPF {
|
||||
dlg.ShowDialog();
|
||||
}
|
||||
|
||||
public void Debug_ShowAnalysisTimers() {
|
||||
if (mShowAnalysisTimersDialog == null) {
|
||||
Tools.WpfGui.ShowText dlg = new Tools.WpfGui.ShowText(null, "(no data yet)");
|
||||
dlg.Title = "Analysis Timers";
|
||||
dlg.Closing += (sender, e) => {
|
||||
Debug.WriteLine("Analysis timers dialog closed");
|
||||
mShowAnalysisTimersDialog = null;
|
||||
};
|
||||
dlg.Show();
|
||||
mShowAnalysisTimersDialog = dlg;
|
||||
} else {
|
||||
// Ask the dialog to close. Do the cleanup in the event.
|
||||
mShowAnalysisTimersDialog.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Debug_ShowAnalyzerOutput() {
|
||||
if (mShowAnalyzerOutputDialog == null) {
|
||||
Tools.WpfGui.ShowText dlg = new Tools.WpfGui.ShowText(null, "(no data yet)");
|
||||
dlg.Title = "Analyzer Output";
|
||||
dlg.Closing += (sender, e) => {
|
||||
Debug.WriteLine("Analyzer output dialog closed");
|
||||
mShowAnalyzerOutputDialog = null;
|
||||
};
|
||||
dlg.Show();
|
||||
mShowAnalyzerOutputDialog = dlg;
|
||||
} else {
|
||||
// Ask the dialog to close. Do the cleanup in the event.
|
||||
mShowAnalyzerOutputDialog.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Debug_ShowUndoRedoHistory() {
|
||||
if (mShowUndoRedoHistoryDialog == null) {
|
||||
Tools.WpfGui.ShowText dlg = new Tools.WpfGui.ShowText(null,
|
||||
mProject.DebugGetUndoRedoHistory());
|
||||
dlg.Title = "Undo/Redo History";
|
||||
dlg.Closing += (sender, e) => {
|
||||
Debug.WriteLine("Undo/redo history dialog closed");
|
||||
mShowUndoRedoHistoryDialog = null;
|
||||
};
|
||||
dlg.Show();
|
||||
mShowUndoRedoHistoryDialog = dlg;
|
||||
} else {
|
||||
// Ask the dialog to close. Do the cleanup in the event.
|
||||
mShowUndoRedoHistoryDialog.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Debug_RunSourceGenerationTests() {
|
||||
Tests.WpfGui.GenTestRunner dlg = new Tests.WpfGui.GenTestRunner(mMainWin);
|
||||
dlg.ShowDialog();
|
||||
|
@ -53,7 +53,9 @@ namespace SourceGenWPF.Tools.WpfGui {
|
||||
DataContext = this;
|
||||
|
||||
if (owner == null) {
|
||||
// Modeless dialogs can get lost, so show them in the task bar.
|
||||
// Modeless dialogs can get lost, so show them in the task bar. There's no
|
||||
// "is modal" property in WPF, though we can fake it with a hack:
|
||||
// https://stackoverflow.com/a/1266900/294248
|
||||
ShowInTaskbar = true;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ limitations under the License.
|
||||
</RoutedUICommand.InputGestures>
|
||||
</RoutedUICommand>
|
||||
<RoutedUICommand x:Key="CloseCmd" Text="Close"/>
|
||||
<RoutedUICommand x:Key="Debug_SourceGenerationTestsCmd" Text="Source Generation Tests..."/>
|
||||
<RoutedUICommand x:Key="DeleteMlcCmd" Text="Delete Note/Long Comment">
|
||||
<RoutedUICommand.InputGestures>
|
||||
<KeyGesture>Del</KeyGesture>
|
||||
@ -160,6 +159,10 @@ limitations under the License.
|
||||
</RoutedUICommand>
|
||||
|
||||
<RoutedUICommand x:Key="Debug_ExtensionScriptInfoCmd" Text="Extension Script Info..."/>
|
||||
<RoutedUICommand x:Key="Debug_ShowAnalysisTimersCmd" Text="Show Analysis Timers"/>
|
||||
<RoutedUICommand x:Key="Debug_ShowAnalyzerOutputCmd" Text="Show Analyzer Output"/>
|
||||
<RoutedUICommand x:Key="Debug_ShowUndoRedoHistoryCmd" Text="Show Undo/Redo History"/>
|
||||
<RoutedUICommand x:Key="Debug_SourceGenerationTestsCmd" Text="Source Generation Tests..."/>
|
||||
<RoutedUICommand x:Key="Debug_ToggleCommentRulersCmd" Text="Show Comment Rulers"/>
|
||||
<RoutedUICommand x:Key="Debug_ToggleKeepAliveHackCmd" Text="Use Keep-Alive Hack"/>
|
||||
|
||||
@ -261,6 +264,12 @@ limitations under the License.
|
||||
CanExecute="IsProjectOpen" Executed="Debug_RefreshCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource Debug_ExtensionScriptInfoCmd}"
|
||||
CanExecute="IsProjectOpen" Executed="Debug_ExtensionScriptInfoCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource Debug_ShowAnalysisTimersCmd}"
|
||||
CanExecute="IsProjectOpen" Executed="Debug_ShowAnalysisTimersCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource Debug_ShowAnalyzerOutputCmd}"
|
||||
CanExecute="IsProjectOpen" Executed="Debug_ShowAnalyzerOutputCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource Debug_ShowUndoRedoHistoryCmd}"
|
||||
CanExecute="IsProjectOpen" Executed="Debug_ShowUndoRedoHistoryCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource Debug_ToggleCommentRulersCmd}"
|
||||
Executed="Debug_ToggleCommentRulersCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource Debug_ToggleKeepAliveHackCmd}"
|
||||
@ -338,9 +347,12 @@ limitations under the License.
|
||||
<MenuItem Header="_DEBUG" Name="DebugMenu" SubmenuOpened="DebugMenu_SubmenuOpened"
|
||||
Visibility="{Binding ShowDebugMenu, Converter={StaticResource BoolToVis}}">
|
||||
<MenuItem Command="Refresh" Header="Re-analyze"/>
|
||||
<MenuItem Header="Show Undo/Redo History"/>
|
||||
<MenuItem Header="Show Analyzer Output"/>
|
||||
<MenuItem Header="Show Analysis Timers"/>
|
||||
<MenuItem Name ="debugUndoRedoHistoryMenuItem"
|
||||
Command="{StaticResource Debug_ShowUndoRedoHistoryCmd}" IsCheckable="True"/>
|
||||
<MenuItem Name="debugAnalyzerOutputMenuItem"
|
||||
Command="{StaticResource Debug_ShowAnalyzerOutputCmd}" IsCheckable="True"/>
|
||||
<MenuItem Name="debugAnalysisTimersMenuItem"
|
||||
Command="{StaticResource Debug_ShowAnalysisTimersCmd}" IsCheckable="True"/>
|
||||
<MenuItem Command="{StaticResource Debug_ExtensionScriptInfoCmd}"/>
|
||||
<Separator/>
|
||||
<MenuItem Name="debugCommentRulersMenuItem"
|
||||
|
@ -1116,6 +1116,21 @@ namespace SourceGenWPF.WpfGui {
|
||||
mMainCtrl.Debug_Refresh();
|
||||
}
|
||||
|
||||
private void Debug_ShowAnalysisTimersCmd_Executed(object sender,
|
||||
ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.Debug_ShowAnalysisTimers();
|
||||
}
|
||||
|
||||
private void Debug_ShowAnalyzerOutputCmd_Executed(object sender,
|
||||
ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.Debug_ShowAnalyzerOutput();
|
||||
}
|
||||
|
||||
private void Debug_ShowUndoRedoHistoryCmd_Executed(object sender,
|
||||
ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.Debug_ShowUndoRedoHistory();
|
||||
}
|
||||
|
||||
private void Debug_SourceGenerationTestsCmd_Executed(object sender,
|
||||
ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.Debug_RunSourceGenerationTests();
|
||||
@ -1215,6 +1230,9 @@ namespace SourceGenWPF.WpfGui {
|
||||
private void DebugMenu_SubmenuOpened(object sender, RoutedEventArgs e) {
|
||||
debugCommentRulersMenuItem.IsChecked = MultiLineComment.DebugShowRuler;
|
||||
debugKeepAliveHackMenuItem.IsChecked = Sandbox.ScriptManager.UseKeepAliveHack;
|
||||
debugAnalysisTimersMenuItem.IsChecked = mMainCtrl.IsDebugAnalysisTimersOpen;
|
||||
debugAnalyzerOutputMenuItem.IsChecked = mMainCtrl.IsDebugAnalyzerOutputOpen;
|
||||
debugUndoRedoHistoryMenuItem.IsChecked = mMainCtrl.IsDebugUndoRedoHistoryOpen;
|
||||
}
|
||||
|
||||
#endregion Misc
|
||||
|
Loading…
x
Reference in New Issue
Block a user