-
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.
⚒️ Continue with implementing embedded monitors in the UI.
Among other things, split the UI components in multiple parts to make it easier to address ImageCropper quirks. Will probably still have to fork the component in the end.
- Loading branch information
Showing
18 changed files
with
394 additions
and
199 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
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
14 changes: 14 additions & 0 deletions
14
src/Exo/Ui/Exo.Contracts.Ui.Settings/EmbeddedMonitorSetBuiltInGraphicsRequest.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,14 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Exo.Contracts.Ui.Settings; | ||
|
||
[DataContract] | ||
public sealed class EmbeddedMonitorSetBuiltInGraphicsRequest | ||
{ | ||
[DataMember(Order = 1)] | ||
public Guid DeviceId { get; init; } | ||
[DataMember(Order = 2)] | ||
public Guid MonitorId { get; init; } | ||
[DataMember(Order = 3)] | ||
public Guid GraphicsId { get; init; } | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Exo/Ui/Exo.Contracts.Ui.Settings/EmbeddedMonitorSetImageRequest.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,16 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Exo.Contracts.Ui.Settings; | ||
|
||
[DataContract] | ||
public sealed class EmbeddedMonitorSetImageRequest | ||
{ | ||
[DataMember(Order = 1)] | ||
public Guid DeviceId { get; init; } | ||
[DataMember(Order = 2)] | ||
public Guid MonitorId { get; init; } | ||
[DataMember(Order = 3)] | ||
public UInt128 ImageId { get; init; } | ||
[DataMember(Order = 4)] | ||
public Rectangle CropRegion { get; init; } | ||
} |
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
52 changes: 52 additions & 0 deletions
52
src/Exo/Ui/Exo.Settings.Ui/EmbeddedMonitorDeviceSettingsControl.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,52 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<UserControl | ||
x:Class="Exo.Settings.Ui.EmbeddedMonitorDeviceSettingsControl" | ||
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:controls="using:CommunityToolkit.WinUI.Controls" | ||
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}"> | ||
<ContentControl Content="{Binding}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"> | ||
<ContentControl.ContentTemplateSelector> | ||
<lts:EmbeddedMonitorSettingTemplateSelector> | ||
<lts:EmbeddedMonitorSettingTemplateSelector.SingleMonitorTemplate> | ||
<DataTemplate x:DataType="vm:EmbeddedMonitorFeaturesViewModel"> | ||
<local:EmbeddedMonitorSettingControl Monitor="{Binding EmbeddedMonitors[0]}" /> | ||
</DataTemplate> | ||
</lts:EmbeddedMonitorSettingTemplateSelector.SingleMonitorTemplate> | ||
<lts:EmbeddedMonitorSettingTemplateSelector.MonitorMatrixTemplate> | ||
<DataTemplate x:DataType="vm:EmbeddedMonitorFeaturesViewModel"> | ||
<Grid> | ||
<!-- TODO: Create a Control to display items in a fixed grid --> | ||
<ItemsView ItemsSource="{Binding EmbeddedMonitors}"> | ||
<ItemsView.ItemTemplate> | ||
<DataTemplate x:DataType="vm:EmbeddedMonitorViewModel"> | ||
<ItemContainer> | ||
<Grid Width="{Binding DisplayWidth}" Height="{Binding DisplayHeight}" Background="Black" Margin="3"> | ||
<Image></Image> | ||
</Grid> | ||
</ItemContainer> | ||
</DataTemplate> | ||
</ItemsView.ItemTemplate> | ||
<ItemsView.Layout> | ||
<UniformGridLayout MaximumRowsOrColumns="8" /> | ||
</ItemsView.Layout> | ||
</ItemsView> | ||
</Grid> | ||
</DataTemplate> | ||
</lts:EmbeddedMonitorSettingTemplateSelector.MonitorMatrixTemplate> | ||
<lts:EmbeddedMonitorSettingTemplateSelector.MultiMonitorTemplate> | ||
<DataTemplate x:DataType="vm:EmbeddedMonitorFeaturesViewModel"> | ||
<Grid></Grid> | ||
</DataTemplate> | ||
</lts:EmbeddedMonitorSettingTemplateSelector.MultiMonitorTemplate> | ||
</lts:EmbeddedMonitorSettingTemplateSelector> | ||
</ContentControl.ContentTemplateSelector> | ||
</ContentControl> | ||
</UserControl> |
11 changes: 11 additions & 0 deletions
11
src/Exo/Ui/Exo.Settings.Ui/EmbeddedMonitorDeviceSettingsControl.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,11 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Exo.Settings.Ui; | ||
|
||
internal sealed partial class EmbeddedMonitorDeviceSettingsControl : UserControl | ||
{ | ||
public EmbeddedMonitorDeviceSettingsControl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/Exo/Ui/Exo.Settings.Ui/EmbeddedMonitorImageSettingsControl.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,55 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<UserControl | ||
x:Class="Exo.Settings.Ui.EmbeddedMonitorImageSettingsControl" | ||
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:vm="using:Exo.Settings.Ui.ViewModels" | ||
xmlns:controls="using:CommunityToolkit.WinUI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid HorizontalAlignment="Stretch"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
|
||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="{StaticResource PropertyLabelColumnWidth}" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock x:Uid="EmbeddedMonitorImageLabel" Margin="{StaticResource RowLabelMargin}"></TextBlock> | ||
<ComboBox | ||
Grid.Column="1" | ||
Margin="{StaticResource RowContentLabelMargin}" | ||
ItemsSource="{Binding AvailableImages}" | ||
SelectedItem="{Binding Image, Mode=TwoWay}" | ||
HorizontalAlignment="Stretch"> | ||
<ComboBox.ItemTemplate> | ||
<DataTemplate x:DataType="vm:ImageViewModel"> | ||
<StackPanel Orientation="Horizontal"> | ||
<Image Source="{Binding FileName, Converter={StaticResource FileNameToBitmapImageConverter}}" Width="20" Height="20" Margin="0,0,6,0" /> | ||
<TextBlock Text="{Binding Name}" /> | ||
</StackPanel> | ||
</DataTemplate> | ||
</ComboBox.ItemTemplate> | ||
</ComboBox> | ||
<Button Grid.Column="2" Margin="{StaticResource RowContentMargin}" HorizontalAlignment="Right" Command="{Binding ResetCommand}"> | ||
<FontIcon Glyph="" /> | ||
</Button> | ||
</Grid> | ||
<Grid Grid.Row="1" MinHeight="{Binding DisplayHeight}"> | ||
<controls:ImageCropper | ||
x:Name="ImageCropper" | ||
CropShape="{Binding Shape, Converter={StaticResource MonitorShapeToCropShapeConverter}}" | ||
Source="{Binding Image, Converter={StaticResource ImageToWriteableBitmapConverter}}" | ||
ThumbPlacement="Corners" | ||
Padding="20" | ||
Height="{Binding ImageSize.Height}" /> | ||
</Grid> | ||
</Grid> | ||
</UserControl> |
57 changes: 57 additions & 0 deletions
57
src/Exo/Ui/Exo.Settings.Ui/EmbeddedMonitorImageSettingsControl.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,57 @@ | ||
using System.ComponentModel; | ||
using Exo.Settings.Ui.ViewModels; | ||
using Exo.Ui; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Exo.Settings.Ui; | ||
|
||
internal sealed partial class EmbeddedMonitorImageSettingsControl : UserControl | ||
{ | ||
public EmbeddedMonitorImageGraphicsViewModel? ImageGraphics | ||
{ | ||
get => (EmbeddedMonitorImageGraphicsViewModel)GetValue(ImageGraphicsProperty); | ||
set => SetValue(ImageGraphicsProperty, value); | ||
} | ||
|
||
public static readonly DependencyProperty ImageGraphicsProperty = DependencyProperty.Register | ||
( | ||
nameof(ImageGraphics), | ||
typeof(EmbeddedMonitorImageGraphicsViewModel), | ||
typeof(EmbeddedMonitorImageSettingsControl), | ||
new PropertyMetadata(null, (d, e) => ((EmbeddedMonitorImageSettingsControl)d).OnPropertyChanged(e)) | ||
); | ||
|
||
public EmbeddedMonitorImageSettingsControl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void OnPropertyChanged(DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (e.Property == ImageGraphicsProperty) | ||
{ | ||
if (e.OldValue is EmbeddedMonitorImageGraphicsViewModel oldValue) oldValue.PropertyChanged -= OnImageGraphicsPropertyChanged; | ||
if (e.NewValue is EmbeddedMonitorImageGraphicsViewModel newValue) newValue.PropertyChanged += OnImageGraphicsPropertyChanged; | ||
UpdateCroppedRegion(); | ||
} | ||
} | ||
|
||
private void OnImageGraphicsPropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (BindableObject.Equals(e, ChangedProperty.CropRectangle)) | ||
{ | ||
UpdateCroppedRegion(); | ||
} | ||
} | ||
|
||
private void UpdateCroppedRegion() | ||
{ | ||
if (ImageGraphics is { } imageGraphics) | ||
{ | ||
var rectangle = imageGraphics.CropRectangle; | ||
|
||
ImageCropper.TrySetCroppedRegion(new(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height)); | ||
} | ||
} | ||
} |
Oops, something went wrong.