mirror of
https://github.com/fadden/6502bench.git
synced 2025-01-21 05:31:13 +00:00
Implement Toggle Data Scan
Had to fiddle with the menu item IsCheckable stuff for a bit, but I think the approach is reasonable.
This commit is contained in:
parent
99b484df4c
commit
0c5ae78eaf
@ -157,6 +157,18 @@ namespace SourceGenWPF {
|
||||
Disassembly = 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if a project is open and AnalyzeUncategorizedData is enabled.
|
||||
/// </summary>
|
||||
public bool IsAnalyzeUncategorizedDataEnabled {
|
||||
get {
|
||||
if (mProject == null) {
|
||||
return false;
|
||||
}
|
||||
return mProject.ProjectProps.AnalysisParams.AnalyzeUncategorizedData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Init and settings
|
||||
|
||||
@ -2049,6 +2061,15 @@ namespace SourceGenWPF {
|
||||
dlg.ShowDialog();
|
||||
}
|
||||
|
||||
public void ToggleDataScan() {
|
||||
ProjectProperties oldProps = mProject.ProjectProps;
|
||||
ProjectProperties newProps = new ProjectProperties(oldProps);
|
||||
newProps.AnalysisParams.AnalyzeUncategorizedData =
|
||||
!newProps.AnalysisParams.AnalyzeUncategorizedData;
|
||||
UndoableChange uc = UndoableChange.CreateProjectPropertiesChange(oldProps, newProps);
|
||||
ApplyUndoableChanges(new ChangeSet(uc));
|
||||
}
|
||||
|
||||
#endregion Main window UI event handlers
|
||||
|
||||
|
||||
|
@ -110,6 +110,11 @@ limitations under the License.
|
||||
<KeyGesture>Ctrl+A</KeyGesture>
|
||||
</RoutedUICommand.InputGestures>
|
||||
</RoutedUICommand>
|
||||
<RoutedUICommand x:Key="ToggleDataScanCmd" Text="Toggle Data Scan">
|
||||
<RoutedUICommand.InputGestures>
|
||||
<KeyGesture>Ctrl+D</KeyGesture>
|
||||
</RoutedUICommand.InputGestures>
|
||||
</RoutedUICommand>
|
||||
<RoutedUICommand x:Key="UndoCmd" Text="Undo">
|
||||
<RoutedUICommand.InputGestures>
|
||||
<KeyGesture>Ctrl+Z</KeyGesture>
|
||||
@ -181,6 +186,8 @@ limitations under the License.
|
||||
<!-- ListView has a built-in Ctrl+A handler; this only fires when codeListView is not in focus -->
|
||||
<CommandBinding Command="{StaticResource SelectAllCmd}"
|
||||
CanExecute="IsProjectOpen" Executed="SelectAllCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource ToggleDataScanCmd}"
|
||||
CanExecute="IsProjectOpen" Executed="ToggleDataScanCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource UndoCmd}"
|
||||
CanExecute="CanUndo" Executed="UndoCmd_Executed"/>
|
||||
</Window.CommandBindings>
|
||||
@ -203,7 +210,7 @@ limitations under the License.
|
||||
<Separator/>
|
||||
<MenuItem Command="{StaticResource ExitCmd}" InputGestureText="Alt+F4"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Edit">
|
||||
<MenuItem Header="_Edit" SubmenuOpened="EditMenu_SubmenuOpened">
|
||||
<MenuItem Command="{StaticResource UndoCmd}"/>
|
||||
<MenuItem Command="{StaticResource RedoCmd}"/>
|
||||
<Separator/>
|
||||
@ -216,7 +223,9 @@ limitations under the License.
|
||||
<Separator/>
|
||||
<MenuItem Command="{StaticResource EditHeaderCommentCmd}"/>
|
||||
<MenuItem Command="Properties" Header="Project Properties..."/>
|
||||
<MenuItem Header="Toggle Data Scan"/> <!-- Ctrl+D -->
|
||||
<!-- IsChecked is set whenever the menu is opened -->
|
||||
<MenuItem Name="toggleDataScanMenuItem"
|
||||
Command="{StaticResource ToggleDataScanCmd}" IsCheckable="True"/>
|
||||
<Separator/>
|
||||
<MenuItem Command="{StaticResource EditAppSettingsCmd}"/>
|
||||
</MenuItem>
|
||||
|
@ -967,6 +967,10 @@ namespace SourceGenWPF.WpfGui {
|
||||
mMainCtrl.OpenRecentProject(recentIndex);
|
||||
}
|
||||
|
||||
private void ToggleDataScanCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.ToggleDataScan();
|
||||
}
|
||||
|
||||
private void UndoCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.UndoChanges();
|
||||
}
|
||||
@ -1034,6 +1038,24 @@ namespace SourceGenWPF.WpfGui {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update menu items when the "edit" menu is opened.
|
||||
/// </summary>
|
||||
private void EditMenu_SubmenuOpened(object sender, RoutedEventArgs e) {
|
||||
// Set the checkbox on the "Toggle Data Scan" item.
|
||||
//
|
||||
// I initially bound a property to the menu item's IsChecked, but that caused
|
||||
// us to get "set" calls when the menu was selected. I want to get activity
|
||||
// through ICommand, not property set, so things are consistent for menus and
|
||||
// keyboard shortcuts. So we just drive the checkbox manually. I don't know
|
||||
// if there's a better way.
|
||||
//
|
||||
// The project's AnalyzeUncategorizedData property can be set in various ways
|
||||
// (project property dialog, undo, redo), so we want to query it when we need
|
||||
// it rather than try to push changes around.
|
||||
toggleDataScanMenuItem.IsChecked = mMainCtrl.IsAnalyzeUncategorizedDataEnabled;
|
||||
}
|
||||
|
||||
#endregion Misc
|
||||
|
||||
|
||||
@ -1262,6 +1284,5 @@ namespace SourceGenWPF.WpfGui {
|
||||
private string mInfoBoxContents;
|
||||
|
||||
#endregion Info panel
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user