1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-30 01:50:10 +00:00

Implement fourth settings tab ("Pseudo-Op")

Largely unchanged from WinForms version.  Creating and binding
properties for every field seemed tedious.
This commit is contained in:
Andy McFadden 2019-06-30 13:52:42 -07:00
parent d65acc2121
commit f4cb5cd8b8
2 changed files with 166 additions and 81 deletions

View File

@ -347,18 +347,30 @@ limitations under the License.
<TextBlock Grid.Column="0" Grid.Row="5" Text="Null term string:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="1" Grid.Row="5" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Name="equDirectiveTextBox" Grid.Column="1" Grid.Row="0"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="defineData1TextBox" Grid.Column="1" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="defineBigData2TextBox" Grid.Column="1" Grid.Row="2"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strGenericTextBox" Grid.Column="1" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strLen8TextBox" Grid.Column="1" Grid.Row="4"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strNullTermTextBox" Grid.Column="1" Grid.Row="5"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<!-- second column -->
<TextBlock Grid.Column="3" Grid.Row="0" Text="Origin:"
@ -372,16 +384,26 @@ limitations under the License.
<TextBlock Grid.Column="3" Grid.Row="5" Text="Null term/hi:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Column="4" Grid.Row="0" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="4" Grid.Row="1" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="4" Grid.Row="3" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="4" Grid.Row="4" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="4" Grid.Row="5" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Name="orgDirectiveTextBox" Grid.Column="4" Grid.Row="0"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="defineData2TextBox" Grid.Column="4" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strGenericHiTextBox" Grid.Column="4" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strLen8HiTextBox" Grid.Column="4" Grid.Row="4"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strNullTermHiTextBox" Grid.Column="4" Grid.Row="5"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<!-- third column -->
<TextBlock Grid.Column="6" Grid.Row="0" Text="Reg width:"
@ -397,18 +419,30 @@ limitations under the License.
<TextBlock Grid.Column="6" Grid.Row="5" Text="DCI:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Column="7" Grid.Row="0" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="7" Grid.Row="1" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="7" Grid.Row="2" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="7" Grid.Row="3" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="7" Grid.Row="4" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="7" Grid.Row="5" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Name="regWidthDirectiveTextBox" Grid.Column="7" Grid.Row="0"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="defineData3TextBox" Grid.Column="7" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="fillTextBox" Grid.Column="7" Grid.Row="2"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strReverseTextBox" Grid.Column="7" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strLen16TextBox" Grid.Column="7" Grid.Row="4"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strDciTextBox" Grid.Column="7" Grid.Row="5"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<!-- fourth column -->
<TextBlock Grid.Column="9" Grid.Row="1" Text="Four bytes:"
@ -422,24 +456,38 @@ limitations under the License.
<TextBlock Grid.Column="9" Grid.Row="5" Text="DCI/hi:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Grid.Column="10" Grid.Row="1" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="10" Grid.Row="2" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="10" Grid.Row="3" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="10" Grid.Row="4" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Grid.Column="10" Grid.Row="5" VerticalAlignment="Center" Text=".placeho"
FontFamily="{StaticResource GeneralMonoFont}" Margin="{StaticResource TBS}"/>
<TextBox Name="defineData4TextBox" Grid.Column="10" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="denseTextBox" Grid.Column="10" Grid.Row="2"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strReverseHiTextBox" Grid.Column="10" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strLen16HiTextBox" Grid.Column="10" Grid.Row="4"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strDciHiTextBox" Grid.Column="10" Grid.Row="5"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="8"
FontFamily="{StaticResource GeneralMonoFont}"/>
</Grid>
<GroupBox DockPanel.Dock="Bottom" Header="Quick Set"
Width="400" HorizontalAlignment="Right">
<DockPanel LastChildFill="False" Margin="8">
<Button DockPanel.Dock="Left" Content="Default" Width="75"/>
<Button DockPanel.Dock="Right" Content="Set" Width="75" Margin="8,0,0,0"/>
<ComboBox DockPanel.Dock="Right" Width="170"/>
<Button DockPanel.Dock="Left" Content="Default" Width="75"
Click="PseudoOpDefaultButton_Click"/>
<Button DockPanel.Dock="Right" Content="Set" Width="75" Margin="8,0,0,0"
Click="PseudoOpSetButton_Click"/>
<ComboBox Name="pseudoOpQuickComboBox" DockPanel.Dock="Right"
Width="170" IsReadOnly="True"
ItemsSource="{Binding AssemblerList}" DisplayMemberPath="Name"/>
</DockPanel>
</GroupBox>
</DockPanel>

View File

