-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to Add and Remove WAD Entries
- Loading branch information
Showing
9 changed files
with
212 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Window x:Class="Obsidian.Windows.FileAddWindow" | ||
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:Obsidian.Windows" | ||
mc:Ignorable="d" | ||
Title="Add Entry" Height="150" Width="750" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen"> | ||
<Grid> | ||
<StackPanel Orientation="Vertical" Margin="10"> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="File: " TextAlignment="Center" Margin="0" FontSize="20"/> | ||
<TextBox x:Name="textboxFile" Height="25" MinWidth="641" Margin="9,0,0,0" IsReadOnly="True"/> | ||
<Button x:Name="buttonSelectFile" Margin="3,1,0,1" Width="29" Click="buttonSelectFile_Click"/> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="Path: " TextAlignment="Center" Margin="0" FontSize="20"/> | ||
<TextBox x:Name="textboxPath" Height="25" MinWidth="673"/> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Button x:Name="buttonAddEntry" Content="Add Entry" Margin="300,10,0,0" Height="28" Width="79" IsEnabled="False" Click="buttonAddEntry_Click"/> | ||
<CheckBox x:Name="checkboxCompress" Content="Compress" FontSize="15" Margin="10,15,0,0" IsChecked="True"/> | ||
</StackPanel> | ||
</StackPanel> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.IO; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
using System.Windows.Forms; | ||
|
||
namespace Obsidian.Windows | ||
{ | ||
/// <summary> | ||
/// Interaction logic for FileAddWindow.xaml | ||
/// </summary> | ||
public partial class FileAddWindow : Window | ||
{ | ||
public MainWindow MainWindow { get; set; } | ||
public FileAddWindow(MainWindow window) | ||
{ | ||
this.MainWindow = window; | ||
InitializeComponent(); | ||
this.Closed += FileAddWindow_Closed; | ||
} | ||
|
||
private void FileAddWindow_Closed(object sender, EventArgs e) | ||
{ | ||
this.MainWindow.IsEnabled = true; | ||
} | ||
|
||
private void buttonSelectFile_Click(object sender, RoutedEventArgs e) | ||
{ | ||
OpenFileDialog openFileDialog = new OpenFileDialog(); | ||
openFileDialog.Multiselect = false; | ||
|
||
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) | ||
{ | ||
this.textboxFile.Text = openFileDialog.FileName; | ||
this.buttonAddEntry.IsEnabled = true; | ||
} | ||
} | ||
|
||
private void buttonAddEntry_Click(object sender, RoutedEventArgs e) | ||
{ | ||
try | ||
{ | ||
this.MainWindow.wad.AddEntry(this.textboxPath.Text, File.ReadAllBytes(this.textboxFile.Text), this.checkboxCompress.IsChecked.Value); | ||
CollectionViewSource.GetDefaultView(this.MainWindow.datagridWadEntries.ItemsSource).Refresh(); | ||
this.Close(); | ||
} | ||
catch (Exception exception) | ||
{ | ||
System.Windows.MessageBox.Show(exception.Message, "Please choose a different Path", MessageBoxButton.OK, MessageBoxImage.Warning); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Window x:Class="Obsidian.Windows.FileRedirectionAddWindow" | ||
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:Obsidian.Windows" | ||
mc:Ignorable="d" | ||
Title="Add File Redirection Entry" Height="150" Width="750" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen"> | ||
<Grid> | ||
<StackPanel Orientation="Vertical" Margin="10"> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="File: " TextAlignment="Center" Margin="0" FontSize="20"/> | ||
<TextBox x:Name="textboxFile" Height="25" MinWidth="673" Margin="9,0,0,0" TextChanged="textboxFile_TextChanged"/> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="Path: " TextAlignment="Center" Margin="0" FontSize="20"/> | ||
<TextBox x:Name="textboxPath" Height="25" MinWidth="673"/> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Button x:Name="buttonAddFileRedirectionEntry" Content="Add File Redirection Entry" Margin="275,10,0,0" Height="28" Width="150" IsEnabled="False" Click="buttonAddFileRedirectionEntry_Click"/> | ||
</StackPanel> | ||
</StackPanel> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
|
||
namespace Obsidian.Windows | ||
{ | ||
/// <summary> | ||
/// Interaction logic for FileRedirectionAddWindow.xaml | ||
/// </summary> | ||
public partial class FileRedirectionAddWindow : Window | ||
{ | ||
public MainWindow MainWindow { get; set; } | ||
public FileRedirectionAddWindow(MainWindow window) | ||
{ | ||
this.MainWindow = window; | ||
InitializeComponent(); | ||
this.Closed += FileRedirectionAddWindow_Closed; | ||
} | ||
|
||
private void FileRedirectionAddWindow_Closed(object sender, EventArgs e) | ||
{ | ||
this.MainWindow.IsEnabled = true; | ||
} | ||
|
||
private void textboxFile_TextChanged(object sender, TextChangedEventArgs e) | ||
{ | ||
this.buttonAddFileRedirectionEntry.IsEnabled = this.textboxFile.Text.Length != 0; | ||
} | ||
|
||
private void buttonAddFileRedirectionEntry_Click(object sender, RoutedEventArgs e) | ||
{ | ||
try | ||
{ | ||
this.MainWindow.wad.AddEntry(this.textboxFile.Text, this.textboxPath.Text); | ||
CollectionViewSource.GetDefaultView(this.MainWindow.datagridWadEntries.ItemsSource).Refresh(); | ||
this.Close(); | ||
} | ||
catch (Exception exception) | ||
{ | ||
MessageBox.Show(exception.Message, "Please choose a different Path", MessageBoxButton.OK, MessageBoxImage.Warning); | ||
} | ||
} | ||
} | ||
} |