TMusic/ViewModel/ThemeBgViewModel.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using TMusic.Model;
using TMusic.Util;
namespace TMusic.ViewModel
{
public class ThemeBgViewModel : ObservableObject
{
public ThemeBgViewModel()
{
Init();
}
private string _selectedBgPath;
public string SelectedBgPath { get => _selectedBgPath; set => SetProperty(ref _selectedBgPath, value); }
public List<MusicBgImgModel> BgImgList { get; set; }
public RelayCommand<KeyValueModel> ChangeBgCmd => new RelayCommand<KeyValueModel>(ChangeBg);
public RelayCommand UploadLocalImgCmd => new RelayCommand(UploadLocalImg);
public Action<KeyValueModel> ChangedBg { get; set; }
private void Init()
{
LoadBgImgList();
}
private void ChangeBg(KeyValueModel model)
{
SelectedBgPath = model.Value;
ChangedBg?.Invoke(model);
}
private void UploadLocalImg()
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "图像文件|*.jpg;*.png;*.jpeg;*.bmp;*.gif|所有文件|*.*"
};
var result = openFileDialog.ShowDialog();
if (result.HasValue && result.Value)
{
Console.WriteLine(openFileDialog.FileName);
string path = FileUtil.CopyToApp(openFileDialog.FileName, "Image\\Bg");
SelectedBgPath = path;
ChangedBg?.Invoke(new KeyValueModel(path, path));
}
}
private void LoadBgImgList()
{
BgImgList = new List<MusicBgImgModel>();
后面还有 21 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
