feat: Complete the basic GUI layout.

This commit is contained in:
real-zony committed 2024-06-28 12:33:14 +08:00
1 parent 14812bceb7
commit 5ccd8a7c53
19 files changed
+689 -19

No files matched your search

@@ -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;