1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-27 18:29:30 +00:00

Allow multiple files to be added at once in file concatenator

Also, show the current number of elements.
This commit is contained in:
Andy McFadden 2020-02-04 14:11:04 -08:00
parent 5b75ae35fc
commit d7593181f5
2 changed files with 10 additions and 6 deletions

View File

@ -47,7 +47,8 @@ limitations under the License.
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Select files:" Margin="0,0,0,4"/>
<TextBlock Grid.Row="0" Margin="0,0,0,4"
Text="{Binding ConcatItems.Count, StringFormat={}File list ({0} items):}"/>
<DataGrid Name="concatGrid" Grid.Row="1" Height="300" Width="480"
IsReadOnly="True"

View File

@ -113,6 +113,7 @@ namespace SourceGen.Tools.WpfGui {
OpenFileDialog fileDlg = new OpenFileDialog() {
Filter = Res.Strings.FILE_FILTER_ALL,
FilterIndex = 0,
Multiselect = true,
Title = (string)FindResource("str_SelectFileTitle")
};
if (fileDlg.ShowDialog() != true) {
@ -120,11 +121,13 @@ namespace SourceGen.Tools.WpfGui {
}
try {
string pathName = Path.GetFullPath(fileDlg.FileName);
long length = new FileInfo(pathName).Length;
uint crc32 = CRC32.OnWholeFile(pathName);
ConcatItems.Add(new ConcatItem(pathName, length, crc32));
concatGrid.SelectedIndex = ConcatItems.Count - 1;
foreach (string pathName in fileDlg.FileNames) {
// The names in FileNames appear to be fully qualified.
long length = new FileInfo(pathName).Length;
uint crc32 = CRC32.OnWholeFile(pathName);
ConcatItems.Add(new ConcatItem(pathName, length, crc32));
concatGrid.SelectedIndex = ConcatItems.Count - 1;
}
} catch (Exception ex) {
string caption = (string)FindResource("str_FileAccessFailedCaption");
string fmt = (string)FindResource("str_FileAccessFailedFmt");