Skip to content

Commit

Permalink
#204 SIQuester: support common package tags
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirKhil committed Feb 6, 2024
1 parent 8ae3ca2 commit 84269de
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
21 changes: 21 additions & 0 deletions src/SIQuester/SIQuester.ViewModel/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/SIQuester/SIQuester.ViewModel/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@
<data name="DBStorageComment" xml:space="preserve">
<value>The package is stored in the Database {0} under the name {1}</value>
</data>
<data name="DefaultTags" xml:space="preserve">
<value>Art
Astronomy
Biology
Chemistry
Erudition
Games
Geography
History
Literature
Mathematics
Memes
Physics
TV</value>
</data>
<data name="DocumentLoading" xml:space="preserve">
<value>Document loading</value>
</data>
Expand Down
15 changes: 15 additions & 0 deletions src/SIQuester/SIQuester.ViewModel/Properties/Resources.ru-RU.resx
Original file line number Diff line number Diff line change
Expand Up @@ -693,4 +693,19 @@ theme - тема Кота</value>
<data name="CommonTag" xml:space="preserve">
<value>Общие знания (солянка)</value>
</data>
<data name="DefaultTags" xml:space="preserve">
<value>Астрономия
Биология
География
Игры
Искусство
История
Литература
Мемы
Математика
ТВ
Физика
Химия
Эрудиция</value>
</data>
</root>
9 changes: 8 additions & 1 deletion src/SIQuester/SIQuester.ViewModel/SelectTagsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
using SIQuester.ViewModel.Properties;
using System.Globalization;

namespace SIQuester.ViewModel;

public sealed class SelectTagsViewModel
{
private static readonly string[] _defaultTags = Resources.DefaultTags.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

public Tag[] Tags { get; }

public Tag CommonTag { get; } = new(Resources.CommonTag);

public SelectTagsViewModel(string[] tags) => Tags = tags.Select(t => new Tag(t)).ToArray();
public SelectTagsViewModel(string[] tags) => Tags = tags
.Union(_defaultTags)
.OrderBy(t => t, CultureInfo.CurrentUICulture.CompareInfo.GetStringComparer(CompareOptions.None))
.Select(t => new Tag(t))
.ToArray();

public string[] SelectedTags => Tags.Concat(new[] { CommonTag }).Where(t => t.IsSelected).Select(t => t.Name).ToArray();

Expand Down
34 changes: 27 additions & 7 deletions src/SIQuester/SIQuester/View/SelectTagsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@
mc:Ignorable="d"
d:DesignHeight="250"
d:DesignWidth="200"
MaxWidth="700"
MaxHeight="1000"
MinWidth="500"
MaxWidth="900"
MinHeight="400"
MaxHeight="700"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
ResizeMode="CanResize"
Title="{x:Static lp:Resources.SetTags}"
d:DataContext="{d:DesignInstance lvm:SelectTagsViewModel}">
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<ScrollViewer Margin="1">
<ItemsControl ItemsSource="{Binding Tags}">
<ItemsControl.ItemsPanel>
Expand All @@ -43,14 +52,25 @@
<ToggleButton
IsChecked="{Binding CommonTag.IsSelected}"
Content="{Binding CommonTag.Name}"
Grid.Row="1"
Margin="5,15,5,5"
Padding="4,10"
Width="200"
BorderThickness="0"
HorizontalAlignment="Center"
Cursor="Hand" />

<TextBlock Text="{x:Static lp:Resources.CustomTagsHint}" HorizontalAlignment="Center" Margin="10" />
<Button Name="ok" Click="Button_Click" Content="OK" Margin="5" Width="200" Padding="60,6" HorizontalAlignment="Right" IsDefault="True" />
</StackPanel>
<TextBlock Grid.Row="2" Text="{x:Static lp:Resources.CustomTagsHint}" HorizontalAlignment="Center" Margin="10" />

<Button
Grid.Row="3"
Name="ok"
Click="Button_Click"
Content="OK"
Margin="5"
Width="200"
Padding="60,6"
HorizontalAlignment="Right"
IsDefault="True" />
</Grid>
</Window>

0 comments on commit 84269de

Please sign in to comment.