-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Start adding embedded monitors to the UI.
- Loading branch information
Showing
17 changed files
with
378 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Exo/Service/Exo.Service.Grpc/GrpcEmbeddedMonitorService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Exo.Contracts.Ui.Settings; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Exo.Service.Grpc; | ||
|
||
internal sealed class GrpcEmbeddedMonitorService : IEmbeddedMonitorService | ||
{ | ||
private readonly ConfigurationService _configurationService; | ||
private readonly ILogger<GrpcDeviceService> _logger; | ||
private readonly EmbeddedMonitorService _embeddedMonitorService; | ||
|
||
public GrpcEmbeddedMonitorService(ILogger<GrpcDeviceService> logger, ConfigurationService configurationService, EmbeddedMonitorService embeddedMonitorService) | ||
{ | ||
_logger = logger; | ||
_configurationService = configurationService; | ||
_embeddedMonitorService = embeddedMonitorService; | ||
} | ||
|
||
public async IAsyncEnumerable<Contracts.Ui.Settings.EmbeddedMonitorDeviceInformation> WatchEmbeddedMonitorDevicesAsync(CancellationToken cancellationToken) | ||
{ | ||
_logger.GrpcSpecializedDeviceServiceWatchStart(GrpcService.EmbeddedMonitor); | ||
try | ||
{ | ||
await foreach (var notification in _embeddedMonitorService.WatchDevicesAsync(cancellationToken).ConfigureAwait(false)) | ||
{ | ||
yield return notification.ToGrpc(); | ||
} | ||
} | ||
finally | ||
{ | ||
_logger.GrpcSpecializedDeviceServiceWatchStop(GrpcService.EmbeddedMonitor); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/Exo/Ui/Exo.Settings.Ui/DataTemplateSelectors/EmbeddedMonitorSettingTemplateSelector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Exo.Settings.Ui.ViewModels; | ||
using Exo.Contracts.Ui.Settings; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Exo.Settings.Ui.DataTemplateSelectors; | ||
|
||
internal sealed class EmbeddedMonitorSettingTemplateSelector : DataTemplateSelector | ||
{ | ||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
public DataTemplate SingleMonitorTemplate { get; set; } | ||
public DataTemplate MonitorMatrixTemplate { get; set; } | ||
public DataTemplate MultiMonitorTemplate { get; set; } | ||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
|
||
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) | ||
=> SelectTemplateCore(item); | ||
|
||
protected override DataTemplate SelectTemplateCore(object item) | ||
{ | ||
// NB: This can't detect changes. If we ever need to update the display mode dynamically, it will have to be driven externally. (For example triggering a PropertyChanged event somewhere) | ||
if (item is EmbeddedMonitorFeaturesViewModel s) | ||
{ | ||
if (s.EmbeddedMonitors.Count == 1) return SingleMonitorTemplate; | ||
// TODO: This is hardcoded for StreamDeck. Have this less hardcoded. Should probably be driven by the ViewModel + metadata. | ||
else if (s.EmbeddedMonitors.Count == 32) return MonitorMatrixTemplate; | ||
} | ||
return MultiMonitorTemplate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/Exo/Ui/Exo.Settings.Ui/EmbeddedMonitorSettingsControl.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<UserControl | ||
x:Class="Exo.Settings.Ui.EmbeddedMonitorSettingsControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Exo.Settings.Ui" | ||
xmlns:lconverters="using:Exo.Settings.Ui.Converters" | ||
xmlns:lts="using:Exo.Settings.Ui.DataTemplateSelectors" | ||
xmlns:vm="using:Exo.Settings.Ui.ViewModels" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
d:DataContext="{d:DesignInstance vm:EmbeddedMonitorFeaturesViewModel, IsDesignTimeCreatable=False}"> | ||
<ContentPresenter Content="{Binding}" HorizontalAlignment="Stretch"> | ||
<ContentPresenter.ContentTemplateSelector> | ||
<lts:EmbeddedMonitorSettingTemplateSelector> | ||
<lts:EmbeddedMonitorSettingTemplateSelector.SingleMonitorTemplate> | ||
<DataTemplate x:DataType="vm:EmbeddedMonitorFeaturesViewModel"> | ||
<Grid HorizontalAlignment="Stretch" DataContext="{Binding EmbeddedMonitors[0]}"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<Grid HorizontalAlignment="Stretch"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="{StaticResource PropertyLabelColumnWidth}" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
</Grid> | ||
<Image Grid.Row="1" Width="{Binding ImageSize.Width}" Height="{Binding ImageSize.Height}" /> | ||
</Grid> | ||
</DataTemplate> | ||
</lts:EmbeddedMonitorSettingTemplateSelector.SingleMonitorTemplate> | ||
<lts:EmbeddedMonitorSettingTemplateSelector.MonitorMatrixTemplate> | ||
<DataTemplate x:DataType="vm:EmbeddedMonitorFeaturesViewModel"> | ||
<Grid></Grid> | ||
</DataTemplate> | ||
</lts:EmbeddedMonitorSettingTemplateSelector.MonitorMatrixTemplate> | ||
<lts:EmbeddedMonitorSettingTemplateSelector.MultiMonitorTemplate> | ||
<DataTemplate x:DataType="vm:EmbeddedMonitorFeaturesViewModel"> | ||
<Grid></Grid> | ||
</DataTemplate> | ||
</lts:EmbeddedMonitorSettingTemplateSelector.MultiMonitorTemplate> | ||
</lts:EmbeddedMonitorSettingTemplateSelector> | ||
</ContentPresenter.ContentTemplateSelector> | ||
</ContentPresenter> | ||
</UserControl> |
26 changes: 26 additions & 0 deletions
26
src/Exo/Ui/Exo.Settings.Ui/EmbeddedMonitorSettingsControl.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.UI.Xaml.Data; | ||
using Microsoft.UI.Xaml.Input; | ||
using Microsoft.UI.Xaml.Media; | ||
using Microsoft.UI.Xaml.Navigation; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace Exo.Settings.Ui; | ||
public sealed partial class EmbeddedMonitorSettingsControl : UserControl | ||
{ | ||
public EmbeddedMonitorSettingsControl() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.