Commit d664ac6d authored by Kad Venku's avatar Kad Venku

Finished search modes.

parent 382fc841
......@@ -28,7 +28,7 @@
<RowDefinition Height="3*"/>
<RowDefinition Height="1*" MinHeight="150"/>
</Grid.RowDefinitions>
<DataGrid x:Name="_basicEditorDataGrid" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" ItemsSource="{Binding ListItemCollection}" AutoGenerateColumns="False" CanUserReorderColumns="False" SelectionUnit="FullRow" MouseDoubleClick="_basicEditorDataGrid_OnDoubleClick" EnableColumnVirtualization="True" IsReadOnly="True" >
<DataGrid x:Name="_basicEditorDataGrid" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" ItemsSource="{Binding TranslationCollection}" AutoGenerateColumns="False" CanUserReorderColumns="False" SelectionUnit="FullRow" MouseDoubleClick="_basicEditorDataGrid_OnDoubleClick" EnableColumnVirtualization="True" IsReadOnly="True" >
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Header="Copy">
......@@ -64,11 +64,11 @@
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<Button x:Name="_refreshButton" Content="{iconPacks:FontAwesome SyncSolid}" Grid.Column="0" Click="OnRefreshClick" ToolTip="Refresh..."/>
<Button x:Name="_refreshButton" Content="{iconPacks:FontAwesome SearchSolid}" Grid.Column="0" Click="OnRefreshClick" ToolTip="Search/Refresh"/>
<Button x:Name="_clearButton" Content="{iconPacks:FontAwesome TrashSolid}" Grid.Column="1" Click="OnClearClick" ToolTip="Clear..."/>
</Grid>
<RadioButton Content="Search keys" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" Margin="10,0,0,0" IsChecked="{Binding Path=UseKeySearch, Mode=TwoWay}" />
<RadioButton Content="Search translation" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="3" Margin="10,0,0,0" IsChecked="{Binding Path=UseValueSearch, Mode=TwoWay}"/>
<RadioButton Content="Search keys" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" Margin="10,0,0,0" IsChecked="{Binding Path=IsKeySearchChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<RadioButton Content="Search translation" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="3" Margin="10,0,0,0" IsChecked="{Binding Path=IsValueSearchChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<CheckBox x:Name="_enableAdvancedSearchCheckBox" Content="Enable advanced search options" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3" Margin="10,0,0,0" IsChecked="{Binding Path=IsAdvancedSearchCheckBoxChecked, Mode=TwoWay}" Checked="AdvancedSearchCheckBoxCheckedChanged" Unchecked="AdvancedSearchCheckBoxCheckedChanged"/>
</Grid>
</GroupBox>
......@@ -86,7 +86,7 @@
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<CheckBox x:Name="_matchCaseCheckBox" Content="Match case" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" IsChecked="{Binding Path=MatchCase, Mode=TwoWay}"/>
<CheckBox x:Name="_matchCaseCheckBox" Content="Match case" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" IsChecked="{Binding Path=IsMatchCaseChecked, Mode=TwoWay}"/>
<RadioButton x:Name="_normalCheckBox" Content="Simple Search" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" IsChecked="{Binding Path=UseSimpleSearch, Mode=TwoWay}"/>
<RadioButton x:Name="_wildCardCheckBox" Content="Wildcard Search" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="3" IsChecked="{Binding Path=UseWildCardSearch, Mode=TwoWay}"/>
<RadioButton x:Name="_regExSearch" Content="RegEx Search" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3" IsChecked="{Binding Path=UseRegExSearch, Mode=TwoWay}"/>
......
using System;
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
......@@ -33,9 +32,9 @@ namespace eaw_texteditor.client.ui.main
private void ImportFormData(MainWindowData data)
{
data.UseKeySearch = true;
data.IsKeySearchChecked = true;
data.UseSimpleSearch = true;
data.MatchCase = true;
data.IsMatchCaseChecked = true;
FormData = data;
DataContext = data;
}
......@@ -114,5 +113,10 @@ namespace eaw_texteditor.client.ui.main
}
}
private void OnSearchClick(object sender, RoutedEventArgs e)
{
FormData.TryRefresh();
}
}
}
......@@ -114,6 +114,7 @@
<Compile Include="ObservableTranslationDataHolder.xaml.cs">
<DependentUpon>ObservableTranslationDataHolder.xaml</DependentUpon>
</Compile>
<Compile Include="shared\common\util\search\SearchUtility.cs" />
<Compile Include="shared\common\util\ui\UiUtility.cs" />
<Compile Include="shared\data\dialogs\edit\EditTextKeyWindowData.cs" />
<Compile Include="shared\data\AWindowData.cs" />
......@@ -166,7 +167,6 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="ClassDiagram1.cd" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
......
using System;
using System.Text.RegularExpressions;
namespace eaw_texteditor.shared.common.util.search
{
internal static class SearchUtility
{
public static bool VerifyRegEx(string testPattern)
{
bool isValid = true;
if ((testPattern != null) && (testPattern.Trim().Length > 0))
{
try
{
Regex.Match("", testPattern);
}
catch (ArgumentException)
{
isValid = false;
}
}
else
{
isValid = false;
}
return (isValid);
}
public static bool RegExMatch(string regEx, string patternToMatch, RegexOptions option = RegexOptions.None)
{
regEx = "^" + regEx + "$";
return VerifyRegEx(regEx) && new Regex(regEx, option).Match(patternToMatch).Success;
}
public static bool PatternMatch(string pattern, string patterntoMatch, RegexOptions option = RegexOptions.None)
{
return RegExMatch(GenerateRegExFromPattern(pattern), patterntoMatch, option);
}
public static string GenerateRegExFromPattern(string pattern)
{
string regEx = pattern.Replace("?", ".");
regEx = regEx.Replace("*", ".*");
return regEx;
}
}
}
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