Skip to content

Commit

Permalink
文件类型过滤,UI部分(全平台)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeric-X committed Aug 7, 2024
1 parent a34a853 commit 122d515
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/SyncClipboard.Core/Clipboard/ClipboardFactoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public async Task<ClipboardProfileDTO> CreateProfileDto(string destFolder)
bool isCut = (meta.Effects & DragDropEffects.Move) == DragDropEffects.Move;
if ((doNotUploadWhenCut && isCut) || !profile.IsAvailableFromLocal())
{
return new TextProfile("").ToDto();
return new UnknownProfile().ToDto();
}

if (profile is FileProfile fileProfile)
Expand Down
20 changes: 10 additions & 10 deletions src/SyncClipboard.Core/I18n/Strings.Designer.cs

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

6 changes: 3 additions & 3 deletions src/SyncClipboard.Core/I18n/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
<value>Retry Times</value>
</data>
<data name="FileSyncFilter" xml:space="preserve">
<value>File Sync Filter</value>
<value>Uploading File Filter</value>
</data>
<data name="FilterMode" xml:space="preserve">
<value>Filter Mode</value>
Expand All @@ -543,7 +543,7 @@
<data name="FileFilterDescription" xml:space="preserve">
<value>Each file extension per line</value>
</data>
<data name="Apply" xml:space="preserve">
<value>Apply</value>
<data name="Save" xml:space="preserve">
<value>Save</value>
</data>
</root>
6 changes: 3 additions & 3 deletions src/SyncClipboard.Core/I18n/Strings.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
<value>重试次数</value>
</data>
<data name="FileSyncFilter" xml:space="preserve">
<value>同步文件过滤</value>
<value>上传文件过滤</value>
</data>
<data name="FilterMode" xml:space="preserve">
<value>过滤模式</value>
Expand All @@ -543,7 +543,7 @@
<data name="FileFilterDescription" xml:space="preserve">
<value>每行一个文件扩展名</value>
</data>
<data name="Apply" xml:space="preserve">
<value>应用</value>
<data name="Save" xml:space="preserve">
<value>保存</value>
</data>
</root>
59 changes: 59 additions & 0 deletions src/SyncClipboard.Desktop/Views/FileSyncFilterSettingPage.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<UserControl x:Class="SyncClipboard.Desktop.Views.FileSyncFilterSettingPage"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:FluentAvalonia.UI.Controls"
xmlns:i18n="using:SyncClipboard.Core.I18n"
xmlns:vm="using:SyncClipboard.Core.ViewModels"
xmlns:m="using:SyncClipboard.Core.Models"
x:DataType="vm:FileSyncFilterSettingViewModel"
d:DesignWidth="800"
d:DesignHeight="450"
mc:Ignorable="d">
<Design.DataContext>
<vm:FileSyncFilterSettingViewModel />
</Design.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ui:SettingsExpander Grid.Row="0" Header="{x:Static i18n:Strings.FilterMode}" Description="{x:Static i18n:Strings.FileFilterDescription}">
<ui:SettingsExpander.IconSource>
<ui:FontIconSource Glyph="&#xE71C;" FontFamily="{StaticResource SymbolThemeFontFamily}" />
</ui:SettingsExpander.IconSource>
<ui:SettingsExpander.Footer>
<ComboBox SelectedItem="{Binding FilterMode, Mode=TwoWay}" ItemsSource="{x:Static vm:FileSyncFilterSettingViewModel.Modes}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="m:LocaleString">
<TextBlock Text="{Binding ShownString}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</ui:SettingsExpander.Footer>
</ui:SettingsExpander>
<Grid Grid.Row="1" Margin="0,10,0,0" IsVisible="{Binding EnableText, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ScrollViewer x:Name="_ScrollViewer" Grid.Column="0" VerticalScrollBarVisibility="Auto">
<TextBox Grid.Column="0"
Text="{Binding ShownText, Mode=TwoWay}"
TextWrapping="Wrap"
FontSize="16"
AcceptsReturn="True"
VerticalContentAlignment="Top"
CornerRadius="{DynamicResource ControlCornerRadius}" />
</ScrollViewer>
<StackPanel Grid.Column="1"
MinWidth="80"
Margin="16,0,0,0"
Orientation="Vertical"
Spacing="10">
<Button HorizontalAlignment="Stretch" Content="{x:Static i18n:Strings.Save}" Command="{Binding ApplyCommand}" />
</StackPanel>
</Grid>
</Grid>
</UserControl>
31 changes: 31 additions & 0 deletions src/SyncClipboard.Desktop/Views/FileSyncFilterSettingPage.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Navigation;
using Microsoft.Extensions.DependencyInjection;
using SyncClipboard.Core.ViewModels;

namespace SyncClipboard.Desktop.Views;

public partial class FileSyncFilterSettingPage : UserControl
{
private readonly FileSyncFilterSettingViewModel _viewModel;
public FileSyncFilterSettingPage()
{
_viewModel = App.Current.Services.GetRequiredService<FileSyncFilterSettingViewModel>();
DataContext = _viewModel;
InitializeComponent();
AddHandler(Frame.NavigatedToEvent, OnNavigatedTo, RoutingStrategies.Direct);
AddHandler(Frame.NavigatedFromEvent, OnNavigatedFrom, RoutingStrategies.Direct);
}

private void OnNavigatedFrom(object? sender, NavigationEventArgs e)
{
App.Current.MainWindow.EnableScrollViewer();
}

private void OnNavigatedTo(object? sender, NavigationEventArgs e)
{
App.Current.MainWindow.DispableScrollViewer();
}
}
5 changes: 5 additions & 0 deletions src/SyncClipboard.Desktop/Views/SyncSettingPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
</UserControl.Styles>
<UserControl.Resources>
<vc:BoolToPasswordIconConverter x:Key="BoolToPasswordFontIcon" />
<ui:SymbolIconSource x:Key="GoIcon" Symbol="ChevronRight" />
</UserControl.Resources>
<StackPanel Spacing="10">
<ui:SettingsExpander Header="{x:Static i18n:Strings.Server}" Description="{x:Static i18n:Strings.ServerDescription}" IsExpanded="True">
Expand Down Expand Up @@ -160,6 +161,10 @@
<ui:NumberBox Minimum="0" Maximum="100000" Value="{Binding MaxFileSize, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem ActionIconSource="{StaticResource GoIcon}"
IsClickEnabled="True"
Command="{Binding SetFileSyncFilterCommand}"
Content="{x:Static i18n:Strings.FileSyncFilter}" />
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
Margin="16,0,0,0"
Orientation="Vertical"
Spacing="10">
<Button HorizontalAlignment="Stretch" Content="{x:Bind i18n:Strings.Apply}" Command="{x:Bind _viewModel.ApplyCommand}" />
<Button HorizontalAlignment="Stretch" Content="{x:Bind i18n:Strings.Confirm}" Command="{x:Bind _viewModel.ConfirmCommand}" />
<Button HorizontalAlignment="Stretch" Content="{x:Bind i18n:Strings.Save}" Command="{x:Bind _viewModel.ApplyCommand}" />
</StackPanel>
</Grid>
</Grid>
Expand Down

0 comments on commit 122d515

Please sign in to comment.