diff --git a/SourceGenWPF/Res/Strings.xaml b/SourceGenWPF/Res/Strings.xaml
index af863c9..89f1fc7 100644
--- a/SourceGenWPF/Res/Strings.xaml
+++ b/SourceGenWPF/Res/Strings.xaml
@@ -26,6 +26,8 @@ limitations under the License.
Assembled output does not match: offset +{0:x6} has value ${1:x2}, expected ${2:x2}.
Assembled output does not match: length is {0}, expected {1}.
Expected output file wasn't created
+ Assembler Source
+ Disassembly
Default
Bad format descriptor at +{0:x6}.
Bad format descriptor type
diff --git a/SourceGenWPF/Res/Strings.xaml.cs b/SourceGenWPF/Res/Strings.xaml.cs
index 69ee952..2f6400f 100644
--- a/SourceGenWPF/Res/Strings.xaml.cs
+++ b/SourceGenWPF/Res/Strings.xaml.cs
@@ -39,6 +39,10 @@ namespace SourceGenWPF.Res {
(string)Application.Current.FindResource("str_AsmOutputNotFound");
public static string DEFAULT_VALUE =
(string)Application.Current.FindResource("str_DefaultValue");
+ public static string CLIPFORMAT_ASSEMBLER_SOURCE =
+ (string)Application.Current.FindResource("str_ClipformatAssemblerSource");
+ public static string CLIPFORMAT_DISASSEMBLY =
+ (string)Application.Current.FindResource("str_ClipformatDisassembly");
public static string ERR_BAD_FD =
(string)Application.Current.FindResource("str_ErrBadFd");
public static string ERR_BAD_FD_FORMAT =
diff --git a/SourceGenWPF/WpfGui/EditAppSettings.xaml b/SourceGenWPF/WpfGui/EditAppSettings.xaml
index 95c5e8d..6d7cc5f 100644
--- a/SourceGenWPF/WpfGui/EditAppSettings.xaml
+++ b/SourceGenWPF/WpfGui/EditAppSettings.xaml
@@ -112,10 +112,8 @@ limitations under the License.
Format for lines copied to clipboard:
- Assembler Source
- Disassembly
-
+ ItemsSource="{Binding ClipboardFormatItems}" DisplayMemberPath="Name"
+ SelectionChanged="ClipboardFormatComboBox_SelectionChanged"/>
diff --git a/SourceGenWPF/WpfGui/EditAppSettings.xaml.cs b/SourceGenWPF/WpfGui/EditAppSettings.xaml.cs
index 7cdc47e..6604105 100644
--- a/SourceGenWPF/WpfGui/EditAppSettings.xaml.cs
+++ b/SourceGenWPF/WpfGui/EditAppSettings.xaml.cs
@@ -245,6 +245,30 @@ namespace SourceGenWPF.WpfGui {
#region Code View
+ ///
+ /// Entries for the clipboard format item combo box.
+ ///
+ public class ClipboardFormatItem {
+ public string Name { get; private set; }
+ public MainController.ClipLineFormat Value { get; private set; }
+
+ public ClipboardFormatItem(string name, MainController.ClipLineFormat value) {
+ Name = name;
+ Value = value;
+ }
+ }
+ // NOTE: in the current implementation, the array index must match the enum value
+ private static ClipboardFormatItem[] sClipboardFormatItems = {
+ new ClipboardFormatItem(Res.Strings.CLIPFORMAT_ASSEMBLER_SOURCE,
+ MainController.ClipLineFormat.AssemblerSource),
+ new ClipboardFormatItem(Res.Strings.CLIPFORMAT_DISASSEMBLY,
+ MainController.ClipLineFormat.Disassembly)
+ };
+ // ItemsSource for combo box
+ public ClipboardFormatItem[] ClipboardFormatItems {
+ get { return sClipboardFormatItems; }
+ }
+
private void Loaded_CodeView() {
// Column widths. We called CaptureColumnWidths() during init, so this
// should always be a valid serialized string.
@@ -271,10 +295,12 @@ namespace SourceGenWPF.WpfGui {
UpperOperandS = mSettings.GetBool(AppSettings.FMT_UPPER_OPERAND_S, false);
UpperOperandXY = mSettings.GetBool(AppSettings.FMT_UPPER_OPERAND_XY, false);
+ Debug.Assert(clipboardFormatComboBox.Items.Count == sClipboardFormatItems.Length);
int clipIndex = mSettings.GetEnum(AppSettings.CLIP_LINE_FORMAT,
typeof(MainController.ClipLineFormat), 0);
- if (clipIndex >= 0 && clipIndex < clipboardFormatComboBox.Items.Count) {
- // NOTE: this couples the ClipLineFormat enum to the XAML.
+ if (clipIndex >= 0 && clipIndex < sClipboardFormatItems.Length) {
+ // require Value == clipIndex because we're lazy and don't want to search
+ Debug.Assert((int)sClipboardFormatItems[clipIndex].Value == clipIndex);
clipboardFormatComboBox.SelectedIndex = clipIndex;
}
@@ -416,9 +442,9 @@ namespace SourceGenWPF.WpfGui {
private void ClipboardFormatComboBox_SelectionChanged(object sender,
SelectionChangedEventArgs e) {
- // NOTE: again, this ties the combo box index to the enum value
+ ClipboardFormatItem item = (ClipboardFormatItem)clipboardFormatComboBox.SelectedItem;
mSettings.SetEnum(AppSettings.CLIP_LINE_FORMAT, typeof(MainController.ClipLineFormat),
- clipboardFormatComboBox.SelectedIndex);
+ (int)item.Value);
IsDirty = true;
}