Skip to content

Commit

Permalink
feat: Add support for XamlRoot.RasterizationScale
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Feb 1, 2022
1 parent 3a57dab commit 8ff10bf
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 10 deletions.
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\XamlRoot\XamlRoot_Properties.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\xBindTests\NoPhaseBinding_Large.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -5156,6 +5160,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\WindowTests\Window_ContentIsFullyVisible.xaml.cs">
<DependentUpon>Window_ContentIsFullyVisible.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\XamlRoot\XamlRoot_Properties.xaml.cs">
<DependentUpon>XamlRoot_Properties.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\xBindTests\NoPhaseBinding_Large.xaml.cs">
<DependentUpon>NoPhaseBinding_Large.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<UserControl
x:Class="UITests.Windows_UI_Xaml.XamlRoot.XamlRoot_Properties"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Windows_UI_Xaml.XamlRoot"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">

<StackPanel>
<TextBlock>
RasterizationScale: <Run x:Name="rasterizationScale" />
</TextBlock>
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Uno.UI.Samples.Controls;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

namespace UITests.Windows_UI_Xaml.XamlRoot
{
[Sample("XamlRoot", Description = "")]
public sealed partial class XamlRoot_Properties : UserControl
{
public XamlRoot_Properties()
{
this.InitializeComponent();

Loaded += (s, e) => {
rasterizationScale.Text = XamlRoot.RasterizationScale.ToString();
};
}
}
}
10 changes: 0 additions & 10 deletions src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml/XamlRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ public bool IsHostVisible
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public double RasterizationScale
{
get
{
throw new global::System.NotImplementedException("The member double XamlRoot.RasterizationScale is not implemented in Uno.");
}
}
#endif
// Skipping already declared property Size
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UI/UI/Xaml/XamlRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public sealed partial class XamlRoot

public Size Size => Content?.RenderSize ?? Size.Empty;

public double RasterizationScale
=> global::Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;

internal void NotifyChanged()
{
Changed?.Invoke(this, new XamlRootChangedEventArgs());
Expand Down

0 comments on commit 8ff10bf

Please sign in to comment.