Skip to content

Commit

Permalink
DetailPage 검색어 유지 및 엔터 기능 동작 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ChJR authored and rkttu committed Oct 15, 2023
1 parent 8361d35 commit 79dca77
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/TableCloth/Models/DetailPageArgumentModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public DetailPageArgumentModel(

public bool ShowCommandLineHelp { get; private set; }

public string CurrentSearchString { get; set; }

public TableClothConfiguration GetTableClothConfiguration()
{
var certPublicKeyData = new byte[] { };
Expand Down
4 changes: 2 additions & 2 deletions src/TableCloth/Pages/CatalogPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private void SiteCatalog_KeyDown(object sender, KeyEventArgs e)
{
NavigationService.Navigate(
new Uri("Pages/DetailPage.xaml", UriKind.Relative),
new DetailPageArgumentModel(data, builtFromCommandLine: false));
new DetailPageArgumentModel(data, builtFromCommandLine: false) { CurrentSearchString = SiteCatalogFilter.Text });
}
}
}
Expand All @@ -234,7 +234,7 @@ private void SiteCatalog_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
NavigationService.Navigate(
new Uri("Pages/DetailPage.xaml", UriKind.Relative),
new DetailPageArgumentModel(data, builtFromCommandLine: false));
new DetailPageArgumentModel(data, builtFromCommandLine: false) { CurrentSearchString = SiteCatalogFilter.Text });
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/TableCloth/Pages/DetailPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<Image Source="{StaticResource BackButtonImage}" />
</Button.Content>
</Button>
<TextBox Grid.Row="0" Grid.Column="2" x:Name="SiteCatalogFilter" Width="Auto" Margin="8" VerticalContentAlignment="Center" GotKeyboardFocus="SiteCatalogFilter_GotKeyboardFocus" LostFocus="SiteCatalogFilter_LostFocus">
<TextBox.Style>
<TextBox Grid.Row="0" Grid.Column="2" x:Name="SiteCatalogFilter" Width="Auto" Margin="8" VerticalContentAlignment="Center" GotKeyboardFocus="SiteCatalogFilter_GotKeyboardFocus" LostFocus="SiteCatalogFilter_LostFocus" PreviewKeyUp="SiteCatalogFilter_PreviewKeyUp">
<TextBox.Style>
<Style TargetType="TextBox" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style.Resources>
<VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None">
Expand Down
17 changes: 16 additions & 1 deletion src/TableCloth/Pages/DetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ private void Page_Loaded(object sender, RoutedEventArgs e)

if (Arguments.BuiltFromCommandLine)
RunSandbox(Arguments.GetTableClothConfiguration());

if (!string.IsNullOrEmpty(Arguments.CurrentSearchString))
{
SiteCatalogFilter.Text = Arguments.CurrentSearchString;
}
}

private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
Expand Down Expand Up @@ -322,7 +327,7 @@ private void Hyperlink_Click(object sender, RoutedEventArgs e)

private void SiteCatalogFilter_LostFocus(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(
NavigationService?.Navigate(
new Uri("Pages/CatalogPage.xaml", UriKind.Relative),
new CatalogPageArgumentModel(SiteCatalogFilter.Text));
}
Expand All @@ -349,5 +354,15 @@ private void CopyCommandLineButton_Click(object sender, RoutedEventArgs e)
{expression}",
MessageBoxButton.OK);
}

private void SiteCatalogFilter_PreviewKeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter || e.Key == Key.Escape || e.Key == Key.Tab)
{
NavigationService.Navigate(
new Uri("Pages/CatalogPage.xaml", UriKind.Relative),
new CatalogPageArgumentModel(SiteCatalogFilter.Text));
}
}
}
}

0 comments on commit 79dca77

Please sign in to comment.