using System; using System.Linq; using System.Threading; using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using DynamicData; using DynamicData.Binding; using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Core.Inference; using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models.Api.Comfy; using StabilityMatrix.Core.Models.FileInterfaces; 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 ControlNetModels { get; } = new ObservableCollectionExtended(); public IObservableCollection PromptExpansionModels { get; } = new ObservableCollectionExtended(); public IObservableCollection Samplers { get; } = new ObservableCollectionExtended(ComfySampler.Defaults); public IObservableCollection Upscalers { get; } = new ObservableCollectionExtended( ComfyUpscaler.Defaults.Concat(ComfyUpscaler.DefaultDownloadableModels) ); 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 MockInferenceClientManager() { Models.AddRange( new[] { HybridModelFile.FromRemote("v1-5-pruned-emaonly.safetensors"), HybridModelFile.FromRemote("artshaper1.safetensors"), } ); } /// public Task CopyImageToInputAsync(FilePath imageFile, CancellationToken cancellationToken = default) { return Task.CompletedTask; } /// public Task UploadInputImageAsync(ImageSource image, CancellationToken cancellationToken = default) { return Task.CompletedTask; } /// public Task WriteImageToInputAsync(ImageSource imageSource, CancellationToken cancellationToken = default) { return Task.CompletedTask; } 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); } }