1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-25 05:29:31 +00:00

Add status flag editing

Getting the layout just right got a little wordy in XAML.  There's
probably a way to make a Grid do what I want.  This'll do for now.

Also, fixed the labels on the buttons in DiscardChanges, which were
reversed.
This commit is contained in:
Andy McFadden 2019-06-21 15:06:04 -07:00
parent ea6125ea82
commit fdf53bdb34
8 changed files with 500 additions and 37 deletions

View File

@ -966,7 +966,10 @@ namespace SourceGenWPF {
return false;
}
// Save the project. If it hasn't been saved before, use save-as behavior instead.
/// <summary>
/// Save the project. If it hasn't been saved before, use save-as behavior instead.
/// </summary>
/// <returns>True on success, false if the save attempt failed.</returns>
private bool DoSave() {
if (string.IsNullOrEmpty(mProjectPathName)) {
return DoSaveAs();
@ -1054,6 +1057,7 @@ namespace SourceGenWPF {
}
mDataPathName = null;
mProjectPathName = null;
mTargetHighlightIndex = -1;
#if false
mSymbolSubset = new SymbolTableSubset(new SymbolTable());
#endif
@ -1101,11 +1105,9 @@ namespace SourceGenWPF {
}
break;
case LineListGen.Line.Type.RegWidthDirective:
#if false
if (overrideStatusFlagsToolStripMenuItem.Enabled) {
EditStatusFlags_Click(sender, e);
if (CanEditStatusFlags()) {
EditStatusFlags();
}
#endif
break;
case LineListGen.Line.Type.LongComment:
#if false
@ -1143,11 +1145,9 @@ namespace SourceGenWPF {
#endif
break;
case ColumnIndex.Flags:
#if false
if (overrideStatusFlagsToolStripMenuItem.Enabled) {
EditStatusFlags_Click(sender, e);
if (CanEditStatusFlags()) {
EditStatusFlags();
}
#endif
break;
case ColumnIndex.Attributes:
// does nothing
@ -1230,8 +1230,7 @@ namespace SourceGenWPF {
Anattrib attr = mProject.GetAnattrib(offset);
EditAddress dlg = new EditAddress(mMainWin, attr.Address, mProject.CpuDef.MaxAddressValue);
bool? ok = dlg.ShowDialog();
if (ok != true) {
if (dlg.ShowDialog() != true) {
return;
}
@ -1258,6 +1257,34 @@ namespace SourceGenWPF {
}
}
public bool CanEditStatusFlags() {
if (SelectionAnalysis.mNumItemsSelected != 1) {
return false;
}
EntityCounts counts = SelectionAnalysis.mEntityCounts;
// Line must be code, or a RegWidth directive.
return (SelectionAnalysis.mLineType == LineListGen.Line.Type.Code ||
SelectionAnalysis.mLineType == LineListGen.Line.Type.RegWidthDirective);
}
public void EditStatusFlags() {
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
int offset = CodeLineList[selIndex].FileOffset;
EditStatusFlags dlg = new EditStatusFlags(mMainWin,
mProject.StatusFlagOverrides[offset], mProject.CpuDef.HasEmuFlag);
if (dlg.ShowDialog() != true) {
return;
}
if (dlg.FlagValue != mProject.StatusFlagOverrides[offset]) {
UndoableChange uc = UndoableChange.CreateStatusFlagChange(offset,
mProject.StatusFlagOverrides[offset], dlg.FlagValue);
ChangeSet cs = new ChangeSet(uc);
ApplyUndoableChanges(cs);
}
}
/// <summary>
/// Moves the view and selection to the specified offset. We want to select stuff
/// differently if we're jumping to a note vs. jumping to an instruction.
@ -1318,23 +1345,6 @@ namespace SourceGenWPF {
}
}
/// <summary>
/// Scrolls the code list so that the specified label is shown.
/// </summary>
/// <param name="sym">Label symbol.</param>
public void GoToLabel(Symbol sym) {
if (sym.IsInternalLabel) {
int offset = mProject.FindLabelOffsetByName(sym.Label);
if (offset >= 0) {
GoToOffset(offset, false, true);
} else {
Debug.WriteLine("DClick symbol: " + sym + ": label not found");
}
} else {
Debug.WriteLine("DClick symbol: " + sym + ": not label");
}
}
public bool CanNavigateBackward() {
return mNavStack.HasBackward;
}
@ -1353,6 +1363,23 @@ namespace SourceGenWPF {
GoToOffset(fwdOff, false, false);
}
/// <summary>
/// Scrolls the code list so that the specified label is shown.
/// </summary>
/// <param name="sym">Label symbol.</param>
public void GoToLabel(Symbol sym) {
if (sym.IsInternalLabel) {
int offset = mProject.FindLabelOffsetByName(sym.Label);
if (offset >= 0) {
GoToOffset(offset, false, true);
} else {
Debug.WriteLine("DClick symbol: " + sym + ": label not found");
}
} else {
Debug.WriteLine("DClick symbol: " + sym + ": not label");
}
}
public void SelectionChanged() {
SelectionAnalysis = UpdateSelectionState();

View File

@ -22,15 +22,20 @@ limitations under the License.
xmlns:local="clr-namespace:SourceGenWPF.ProjWin"
mc:Ignorable="d"
Title="Discard Changes?"
FocusManager.FocusedElement="{Binding ElementName=cancelButton}"
SizeToContent="WidthAndHeight" ResizeMode="NoResize"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner">
<StackPanel Margin="8">
<TextBlock Text="You have unsaved changes that will be lost if you continue."/>
<TextBlock Margin="0,8,0,0" Text="How do you wish to proceed?"/>
<StackPanel Margin="0,16,0,0" Orientation="Horizontal">
<Button Name="dontSaveButton" Width="120" Content="_Save &amp; Continue" Click="DontSaveButton_Click"/>
<Button Name="saveButton" Width="120" Margin="8,0,0,0" Content="_Discard &amp; Continue" Click="SaveButton_Click"/>
<Button Name="cancelButton" Width="120" Margin="8,0,0,0" Content="Cancel" IsCancel="True"/>
<Button Name="saveButton" Width="120"
Content="_Save &amp; Continue" Click="SaveButton_Click"/>
<Button Name="dontSaveButton" Width="120" Margin="8,0,0,0"
Content="_Discard &amp; Continue" Click="DontSaveButton_Click"/>
<Button Name="cancelButton" Width="120" Margin="8,0,0,0"
Content="Cancel" IsCancel="True"/>
</StackPanel>
</StackPanel>
</Window>

View File

@ -36,10 +36,6 @@ namespace SourceGenWPF.ProjWin {
Owner = owner;
}
// TODO:
// https://stackoverflow.com/questions/817610/wpf-and-initial-focus
// FocusManager.FocusedElement={Binding ElementName=cancelButton}"
private void SaveButton_Click(object sender, RoutedEventArgs e) {
UserChoice = Choice.SaveAndContinue;
DialogResult = true;

View File

@ -0,0 +1,242 @@
<!--
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.
-->
<Window x:Class="SourceGenWPF.ProjWin.EditStatusFlags"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SourceGenWPF.ProjWin"
mc:Ignorable="d"
Title="Override Status Flags"
SizeToContent="WidthAndHeight" ResizeMode="NoResize"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded">
<Window.Resources>
<Thickness x:Key="Spacer" Left="0" Top="1" Right="0" Bottom="0"/>
</Window.Resources>
<StackPanel Margin="8">
<TextBlock>Override the processor state values determined by the code analyzer.</TextBlock>
<StackPanel Orientation="Horizontal" Margin="0,8,0,0" >
<StackPanel>
<TextBlock FontSize="16" Margin="0,0,0,-1"/>
<TextBlock HorizontalAlignment="Right" Margin="{StaticResource Spacer}">Default</TextBlock>
<TextBlock HorizontalAlignment="Right" Margin="{StaticResource Spacer}">Zero</TextBlock>
<TextBlock HorizontalAlignment="Right" Margin="{StaticResource Spacer}">One</TextBlock>
<TextBlock HorizontalAlignment="Right" Margin="{StaticResource Spacer}">Indeterminate</TextBlock>
</StackPanel>
<!-- RadioButton and TextBlock don't have the same vertical dimensions, so we
use a StackPanel with one of each to make the buttons line up with the labels.
Unfortunately this foils the automatic grouping. -->
<StackPanel Margin="8,0,0,0">
<TextBlock HorizontalAlignment="Center" FontSize="16">N</TextBlock>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioNDefault" GroupName="N" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioNZero" GroupName="N" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioNOne" GroupName="N" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioNIndeterminate" GroupName="N" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
</StackPanel>
<StackPanel Margin="8,0,0,0">
<TextBlock HorizontalAlignment="Center" FontSize="16">V</TextBlock>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioVDefault" GroupName="V" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioVZero" GroupName="V" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioVOne" GroupName="V" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioVIndeterminate" GroupName="V" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
</StackPanel>
<StackPanel Name="panelM" Margin="8,0,0,0">
<TextBlock HorizontalAlignment="Center" FontSize="16">M</TextBlock>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioMDefault" GroupName="M" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioMZero" GroupName="M" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioMOne" GroupName="M" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioMIndeterminate" GroupName="M" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
</StackPanel>
<StackPanel Name="panelX" Margin="8,0,0,0">
<TextBlock HorizontalAlignment="Center" FontSize="16">X</TextBlock>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioXDefault" GroupName="X" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioXZero" GroupName="X" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioXOne" GroupName="X" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioXIndeterminate" GroupName="X" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
</StackPanel>
<StackPanel Margin="8,0,0,0">
<TextBlock HorizontalAlignment="Center" FontSize="16">D</TextBlock>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioDDefault" GroupName="D" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioDZero" GroupName="D" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioDOne" GroupName="D" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioDIndeterminate" GroupName="D" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
</StackPanel>
<StackPanel Margin="8,0,0,0">
<TextBlock FontSize="16" HorizontalAlignment="Center">I</TextBlock>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioIDefault" GroupName="I" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioIZero" GroupName="I" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioIOne" GroupName="I" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioIIndeterminate" GroupName="I" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
</StackPanel>
<StackPanel Margin="8,0,0,0">
<TextBlock HorizontalAlignment="Center" FontSize="16">Z</TextBlock>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioZDefault" GroupName="Z" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioZZero" GroupName="Z" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioZOne" GroupName="Z" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioZIndeterminate" GroupName="Z" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
</StackPanel>
<StackPanel Margin="8,0,0,0">
<TextBlock HorizontalAlignment="Center" FontSize="16">C</TextBlock>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioCDefault" GroupName="C" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioCZero" GroupName="C" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioCOne" GroupName="C" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioCIndeterminate" GroupName="C" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
</StackPanel>
<StackPanel Name="panelE" Margin="16,0,0,0">
<TextBlock HorizontalAlignment="Center" FontSize="16">E</TextBlock>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioEDefault" GroupName="E" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioEZero" GroupName="E" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioEOne" GroupName="E" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton Name="radioEIndeterminate" GroupName="E" Margin="{StaticResource Spacer}"/>
<TextBlock Margin="{StaticResource Spacer}"/>
</StackPanel>
</StackPanel>
</StackPanel>
<TextBlock Margin="0,8,0,0">Tip: to configure 16-bit wide regs on 65802/65816, set M, X, and E to 0.</TextBlock>
<DockPanel Margin="0,16,0,0" LastChildFill="False">
<Button DockPanel.Dock="Left" Name="resetButton" Content="Reset to Default"
Width="120" Click="ResetButton_Click" HorizontalAlignment="Left"/>
<Button DockPanel.Dock="Right" Name="cancelButton" Content="Cancel" IsCancel="True"
Width="70" Margin="4,0,0,0"/>
<Button DockPanel.Dock="Right" Name="okButton" Content="OK" IsDefault="True"
Width="70" Click="OkButton_Click"/>
</DockPanel>
</StackPanel>
</Window>

View File

@ -0,0 +1,169 @@
/*
* 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.Windows;
using System.Windows.Controls;
using Asm65;
namespace SourceGenWPF.ProjWin {
/// <summary>
/// Edit Status Flags dialog.
/// </summary>
public partial class EditStatusFlags : Window {
/// <summary>
/// Edited status flag value.
/// </summary>
public StatusFlags FlagValue { get; private set; }
/// <summary>
/// Set this if the CPU has an emulation flag (65802/65816). If this isn't
/// set, the M, X, and E flag buttons will be disabled.
/// </summary>
private bool mHasEmuFlag;
public EditStatusFlags(Window owner, StatusFlags flagValue, bool hasEmuFlag) {
InitializeComponent();
FlagValue = flagValue;
mHasEmuFlag = hasEmuFlag;
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
if (!mHasEmuFlag) {
panelM.IsEnabled = false;
panelX.IsEnabled = false;
panelE.IsEnabled = false;
// I'm not going to force the M/X/E flags to have a particular value based
// on the CPU definition. The flags aren't used for non-65802/65816, so
// the values are irrelevant. If somebody is switching between CPUs I think
// it'd be weird to force the values during editing but leave any non-edited
// values alone. If they want to switch to 65816, set M/X/E, and then switch
// back, they're welcome to do so.
}
SetCheckedButtons();
}
private void OkButton_Click(object sender, RoutedEventArgs e) {
StatusFlags flags = new StatusFlags();
flags.N = GetChecked(radioNDefault, radioNZero, radioNOne, radioNIndeterminate);
flags.V = GetChecked(radioVDefault, radioVZero, radioVOne, radioVIndeterminate);
flags.M = GetChecked(radioMDefault, radioMZero, radioMOne, radioMIndeterminate);
flags.X = GetChecked(radioXDefault, radioXZero, radioXOne, radioXIndeterminate);
flags.D = GetChecked(radioDDefault, radioDZero, radioDOne, radioDIndeterminate);
flags.I = GetChecked(radioIDefault, radioIZero, radioIOne, radioIIndeterminate);
flags.Z = GetChecked(radioZDefault, radioZZero, radioZOne, radioZIndeterminate);
flags.C = GetChecked(radioCDefault, radioCZero, radioCOne, radioCIndeterminate);
flags.E = GetChecked(radioEDefault, radioEZero, radioEOne, radioEIndeterminate);
//// If they're setting emulation mode, also set M/X to 1. This is implicitly
//// true, but things are a bit clearer if we make it explicit.
//if (flags.E == 1) {
// flags.M = flags.X = 1;
//}
FlagValue = flags;
DialogResult = true;
}
private void ResetButton_Click(object sender, EventArgs e) {
FlagValue = new StatusFlags();
SetCheckedButtons();
}
/// <summary>
/// Calls SetChecked() for each flag.
/// </summary>
private void SetCheckedButtons() {
SetChecked(FlagValue.N, radioNDefault, radioNZero, radioNOne, radioNIndeterminate);
SetChecked(FlagValue.V, radioVDefault, radioVZero, radioVOne, radioVIndeterminate);
SetChecked(FlagValue.M, radioMDefault, radioMZero, radioMOne, radioMIndeterminate);
SetChecked(FlagValue.X, radioXDefault, radioXZero, radioXOne, radioXIndeterminate);
SetChecked(FlagValue.D, radioDDefault, radioDZero, radioDOne, radioDIndeterminate);
SetChecked(FlagValue.I, radioIDefault, radioIZero, radioIOne, radioIIndeterminate);
SetChecked(FlagValue.Z, radioZDefault, radioZZero, radioZOne, radioZIndeterminate);
SetChecked(FlagValue.C, radioCDefault, radioCZero, radioCOne, radioCIndeterminate);
SetChecked(FlagValue.E, radioEDefault, radioEZero, radioEOne, radioEIndeterminate);
}
/// <summary>
/// Sets the "checked" flag on the appropriate radio button.
/// </summary>
private void SetChecked(int value, RadioButton def, RadioButton zero, RadioButton one,
RadioButton indeterminate) {
switch (value) {
case TriState16.UNSPECIFIED:
def.IsChecked = true;
break;
case TriState16.INDETERMINATE:
indeterminate.IsChecked = true;
break;
case 0:
zero.IsChecked = true;
break;
case 1:
one.IsChecked = true;
break;
default:
throw new Exception("Unexpected value " + value);
}
}
private void okButton_Click(object sender, EventArgs e) {
StatusFlags flags = new StatusFlags();
flags.N = GetChecked(radioNDefault, radioNZero, radioNOne, radioNIndeterminate);
flags.V = GetChecked(radioVDefault, radioVZero, radioVOne, radioVIndeterminate);
flags.M = GetChecked(radioMDefault, radioMZero, radioMOne, radioMIndeterminate);
flags.X = GetChecked(radioXDefault, radioXZero, radioXOne, radioXIndeterminate);
flags.D = GetChecked(radioDDefault, radioDZero, radioDOne, radioDIndeterminate);
flags.I = GetChecked(radioIDefault, radioIZero, radioIOne, radioIIndeterminate);
flags.Z = GetChecked(radioZDefault, radioZZero, radioZOne, radioZIndeterminate);
flags.C = GetChecked(radioCDefault, radioCZero, radioCOne, radioCIndeterminate);
flags.E = GetChecked(radioEDefault, radioEZero, radioEOne, radioEIndeterminate);
//// If they're setting emulation mode, also set M/X to 1. This is implicitly
//// true, but things are a bit clearer if we make it explicit.
//if (flags.E == 1) {
// flags.M = flags.X = 1;
//}
FlagValue = flags;
}
/// <summary>
/// Identifies the checked radio button and returns the appropriate TriState16 value.
/// </summary>
private int GetChecked(RadioButton def, RadioButton zero, RadioButton one,
RadioButton indeterminate) {
if (zero.IsChecked == true) {
return 0;
} else if (one.IsChecked == true) {
return 1;
} else if (indeterminate.IsChecked == true) {
return TriState16.INDETERMINATE;
} else if (def.IsChecked == true) {
return TriState16.UNSPECIFIED;
} else {
throw new Exception("No radio button selected");
}
}
}
}

View File

@ -54,6 +54,7 @@ limitations under the License.
</RoutedUICommand>
<RoutedUICommand x:Key="CloseCmd" Text="Close"/>
<RoutedUICommand x:Key="EditAddressCmd" Text="Set Address..."/>
<RoutedUICommand x:Key="EditStatusFlags" Text="Override Status Flags..."/>
<RoutedUICommand x:Key="HintAsCodeEntryPointCmd" Text="Hint As Code Entry Point"/>
<RoutedUICommand x:Key="HintAsDataStartCmd" Text="Hint As Data Start"/>
<RoutedUICommand x:Key="HintAsInlineDataCmd" Text="Hint As Inline Data"/>
@ -100,6 +101,8 @@ limitations under the License.
CanExecute="IsProjectOpen" Executed="CloseCmd_Executed"/>
<CommandBinding Command="{StaticResource EditAddressCmd}"
CanExecute="CanEditAddress" Executed="EditAddressCmd_Executed"/>
<CommandBinding Command="{StaticResource EditStatusFlags}"
CanExecute="CanEditStatusFlags" Executed="EditStatusFlags_Executed"/>
<CommandBinding Command="Help"
Executed="HelpCmd_Executed"/>
<CommandBinding Command="{StaticResource HintAsCodeEntryPointCmd}"
@ -161,7 +164,7 @@ limitations under the License.
</MenuItem>
<MenuItem Name="ActionsMenu" Header="_Actions">
<MenuItem Command="{StaticResource EditAddressCmd}"/>
<MenuItem Header="Override Status Flags..."/>
<MenuItem Command="{StaticResource EditStatusFlags}"/>
<MenuItem Header="Edit Label..."/>
<MenuItem Header="Edit Operand..."/>
<MenuItem Header="Edit Comment..."/>

View File

@ -270,7 +270,9 @@ namespace SourceGenWPF.ProjWin {
/// </summary>
private void Window_MouseDown(object sender, MouseButtonEventArgs e) {
if (e.ChangedButton == MouseButton.XButton1) {
Debug.WriteLine("TODO: navigate back");
if (mMainCtrl.CanNavigateBackward()) {
mMainCtrl.NavigateBackward();
}
}
}
@ -673,6 +675,14 @@ namespace SourceGenWPF.ProjWin {
e.CanExecute = mMainCtrl.CanEditAddress();
}
private void CanEditStatusFlags(object sender, CanExecuteRoutedEventArgs e) {
if (mMainCtrl == null || !mMainCtrl.IsProjectOpen()) {
e.CanExecute = false;
return;
}
e.CanExecute = mMainCtrl.CanEditStatusFlags();
}
private void CanHintAsCodeEntryPoint(object sender, CanExecuteRoutedEventArgs e) {
if (mMainCtrl == null || !mMainCtrl.IsProjectOpen()) {
e.CanExecute = false;
@ -744,6 +754,10 @@ namespace SourceGenWPF.ProjWin {
mMainCtrl.EditAddress();
}
private void EditStatusFlags_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.EditStatusFlags();
}
private void HelpCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.ShowHelp();
}

View File

@ -84,6 +84,9 @@
<Compile Include="ProjWin\EditAddress.xaml.cs">
<DependentUpon>EditAddress.xaml</DependentUpon>
</Compile>
<Compile Include="ProjWin\EditStatusFlags.xaml.cs">
<DependentUpon>EditStatusFlags.xaml</DependentUpon>
</Compile>
<Compile Include="ProjWin\ProjectLoadIssue.xaml.cs">
<DependentUpon>ProjectLoadIssue.xaml</DependentUpon>
</Compile>
@ -168,6 +171,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ProjWin\EditStatusFlags.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ProjWin\MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>