LANCommander/LANCommander.Launcher.Models/ListItem.cs
Aaron Powell 8cf2139ccf feat: Add Avalonia launcher PoC with cross-platform UI
- Create LANCommander.Launcher.Avalonia project using Avalonia MVVM
- Implement server selection, login, and game library views
- Add library sidebar showing user's games
- Add depot/games list view with game details
- Integrate with LANCommander.Launcher.Services for:
  - DepotService, LibraryService, ImportService, MediaService
  - SDK authentication and connection clients
- Fix async initialization pattern to prevent UI thread deadlocks
- Add ConfigureAwait(false) to ServerConfigurationProvider.RefreshAsync
- Add Microsoft.Extensions.Http package for HttpClient DI

Key features:
- Server discovery and connection
- User authentication with credential persistence
- Library import from server to local SQLite cache
- Game icons and banners via MediaService
- Navigation between library, depot, and game details
2026-01-19 14:24:49 +11:00

97 lines
2.6 KiB
C#

using LANCommander.Launcher.Data.Models;
using LANCommander.SDK.Helpers;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LANCommander.Launcher.Models
{
public enum ListItemState
{
NotInstalled,
Installed,
Queued,
Installing,
UpdateAvailable,
Uninstalling,
}
public enum ListItemType
{
Game,
Redistributable
}
public class ListItem
{
public Guid Key { get; set; }
public Guid IconId { get; set; }
public ListItemType Type { get; set; }
public ListItemState State { get; set; }
public string Name { get; set; }
public string SortName { get; set; }
public string[] Groups { get; set; }
public object DataItem { get; set; }
public ListItem(Collection collection)
{
Key = collection.Id;
Type = ListItemType.Game;
Name = collection.Name;
DataItem = collection;
}
public ListItem(Game game)
{
Key = game.Id;
Type = ListItemType.Game;
Name = game.Title;
SortName = game.SortTitle;
DataItem = game;
var manifestPath = ManifestHelper.GetPath(game.InstallDirectory, game.Id);
if (game.Installed && !String.IsNullOrWhiteSpace(game.LatestVersion) && game.InstalledVersion != game.LatestVersion)
State = ListItemState.UpdateAvailable;
else if (game.Installed && File.Exists(manifestPath))
State = ListItemState.Installed;
else
State = ListItemState.NotInstalled;
var icon = game.Media.FirstOrDefault(m => m.Type == SDK.Enums.MediaType.Icon);
if (icon != null)
IconId = icon.Id;
}
public ListItem(Redistributable redistributable)
{
Key = redistributable.Id;
Type = ListItemType.Redistributable;
Name = redistributable.Name;
DataItem = redistributable;
}
public ListItem(SDK.Models.Game game)
{
Key = game.Id;
Type = ListItemType.Game;
Name = game.Title;
SortName = game.SortTitle;
DataItem = game;
}
public ListItem(SDK.Models.DepotGame game)
{
Key = game.Id;
Type = ListItemType.Game;
Name = game.Title;
SortName = game.SortTitle;
DataItem = game;
}
}
}