...
 
Commits (2)
  • Kad Venku's avatar
    Synchronises all branches. · 245c78d0
    Kad Venku authored
    245c78d0
  • Kad Venku's avatar
    Merge branch... · 3a5c755e
    Kad Venku authored
    Merge branch 'features/3-adding-a-new-translation-for-a-open-project-with-multiple-languages' into 'develop'
    
    Develop Sync
    
    Closes #10
    
    See merge request Kad_Venku/eaw-texteditor!3
    3a5c755e
...@@ -13,6 +13,15 @@ ...@@ -13,6 +13,15 @@
<setting name="USR_LOADED_LANGUAGE" serializeAs="String"> <setting name="USR_LOADED_LANGUAGE" serializeAs="String">
<value>ENGLISH</value> <value>ENGLISH</value>
</setting> </setting>
<setting name="USR_BASE_THEME" serializeAs="String">
<value>BaseLight</value>
</setting>
<setting name="USR_ACCENT_COLOUR" serializeAs="String">
<value>Cyan</value>
</setting>
<setting name="USR_MASTER_LANGUAGE" serializeAs="String">
<value>ENGLISH</value>
</setting>
</eaw_texteditor.Properties.Settings> </eaw_texteditor.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>
using System; using System.Windows;
using System.Collections.Generic; using eaw_texteditor.Properties;
using System.Configuration; using MahApps.Metro;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace eaw_texteditor namespace eaw_texteditor
{ {
/// <summary> /// <summary>
/// Interaction logic for App.xaml /// Interaction logic for App.xaml
/// </summary> /// </summary>
public partial class App : Application public partial class App
{ {
protected override void OnStartup(StartupEventArgs e)
{
ThemeManager.ChangeAppStyle(Current, ThemeManager.GetAccent(Settings.Default.USR_ACCENT_COLOUR), ThemeManager.GetAppTheme(Settings.Default.USR_BASE_THEME));
base.OnStartup(e);
}
} }
} }
...@@ -12,7 +12,7 @@ namespace eaw_texteditor.Properties { ...@@ -12,7 +12,7 @@ namespace eaw_texteditor.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
...@@ -34,5 +34,41 @@ namespace eaw_texteditor.Properties { ...@@ -34,5 +34,41 @@ namespace eaw_texteditor.Properties {
this["USR_LOADED_LANGUAGE"] = value; this["USR_LOADED_LANGUAGE"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("BaseLight")]
public string USR_BASE_THEME {
get {
return ((string)(this["USR_BASE_THEME"]));
}
set {
this["USR_BASE_THEME"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Cyan")]
public string USR_ACCENT_COLOUR {
get {
return ((string)(this["USR_ACCENT_COLOUR"]));
}
set {
this["USR_ACCENT_COLOUR"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("ENGLISH")]
public global::ts.translation.common.typedefs.PGLanguage USR_MASTER_LANGUAGE {
get {
return ((global::ts.translation.common.typedefs.PGLanguage)(this["USR_MASTER_LANGUAGE"]));
}
set {
this["USR_MASTER_LANGUAGE"] = value;
}
}
} }
} }
...@@ -5,5 +5,14 @@ ...@@ -5,5 +5,14 @@
<Setting Name="USR_LOADED_LANGUAGE" Type="ts.translation.common.typedefs.PGLanguage" Scope="User"> <Setting Name="USR_LOADED_LANGUAGE" Type="ts.translation.common.typedefs.PGLanguage" Scope="User">
<Value Profile="(Default)">ENGLISH</Value> <Value Profile="(Default)">ENGLISH</Value>
</Setting> </Setting>
<Setting Name="USR_BASE_THEME" Type="System.String" Scope="User">
<Value Profile="(Default)">BaseLight</Value>
</Setting>
<Setting Name="USR_ACCENT_COLOUR" Type="System.String" Scope="User">
<Value Profile="(Default)">Cyan</Value>
</Setting>
<Setting Name="USR_MASTER_LANGUAGE" Type="ts.translation.common.typedefs.PGLanguage" Scope="User">
<Value Profile="(Default)">ENGLISH</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>
\ No newline at end of file
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/> <ColumnDefinition Width="50"/>
...@@ -36,8 +37,9 @@ ...@@ -36,8 +37,9 @@
<VisualBrush Visual="{iconPacks:FontAwesome BoltSolid}"/> <VisualBrush Visual="{iconPacks:FontAwesome BoltSolid}"/>
</Rectangle.OpacityMask> </Rectangle.OpacityMask>
</Rectangle> </Rectangle>
<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"/> <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 IsInvalidVisible}" Margin="0" TextWrapping="Wrap"/>
<Grid Margin="0" Grid.Row="2" Grid.Column="1"> <TextBlock Grid.Row="2" Grid.Column="1" Foreground="Crimson" Text="The key already exists." Visibility="{Binding IsDuplicateVisible}" Margin="0" TextWrapping="Wrap"/>
<Grid Margin="0" Grid.Row="3" Grid.Column="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
...@@ -60,9 +62,9 @@ ...@@ -60,9 +62,9 @@
<Label x:Name="_valueSpanishLabel" Content="Spanish:" Grid.Row="4" Grid.Column="0" Visibility="Collapsed"/> <Label x:Name="_valueSpanishLabel" Content="Spanish:" Grid.Row="4" Grid.Column="0" Visibility="Collapsed"/>
<TextBox x:Name="_valueSpanishTextBox" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Stretch" Margin="0,5" Text="{Binding SpanishText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" SpellCheck.IsEnabled="True" MinLines="3" Visibility="Collapsed"/> <TextBox x:Name="_valueSpanishTextBox" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Stretch" Margin="0,5" Text="{Binding SpanishText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" SpellCheck.IsEnabled="True" MinLines="3" Visibility="Collapsed"/>
</Grid> </Grid>
<UniformGrid Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" Columns="2"> <UniformGrid Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" Columns="2">
<Button Content="Add" Margin="5" Click="OnAddClick" IsEnabled="{Binding IsValidKey, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource AccentedSquareButtonStyle}"/> <Button Content="Add" Margin="5" Click="OnAddClick" IsEnabled="{Binding IsValid, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource MetroFlatButton}"/>
<Button Content="Cancel" IsDefault="True" Margin="5" Click="OnCancelClick" Style="{DynamicResource AccentedSquareButtonStyle}"/> <Button Content="Cancel" IsDefault="True" Margin="5" Click="OnCancelClick" Style="{DynamicResource MetroFlatButton}"/>
</UniformGrid> </UniformGrid>
</Grid> </Grid>
</simpleChildWindow:ChildWindow> </simpleChildWindow:ChildWindow>
using System; using System;
using System.Windows; using System.Windows;
using eaw_texteditor.shared.data.dialogs.edit; using eaw_texteditor.shared.data.dialogs.add;
using MahApps.Metro.SimpleChildWindow; using MahApps.Metro.SimpleChildWindow;
using ts.translation; using ts.translation;
using ts.translation.common.typedefs; using ts.translation.common.typedefs;
...@@ -13,11 +13,11 @@ namespace eaw_texteditor.client.ui.dialogs.add ...@@ -13,11 +13,11 @@ namespace eaw_texteditor.client.ui.dialogs.add
/// </summary> /// </summary>
public partial class AddTextKeyWindow : ChildWindow public partial class AddTextKeyWindow : ChildWindow
{ {
internal EditTextKeyWindowData FormData { get; set; } internal AddTextKeyWindowData FormData { get; set; }
public AddTextKeyWindow(PGLanguage selectedLanguage, ObservableTranslationData translationEnglish, ObservableTranslationData translationGerman, ObservableTranslationData translationFrench, ObservableTranslationData translationItalian, ObservableTranslationData translationSpanish) public AddTextKeyWindow(PGLanguage selectedLanguage, ObservableTranslationData translationEnglish, ObservableTranslationData translationGerman, ObservableTranslationData translationFrench, ObservableTranslationData translationItalian, ObservableTranslationData translationSpanish)
{ {
InitializeComponent(); InitializeComponent();
FormData = new EditTextKeyWindowData() {SelectedLanguage = selectedLanguage, TranslationEnglish = translationEnglish, TranslationGerman = translationGerman, TranslationFrench = translationFrench, TranslationItalian = translationItalian, TranslationSpanish = translationSpanish}; FormData = new AddTextKeyWindowData() {SelectedLanguage = selectedLanguage, TranslationEnglish = translationEnglish, TranslationGerman = translationGerman, TranslationFrench = translationFrench, TranslationItalian = translationItalian, TranslationSpanish = translationSpanish};
DataContext = FormData; DataContext = FormData;
FormData.IsKeyEditable = true; FormData.IsKeyEditable = true;
FormData.IsValidKey = false; FormData.IsValidKey = false;
......
using System; using System;
using System.Windows; using System.Windows;
using eaw_texteditor.Properties;
using eaw_texteditor.shared.data.dialogs.edit; using eaw_texteditor.shared.data.dialogs.edit;
using MahApps.Metro.SimpleChildWindow; using MahApps.Metro.SimpleChildWindow;
using ts.translation; using ts.translation;
...@@ -27,7 +26,7 @@ namespace eaw_texteditor.client.ui.dialogs.edit ...@@ -27,7 +26,7 @@ namespace eaw_texteditor.client.ui.dialogs.edit
DataContext = FormData; DataContext = FormData;
} }
private void OnClosingFinished(object sender, System.Windows.RoutedEventArgs e) private void OnClosingFinished(object sender, RoutedEventArgs e)
{ {
foreach (PGLanguage loadedLanguage in PGTEXTS.GetLoadedLanguages()) foreach (PGLanguage loadedLanguage in PGTEXTS.GetLoadedLanguages())
{ {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/> <ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions> </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="_exportToXmlButton" Grid.Row="0" Grid.Column="1" Margin="0,5,0,5" HorizontalAlignment="Stretch" Content="Export to *.xml file ..." Style="{DynamicResource MetroFlatButton}" 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"/> <Button x:Name="_exportToDatButton" Grid.Row="1" Grid.Column="1" Margin="0,5,0,5" HorizontalAlignment="Stretch" Content="Export to *.dat file ..." Style="{DynamicResource MetroFlatButton}" Click="_exportToDatButton_OnClick"/>
</Grid> </Grid>
</simpleChildWindow:ChildWindow> </simpleChildWindow:ChildWindow>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/> <ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions> </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="_loadFromXmlButton" Grid.Row="0" Grid.Column="1" Margin="0,5,0,5" HorizontalAlignment="Stretch" Content="Import from *.xml file ..." Style="{DynamicResource MetroFlatButton}" 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"/> <Button x:Name="_loadFromDatButton" Grid.Row="1" Grid.Column="1" Margin="0,5,0,5" HorizontalAlignment="Stretch" Content="Import from *.dat file ..." Style="{DynamicResource MetroFlatButton}" Click="_loadFromDatButton_OnClick"/>
</Grid> </Grid>
</simpleChildWindow:ChildWindow> </simpleChildWindow:ChildWindow>
...@@ -33,5 +33,6 @@ ...@@ -33,5 +33,6 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="1" Content="Language:"/> <Label Grid.Row="0" Grid.Column="1" Content="Language:"/>
<ComboBox Grid.Row="0" Grid.Column="2" HorizontalAlignment="Stretch" IsReadOnly="True" ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage}"/> <ComboBox Grid.Row="0" Grid.Column="2" HorizontalAlignment="Stretch" IsReadOnly="True" ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage}"/>
<Button x:Name="_performProjectFixup" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,5,0,5" HorizontalAlignment="Stretch" Content="Perform project fixup..." Style="{DynamicResource AccentedSquareButtonStyle}" Click="_performProjectFixup_OnClick"/>
</Grid> </Grid>
</simpleChildWindow:ChildWindow> </simpleChildWindow:ChildWindow>
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Windows;
using eaw_texteditor.client.ui.main;
using eaw_texteditor.shared.data.dialogs.settings; using eaw_texteditor.shared.data.dialogs.settings;
using MahApps.Metro.Controls.Dialogs;
using MahApps.Metro.SimpleChildWindow; using MahApps.Metro.SimpleChildWindow;
using ts.translation; using ts.translation;
using ts.translation.common.typedefs; using ts.translation.common.typedefs;
...@@ -15,5 +19,17 @@ namespace eaw_texteditor.client.ui.dialogs.settings ...@@ -15,5 +19,17 @@ namespace eaw_texteditor.client.ui.dialogs.settings
FormData = new SettingsWindowData(PGTEXTS.GetLoadedLanguages() as List<PGLanguage>); FormData = new SettingsWindowData(PGTEXTS.GetLoadedLanguages() as List<PGLanguage>);
DataContext = FormData; DataContext = FormData;
} }
private async void _performProjectFixup_OnClick(object sender, RoutedEventArgs e)
{
try
{
PGTEXTS.PerformTranslationFixup(FormData.SelectedLanguage);
}
catch (Exception ex)
{
await ((MainWindow)this.Parent).ShowMessageAsync("Warning!", $"Something went wrong.\n{ex}");
}
}
} }
} }
...@@ -152,6 +152,7 @@ ...@@ -152,6 +152,7 @@
</Compile> </Compile>
<Compile Include="shared\common\util\search\SearchUtility.cs" /> <Compile Include="shared\common\util\search\SearchUtility.cs" />
<Compile Include="shared\common\util\ui\UiUtility.cs" /> <Compile Include="shared\common\util\ui\UiUtility.cs" />
<Compile Include="shared\data\dialogs\add\AddTextKeyWindowData.cs" />
<Compile Include="shared\data\dialogs\edit\EditTextKeyWindowData.cs" /> <Compile Include="shared\data\dialogs\edit\EditTextKeyWindowData.cs" />
<Compile Include="shared\data\AWindowData.cs" /> <Compile Include="shared\data\AWindowData.cs" />
<Compile Include="shared\data\dialogs\export\ExportToFileWindowData.cs" /> <Compile Include="shared\data\dialogs\export\ExportToFileWindowData.cs" />
......
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Media;
using eaw_texteditor.shared.data.dialogs.edit;
using ts.translation;
namespace eaw_texteditor.shared.data.dialogs.add
{
internal class AddTextKeyWindowData : EditTextKeyWindowData
{
private bool _isDuplicate;
public bool IsDuplicate
{
get => _isDuplicate;
set
{
_isDuplicate = value;
SetValidStateForKeyTextBox();
OnPropertyChanged(nameof(IsValidKey));
}
}
public bool IsValid
{
get
{
return !IsDuplicate && IsValidKey;
}
}
private Visibility _isDuplicateVisible = Visibility.Collapsed;
public Visibility IsDuplicateVisible
{
get => _isDuplicateVisible;
set
{
_isDuplicateVisible = value;
OnPropertyChanged(nameof(IsDuplicateVisible));
}
}
protected override void SetValidStateForKeyTextBox()
{
IsInvalidVisible = !IsValidKey ? Visibility.Visible : Visibility.Collapsed;
IsDuplicateVisible = IsDuplicate ? Visibility.Visible : Visibility.Collapsed;
if (!IsValidKey || IsDuplicate)
{
BackgroundColor = new SolidColorBrush() { Color = Color.FromArgb(100, 220, 20, 60) };
IsBoltVisible = Visibility.Visible;
}
else
{
BackgroundColor = new SolidColorBrush() { Color = Color.FromArgb(255, 255, 255, 255) };
IsBoltVisible = Visibility.Collapsed;
}
OnPropertyChanged(nameof(IsValid));
}
protected override string DoValidate(string value)
{
if (string.IsNullOrEmpty(value))
{
IsValidKey = false;
IsDuplicate = false;
return string.Empty;
}
string newValue = value.TrimEnd();
Regex regEx = new Regex("^[A-Z0-9_]*$");
IsValidKey = regEx.Match(newValue).Success;
IsDuplicate = PGTEXTS.HasText(newValue);
return newValue;
}
}
}
\ No newline at end of file
...@@ -10,7 +10,7 @@ using ts.translation.data.holder.observables; ...@@ -10,7 +10,7 @@ using ts.translation.data.holder.observables;
namespace eaw_texteditor.shared.data.dialogs.edit namespace eaw_texteditor.shared.data.dialogs.edit
{ {
class EditTextKeyWindowData : INotifyPropertyChanged internal class EditTextKeyWindowData : INotifyPropertyChanged
{ {
private ObservableTranslationData _translationEnglish; private ObservableTranslationData _translationEnglish;
private ObservableTranslationData _translationGerman; private ObservableTranslationData _translationGerman;
...@@ -241,16 +241,18 @@ namespace eaw_texteditor.shared.data.dialogs.edit ...@@ -241,16 +241,18 @@ namespace eaw_texteditor.shared.data.dialogs.edit
} }
} }
private void SetValidStateForKeyTextBox() protected virtual void SetValidStateForKeyTextBox()
{ {
if (!IsValidKey) if (!IsValidKey)
{ {
BackgroundColor = new SolidColorBrush() {Color = Color.FromArgb(100, 220, 20, 60)}; BackgroundColor = new SolidColorBrush() {Color = Color.FromArgb(100, 220, 20, 60)};
IsBoltVisible = Visibility.Visible; IsBoltVisible = Visibility.Visible;
IsInvalidVisible = Visibility.Visible;
} }
else{ else{
BackgroundColor = new SolidColorBrush() {Color = Color.FromArgb(255, 255, 255, 255)}; BackgroundColor = new SolidColorBrush() {Color = Color.FromArgb(255, 255, 255, 255)};
IsBoltVisible = Visibility.Collapsed; IsBoltVisible = Visibility.Collapsed;
IsInvalidVisible = Visibility.Visible;
} }
} }
...@@ -266,7 +268,7 @@ namespace eaw_texteditor.shared.data.dialogs.edit ...@@ -266,7 +268,7 @@ namespace eaw_texteditor.shared.data.dialogs.edit
} }
} }
private string DoValidate(string value) protected virtual string DoValidate(string value)
{ {
if (string.IsNullOrEmpty(value)) if (string.IsNullOrEmpty(value))
{ {
...@@ -291,6 +293,18 @@ namespace eaw_texteditor.shared.data.dialogs.edit ...@@ -291,6 +293,18 @@ namespace eaw_texteditor.shared.data.dialogs.edit
} }
} }
private Visibility _isInvalidVisible = Visibility.Collapsed;
public Visibility IsInvalidVisible
{
get => _isInvalidVisible;
set
{
_isInvalidVisible = value;
OnPropertyChanged(nameof(IsInvalidVisible));
}
}
public PGLanguage SelectedLanguage { get; set; } public PGLanguage SelectedLanguage { get; set; }
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
......
...@@ -25,6 +25,29 @@ namespace eaw_texteditor.shared.data.main ...@@ -25,6 +25,29 @@ namespace eaw_texteditor.shared.data.main
} }
} }
private bool _isTodoFilterActive;
public bool IsTodoFilterActive
{
get => _isTodoFilterActive;
set
{
_isTodoFilterActive = value;
TryRefresh();
OnPropertyChanged(nameof(IsTodoFilterActive));
}
}
private IEnumerable<PGLanguage> _languages = new List<PGLanguage>();
public IEnumerable<PGLanguage> Languages
{
get => _languages;
set
{
_languages = value;
OnPropertyChanged(nameof(Languages));
}
}
private bool _isTranslationDataLoaded; private bool _isTranslationDataLoaded;
...@@ -52,6 +75,7 @@ namespace eaw_texteditor.shared.data.main ...@@ -52,6 +75,7 @@ namespace eaw_texteditor.shared.data.main
UseSimpleSearch = true; UseSimpleSearch = true;
IsMatchCaseChecked = true; IsMatchCaseChecked = true;
} }
TryRefresh();
OnPropertyChanged(nameof(IsAdvancedSearchCheckBoxChecked)); OnPropertyChanged(nameof(IsAdvancedSearchCheckBoxChecked));
} }
} }
...@@ -231,76 +255,108 @@ namespace eaw_texteditor.shared.data.main ...@@ -231,76 +255,108 @@ namespace eaw_texteditor.shared.data.main
} }
} }
} }
return Key_UseSimpleSearch_IgnoreCase; return Key_UseSimpleSearch_IgnoreCase;
} }
private bool Key_UseSimpleSearch_MatchCase(object value) private bool Key_UseSimpleSearch_MatchCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
{
return (string.IsNullOrEmpty(SearchTerm) || entry.Key.Contains(SearchTerm)) && entry.IsToDoItem;
}
return string.IsNullOrEmpty(SearchTerm) || entry.Key.Contains(SearchTerm); return string.IsNullOrEmpty(SearchTerm) || entry.Key.Contains(SearchTerm);
} }
private bool Key_UseSimpleSearch_IgnoreCase(object value) private bool Key_UseSimpleSearch_IgnoreCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
{
return (string.IsNullOrEmpty(SearchTerm) || entry.Key.ToLower().Contains(SearchTerm.ToLower())) && entry.IsToDoItem;
}
return string.IsNullOrEmpty(SearchTerm) || entry.Key.ToLower().Contains(SearchTerm.ToLower()); return string.IsNullOrEmpty(SearchTerm) || entry.Key.ToLower().Contains(SearchTerm.ToLower());
} }
private bool Key_UseRegExSearch_MatchCase(object value) private bool Key_UseRegExSearch_MatchCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
{
return (string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Key)) && entry.IsToDoItem;
}
return string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Key); return string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Key);
} }
private bool Key_UseRegExSearch_IgnoreCase(object value) private bool Key_UseRegExSearch_IgnoreCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
{
return (string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Key, RegexOptions.IgnoreCase)) && entry.IsToDoItem;
}
return string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Key, RegexOptions.IgnoreCase); return string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Key, RegexOptions.IgnoreCase);
} }
private bool Key_UsePatternMatchSearch_MatchCase(object value) private bool Key_UsePatternMatchSearch_MatchCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
return (string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Key)) && entry.IsToDoItem;
return string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Key); return string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Key);
} }
private bool Key_UsePatternMatchSearch_IgnoreCase(object value) private bool Key_UsePatternMatchSearch_IgnoreCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
return (string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Key, RegexOptions.IgnoreCase)) && entry.IsToDoItem;
return string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Key, RegexOptions.IgnoreCase); return string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Key, RegexOptions.IgnoreCase);
} }
private bool Value_UseRegExSearch_MatchCase(object value) private bool Value_UseRegExSearch_MatchCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
return (string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Value)) && entry.IsToDoItem;
return string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Value); return string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Value);
} }
private bool Value_UseRegExSearch_IgnoreCase(object value) private bool Value_UseRegExSearch_IgnoreCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
return (string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Value, RegexOptions.IgnoreCase)) && entry.IsToDoItem;
return string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Value, RegexOptions.IgnoreCase); return string.IsNullOrEmpty(SearchTerm) || SearchUtility.RegExMatch(SearchTerm, entry.Value, RegexOptions.IgnoreCase);
} }
private bool Value_UseSimpleSearch_MatchCase(object value) private bool Value_UseSimpleSearch_MatchCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
return (string.IsNullOrEmpty(SearchTerm) || entry.Value.Contains(SearchTerm)) && entry.IsToDoItem;
return string.IsNullOrEmpty(SearchTerm) || entry.Value.Contains(SearchTerm); return string.IsNullOrEmpty(SearchTerm) || entry.Value.Contains(SearchTerm);
} }
private bool Value_UseSimpleSearch_IgnoreCase(object value) private bool Value_UseSimpleSearch_IgnoreCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
return (string.IsNullOrEmpty(SearchTerm) || entry.Value.ToLower().Contains(SearchTerm.ToLower())) && entry.IsToDoItem;
return string.IsNullOrEmpty(SearchTerm) || entry.Value.ToLower().Contains(SearchTerm.ToLower()); return string.IsNullOrEmpty(SearchTerm) || entry.Value.ToLower().Contains(SearchTerm.ToLower());
} }
private bool Value_UsePatternMatchSearch_MatchCase(object value) private bool Value_UsePatternMatchSearch_MatchCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
return (string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Value)) && entry.IsToDoItem;
return string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Value); return string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Value);
} }
private bool Value_UsePatternMatchSearch_IgnoreCase(object value) private bool Value_UsePatternMatchSearch_IgnoreCase(object value)
{ {
if (!(value is ObservableTranslationData entry)) return false; if (!(value is ObservableTranslationData entry)) return false;
if (IsTodoFilterActive)
return (string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Value, RegexOptions.IgnoreCase)) && entry.IsToDoItem;
return string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Value, RegexOptions.IgnoreCase); return string.IsNullOrEmpty(SearchTerm) || SearchUtility.PatternMatch(SearchTerm, entry.Value, RegexOptions.IgnoreCase);
} }
...@@ -311,8 +367,8 @@ namespace eaw_texteditor.shared.data.main ...@@ -311,8 +367,8 @@ namespace eaw_texteditor.shared.data.main
get => _translationCollection; get => _translationCollection;
set { set {
_translationCollection = value; _translationCollection = value;
TryRefresh();
OnPropertyChanged(nameof(TranslationCollection)); OnPropertyChanged(nameof(TranslationCollection));
} }
} }
...@@ -340,7 +396,8 @@ namespace eaw_texteditor.shared.data.main ...@@ -340,7 +396,8 @@ namespace eaw_texteditor.shared.data.main
Dictionary<PGLanguage, CollectionViewSource> _sources = new Dictionary<PGLanguage, CollectionViewSource>(); Dictionary<PGLanguage, CollectionViewSource> _sources = new Dictionary<PGLanguage, CollectionViewSource>();
public Dictionary<PGLanguage, CollectionViewSource> Sources { get => _sources; public Dictionary<PGLanguage, CollectionViewSource> Sources {
get => _sources;
set set
{ {
_sources = value; _sources = value;
......