Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions MDF-Manager/App.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Application x:Class="MDF_Manager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MDF_Manager"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
<Application x:Class="MDF_Manager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MDF_Manager"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
34 changes: 17 additions & 17 deletions MDF-Manager/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace MDF_Manager
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MDF_Manager
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
20 changes: 10 additions & 10 deletions MDF-Manager/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
56 changes: 28 additions & 28 deletions MDF-Manager/BatchConverter.xaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<Window x:Class="MDF_Manager.BatchConverter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MDF_Manager"
mc:Ignorable="d"
Title="Batch Converter" Height="300" Width="500">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ListBox Grid.ColumnSpan="3" Grid.Row="2" Grid.RowSpan="2" Margin="25,0,25,0" x:Name="MDFView" Background="#EEEEEE"/>
<ComboBox Grid.Row="1" Grid.Column="2" Width="100" Height="25" SelectedItem="{Binding ExportType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding TypeList}" Name="TypeSelect"/>
<Button Grid.Row="1" Grid.Column="0" Content="Add MDFs" Click="AddToList" Width="100" Height="25"/>
<Button Grid.Row="1" Grid.Column="1" Content="Remove MDF" Click="RemoveSelected" Width="100" Height="25"/>
<Button Grid.Row="4" Grid.Column="2" Content="Convert" Click="ConvertAll" Width="100" Height="25"/>
</Grid>
</Window>
<Window x:Class="MDF_Manager.BatchConverter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MDF_Manager"
mc:Ignorable="d"
Title="Batch Converter" Height="300" Width="500">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ListBox Grid.ColumnSpan="3" Grid.Row="2" Grid.RowSpan="2" Margin="25,0,25,0" x:Name="MDFView" Background="#EEEEEE"/>
<ComboBox Grid.Row="1" Grid.Column="2" Width="100" Height="25" SelectedItem="{Binding ExportType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding TypeList}" Name="TypeSelect"/>
<Button Grid.Row="1" Grid.Column="0" Content="Add MDFs" Click="AddToList" Width="100" Height="25"/>
<Button Grid.Row="1" Grid.Column="1" Content="Remove MDF" Click="RemoveSelected" Width="100" Height="25"/>
<Button Grid.Row="4" Grid.Column="2" Content="Convert" Click="ConvertAll" Width="100" Height="25"/>
</Grid>
</Window>
192 changes: 96 additions & 96 deletions MDF-Manager/BatchConverter.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
using MDF_Manager.Classes;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Path = System.IO.Path;

namespace MDF_Manager
{
/// <summary>
/// Interaction logic for BatchConverter.xaml
/// </summary>
public partial class BatchConverter : Window
{
private List<MDFTypes> MDFTypeList = new List<MDFTypes>();
public List<MDFTypes> TypeList { get => MDFTypeList; }
public MDFTypes ExportType { get; set; }
public BatchConverter()
{
InitializeComponent();
foreach(MDFTypes type in Enum.GetValues(typeof(MDFTypes)))
{
MDFTypeList.Add(type);
}
ExportType = MDFTypes.Sunbreak;
DataContext = this;
}

private void AddToList(object sender, RoutedEventArgs e)
{
OpenFileDialog importFile = new OpenFileDialog();
importFile.Multiselect = true;
importFile.Filter = MainWindow.MDFFilter;
if (importFile.ShowDialog() == true)
{
foreach(string file in importFile.FileNames)
{
MDFView.Items.Add(new ListBoxItem() { Content = file });
}
}
}

private void RemoveSelected(object sender, RoutedEventArgs e)
{
MDFView.Items.Remove(MDFView.SelectedItem);
MDFView.SelectedIndex = 0;
}

public void ConvertSingle(string path, string output)
{
BinaryReader readFile = HelperFunctions.OpenFileR(path, Encoding.Unicode);
if (readFile != null)
{
MDFTypes type = (MDFTypes)Convert.ToInt32(System.IO.Path.GetExtension(path).Replace(".", ""));
MDFFile file = new MDFFile(path, readFile, type);
//now export with proper format/path
string outPath = Path.ChangeExtension(Path.Combine(output, Path.GetFileName(path)), ((int)ExportType).ToString());
BinaryWriter bw = HelperFunctions.OpenFileW(outPath, Encoding.Unicode);
if(bw != null)
{
file.Export(bw, ExportType);
}
bw.Close();
}
readFile.Close();
}

public void ConvertAll(object sender, RoutedEventArgs e)
{
OpenFileDialog exportFile = new OpenFileDialog();
exportFile.CheckFileExists = false;
exportFile.FileName = "Save Here";
if(exportFile.ShowDialog() == true)
{
foreach (ListBoxItem item in MDFView.Items)
{
string path = item.Content as string;
ConvertSingle(path, System.IO.Path.GetDirectoryName(exportFile.FileName));
}
MessageBox.Show("Batch conversion completed successfully!");
this.Close();
}
}
}
}
using MDF_Manager.Classes;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Path = System.IO.Path;
namespace MDF_Manager
{
/// <summary>
/// Interaction logic for BatchConverter.xaml
/// </summary>
public partial class BatchConverter : Window
{
private List<MDFTypes> MDFTypeList = new List<MDFTypes>();
public List<MDFTypes> TypeList { get => MDFTypeList; }
public MDFTypes ExportType { get; set; }
public BatchConverter()
{
InitializeComponent();
foreach(MDFTypes type in Enum.GetValues(typeof(MDFTypes)))
{
MDFTypeList.Add(type);
}
ExportType = MDFTypes.Sunbreak;
DataContext = this;
}
private void AddToList(object sender, RoutedEventArgs e)
{
OpenFileDialog importFile = new OpenFileDialog();
importFile.Multiselect = true;
importFile.Filter = MainWindow.MDFFilter;
if (importFile.ShowDialog() == true)
{
foreach(string file in importFile.FileNames)
{
MDFView.Items.Add(new ListBoxItem() { Content = file });
}
}
}
private void RemoveSelected(object sender, RoutedEventArgs e)
{
MDFView.Items.Remove(MDFView.SelectedItem);
MDFView.SelectedIndex = 0;
}
public void ConvertSingle(string path, string output)
{
BinaryReader readFile = HelperFunctions.OpenFileR(path, Encoding.Unicode);
if (readFile != null)
{
MDFTypes type = (MDFTypes)Convert.ToInt32(System.IO.Path.GetExtension(path).Replace(".", ""));
MDFFile file = new MDFFile(path, readFile, type);
//now export with proper format/path
string outPath = Path.ChangeExtension(Path.Combine(output, Path.GetFileName(path)), ((int)ExportType).ToString());
BinaryWriter bw = HelperFunctions.OpenFileW(outPath, Encoding.Unicode);
if(bw != null)
{
file.Export(bw, ExportType);
}
bw.Close();
}
readFile.Close();
}
public void ConvertAll(object sender, RoutedEventArgs e)
{
OpenFileDialog exportFile = new OpenFileDialog();
exportFile.CheckFileExists = false;
exportFile.FileName = "Save Here";
if(exportFile.ShowDialog() == true)
{
foreach (ListBoxItem item in MDFView.Items)
{
string path = item.Content as string;
ConvertSingle(path, System.IO.Path.GetDirectoryName(exportFile.FileName));
}
MessageBox.Show("Batch conversion completed successfully!");
this.Close();
}
}
}
}
Loading