Skip to content

Commit

Permalink
🎨 Disable embedded monitor UI during updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
hexawyz committed Feb 9, 2025
1 parent 8b7cebc commit 7a806c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<lts:EmbeddedMonitorSettingTemplateSelector>
<lts:EmbeddedMonitorSettingTemplateSelector.SingleMonitorTemplate>
<DataTemplate x:DataType="vm:EmbeddedMonitorFeaturesViewModel">
<local:EmbeddedMonitorSettingControl Monitor="{Binding EmbeddedMonitors[0]}" />
<local:EmbeddedMonitorSettingControl Monitor="{Binding EmbeddedMonitors[0]}" IsEnabled="{Binding EmbeddedMonitors[0].IsNotBusy}" />
</DataTemplate>
</lts:EmbeddedMonitorSettingTemplateSelector.SingleMonitorTemplate>
<lts:EmbeddedMonitorSettingTemplateSelector.MonitorMatrixTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ internal sealed class EmbeddedMonitorViewModel : ApplicableResettableBindableObj
private readonly ReadOnlyObservableCollection<EmbeddedMonitorGraphicsViewModel> _readOnlySupportedGraphics;
private Guid _initialCurrentGraphicsId;
private EmbeddedMonitorGraphicsViewModel? _currentGraphics;
private bool _isReady;

public EmbeddedMonitorViewModel(EmbeddedMonitorFeaturesViewModel owner, EmbeddedMonitorInformation information)
{
Expand Down Expand Up @@ -157,12 +158,19 @@ public EmbeddedMonitorViewModel(EmbeddedMonitorFeaturesViewModel owner, Embedded
_currentGraphics = imageGraphics ?? _supportedGraphics[0];
_initialCurrentGraphicsId = _currentGraphics.Id;
}
_isReady = true;
}

private bool IsChangedNonRecursive => _currentGraphics?.Id != _initialCurrentGraphicsId;
public override bool IsChanged => IsChangedNonRecursive || CurrentGraphics?.IsChanged == true;
protected override bool CanApply => IsChanged && _currentGraphics?.IsValid == true;

public bool IsNotBusy
{
get => _isReady;
private set => SetValue(ref _isReady, value, ChangedProperty.IsNotBusy);
}

public Guid MonitorId => _monitorId;

public MonitorShape Shape
Expand Down Expand Up @@ -256,7 +264,15 @@ protected override async Task ApplyChangesAsync(CancellationToken cancellationTo
{
if (_currentGraphics is not null)
{
await _currentGraphics.ApplyAsync(cancellationToken).ConfigureAwait(false);
IsNotBusy = false;
try
{
await _currentGraphics.ApplyAsync(cancellationToken);
}
finally
{
IsNotBusy = true;
}
}
}

Expand Down Expand Up @@ -373,7 +389,7 @@ internal override async ValueTask ApplyAsync(CancellationToken cancellationToken
GraphicsId = Id
},
cancellationToken
).ConfigureAwait(false);
);
}

internal sealed class EmbeddedMonitorImageGraphicsViewModel : EmbeddedMonitorGraphicsViewModel, IDisposable
Expand Down

0 comments on commit 7a806c8

Please sign in to comment.