using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using DynamicData.Binding; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Core.Inference; using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models.Api.Comfy; namespace StabilityMatrix.Avalonia.DesignData; public partial class MockInferenceClientManager : ObservableObject, IInferenceClientManager { public ComfyClient? Client { get; set; } public IObservableCollection Models { get; } = new ObservableCollectionExtended(); public IObservableCollection VaeModels { get; } = new ObservableCollectionExtended(); public IObservableCollection Samplers { get; } = new ObservableCollectionExtended(ComfySampler.Defaults); public IObservableCollection Upscalers { get; } = new ObservableCollectionExtended( new ComfyUpscaler[] { new("nearest-exact", ComfyUpscalerType.Latent), new("bicubic", ComfyUpscalerType.Latent), new("ESRGAN-4x", ComfyUpscalerType.ESRGAN) } ); public IObservableCollection Schedulers { get; } = new ObservableCollectionExtended(ComfyScheduler.Defaults); [ObservableProperty] [NotifyPropertyChangedFor(nameof(CanUserConnect))] private bool isConnected; [ObservableProperty] [NotifyPropertyChangedFor(nameof(CanUserConnect))] private bool isConnecting; /// public bool CanUserConnect => !IsConnected && !IsConnecting; /// public bool CanUserDisconnect => IsConnected && !IsConnecting; public async Task ConnectAsync(CancellationToken cancellationToken = default) { IsConnecting = true; await Task.Delay(5000, cancellationToken); IsConnecting = false; IsConnected = true; } /// public Task ConnectAsync(PackagePair packagePair, CancellationToken cancellationToken = default) { return Task.CompletedTask; } public Task CloseAsync() { IsConnected = false; return Task.CompletedTask; } public void Dispose() { GC.SuppressFinalize(this); } }