Ionite
1 year ago
16 changed files with 416 additions and 108 deletions
@ -0,0 +1,48 @@
|
||||
using System; |
||||
using Avalonia.Controls; |
||||
using Avalonia.Controls.Primitives; |
||||
using Dock.Avalonia.Controls; |
||||
using Dock.Model; |
||||
using Dock.Model.Avalonia.Json; |
||||
using Dock.Model.Core; |
||||
|
||||
namespace StabilityMatrix.Avalonia.Controls.Dock; |
||||
|
||||
/// <summary> |
||||
/// Base for Dock controls |
||||
/// Expects a <see cref="DockControl"/> named "Dock" in the XAML |
||||
/// </summary> |
||||
public abstract class DockUserControlBase : UserControlBase |
||||
{ |
||||
private DockControl _dock = null!; |
||||
protected readonly AvaloniaDockSerializer DockSerializer = new(); |
||||
protected readonly DockState DockState = new(); |
||||
|
||||
/// <inheritdoc /> |
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e) |
||||
{ |
||||
base.OnApplyTemplate(e); |
||||
|
||||
_dock = this.FindControl<DockControl>("Dock") |
||||
?? throw new NullReferenceException("DockControl not found"); |
||||
|
||||
if (_dock.Layout is { } layout) |
||||
{ |
||||
DockState.Save(layout); |
||||
} |
||||
} |
||||
|
||||
protected virtual void LoadDockLayout(string data) |
||||
{ |
||||
if (DockSerializer.Deserialize<IDock?>(data) is { } layout) |
||||
{ |
||||
_dock.Layout = layout; |
||||
DockState.Restore(layout); |
||||
} |
||||
} |
||||
|
||||
protected virtual string SaveDockLayout() |
||||
{ |
||||
return DockSerializer.Serialize(_dock.Layout); |
||||
} |
||||
} |
@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls; |
||||
|
||||
namespace StabilityMatrix.Avalonia.Models; |
||||
|
||||
public interface IPersistentViewProvider |
||||
{ |
||||
Control? AttachedPersistentView { get; set; } |
||||
} |
@ -1,3 +0,0 @@
|
||||
namespace StabilityMatrix.Avalonia.Models.Inference; |
||||
|
||||
public record ModelCardModel(string? SelectedModelName) { } |
@ -1,17 +1,21 @@
|
||||
using Avalonia.Markup.Xaml; |
||||
using StabilityMatrix.Avalonia.Controls; |
||||
using System.Diagnostics; |
||||
using StabilityMatrix.Avalonia.Controls.Dock; |
||||
|
||||
namespace StabilityMatrix.Avalonia.Views; |
||||
|
||||
public partial class InferenceTextToImageView : UserControlBase |
||||
public partial class InferenceTextToImageView : DockUserControlBase |
||||
{ |
||||
public InferenceTextToImageView() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
private void InitializeComponent() |
||||
~InferenceTextToImageView() |
||||
{ |
||||
AvaloniaXamlLoader.Load(this); |
||||
if (DataContext is { } dataContext) |
||||
{ |
||||
Debug.WriteLine("InferenceTextToImageView destructor"); |
||||
} |
||||
Debug.WriteLine("InferenceTextToImageView destructor"); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue