Compare commits

...

2 Commits

Author SHA1 Message Date
Andy McFadden da91d9fc0e Allow arbitrary code list font sizes
The point size must be between 3 and 64, inclusive, just to avoid
doing anything too weird.  Also, added 14 to the drop-down.
2024-04-19 14:46:17 -07:00
Andy McFadden 8532cfb433 Rename menu item
Changed "File > Assemble" to "File > Generate Assembly".

Also, correctly mark a read-only text field as such.
2024-04-19 14:16:30 -07:00
6 changed files with 39 additions and 15 deletions

View File

@ -75,7 +75,7 @@ limitations under the License.
<DockPanel Grid.Column="3" Grid.Row="2"> <DockPanel Grid.Column="3" Grid.Row="2">
<TextBlock DockPanel.Dock="Left" Margin="0,1,0,0">Work directory:</TextBlock> <TextBlock DockPanel.Dock="Left" Margin="0,1,0,0">Work directory:</TextBlock>
<TextBox DockPanel.Dock="Right" Name="workDirectoryTextBox" Margin="8,0,0,0" <TextBox DockPanel.Dock="Right" Name="workDirectoryTextBox" Margin="8,0,0,0"
Text="C:\this\that\theother"/> IsReadOnly="True" Text="C:\this\that\theother"/>
</DockPanel> </DockPanel>
</Grid> </Grid>

View File

@ -56,15 +56,20 @@ limitations under the License.
</ListBox> </ListBox>
<TextBlock Text="Font size:" Margin="0,8,0,0"/> <TextBlock Text="Font size:" Margin="0,8,0,0"/>
<ComboBox Name="sizeComboBox" IsReadOnly="True" Margin="0,4,0,0" Width="75" <StackPanel Orientation="Horizontal">
HorizontalAlignment="Left"> <ComboBox Name="sizeComboBox" Margin="0,4,0,0" Width="75"
<!-- these are parsed directly, so only use numeric values --> HorizontalAlignment="Left" IsEditable="True">
<ComboBoxItem>8</ComboBoxItem> <!-- these are parsed directly, so only use numeric values -->
<ComboBoxItem>10</ComboBoxItem> <ComboBoxItem>8</ComboBoxItem>
<ComboBoxItem>12</ComboBoxItem> <ComboBoxItem>10</ComboBoxItem>
<ComboBoxItem>16</ComboBoxItem> <ComboBoxItem>12</ComboBoxItem>
<ComboBoxItem>20</ComboBoxItem> <ComboBoxItem>14</ComboBoxItem>
</ComboBox> <ComboBoxItem>16</ComboBoxItem>
<ComboBoxItem>20</ComboBoxItem>
</ComboBox>
<TextBlock Name="sizeErrMsg" Margin="8,6,0,0" Text="Must be an integer from 3 to 64."
Foreground="Red" Visibility="Hidden"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,8,0,0"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,8,0,0">
<Button Name="okButton" Content="OK" IsDefault="True" <Button Name="okButton" Content="OK" IsDefault="True"

View File

@ -44,7 +44,7 @@ namespace SourceGen.WpfGui {
GenerateMonoFontList(initialFamily); GenerateMonoFontList(initialFamily);
int selIndex = 0; int selIndex = -1;
string sizeStr = initialSize.ToString(); string sizeStr = initialSize.ToString();
for (int i = 0; i < sizeComboBox.Items.Count; i++) { for (int i = 0; i < sizeComboBox.Items.Count; i++) {
ComboBoxItem item = (ComboBoxItem)sizeComboBox.Items[i]; ComboBoxItem item = (ComboBoxItem)sizeComboBox.Items[i];
@ -53,6 +53,10 @@ namespace SourceGen.WpfGui {
break; break;
} }
} }
if (selIndex < 0) {
// Size is not one of the standard combo box items.
sizeComboBox.Text = initialSize.ToString();
}
sizeComboBox.SelectedIndex = selIndex; sizeComboBox.SelectedIndex = selIndex;
} }
@ -114,7 +118,21 @@ namespace SourceGen.WpfGui {
private void OkButton_Click(object sender, RoutedEventArgs e) { private void OkButton_Click(object sender, RoutedEventArgs e) {
ComboBoxItem item = (ComboBoxItem)sizeComboBox.SelectedItem; ComboBoxItem item = (ComboBoxItem)sizeComboBox.SelectedItem;
SelectedSize = int.Parse((string)item.Content); if (item != null) {
SelectedSize = int.Parse((string)item.Content);
} else {
// Catch bad font sizes when "OK" is hit. Not as nice as disabling the OK
// button on bad input, but much simpler.
try {
SelectedSize = int.Parse(sizeComboBox.Text);
} catch (FormatException) {
SelectedSize = -1; // trigger next test
}
if (SelectedSize < 3 || SelectedSize > 64) {
sizeErrMsg.Visibility = Visibility.Visible;
return;
}
}
DialogResult = true; DialogResult = true;
} }
} }

View File

@ -57,7 +57,7 @@ limitations under the License.
</Style> </Style>
<RoutedUICommand x:Key="AboutCmd" Text="About..."/> <RoutedUICommand x:Key="AboutCmd" Text="About..."/>
<RoutedUICommand x:Key="AssembleCmd" Text="Assemble..."> <RoutedUICommand x:Key="AssembleCmd" Text="Generate Assembly...">
<RoutedUICommand.InputGestures> <RoutedUICommand.InputGestures>
<KeyGesture>Ctrl+Shift+A</KeyGesture> <KeyGesture>Ctrl+Shift+A</KeyGesture>
</RoutedUICommand.InputGestures> </RoutedUICommand.InputGestures>

View File

@ -19,7 +19,7 @@ the target assembler, will recreate the original data file exactly.
Every assembler is different, so support must be added to SourceGen Every assembler is different, so support must be added to SourceGen
for each.</p> for each.</p>
<p>The generation / assembly dialog can be opened with <p>The generation / assembly dialog can be opened with
<samp>File &gt; Assemble</samp>.</p> <samp>File &gt; Generate Assembly</samp>.</p>
<p>If you want to show code to others, perhaps by adding a page to <p>If you want to show code to others, perhaps by adding a page to
your web site, you can "export" the formatted code as text or HTML. your web site, you can "export" the formatted code as text or HTML.
This is explained in more detail <a href="#export-source">below</a>. This is explained in more detail <a href="#export-source">below</a>.

View File

@ -91,7 +91,8 @@
</div> </div>
<div class="grid-item-text"> <div class="grid-item-text">
<p>You can generate assembly source code from the disassembled data. <p>You can generate assembly source code from the disassembled data.
Select <samp>File &gt; Assemble</samp> (or hit <kbd class="key">Ctrl+Shift+A</kbd>) Select <samp>File &gt; Generate Assembly</samp>
(or hit <kbd class="key">Ctrl+Shift+A</kbd>)
to open the source generation and assembly dialog.</p> to open the source generation and assembly dialog.</p>
</div> </div>
</div> </div>