Skip to content

Commit

Permalink
Add settings window
Browse files Browse the repository at this point in the history
Basic settings window created covering file paths and level max/step. Does hardly any validation.
App now remembers window location and size.
Closes #5.
  • Loading branch information
coldino committed Jan 17, 2018
1 parent f0b71e6 commit bd825fc
Show file tree
Hide file tree
Showing 19 changed files with 843 additions and 79 deletions.
5 changes: 4 additions & 1 deletion LarkatorGUI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:LarkatorGUI"
StartupUri="Welcome.xaml">
xmlns:prop="clr-namespace:LarkatorGUI.Properties"
StartupUri="Welcome.xaml"
Exit="Application_Exit">
<Application.Resources>

<SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FF2D6BA8"/>
<local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
<local:OptionalIntConverter x:Key="OptionalIntConverter"/>
<prop:Settings x:Key="Settings"/>

</Application.Resources>
</Application>
13 changes: 6 additions & 7 deletions LarkatorGUI/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;

namespace LarkatorGUI
{
Expand All @@ -17,5 +11,10 @@ protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
}

private void Application_Exit(object sender, ExitEventArgs e)
{
LarkatorGUI.Properties.Settings.Default.Save();
}
}
}
13 changes: 9 additions & 4 deletions LarkatorGUI/ArkReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@ private void EnsureDirectory(string outputDir)
}

public async Task PerformConversion(bool force = false)
{;
{
outputDir = Path.Combine(Properties.Settings.Default.OutputDir, Tamed ? "tamed" : "wild");
EnsureDirectory(outputDir);

if (force || IsConversionRequired())
{
await RunArkTools();

if (ClassMapping.Count == 0)
ClassMapping.Clear();
}
else if (ClassMapping.Count == 0)
{
await LoadClassesJson();
}
}

private bool IsConversionRequired()
Expand Down Expand Up @@ -84,7 +88,7 @@ private async Task ExecuteArkTools(string op, string saveFile, string outDir)
{
var exe = Properties.Resources.ArkToolsExe;
var exeDir = Path.GetDirectoryName(Properties.Settings.Default.ArkTools);
var commandLine = $"/S /C \"cd \"{exeDir}\" && {exe} -p {op} \"{saveFile}\" \"{outDir}\" \"";
var commandLine = $"/S /C {exe} -p {op} \"{saveFile}\" \"{outDir}\"";

var completionTask = new TaskCompletionSource<int>();
var psi = new ProcessStartInfo("cmd.exe", commandLine)
Expand All @@ -94,6 +98,7 @@ private async Task ExecuteArkTools(string op, string saveFile, string outDir)
RedirectStandardError = true,
RedirectStandardOutput = true,
ErrorDialog = true,
WorkingDirectory = exeDir,
};
process = new Process
{
Expand Down
17 changes: 17 additions & 0 deletions LarkatorGUI/DirectoryEntryBox.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<UserControl x:Class="LarkatorGUI.DirectoryEntryBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:LarkatorGUI"
mc:Ignorable="d" d:DesignWidth="240"
Margin="0" Padding="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" MaxLines="1" Text="{Binding Path=Value, Mode=TwoWay}" ToolTip="{Binding Tooltip}" HorizontalContentAlignment="Right"/>
<Button Grid.Column="1" Padding="8,2" Margin="2,0" Click="Browse_Click" ToolTip="Browse...">...</Button>
</Grid>
</UserControl>
76 changes: 76 additions & 0 deletions LarkatorGUI/DirectoryEntryBox.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Avalon.Windows.Dialogs;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;

namespace LarkatorGUI
{
/// <summary>
/// Interaction logic for FileEntryBox.xaml
/// </summary>
public partial class DirectoryEntryBox : UserControl
{
public string Value
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}

public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}

public string Tooltip
{
get { return (string)GetValue(TooltipProperty); }
set { SetValue(TooltipProperty, value); }
}

public static readonly DependencyProperty TooltipProperty =
DependencyProperty.Register("Tooltip", typeof(string), typeof(DirectoryEntryBox), new PropertyMetadata("Enter path to the directory"));

public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("Title", typeof(string), typeof(DirectoryEntryBox), new PropertyMetadata("Select directory"));

public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(string), typeof(DirectoryEntryBox), new PropertyMetadata(""));

public DirectoryEntryBox()
{
InitializeComponent();

DataContext = this;
}

private void Browse_Click(object sender, RoutedEventArgs e)
{
var dialog = new FolderBrowserDialog()
{
RootType = RootType.Path,
ValidateResult = true,
Title = Title,
SelectedPath = Value,
};

var result = dialog.ShowDialog();
if (result == true)
{
Value = dialog.SelectedPath;
}
}
}
}
17 changes: 17 additions & 0 deletions LarkatorGUI/FileEntryBox.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<UserControl x:Class="LarkatorGUI.FileEntryBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:LarkatorGUI"
mc:Ignorable="d" d:DesignWidth="240"
Margin="0" Padding="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" MaxLines="1" Text="{Binding Path=Value, Mode=TwoWay}" ToolTip="{Binding Tooltip}" HorizontalContentAlignment="Right"/>
<Button Grid.Column="1" Padding="8,2" Margin="2,0" Click="Browse_Click" ToolTip="Browse...">...</Button>
</Grid>
</UserControl>
99 changes: 99 additions & 0 deletions LarkatorGUI/FileEntryBox.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;

