Commit 7c0e7826 authored by Kad Venku's avatar Kad Venku

Implemented import and export functionality.

TODO: Import form DAT doesn't work at the moment.
parent d664ac6d
......@@ -39,8 +39,8 @@
<TextBlock Grid.Row="1" Grid.Column="1" Foreground="Crimson" Text="The text key should only contain uppercase letters, numbers and underscores. Some hardcoded vanilla keys do not follow this convention, so the message can be disregarded for those keys." Visibility="{Binding IsBoltVisible}" Margin="0" TextWrapping="Wrap"/>
<TextBox x:Name="_valueTextBox" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Stretch" Margin="0,5" Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" SpellCheck.IsEnabled="True" MinLines="5"/>
<UniformGrid Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" Columns="2">
<Button Content="Add" Margin="5" Click="OnAddClick" IsEnabled="{Binding IsValidKey, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
<Button Content="Cancel" IsDefault="True" Margin="5" Click="OnCancelClick"/>
<Button Content="Add" Margin="5" Click="OnAddClick" IsEnabled="{Binding IsValidKey, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource AccentedSquareButtonStyle}"/>
<Button Content="Cancel" IsDefault="True" Margin="5" Click="OnCancelClick" Style="{DynamicResource AccentedSquareButtonStyle}"/>
</UniformGrid>
</Grid>
</simpleChildWindow:ChildWindow>
......@@ -6,7 +6,8 @@
xmlns:local="clr-namespace:eaw_texteditor.client.ui.dialogs.edit"
xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" x:Class="eaw_texteditor.client.ui.dialogs.edit.EditTextKeyWindow"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
x:Class="eaw_texteditor.client.ui.dialogs.edit.EditTextKeyWindow"
BorderBrush="{DynamicResource AccentBaseColorBrush}"
BorderThickness="1"
GlowBrush="{DynamicResource AccentColorBrush}"
......
<simpleChildWindow:ChildWindow
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:eaw_texteditor.client.ui.dialogs.export"
xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
x:Class="eaw_texteditor.client.ui.dialogs.export.ExportToFileWindow"
BorderBrush="{DynamicResource AccentBaseColorBrush}"
BorderThickness="1"
GlowBrush="{DynamicResource AccentColorBrush}"
mc:Ignorable="d"
ShowTitleBar="False"
HorizontalContentAlignment="Stretch"
EnableDropShadow="False"
CloseOnOverlay="True">
<Grid Margin="0,50,0,50" MaxWidth="400">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Button x:Name="_exportToXmlButton" Grid.Row="0" Grid.Column="1" Margin="0,5,0,5" HorizontalAlignment="Stretch" Content="Export to *.xml file ..." Style="{DynamicResource AccentedSquareButtonStyle}" Click="_exportToXmlButton_OnClick"/>
<Button x:Name="_exportToDatButton" Grid.Row="1" Grid.Column="1" Margin="0,5,0,5" HorizontalAlignment="Stretch" Content="Export to *.dat file ..." Style="{DynamicResource AccentedSquareButtonStyle}" Click="_exportToDatButton_OnClick"/>
</Grid>
</simpleChildWindow:ChildWindow>
using System;
using System.Windows;
using eaw_texteditor.shared.data.dialogs.export;
using MahApps.Metro.SimpleChildWindow;
using Microsoft.WindowsAPICodePack.Dialogs;
using ts.translation.common.typedefs;
namespace eaw_texteditor.client.ui.dialogs.export
{
/// <summary>
/// Interaction logic for ExportToFileWindow.xaml
/// </summary>
public partial class ExportToFileWindow : ChildWindow
{
internal ExportToFileWindowData FormData { get; set; }
public ExportToFileWindow()
{
InitializeComponent();
ImportFormData(new ExportToFileWindowData());
}
private void ImportFormData(ExportToFileWindowData data)
{
FormData = data;
DataContext = data;
}
private void _exportToXmlButton_OnClick(object sender, RoutedEventArgs e)
{
using (CommonOpenFileDialog saveFileDialog = new CommonOpenFileDialog())
{
saveFileDialog.IsFolderPicker = true;
saveFileDialog.AllowNonFileSystemItems = false;
saveFileDialog.Multiselect = false;
saveFileDialog.EnsurePathExists = true;
if (saveFileDialog.ShowDialog() == CommonFileDialogResult.Ok)
{
FormData.ExportPath = saveFileDialog.FileName;
FormData.ExportType = TSFileTypes.FileTypeXml;
FormData.ResultOk = true;
this.Close();
}
}
}
private void _exportToDatButton_OnClick(object sender, RoutedEventArgs e)
{
using (CommonOpenFileDialog saveFileDialog = new CommonOpenFileDialog())
{
saveFileDialog.IsFolderPicker = true;
saveFileDialog.AllowNonFileSystemItems = false;
saveFileDialog.Multiselect = false;
saveFileDialog.EnsurePathExists = true;
if (saveFileDialog.ShowDialog() == CommonFileDialogResult.Ok)
{
FormData.ExportPath = saveFileDialog.FileName;
FormData.ExportType = TSFileTypes.FileTypeDat;
FormData.ResultOk = true;
this.Close();
}
}
}
}
}
<simpleChildWindow:ChildWindow
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:eaw_texteditor.client.ui.dialogs.load"
xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
x:Class="eaw_texteditor.client.ui.dialogs.load.LoadFromFileWindow"
BorderBrush="{DynamicResource AccentBaseColorBrush}"
BorderThickness="1"
GlowBrush="{DynamicResource AccentColorBrush}"
mc:Ignorable="d"
ShowTitleBar="False"
HorizontalContentAlignment="Stretch"
EnableDropShadow="False"
CloseOnOverlay="True">
<Grid Margin="0,50,0,50" MaxWidth="400">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Button x:Name="_loadFromXmlButton" Grid.Row="0" Grid.Column="1" Margin="0,5,0,5" HorizontalAlignment="Stretch" Content="Import from *.xml file ..." Style="{DynamicResource AccentedSquareButtonStyle}" Click="_loadFromXmlButton_OnClick"/>
<Button x:Name="_loadFromDatButton" Grid.Row="1" Grid.Column="1" Margin="0,5,0,5" HorizontalAlignment="Stretch" Content="Import from *.dat file ..." Style="{DynamicResource AccentedSquareButtonStyle}" Click="_loadFromDatButton_OnClick"/>
</Grid>
</simpleChildWindow:ChildWindow>
using System.Windows;
using System.Windows.Forms;
using eaw_texteditor.shared.data.dialogs.load;
using MahApps.Metro.SimpleChildWindow;
using ts.translation.common.typedefs;
using MessageBox = System.Windows.Forms.MessageBox;
namespace eaw_texteditor.client.ui.dialogs.load
{
/// <summary>
/// Interaction logic for LoadFromFileWindow.xaml
/// </summary>
public partial class LoadFromFileWindow : ChildWindow
{
internal LoadFromFileWindowData FormData { get; set; }
public LoadFromFileWindow()
{
InitializeComponent();
ImportFormData(new LoadFromFileWindowData());
}
private void ImportFormData(LoadFromFileWindowData data)
{
FormData = data;
DataContext = data;
}
private void _loadFromXmlButton_OnClick(object sender, RoutedEventArgs e)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.Filter = "xml files (*.xml)|*.xml";
openFileDialog.CheckPathExists = true;
openFileDialog.CheckFileExists = true;
openFileDialog.Multiselect = false;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
FormData.ImportPath = openFileDialog.FileName;
FormData.ImportType = TSFileTypes.FileTypeXml;
FormData.ResultOk = true;
this.Close();
}
}
}
private void _loadFromDatButton_OnClick(object sender, RoutedEventArgs e)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.Filter = "dat files (*.dat)|mastertextfile_*.dat";
openFileDialog.CheckPathExists = true;
openFileDialog.CheckFileExists = true;
openFileDialog.Multiselect = false;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
FormData.ImportPath = openFileDialog.FileName;
FormData.ImportType = TSFileTypes.FileTypeDat;
FormData.ResultOk = true;
this.Close();
}
}
}
}
}
<simpleChildWindow:ChildWindow
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:eaw_texteditor.client.ui.dialogs.load"
xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
x:Class="eaw_texteditor.client.ui.dialogs.load.LoadingScreenWindow"
BorderBrush="{DynamicResource AccentBaseColorBrush}"
BorderThickness="1"
GlowBrush="{DynamicResource AccentColorBrush}"
mc:Ignorable="d"
ShowTitleBar="False"
HorizontalContentAlignment="Stretch"
EnableDropShadow="False"
CloseOnOverlay="True">
<Grid Margin="0,50,0,50" MaxWidth="400">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<mah:ProgressRing Grid.Row="0" Grid.Column="1" IsActive="True" />
</Grid>
</simpleChildWindow:ChildWindow>
using MahApps.Metro.SimpleChildWindow;
namespace eaw_texteditor.client.ui.dialogs.load
{
/// <summary>
/// Interaction logic for LoadingScreenWindow.xaml
/// </summary>
public partial class LoadingScreenWindow : ChildWindow
{
public LoadingScreenWindow()
{
InitializeComponent();
}
}
}
......@@ -76,6 +76,12 @@
<Reference Include="MahApps.Metro.SimpleChildWindow, Version=1.5.0.16, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.SimpleChildWindow.1.5.0\lib\net45\MahApps.Metro.SimpleChildWindow.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.3.3, Culture=neutral, PublicKeyToken=8985beaab7ea3f04, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft-WindowsAPICodePack-Core.1.1.3.3\lib\net452\Microsoft.WindowsAPICodePack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.3.3, Culture=neutral, PublicKeyToken=8985beaab7ea3f04, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft-WindowsAPICodePack-Shell.1.1.3.3\lib\net452\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
</Reference>
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
<Reference Include="System" />
<Reference Include="System.Data" />
......@@ -108,6 +114,15 @@
<Compile Include="client\ui\dialogs\edit\EditTextKeyWindow.xaml.cs">
<DependentUpon>EditTextKeyWindow.xaml</DependentUpon>
</Compile>
<Compile Include="client\ui\dialogs\export\ExportToFileWindow.xaml.cs">
<DependentUpon>ExportToFileWindow.xaml</DependentUpon>
</Compile>
<Compile Include="client\ui\dialogs\load\LoadFromFileWindow.xaml.cs">
<DependentUpon>LoadFromFileWindow.xaml</DependentUpon>
</Compile>
<Compile Include="client\ui\dialogs\load\LoadingScreenWindow.xaml.cs">
<DependentUpon>LoadingScreenWindow.xaml</DependentUpon>
</Compile>
<Compile Include="client\ui\dialogs\settings\SettingsWindow.xaml.cs">
<DependentUpon>SettingsWindow.xaml</DependentUpon>
</Compile>
......@@ -118,6 +133,8 @@
<Compile Include="shared\common\util\ui\UiUtility.cs" />
<Compile Include="shared\data\dialogs\edit\EditTextKeyWindowData.cs" />
<Compile Include="shared\data\AWindowData.cs" />
<Compile Include="shared\data\dialogs\export\ExportToFileWindowData.cs" />
<Compile Include="shared\data\dialogs\load\LoadFromFileWindowData.cs" />
<Compile Include="shared\data\dialogs\settings\SettingsWindowData.cs" />
<Compile Include="shared\data\main\MainWindowData.cs" />
<Page Include="client\ui\dialogs\add\AddTextKeyWindow.xaml">
......@@ -128,6 +145,18 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="client\ui\dialogs\export\ExportToFileWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="client\ui\dialogs\load\LoadFromFileWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="client\ui\dialogs\load\LoadingScreenWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="client\ui\dialogs\settings\SettingsWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
......@@ -6,4 +6,6 @@
<package id="MahApps.Metro" version="1.6.5" targetFramework="net45" requireReinstallation="true" />
<package id="MahApps.Metro.IconPacks" version="2.3.0" targetFramework="net45" requireReinstallation="true" />
<package id="MahApps.Metro.SimpleChildWindow" version="1.5.0" targetFramework="net471" />
<package id="Microsoft-WindowsAPICodePack-Core" version="1.1.3.3" targetFramework="net471" />
<package id="Microsoft-WindowsAPICodePack-Shell" version="1.1.3.3" targetFramework="net471" />
</packages>
\ No newline at end of file
......@@ -12,12 +12,15 @@ namespace eaw_texteditor.shared.data.dialogs.edit
{
private ObservableTranslationData _translation;
public bool TranslationChanged = false;
public ObservableTranslationData Translation
{
get => _translation;
set
{
_translation = value;
TranslationChanged = true;
OnPropertyChanged(nameof(Translation));
}
}
......
using System.ComponentModel;
using System.Runtime.CompilerServices;
using ts.translation.Annotations;
using ts.translation.common.typedefs;
namespace eaw_texteditor.shared.data.dialogs.export
{
class ExportToFileWindowData : INotifyPropertyChanged
{
private string _exportPath;
private TSFileTypes _exportType;
public string ExportPath
{
get => _exportPath;
set
{
_exportPath = value;
OnPropertyChanged(nameof(ExportPath));
}
}
public TSFileTypes ExportType
{
get => _exportType;
set
{
_exportType = value;
OnPropertyChanged(nameof(ExportType));
}
}
public bool ResultOk { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
using System.ComponentModel;
using System.Runtime.CompilerServices;
using ts.translation.Annotations;
using ts.translation.common.typedefs;
namespace eaw_texteditor.shared.data.dialogs.load
{
internal class LoadFromFileWindowData : INotifyPropertyChanged
{
private string _importPath;
private TSFileTypes _importType;
public string ImportPath
{
get => _importPath;
set
{
_importPath = value;
OnPropertyChanged(nameof(ImportPath));
}
}
public TSFileTypes ImportType
{
get => _importType;
set
{
_importType = value;
OnPropertyChanged(nameof(ImportType));
}
}
public bool ResultOk { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
......@@ -13,6 +13,32 @@ namespace eaw_texteditor.shared.data.main
{
public class MainWindowData : INotifyPropertyChanged
{
private bool _isEdited;
public bool IsEdited
{
get => _isEdited;
set
{
_isEdited = value;
OnPropertyChanged(nameof(IsEdited));
}
}
private bool _isTranslationDataLoaded;
public bool IsTranslationDataLoaded
{
get => _isTranslationDataLoaded;
set
{
_isTranslationDataLoaded = value;
OnPropertyChanged(nameof(IsTranslationDataLoaded));
}
}
private bool _isAdvancedSearchCheckBoxChecked;
public bool IsAdvancedSearchCheckBoxChecked
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment