/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Views/Properties/HashesPage.xaml
251 строка
9 KB
Lamparter
Feature: Added a comparison text box for hashes (#16771)
21 мар 2025, 17:37
Не верифицирован
21 мар 2025, 17:37
cec20ff
Код
Авторство
О чём код?
<!-- Copyright (c) Files Community. Licensed under the MIT License. --> <vm:BasePropertiesPage x:Class="Files.App.Views.Properties.HashesPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:datamodels="using:Files.App.Data.Models" xmlns:helpers="using:Files.App.Helpers" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:toolkitconverters="using:CommunityToolkit.WinUI.Converters" xmlns:vm="using:Files.App.ViewModels.Properties" DataContext="{x:Bind HashesViewModel, Mode=OneWay}" Tag="Hashes" mc:Ignorable="d"> <vm:BasePropertiesPage.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="ms-appx:///Styles/PropertiesStyles.xaml" /> </ResourceDictionary.MergedDictionaries> <toolkitconverters:BoolNegationConverter x:Key="BoolNegationConverter" /> <toolkitconverters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /> </ResourceDictionary> </vm:BasePropertiesPage.Resources> <Grid x:Name="RootGrid"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <!-- Hash Comparison Section --> <Grid x:Name="HashComparisonGrid" Margin="12,12,12,4" Padding="12" VerticalAlignment="Top" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1" ColumnSpacing="8" CornerRadius="4"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <!-- Hash Input --> <TextBox x:Name="HashInputTextBox" Grid.Column="0" PlaceholderText="{helpers:ResourceString Name=EnterHashToCompare}" Text="{x:Bind HashesViewModel.HashInput, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> <!-- Compare File Button --> <Button x:Name="CompareFileButton" Grid.Column="1" Command="{x:Bind HashesViewModel.CompareFileCommand}" Content="{helpers:ResourceString Name=CompareFile}" /> </Grid> <InfoBar x:Name="HashMatchInfoBar" Grid.Row="1" Margin="12,4,12,4" x:Load="{x:Bind HashesViewModel.IsInfoBarOpen, Mode=OneWay}" IsClosable="False" IsOpen="True" Message="{x:Bind HashesViewModel.InfoBarTitle, Mode=OneWay}" Severity="{x:Bind HashesViewModel.InfoBarSeverity, Mode=OneWay}" /> <Grid x:Name="HashesListGrid" Grid.Row="2" Margin="12,4,12,12" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1" CornerRadius="4"> <!-- Hashes ListView --> <ListView x:Name="HashesListView" ItemsSource="{x:Bind HashesViewModel.Hashes, Mode=OneWay}" SelectedItem="{x:Bind HashesViewModel.SelectedItem, Mode=TwoWay}"> <!-- Header --> <ListView.Header> <Grid Height="44" Padding="16,8,12,0" BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}" BorderThickness="0,0,0,1" ColumnSpacing="12"> <Grid.ColumnDefinitions> <ColumnDefinition Width="64" /> <ColumnDefinition Width="1" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <!-- Algorithm --> <TextBlock VerticalAlignment="Center" Style="{StaticResource App.Theme.BaseTextBlockStyle}" Text="{helpers:ResourceString Name=Algorithm}" /> <!-- (Divider) --> <Border Grid.Column="1" Width="1" Height="36" VerticalAlignment="Bottom" Background="{ThemeResource DividerStrokeColorDefaultBrush}" /> <!-- Hash --> <TextBlock Grid.Column="2" VerticalAlignment="Center" Style="{StaticResource App.Theme.BaseTextBlockStyle}" Text="{helpers:ResourceString Name=HashValue}" /> <!-- Toggle Hashes --> <Button x:Name="SelectAlgorithmsButton" Grid.Column="3" Padding="6" AutomationProperties.Name="{helpers:ResourceString Name=SelectHashesToShow}" Background="Transparent" BorderBrush="Transparent" ToolTipService.ToolTip="{helpers:ResourceString Name=SelectHashesToShow}"> <FontIcon FontSize="14" Glyph="" /> <Button.Flyout> <MenuFlyout x:Name="SelectAlgorithmsMenuFlyout" Closing="MenuFlyout_Closing"> <ToggleMenuFlyoutItem Click="ToggleMenuFlyoutItem_Click" Command="{x:Bind HashesViewModel.ToggleIsEnabledCommand}" CommandParameter="CRC32" IsChecked="{x:Bind HashesViewModel.ShowHashes['CRC32']}" Text="CRC32" /> <ToggleMenuFlyoutItem Click="ToggleMenuFlyoutItem_Click" Command="{x:Bind HashesViewModel.ToggleIsEnabledCommand}" CommandParameter="MD5" IsChecked="{x:Bind HashesViewModel.ShowHashes['MD5']}" Text="MD5" /> <ToggleMenuFlyoutItem Click="ToggleMenuFlyoutItem_Click" Command="{x:Bind HashesViewModel.ToggleIsEnabledCommand}" CommandParameter="SHA1" IsChecked="{x:Bind HashesViewModel.ShowHashes['SHA1']}" Text="SHA1" /> <ToggleMenuFlyoutItem Click="ToggleMenuFlyoutItem_Click" Command="{x:Bind HashesViewModel.ToggleIsEnabledCommand}" CommandParameter="SHA256" IsChecked="{x:Bind HashesViewModel.ShowHashes['SHA256']}" Text="SHA256" /> <ToggleMenuFlyoutItem Click="ToggleMenuFlyoutItem_Click" Command="{x:Bind HashesViewModel.ToggleIsEnabledCommand}" CommandParameter="SHA384" IsChecked="{x:Bind HashesViewModel.ShowHashes['SHA384']}" Text="SHA384" /> <ToggleMenuFlyoutItem Click="ToggleMenuFlyoutItem_Click" Command="{x:Bind HashesViewModel.ToggleIsEnabledCommand}" CommandParameter="SHA512" IsChecked="{x:Bind HashesViewModel.ShowHashes['SHA512']}" Text="SHA512" /> </MenuFlyout> </Button.Flyout> </Button> </Grid> </ListView.Header> <!-- Template --> <ListView.ItemTemplate> <DataTemplate x:DataType="datamodels:HashInfoItem"> <ListViewItem IsSelected="{x:Bind IsSelected, Mode=TwoWay}" Visibility="{x:Bind IsEnabled, Mode=OneWay}"> <Grid ColumnSpacing="12"> <Grid.ColumnDefinitions> <ColumnDefinition Width="64" /> <ColumnDefinition Width="1" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <!-- Algorithm Name --> <TextBlock VerticalAlignment="Center" Style="{StaticResource PropertyName}" Text="{x:Bind Algorithm}" /> <!-- Calculating --> <StackPanel x:Name="CalculatingPanel" Grid.Column="2" x:Load="{x:Bind IsCalculating, Mode=OneWay}" Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" Style="{StaticResource App.Theme.BodyTextBlockStyle}" Text="{helpers:ResourceString Name=Calculating}" /> <ProgressBar Width="100" Margin="16,0,0,0" HorizontalAlignment="Left" IsIndeterminate="True" /> </StackPanel> <!-- Hash Value --> <TextBlock x:Name="HashValueText" Grid.Column="2" VerticalAlignment="Center" x:Load="{x:Bind IsCalculating, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}" Style="{StaticResource App.Theme.BodyTextBlockStyle}" Text="{x:Bind HashValue, Mode=OneWay}" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" ToolTipService.ToolTip="{x:Bind HashValue, Mode=OneWay}" /> <!-- Copy button --> <Button x:Name="CopyHashButton" Grid.Column="3" Padding="6" x:Load="{x:Bind IsCalculated, Mode=OneWay}" AutomationProperties.Name="{helpers:ResourceString Name=Copy}" Background="Transparent" BorderBrush="Transparent" Click="CopyHashButton_Click" ToolTipService.ToolTip="{helpers:ResourceString Name=Copy}"> <FontIcon FontSize="14" Glyph="" /> </Button> </Grid> </ListViewItem> </DataTemplate> </ListView.ItemTemplate> </ListView> </Grid> </Grid> </vm:BasePropertiesPage>