Skip to content

Commit

Permalink
Add context menu for marking archives as non duplicates #35
Browse files Browse the repository at this point in the history
  • Loading branch information
Guerra24 committed May 29, 2024
1 parent 8ea4e75 commit b6d570d
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 7 deletions.
9 changes: 6 additions & 3 deletions LRReader.Shared/ViewModels/Tools/DeduplicatorToolViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@ private async Task DeleteArchive(string arcid)
}

[RelayCommand]
private void MarkNonDup()
private void MarkNonDup() => MarkNonDupValue(_current);

[RelayCommand]
private void MarkNonDupValue(ArchiveHit archiveHit)
{
Settings.Profile.MarkedAsNonDuplicated.Add(_current);
Items.Remove(_current);
Settings.Profile.MarkedAsNonDuplicated.Add(archiveHit);
Items.Remove(archiveHit);
Settings.SaveProfiles();
}

Expand Down
3 changes: 3 additions & 0 deletions LRReader.UWP/Strings/en/Tools.resw
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ At last enable Skip missing thumbnails and try again</value>
<data name="Deduplicator.MarkNonDup.Text" xml:space="preserve">
<value>Mark as non duplicate?</value>
</data>
<data name="Deduplicator.MarkNonDuplicate.Text" xml:space="preserve">
<value>Mark as non duplicate</value>
</data>
<data name="Deduplicator.MarkNonDupTT.ToolTipService.ToolTip" xml:space="preserve">
<value>Mark as non duplicate</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions LRReader.UWP/Strings/es/Tools.resw
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ Por último, active la opción de omitir las miniaturas que faltan y vuelva a in
<data name="Deduplicator.MarkNonDup.Text" xml:space="preserve">
<value>¿Marcar como no duplicado?</value>
</data>
<data name="Deduplicator.MarkNonDuplicate.Text" xml:space="preserve">
<value>Marcar como no duplicado</value>
</data>
<data name="Deduplicator.MarkNonDupTT.ToolTipService.ToolTip" xml:space="preserve">
<value>Marcar como no duplicado</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions LRReader.UWP/Strings/ru/Tools.resw
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@
<data name="Deduplicator.MarkNonDup.Text" xml:space="preserve">
<value>Пометить как не дубликат?</value>
</data>
<data name="Deduplicator.MarkNonDuplicate.Text" xml:space="preserve">
<value>Пометить как не дубликат</value>
</data>
<data name="Deduplicator.MarkNonDupTT.ToolTipService.ToolTip" xml:space="preserve">
<value>Пометить как не дубликат</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions LRReader.UWP/Strings/zh-cn/Tools.resw
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
<data name="Deduplicator.MarkNonDup.Text" xml:space="preserve">
<value>标记为非重复?</value>
</data>
<data name="Deduplicator.MarkNonDuplicate.Text" xml:space="preserve">
<value>标记为非重复</value>
</data>
<data name="Deduplicator.MarkNonDupTT.ToolTipService.ToolTip" xml:space="preserve">
<value>标记为非重复</value>
</data>
Expand Down
4 changes: 2 additions & 2 deletions LRReader.UWP/Views/Content/Tools/Deduplicator.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<Thickness x:Key="FlyoutContentPadding">8,7,8,9</Thickness>
</Page.Resources>

<Grid>
<Grid x:Name="RootGrid">
<GridView
x:Name="Results"
ext:Element.ModernShadow="{StaticResource ElementShadow}"
Expand Down Expand Up @@ -249,7 +249,7 @@
</GridView.Header>
<GridView.ItemTemplate>
<DataTemplate x:DataType="items:ArchiveHit">
<items1:ArchiveHitItem />
<items1:ArchiveHitItem MarkNonDuplicateCommand="{Binding ElementName=RootGrid, Path=DataContext.MarkNonDupValueCommand}" />
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
Expand Down
9 changes: 7 additions & 2 deletions LRReader.UWP/Views/Items/ArchiveHitItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
<ColumnDefinition Width="2" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Grid Grid.ColumnSpan="3" Background="Transparent" Visibility="{x:Bind ShowRemove, Mode=OneWay}">
<Grid Grid.ColumnSpan="3" Background="Transparent">
<Grid.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem x:Uid="/Tools/DeduplicatorHidden/Remove" Click="Remove_Click" Icon="Delete" />
<MenuFlyoutItem x:Uid="/Tools/Deduplicator/MarkNonDuplicate" Command="{x:Bind MarkNonDuplicateCommand, Mode=OneWay}" CommandParameter="{x:Bind Data.ArchiveHit, Mode=OneWay}" Visibility="{x:Bind ShowRemove, Mode=OneWay, Converter={StaticResource NegateBoolToVisibilityConverter}}">
<MenuFlyoutItem.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE8A6;" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem x:Uid="/Tools/DeduplicatorHidden/Remove" Click="Remove_Click" Icon="Delete" Visibility="{x:Bind ShowRemove, Mode=OneWay}" />
</MenuFlyout>
</Grid.ContextFlyout>
</Grid>
Expand Down
7 changes: 7 additions & 0 deletions LRReader.UWP/Views/Items/ArchiveHitItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public ICommand RemoveCommand
set => SetValue(RemoveCommandProperty, value);
}

public ICommand MarkNonDuplicateCommand
{
get => (ICommand)GetValue(MarkNonDuplicateCommandProperty);
set => SetValue(MarkNonDuplicateCommandProperty, value);
}

private async void UserControl_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
{
if (args.NewValue == null)
Expand Down Expand Up @@ -101,6 +107,7 @@ private void Remove_Click(object sender, RoutedEventArgs e)

public static readonly DependencyProperty ShowRemoveProperty = DependencyProperty.Register("ShowRemove", typeof(bool), typeof(ArchiveHitItem), new PropertyMetadata(false));
public static readonly DependencyProperty RemoveCommandProperty = DependencyProperty.RegisterAttached("RemoveCommand", typeof(ICommand), typeof(ArchiveHitItem), new PropertyMetadata(null));
public static readonly DependencyProperty MarkNonDuplicateCommandProperty = DependencyProperty.RegisterAttached("MarkNonDuplicateCommand", typeof(ICommand), typeof(ArchiveHitItem), new PropertyMetadata(null));

}
}

0 comments on commit b6d570d

Please sign in to comment.