首次提交:本地项目同步到Gitea
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Ke.Bee.Localization.Localizer.Abstractions;
|
||||
using Plugin.Cowain.Driver.IServices;
|
||||
using Plugin.Cowain.Driver.Models;
|
||||
|
||||
namespace Plugin.Cowain.Driver.ViewModels;
|
||||
|
||||
public partial class DriverSelectedDialogViewModel : ObservableObject
|
||||
{
|
||||
|
||||
[ObservableProperty]
|
||||
private DriverInfo? _driver;
|
||||
[ObservableProperty]
|
||||
private List<DeviceTypeInfo>? _deviceTypes;
|
||||
|
||||
private readonly ILocalizer _l;
|
||||
private readonly IDriverPluginService _driverService;
|
||||
|
||||
public DriverSelectedDialogViewModel(ILocalizer l, IDriverPluginService driverService)
|
||||
{
|
||||
_l = l;
|
||||
_driverService = driverService;
|
||||
DeviceTypes = GetDrivers(_driverService.GetDriverInfos());
|
||||
}
|
||||
|
||||
public List<DeviceTypeInfo> GetDrivers(List<DriverInfo> driverInfoList)
|
||||
{
|
||||
var multiLevelDataSource = driverInfoList
|
||||
.GroupBy(d => d.DeviceType)
|
||||
.Select(deviceTypeGroup => new DeviceTypeInfo
|
||||
{
|
||||
Name = deviceTypeGroup.Key,
|
||||
Groups = deviceTypeGroup
|
||||
.GroupBy(d => d.Group)
|
||||
.Select(groupGroup => new DriverInfoGroup
|
||||
{
|
||||
Name = groupGroup.Key,
|
||||
Drivers = groupGroup
|
||||
.Select(d => new DriverInfo
|
||||
{
|
||||
Name = d.Name,
|
||||
DeviceType = d.DeviceType,
|
||||
Group = d.Group,
|
||||
Desc = d.Desc,
|
||||
})
|
||||
.ToList()
|
||||
})
|
||||
.ToList()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return multiLevelDataSource;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user