namespace LarkatorGUI
{
/// <summary>
/// Interaction logic for FileEntryBox.xaml
/// </summary>
public partial class FileEntryBox : UserControl
{

public string Value
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}

public string DefaultExt
{
get { return (string)GetValue(DefaultExtProperty); }
set { SetValue(DefaultExtProperty, value); }
}

public string Filter
{
get { return (string)GetValue(FilterProperty); }
set { SetValue(FilterProperty, value); }
}

public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}

public string Tooltip
{
get { return (string)GetValue(TooltipProperty); }
set { SetValue(TooltipProperty, value); }
}

public static readonly DependencyProperty TooltipProperty =
DependencyProperty.Register("Tooltip", typeof(string), typeof(FileEntryBox), new PropertyMetadata("Enter path to the file"));

public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("Title", typeof(string), typeof(FileEntryBox), new PropertyMetadata("Select file"));

public static readonly DependencyProperty FilterProperty =
DependencyProperty.Register("Filter", typeof(string), typeof(FileEntryBox), new PropertyMetadata("All files|*.*"));

public static readonly DependencyProperty DefaultExtProperty =
DependencyProperty.Register("DefaultExt", typeof(string), typeof(FileEntryBox), new PropertyMetadata(""));

public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(string), typeof(FileEntryBox), new PropertyMetadata(""));

public FileEntryBox()
{
InitializeComponent();

DataContext = this;
}

private void Browse_Click(object sender, RoutedEventArgs e)
{
var dialog = new OpenFileDialog()
{
AddExtension = true,
CheckFileExists = true,
CheckPathExists = true,
DefaultExt = DefaultExt,
DereferenceLinks = true,
Filter = Filter,
Multiselect = false,
Title = Title,
FileName = Value,
};

var result = dialog.ShowDialog();
if (result == true)
{
Value = dialog.FileName;
}
}
}
}
49 changes: 42 additions & 7 deletions LarkatorGUI/LarkatorGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<MapFileExtensions>true</MapFileExtensions>
<ProductName>Larkator</ProductName>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down Expand Up @@ -74,6 +74,9 @@
<SignManifests>false</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="AvalonLibrary, Version=2.3.0.0, Culture=neutral, PublicKeyToken=b5d01516e28df45f, processorArchitecture=MSIL">
<HintPath>..\packages\AvalonLibrary.2.3.0.0\lib\net40\AvalonLibrary.dll</HintPath>
</Reference>
<Reference Include="FastMember.Signed, Version=1.0.0.9, Culture=neutral, PublicKeyToken=9e8f22703bef9a29, processorArchitecture=MSIL">
<HintPath>..\packages\FastMember.Signed.1.1.0\lib\net40\FastMember.Signed.dll</HintPath>
</Reference>
Expand All @@ -83,8 +86,8 @@
<Reference Include="GongSolutions.WPF.DragDrop, Version=1.2.0.57, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\gong-wpf-dragdrop.1.2.0-alpha0057\lib\net46\GongSolutions.WPF.DragDrop.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.1-beta1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand All @@ -111,11 +114,23 @@
<Compile Include="ArkReader.cs" />
<Compile Include="DinoViewModel.cs" />
<Compile Include="ExternalToolsException.cs" />
<Compile Include="DirectoryEntryBox.xaml.cs">
<DependentUpon>DirectoryEntryBox.xaml</DependentUpon>
</Compile>
<Compile Include="FileEntryBox.xaml.cs">
<DependentUpon>FileEntryBox.xaml</DependentUpon>
</Compile>
<Compile Include="ListViewHackyCell.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Converters.cs" />
<Compile Include="NumericEntryControl.xaml.cs">
<DependentUpon>NumericEntryControl.xaml</DependentUpon>
</Compile>
<Compile Include="SettingsWindow.xaml.cs">
<DependentUpon>SettingsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Welcome.xaml.cs">
<DependentUpon>Welcome.xaml</DependentUpon>
</Compile>
Expand All @@ -124,10 +139,26 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="WindowAspectRatio.cs" />
<Page Include="DirectoryEntryBox.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="FileEntryBox.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="NumericEntryControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SettingsWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Welcome.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand All @@ -151,11 +182,15 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<Generator>PublicSettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
Expand Down
Loading

0 comments on commit bd825fc

Please sign in to comment.