@ -124,7 +124,15 @@ namespace SourceGenWPF.WpfGui {
mColumnFormats[i] = (string) mColButtons[i].Content;
}
#if false
// Create an assembler list for the assembler-config combo box and the two
// "quick set" combo boxes.
AssemblerList = new List<AssemblerInfo>();
IEnumerator<AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();
while (iter.MoveNext()) {
AssemblerList.Add(iter.Current);
}
// Can't set the selected item yet.
// Map text boxes to PseudoOpName fields.
mPseudoNameMap = new TextBoxPropertyMap[] {
new TextBoxPropertyMap(equDirectiveTextBox, "EquDirective"),
@ -150,43 +158,13 @@ namespace SourceGenWPF.WpfGui {
new TextBoxPropertyMap(strDciTextBox, "StrDci"),
new TextBoxPropertyMap(strDciHiTextBox, "StrDciHi"),
};
#endif
// Create an assembler list for the assembler-config combo box and the two
// "quick set" combo boxes.
AssemblerList = new List<AssemblerInfo>();
IEnumerator<AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();
while (iter.MoveNext()) {
AssemblerList.Add(iter.Current);
}
// Can't set the selected item yet.
#if false
expressionStyleComboBox.DisplayMember = "Name";
foreach (ExpressionStyleItem esi in sExpStyleItems) {
expressionStyleComboBox.Items.Add(esi);
}
#endif
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
Loaded_CodeView();
Loaded_AsmConfig();
Loaded_DisplayFormat();
#if false
// Pseudo ops.
string opStrCereal = mSettings.GetString(AppSettings.FMT_PSEUDO_OP_NAMES, null);
if (!string.IsNullOrEmpty(opStrCereal)) {
PseudoOp.PseudoOpNames opNames = PseudoOp.PseudoOpNames.Deserialize(opStrCereal);
ImportPseudoOpNames(opNames);
} else {
// no data available, populate with blanks
//PseudoOp.PseudoOpNames opNames = PseudoOp.sDefaultPseudoOpNames;
ImportPseudoOpNames(new PseudoOp.PseudoOpNames());
}
#endif
Loaded_PseudoOp();
switch (mInitialTab) {
case Tab.CodeView:
@ -223,11 +201,9 @@ namespace SourceGenWPF.WpfGui {
}
private void ApplySettings() {
#if false
PseudoOp.PseudoOpNames opNames = ExportPseudoOpNames();
string pseudoCereal = opNames.Serialize();
mSettings.SetString(AppSettings.FMT_PSEUDO_OP_NAMES, pseudoCereal);
#endif
mMainCtrl.SetAppSettings(mSettings);
AsmGen.AssemblerVersionCache.QueryVersions();
@ -867,6 +843,67 @@ namespace SourceGenWPF.WpfGui {
}
private TextBoxPropertyMap[] mPseudoNameMap;
private void Loaded_PseudoOp() {
string opStrCereal = mSettings.GetString(AppSettings.FMT_PSEUDO_OP_NAMES, null);
if (!string.IsNullOrEmpty(opStrCereal)) {
PseudoOp.PseudoOpNames opNames = PseudoOp.PseudoOpNames.Deserialize(opStrCereal);
ImportPseudoOpNames(opNames);
} else {
// no data available, populate with blanks
//PseudoOp.PseudoOpNames opNames = PseudoOp.sDefaultPseudoOpNames;
ImportPseudoOpNames(new PseudoOp.PseudoOpNames());
}
// No need to set this to anything specific.
pseudoOpQuickComboBox.SelectedIndex = 0;
}
/// <summary>
/// Imports values from PseudoOpNames struct into text fields.
/// </summary>
private void ImportPseudoOpNames(PseudoOp.PseudoOpNames opNames) {
for (int i = 0; i < mPseudoNameMap.Length; i++) {
string str = (string)mPseudoNameMap[i].PropInfo.GetValue(opNames);
mPseudoNameMap[i].TextBox.Text = (str == null) ? string.Empty : str;
}
}
/// <summary>
/// Exports values from text fields to a PseudoOpNames object.
/// </summary>
private PseudoOp.PseudoOpNames ExportPseudoOpNames() {
PseudoOp.PseudoOpNames opNames = new PseudoOp.PseudoOpNames();
for (int i = 0; i < mPseudoNameMap.Length; i++) {
// NOTE: PseudoOpNames must be a class (not a struct) or this will fail.
// SetValue() would be invoked on a boxed copy that is discarded afterward.
mPseudoNameMap[i].PropInfo.SetValue(opNames, mPseudoNameMap[i].TextBox.Text);
}
return opNames;
}
// Invoked when text is changed in any pseudo-op text box.
private void PseudoOpTextChanged(object sender, EventArgs e) {
// Just set the dirty flag. The (somewhat expensive) export will happen
// on Apply/OK.
IsDirty = true;
}
private void PseudoOpDefaultButton_Click(object sender, RoutedEventArgs e) {
ImportPseudoOpNames(new PseudoOp.PseudoOpNames());
}
private void PseudoOpSetButton_Click(object sender, RoutedEventArgs e) {
AssemblerInfo asmInfo = (AssemblerInfo)pseudoOpQuickComboBox.SelectedItem;
AsmGen.IGenerator gen = AssemblerInfo.GetGenerator(asmInfo.AssemblerId);
PseudoOp.PseudoOpNames opNames;
Asm65.Formatter.FormatConfig formatConfig;
gen.GetDefaultDisplayFormat(out opNames, out formatConfig);
ImportPseudoOpNames(opNames);
// dirty flag set by change watchers if one or more fields have changed
}
#endregion PseudoOp
}