|
1 | | -using MDF_Manager.Classes; |
2 | | -using Microsoft.Win32; |
3 | | -using System; |
4 | | -using System.Collections.Generic; |
5 | | -using System.IO; |
6 | | -using System.Linq; |
7 | | -using System.Text; |
8 | | -using System.Threading.Tasks; |
9 | | -using System.Windows; |
10 | | -using System.Windows.Controls; |
11 | | -using System.Windows.Data; |
12 | | -using System.Windows.Documents; |
13 | | -using System.Windows.Input; |
14 | | -using System.Windows.Media; |
15 | | -using System.Windows.Media.Imaging; |
16 | | -using System.Windows.Shapes; |
17 | | -using Path = System.IO.Path; |
18 | | - |
19 | | -namespace MDF_Manager |
20 | | -{ |
21 | | - /// <summary> |
22 | | - /// Interaction logic for BatchConverter.xaml |
23 | | - /// </summary> |
24 | | - public partial class BatchConverter : Window |
25 | | - { |
26 | | - private List<MDFTypes> MDFTypeList = new List<MDFTypes>(); |
27 | | - public List<MDFTypes> TypeList { get => MDFTypeList; } |
28 | | - public MDFTypes ExportType { get; set; } |
29 | | - public BatchConverter() |
30 | | - { |
31 | | - InitializeComponent(); |
32 | | - foreach(MDFTypes type in Enum.GetValues(typeof(MDFTypes))) |
33 | | - { |
34 | | - MDFTypeList.Add(type); |
35 | | - } |
36 | | - ExportType = MDFTypes.Sunbreak; |
37 | | - DataContext = this; |
38 | | - } |
39 | | - |
40 | | - private void AddToList(object sender, RoutedEventArgs e) |
41 | | - { |
42 | | - OpenFileDialog importFile = new OpenFileDialog(); |
43 | | - importFile.Multiselect = true; |
44 | | - importFile.Filter = MainWindow.MDFFilter; |
45 | | - if (importFile.ShowDialog() == true) |
46 | | - { |
47 | | - foreach(string file in importFile.FileNames) |
48 | | - { |
49 | | - MDFView.Items.Add(new ListBoxItem() { Content = file }); |
50 | | - } |
51 | | - } |
52 | | - } |
53 | | - |
54 | | - private void RemoveSelected(object sender, RoutedEventArgs e) |
55 | | - { |
56 | | - MDFView.Items.Remove(MDFView.SelectedItem); |
57 | | - MDFView.SelectedIndex = 0; |
58 | | - } |
59 | | - |
60 | | - public void ConvertSingle(string path, string output) |
61 | | - { |
62 | | - BinaryReader readFile = HelperFunctions.OpenFileR(path, Encoding.Unicode); |
63 | | - if (readFile != null) |
64 | | - { |
65 | | - MDFTypes type = (MDFTypes)Convert.ToInt32(System.IO.Path.GetExtension(path).Replace(".", "")); |
66 | | - MDFFile file = new MDFFile(path, readFile, type); |
67 | | - //now export with proper format/path |
68 | | - string outPath = Path.ChangeExtension(Path.Combine(output, Path.GetFileName(path)), ((int)ExportType).ToString()); |
69 | | - BinaryWriter bw = HelperFunctions.OpenFileW(outPath, Encoding.Unicode); |
70 | | - if(bw != null) |
71 | | - { |
72 | | - file.Export(bw, ExportType); |
73 | | - } |
74 | | - bw.Close(); |
75 | | - } |
76 | | - readFile.Close(); |
77 | | - } |
78 | | - |
79 | | - public void ConvertAll(object sender, RoutedEventArgs e) |
80 | | - { |
81 | | - OpenFileDialog exportFile = new OpenFileDialog(); |
82 | | - exportFile.CheckFileExists = false; |
83 | | - exportFile.FileName = "Save Here"; |
84 | | - if(exportFile.ShowDialog() == true) |
85 | | - { |
86 | | - foreach (ListBoxItem item in MDFView.Items) |
87 | | - { |
88 | | - string path = item.Content as string; |
89 | | - ConvertSingle(path, System.IO.Path.GetDirectoryName(exportFile.FileName)); |
90 | | - } |
91 | | - MessageBox.Show("Batch conversion completed successfully!"); |
92 | | - this.Close(); |
93 | | - } |
94 | | - } |
95 | | - } |
96 | | -} |
| 1 | +using MDF_Manager.Classes; |
| 2 | +using Microsoft.Win32; |
| 3 | +using System; |
| 4 | +using System.Collections.Generic; |
| 5 | +using System.IO; |
| 6 | +using System.Linq; |
| 7 | +using System.Text; |
| 8 | +using System.Threading.Tasks; |
| 9 | +using System.Windows; |
| 10 | +using System.Windows.Controls; |
| 11 | +using System.Windows.Data; |
| 12 | +using System.Windows.Documents; |
| 13 | +using System.Windows.Input; |
| 14 | +using System.Windows.Media; |
| 15 | +using System.Windows.Media.Imaging; |
| 16 | +using System.Windows.Shapes; |
| 17 | +using Path = System.IO.Path; |
| 18 | + |
| 19 | +namespace MDF_Manager |
| 20 | +{ |
| 21 | + /// <summary> |
| 22 | + /// Interaction logic for BatchConverter.xaml |
| 23 | + /// </summary> |
| 24 | + public partial class BatchConverter : Window |
| 25 | + { |
| 26 | + private List<MDFTypes> MDFTypeList = new List<MDFTypes>(); |
| 27 | + public List<MDFTypes> TypeList { get => MDFTypeList; } |
| 28 | + public MDFTypes ExportType { get; set; } |
| 29 | + public BatchConverter() |
| 30 | + { |
| 31 | + InitializeComponent(); |
| 32 | + foreach(MDFTypes type in Enum.GetValues(typeof(MDFTypes))) |
| 33 | + { |
| 34 | + MDFTypeList.Add(type); |
| 35 | + } |
| 36 | + ExportType = MDFTypes.Sunbreak; |
| 37 | + DataContext = this; |
| 38 | + } |
| 39 | + |
| 40 | + private void AddToList(object sender, RoutedEventArgs e) |
| 41 | + { |
| 42 | + OpenFileDialog importFile = new OpenFileDialog(); |
| 43 | + importFile.Multiselect = true; |
| 44 | + importFile.Filter = MainWindow.MDFFilter; |
| 45 | + if (importFile.ShowDialog() == true) |
| 46 | + { |
| 47 | + foreach(string file in importFile.FileNames) |
| 48 | + { |
| 49 | + MDFView.Items.Add(new ListBoxItem() { Content = file }); |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + private void RemoveSelected(object sender, RoutedEventArgs e) |
| 55 | + { |
| 56 | + MDFView.Items.Remove(MDFView.SelectedItem); |
| 57 | + MDFView.SelectedIndex = 0; |
| 58 | + } |
| 59 | + |
| 60 | + public void ConvertSingle(string path, string output) |
| 61 | + { |
| 62 | + BinaryReader readFile = HelperFunctions.OpenFileR(path, Encoding.Unicode); |
| 63 | + if (readFile != null) |
| 64 | + { |
| 65 | + MDFTypes type = (MDFTypes)Convert.ToInt32(System.IO.Path.GetExtension(path).Replace(".", "")); |
| 66 | + MDFFile file = new MDFFile(path, readFile, type); |
| 67 | + //now export with proper format/path |
| 68 | + string outPath = Path.ChangeExtension(Path.Combine(output, Path.GetFileName(path)), ((int)ExportType).ToString()); |
| 69 | + BinaryWriter bw = HelperFunctions.OpenFileW(outPath, Encoding.Unicode); |
| 70 | + if(bw != null) |
| 71 | + { |
| 72 | + file.Export(bw, ExportType); |
| 73 | + } |
| 74 | + bw.Close(); |
| 75 | + } |
| 76 | + readFile.Close(); |
| 77 | + } |
| 78 | + |
| 79 | + public void ConvertAll(object sender, RoutedEventArgs e) |
| 80 | + { |
| 81 | + OpenFileDialog exportFile = new OpenFileDialog(); |
| 82 | + exportFile.CheckFileExists = false; |
| 83 | + exportFile.FileName = "Save Here"; |
| 84 | + if(exportFile.ShowDialog() == true) |
| 85 | + { |
| 86 | + foreach (ListBoxItem item in MDFView.Items) |
| 87 | + { |
| 88 | + string path = item.Content as string; |
| 89 | + ConvertSingle(path, System.IO.Path.GetDirectoryName(exportFile.FileName)); |
| 90 | + } |
| 91 | + MessageBox.Show("Batch conversion completed successfully!"); |
| 92 | + this.Close(); |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | +} |
0 commit comments