mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-07-01 12:11:13 +00:00
feat: Complete the basic GUI layout.
This commit is contained in:
parent
14812bceb7
commit
5ccd8a7c53
@ -6,6 +6,6 @@ namespace ZonyLrcTools.Common.Configuration
|
||||
|
||||
public int Priority { get; set; }
|
||||
|
||||
public Dictionary<string, string> Extensions { get; set; } = null!;
|
||||
public Dictionary<string, string>? Extensions { get; set; } = null!;
|
||||
}
|
||||
}
|
@ -2,14 +2,27 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="ZonyLrcTools.Desktop.App"
|
||||
xmlns:local="using:ZonyLrcTools.Desktop"
|
||||
RequestedThemeVariant="Default">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia"
|
||||
RequestedThemeVariant="Default"
|
||||
xmlns:ic="using:FluentIcons.Avalonia.Fluent"
|
||||
xmlns:sty="using:FluentAvalonia.Styling">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.DataTemplates>
|
||||
<local:ViewLocator/>
|
||||
<local:ViewLocator />
|
||||
</Application.DataTemplates>
|
||||
|
||||
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<FontFamily x:Key="GlobalFontFamily">Microsoft YaHei, Simsun, Arial</FontFamily>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
<styling:FluentAvaloniaTheme />
|
||||
<Style Selector="TextBlock">
|
||||
<Setter Property="FontFamily" Value="{StaticResource GlobalFontFamily}" />
|
||||
</Style>
|
||||
</Application.Styles>
|
||||
</Application>
|
@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
|
||||
using ZonyLrcTools.Desktop.ViewModels;
|
||||
using ZonyLrcTools.Desktop.Views;
|
||||
|
||||
@ -8,6 +11,23 @@ namespace ZonyLrcTools.Desktop;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public new static App Current => (App)Application.Current!;
|
||||
public IServiceProvider Services { get; }
|
||||
|
||||
public App()
|
||||
{
|
||||
Services = ConfigureServices();
|
||||
}
|
||||
|
||||
private static IServiceProvider ConfigureServices()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.ConfigureConfiguration();
|
||||
|
||||
return services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
@ -19,7 +39,7 @@ public partial class App : Application
|
||||
{
|
||||
desktop.MainWindow = new MainWindow
|
||||
{
|
||||
DataContext = new MainWindowViewModel(),
|
||||
DataContext = new HomeViewModel(),
|
||||
};
|
||||
}
|
||||
|
||||
|
BIN
src/ZonyLrcTools.Desktop/Assets/logo.ico
Normal file
BIN
src/ZonyLrcTools.Desktop/Assets/logo.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
43
src/ZonyLrcTools.Desktop/Pages/HomePage.axaml
Normal file
43
src/ZonyLrcTools.Desktop/Pages/HomePage.axaml
Normal file
@ -0,0 +1,43 @@
|
||||
<UserControl 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:viewModels="clr-namespace:ZonyLrcTools.Desktop.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="ZonyLrcTools.Desktop.Pages.HomePage"
|
||||
x:DataType="viewModels:HomeViewModel">
|
||||
|
||||
<DockPanel>
|
||||
<StackPanel DockPanel.Dock="Bottom" Margin="10">
|
||||
<TextBlock Text="下载进度:" Margin="0,0,0,5" />
|
||||
<ProgressBar Value="{Binding DownloadProgress}" Maximum="100" Height="20" />
|
||||
</StackPanel>
|
||||
|
||||
<DataGrid AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
GridLinesVisibility="All"
|
||||
BorderThickness="1"
|
||||
BorderBrush="Gray"
|
||||
ItemsSource="{Binding Songs}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="歌曲名称" Binding="{Binding SongName}" Width="*" />
|
||||
<DataGridTextColumn Header="歌手名称" Binding="{Binding ArtistName}" Width="*" />
|
||||
<DataGridTextColumn Header="文件路径" Binding="{Binding FilePath}" Width="2*" />
|
||||
<DataGridTextColumn Header="下载状态" Binding="{Binding DownloadStatus}" Width="1*" />
|
||||
</DataGrid.Columns>
|
||||
|
||||
<DataGrid.Styles>
|
||||
<Style Selector="DataGridColumnHeader">
|
||||
<Setter Property="Background" Value="{DynamicResource ControlFillColorDefault}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimary}" />
|
||||
<Setter Property="FontWeight" Value="SemiBold" />
|
||||
<Setter Property="Padding" Value="12,8,12,8" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
</Style>
|
||||
<Style Selector="DataGridCell">
|
||||
<Setter Property="Padding" Value="12,8" />
|
||||
</Style>
|
||||
</DataGrid.Styles>
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
</UserControl>
|
11
src/ZonyLrcTools.Desktop/Pages/HomePage.axaml.cs
Normal file
11
src/ZonyLrcTools.Desktop/Pages/HomePage.axaml.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.Pages;
|
||||
|
||||
public partial class HomePage : UserControl
|
||||
{
|
||||
public HomePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
143
src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml
Normal file
143
src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml
Normal file
@ -0,0 +1,143 @@
|
||||
<UserControl 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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="ZonyLrcTools.Desktop.Pages.SettingsPage"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:viewModels="clr-namespace:ZonyLrcTools.Desktop.ViewModels"
|
||||
xmlns:settings="clr-namespace:ZonyLrcTools.Desktop.ViewModels.Settings"
|
||||
x:DataType="settings:LyricsSettingsViewModel">
|
||||
<ScrollViewer>
|
||||
<StackPanel Spacing="20">
|
||||
<!-- Global Configuration -->
|
||||
<ui:SettingsExpander Header="Global Lyrics Configuration" Description="Configure global settings for lyrics">
|
||||
<ui:SettingsExpanderItem Content="Merge Bilingual Lyrics">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<ToggleSwitch IsChecked="{Binding Config.IsOneLine}" />
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
|
||||
<ui:SettingsExpanderItem Content="Line Break Format">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<ComboBox SelectedItem="{Binding Config.LineBreak}">
|
||||
<ComboBoxItem Content="Windows" />
|
||||
<ComboBoxItem Content="Unix" />
|
||||
<ComboBoxItem Content="Mac" />
|
||||
</ComboBox>
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
|
||||
<ui:SettingsExpanderItem Content="Enable Translation">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<ToggleSwitch IsChecked="{Binding Config.IsEnableTranslation}" />
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
|
||||
<ui:SettingsExpanderItem Content="Skip Existing Lyric Files">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<ToggleSwitch IsChecked="{Binding Config.IsSkipExistLyricFiles}" />
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
|
||||
<ui:SettingsExpanderItem Content="File Encoding">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<ComboBox SelectedItem="{Binding Config.FileEncoding}">
|
||||
<ComboBoxItem Content="UTF-8" />
|
||||
<ComboBoxItem Content="UTF-16" />
|
||||
<ComboBoxItem Content="ASCII" />
|
||||
</ComboBox>
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
|
||||
<ui:SettingsExpanderItem Content="Only Output Translation">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<ToggleSwitch IsChecked="{Binding Config.IsOnlyOutputTranslation}" />
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<!-- Plugin Configuration -->
|
||||
<ui:SettingsExpander Header="Lyrics Provider Plugins" Description="Configure settings for lyrics provider plugins">
|
||||
<ItemsRepeater ItemsSource="{Binding Plugin}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ui:SettingsExpander Margin="0,0,0,10">
|
||||
<ui:SettingsExpander.Header>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</ui:SettingsExpander.Header>
|
||||
|
||||
<ui:SettingsExpanderItem Content="Priority">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<NumericUpDown Value="{Binding Priority}" Minimum="-1" Maximum="100" />
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
|
||||
<ui:SettingsExpanderItem Content="Search Depth">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<NumericUpDown Value="{Binding Depth}" Minimum="1" Maximum="100" />
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
</ui:SettingsExpander>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<!-- Tag Info Configuration -->
|
||||
<ui:SettingsExpander Header="Tag Info Configuration" Description="Configure settings for tag information">
|
||||
<!-- Block Word Options -->
|
||||
<ui:SettingsExpanderItem Content="Enable Block Word Feature">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<ToggleSwitch IsChecked="{Binding Tag.BlockWord.IsEnable}" />
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
|
||||
<ui:SettingsExpanderItem Content="Block Word Dictionary File Path">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<StackPanel Orientation="Horizontal" Spacing="10">
|
||||
<TextBox Text="{Binding Tag.BlockWord.FilePath}" Width="200" />
|
||||
<Button Content="Browse" Command="{Binding BrowseBlockWordFileCommand}" />
|
||||
</StackPanel>
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
|
||||
<!-- Tag Info Providers -->
|
||||
<ui:SettingsExpander Header="Tag Info Providers" Description="Configure settings for tag info provider plugins">
|
||||
<ItemsRepeater ItemsSource="{Binding Tag.Plugin}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ui:SettingsExpander Margin="0,0,0,10">
|
||||
<ui:SettingsExpander.Header>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</ui:SettingsExpander.Header>
|
||||
|
||||
<ui:SettingsExpanderItem Content="Priority">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<NumericUpDown Value="{Binding Priority}" Minimum="-1" Maximum="100" />
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
|
||||
<ui:SettingsExpanderItem Content="Extensions">
|
||||
<ui:SettingsExpanderItem.Footer>
|
||||
<ItemsRepeater ItemsSource="{Binding Extensions}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid ColumnDefinitions="Auto,*" Margin="0,5">
|
||||
<TextBlock Grid.Column="0" Text="{Binding Key}" Margin="0,0,10,0" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Value}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</ui:SettingsExpanderItem.Footer>
|
||||
</ui:SettingsExpanderItem>
|
||||
</ui:SettingsExpander>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</ui:SettingsExpander>
|
||||
</ui:SettingsExpander>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
17
src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml.cs
Normal file
17
src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Avalonia.Controls;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
using ZonyLrcTools.Desktop.ViewModels;
|
||||
using ZonyLrcTools.Desktop.ViewModels.Settings;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.Pages;
|
||||
|
||||
public partial class SettingsPage : UserControl
|
||||
{
|
||||
public SettingsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new LyricsSettingsViewModel(App.Current.Services.GetRequiredService<IOptions<GlobalOptions>>().Value);
|
||||
}
|
||||
}
|
25
src/ZonyLrcTools.Desktop/ViewModels/HomeViewModel.cs
Normal file
25
src/ZonyLrcTools.Desktop/ViewModels/HomeViewModel.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.ViewModels;
|
||||
|
||||
public class HomeViewModel : ViewModelBase
|
||||
{
|
||||
public ObservableCollection<SongInfo> Songs { get; } = [];
|
||||
|
||||
private double _downloadProgress;
|
||||
|
||||
public double DownloadProgress
|
||||
{
|
||||
get => _downloadProgress;
|
||||
set => this.RaiseAndSetIfChanged(ref _downloadProgress, value);
|
||||
}
|
||||
}
|
||||
|
||||
public class SongInfo
|
||||
{
|
||||
public string SongName { get; set; }
|
||||
public string ArtistName { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
public string DownloadStatus { get; set; }
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.ViewModels.Settings;
|
||||
|
||||
public class BlockWordViewModel : ViewModelBase
|
||||
{
|
||||
private readonly BlockWordOptions _options;
|
||||
|
||||
public BlockWordViewModel(BlockWordOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public bool IsEnable
|
||||
{
|
||||
get => _options.IsEnable;
|
||||
set
|
||||
{
|
||||
if (_options.IsEnable != value)
|
||||
{
|
||||
_options.IsEnable = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FilePath
|
||||
{
|
||||
get => _options.FilePath;
|
||||
set
|
||||
{
|
||||
if (_options.FilePath != value)
|
||||
{
|
||||
_options.FilePath = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.ViewModels.Settings;
|
||||
|
||||
public class GlobalConfigurationViewModel : ViewModelBase
|
||||
{
|
||||
private readonly GlobalLyricsConfigOptions _config;
|
||||
|
||||
public GlobalConfigurationViewModel(GlobalLyricsConfigOptions config)
|
||||
{
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public bool IsOneLine
|
||||
{
|
||||
get => _config.IsOneLine;
|
||||
set
|
||||
{
|
||||
if (_config.IsOneLine != value)
|
||||
{
|
||||
_config.IsOneLine = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string LineBreak
|
||||
{
|
||||
get => _config.LineBreak;
|
||||
set
|
||||
{
|
||||
if (_config.LineBreak != value)
|
||||
{
|
||||
_config.LineBreak = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnableTranslation
|
||||
{
|
||||
get => _config.IsEnableTranslation;
|
||||
set
|
||||
{
|
||||
if (_config.IsEnableTranslation != value)
|
||||
{
|
||||
_config.IsEnableTranslation = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSkipExistLyricFiles
|
||||
{
|
||||
get => _config.IsSkipExistLyricFiles;
|
||||
set
|
||||
{
|
||||
if (_config.IsSkipExistLyricFiles != value)
|
||||
{
|
||||
_config.IsSkipExistLyricFiles = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FileEncoding
|
||||
{
|
||||
get => _config.FileEncoding;
|
||||
set
|
||||
{
|
||||
if (_config.FileEncoding != value)
|
||||
{
|
||||
_config.FileEncoding = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOnlyOutputTranslation
|
||||
{
|
||||
get => _config.IsOnlyOutputTranslation;
|
||||
set
|
||||
{
|
||||
if (_config.IsOnlyOutputTranslation != value)
|
||||
{
|
||||
_config.IsOnlyOutputTranslation = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.ViewModels.Settings;
|
||||
|
||||
public class LyricsProviderViewModel : ViewModelBase
|
||||
{
|
||||
private readonly LyricsProviderOptions _options;
|
||||
|
||||
public LyricsProviderViewModel(LyricsProviderOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _options.Name;
|
||||
set
|
||||
{
|
||||
if (_options.Name != value)
|
||||
{
|
||||
_options.Name = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get => _options.Priority;
|
||||
set
|
||||
{
|
||||
if (_options.Priority != value)
|
||||
{
|
||||
_options.Priority = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Depth
|
||||
{
|
||||
get => _options.Depth;
|
||||
set
|
||||
{
|
||||
if (_options.Depth != value)
|
||||
{
|
||||
_options.Depth = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using ReactiveUI;
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.ViewModels.Settings;
|
||||
|
||||
public class LyricsSettingsViewModel : ViewModelBase
|
||||
{
|
||||
private readonly GlobalOptions _globalOptions;
|
||||
|
||||
public LyricsSettingsViewModel(GlobalOptions globalOptions)
|
||||
{
|
||||
_globalOptions = globalOptions;
|
||||
Config = new GlobalConfigurationViewModel(globalOptions.Provider.Lyric.Config);
|
||||
Plugin = new ObservableCollection<LyricsProviderViewModel>(
|
||||
globalOptions.Provider.Lyric.Plugin.Select(p => new LyricsProviderViewModel(p)));
|
||||
Tag = new TagInfoViewModel(globalOptions.Provider.Tag);
|
||||
BrowseBlockWordFileCommand = ReactiveCommand.Create(BrowseBlockWordFile);
|
||||
}
|
||||
|
||||
public TagInfoViewModel Tag { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> BrowseBlockWordFileCommand { get; }
|
||||
|
||||
public GlobalConfigurationViewModel Config { get; }
|
||||
|
||||
public ObservableCollection<LyricsProviderViewModel> Plugin { get; }
|
||||
|
||||
private void BrowseBlockWordFile()
|
||||
{
|
||||
// Implement file browsing logic here
|
||||
// Update Tag.BlockWord.FilePath with the selected file path
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.ViewModels.Settings;
|
||||
|
||||
public class TagInfoProviderViewModel : ViewModelBase
|
||||
{
|
||||
private readonly TagInfoProviderOptions _options;
|
||||
|
||||
public TagInfoProviderViewModel(TagInfoProviderOptions options)
|
||||
{
|
||||
_options = options;
|
||||
Extensions = new ObservableCollection<KeyValuePair<string, string>>(options.Extensions ?? new Dictionary<string, string>());
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _options.Name;
|
||||
set
|
||||
{
|
||||
if (_options.Name != value)
|
||||
{
|
||||
_options.Name = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get => _options.Priority;
|
||||
set
|
||||
{
|
||||
if (_options.Priority != value)
|
||||
{
|
||||
_options.Priority = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<KeyValuePair<string, string>> Extensions { get; }
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.ViewModels.Settings;
|
||||
|
||||
public class TagInfoViewModel : ViewModelBase
|
||||
{
|
||||
private readonly TagInfoOptions _options;
|
||||
|
||||
public TagInfoViewModel(TagInfoOptions options)
|
||||
{
|
||||
_options = options;
|
||||
BlockWord = new BlockWordViewModel(options.BlockWord);
|
||||
Plugin = new ObservableCollection<TagInfoProviderViewModel>(
|
||||
options.Plugin.Select(p => new TagInfoProviderViewModel(p)));
|
||||
}
|
||||
|
||||
public BlockWordViewModel BlockWord { get; }
|
||||
public ObservableCollection<TagInfoProviderViewModel> Plugin { get; }
|
||||
}
|
@ -2,6 +2,4 @@
|
||||
|
||||
namespace ZonyLrcTools.Desktop.ViewModels;
|
||||
|
||||
public class ViewModelBase : ReactiveObject
|
||||
{
|
||||
}
|
||||
public abstract class ViewModelBase : ReactiveObject;
|
74
src/ZonyLrcTools.Desktop/Views/MainView.axaml
Normal file
74
src/ZonyLrcTools.Desktop/Views/MainView.axaml
Normal file
@ -0,0 +1,74 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:fluent="clr-namespace:FluentIcons.Avalonia.Fluent;assembly=FluentIcons.Avalonia.Fluent"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="ZonyLrcTools.Desktop.Views.MainView">
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<Grid Name="TitleBarHost"
|
||||
Background="Transparent"
|
||||
ColumnDefinitions="Auto,Auto,*,Auto,0">
|
||||
<Grid.Styles>
|
||||
<Style Selector="Button.AppBarButton">
|
||||
<Setter Property="Padding" Value="8" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Theme" Value="{StaticResource TransparentButton}" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
|
||||
<Image Width="20" Height="20" Margin="14"
|
||||
Source="/Assets/logo.ico" IsHitTestVisible="False"
|
||||
IsVisible="{Binding !#FrameView.CanGoBack}"
|
||||
RenderOptions.BitmapInterpolationMode="HighQuality" />
|
||||
|
||||
<Button Grid.Column="0" Margin="6"
|
||||
Classes="AppBarButton" Command="{Binding #FrameView.GoBack}"
|
||||
IsEnabled="{Binding #FrameView.CanGoBack}"
|
||||
IsVisible="{Binding #FrameView.CanGoBack}">
|
||||
<Button.Content>
|
||||
<fluent:SymbolIcon Symbol="ArrowLeft" />
|
||||
</Button.Content>
|
||||
<ToolTip.Tip>Back</ToolTip.Tip>
|
||||
</Button>
|
||||
|
||||
<TextBlock Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12"
|
||||
Text="ZonyLrcToolsX" IsHitTestVisible="False" />
|
||||
|
||||
<StackPanel Grid.Column="3"
|
||||
Orientation="Horizontal" Margin="6" Spacing="6">
|
||||
<Button Name="OpenFolderButton" Classes="AppBarButton">
|
||||
<Button.Content>
|
||||
<fluent:SymbolIcon Symbol="FolderAdd" />
|
||||
</Button.Content>
|
||||
<ToolTip.Tip>扫描文件夹</ToolTip.Tip>
|
||||
</Button>
|
||||
|
||||
<Button Name="DownloadButton" Classes="AppBarButton">
|
||||
<Button.Content>
|
||||
<fluent:SymbolIcon Symbol="ArrowDownload" />
|
||||
</Button.Content>
|
||||
<ToolTip.Tip>下载歌词</ToolTip.Tip>
|
||||
</Button>
|
||||
|
||||
<Button Name="SettingsButton" Classes="AppBarButton">
|
||||
<Button.Content>
|
||||
<fluent:SymbolIcon Symbol="Settings" />
|
||||
</Button.Content>
|
||||
<ToolTip.Tip>软件设置</ToolTip.Tip>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="1" Grid.ColumnSpan="3"
|
||||
Background="{DynamicResource LayerFillColorDefaultBrush}"
|
||||
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
|
||||
BorderThickness="0,1,0,0"
|
||||
CornerRadius="8 8 0 0">
|
||||
<ui:Frame Name="FrameView" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
60
src/ZonyLrcTools.Desktop/Views/MainView.axaml.cs
Normal file
60
src/ZonyLrcTools.Desktop/Views/MainView.axaml.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using ZonyLrcTools.Desktop.Pages;
|
||||
|
||||
namespace ZonyLrcTools.Desktop.Views;
|
||||
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
private Window? _window;
|
||||
|
||||
private Frame? _frameView;
|
||||
private Button? _settingsButton;
|
||||
private Button? _openFolderButton;
|
||||
private Button? _downloadButton;
|
||||
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
|
||||
_window = e.Root as Window;
|
||||
|
||||
_frameView = this.FindControl<Frame>("FrameView");
|
||||
_frameView?.Navigate(typeof(HomePage));
|
||||
|
||||
_settingsButton = this.FindControl<Button>("SettingsButton");
|
||||
if (_settingsButton != null) _settingsButton.Click += OnSettingsButtonClick;
|
||||
|
||||
_openFolderButton = this.FindControl<Button>("OpenFolderButton");
|
||||
if (_openFolderButton != null) _openFolderButton.Click += OnOpenFolderButtonClick;
|
||||
_downloadButton = this.FindControl<Button>("DownloadButton");
|
||||
}
|
||||
|
||||
private async void OnOpenFolderButtonClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var storage = _window?.StorageProvider;
|
||||
if (storage?.CanOpen == true)
|
||||
{
|
||||
var options = new FolderPickerOpenOptions
|
||||
{
|
||||
SuggestedStartLocation = await storage.TryGetWellKnownFolderAsync(WellKnownFolder.Music)
|
||||
};
|
||||
var folders = await storage.OpenFolderPickerAsync(options);
|
||||
var folderPath = folders[0].Path;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSettingsButtonClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_frameView?.CurrentSourcePageType != typeof(SettingsPage))
|
||||
_frameView?.Navigate(typeof(SettingsPage));
|
||||
}
|
||||
}
|
@ -1,20 +1,16 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:ZonyLrcTools.Desktop.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:views="clr-namespace:ZonyLrcTools.Desktop.Views"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="ZonyLrcTools.Desktop.Views.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
Background="{DynamicResource AcrylicBackgroundFillColorDefaultBrush}"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Title="ZonyLrcTools.Desktop">
|
||||
|
||||
<Design.DataContext>
|
||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||
<vm:MainWindowViewModel/>
|
||||
</Design.DataContext>
|
||||
<Panel>
|
||||
<views:MainView />
|
||||
</Panel>
|
||||
|
||||
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
|
||||
</Window>
|
||||
</Window>
|
Loading…
x
Reference in New Issue
Block a user