forked from firstfloorsoftware/mui
-
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.
improved support for HighDPI screens
* new DpiAwareWindow base class with support for PerMonitor DPI awareness availabe in Windows 8.1 * ModernWindow styles updated for better viewing on high dpi screens * default ModernButton size increased * BBCodeBlock.BBCode now default Content property * ModernWindow resizegrip now functions properly
- Loading branch information
kozw_cp
authored and
kozw_cp
committed
Aug 9, 2014
1 parent
804de78
commit 05da91d
Showing
30 changed files
with
1,399 additions
and
143 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
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
49 changes: 49 additions & 0 deletions
49
1.0/FirstFloor.ModernUI/FirstFloor.ModernUI.App/Pages/DpiAwareness.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,49 @@ | ||
<UserControl x:Class="FirstFloor.ModernUI.App.Pages.DpiAwareness" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mui="http://firstfloorsoftware.com/ModernUI" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" d:DesignWidth="300"> | ||
<Grid Style="{StaticResource ContentRoot}"> | ||
<ScrollViewer> | ||
<StackPanel > | ||
<TextBlock Text="DPI AWARENESS" Style="{StaticResource Heading1}" Margin="0,0,0,8"/> | ||
<mui:BBCodeBlock Margin="0,0,0,32" xml:space="preserve">Windows 8.1 gives developers new functionality to create desktop applications that are per-monitor DPI-aware. MUI automatically enables per-monitor DPI awereness when supported by the host OS. When enabled a window is scaled across monitors of different DPIs. | ||
|
||
MUI's implementation of per-monitor DPI awareness is largely based on the MSDN article [url=http://msdn.microsoft.com/en-us/library/windows/desktop/ee308410(v=vs.85).aspx]Developing a Per-Monitor DPI-Aware WPF Application[/url].</mui:BBCodeBlock> | ||
|
||
<TextBlock Text="DPI INFORMATION" Style="{StaticResource Heading2}"/> | ||
<mui:BBCodeBlock BBCode="{Binding DpiAwareMessage}" Margin="0,0,0,16" /> | ||
<Grid> | ||
<Grid.Resources> | ||
<Style x:Key="RightAlign" TargetType="TextBlock"> | ||
<Setter Property="HorizontalAlignment" Value="Right" /> | ||
<Setter Property="Margin" Value="16,0,0,4" /> | ||
</Style> | ||
</Grid.Resources> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="Auto"/> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
</Grid.RowDefinitions> | ||
|
||
<TextBlock Text="WPF rendering DPI:" /> | ||
<TextBlock Grid.Column="1" Text="{Binding WpfDpi}" Style="{StaticResource RightAlign}" /> | ||
<TextBlock Grid.Row="1" Text="Current monitor DPI:" /> | ||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding MonitorDpi}" Style="{StaticResource RightAlign}" /> | ||
<TextBlock Grid.Row="2" Text="Layout scale:" /> | ||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding LayoutScale}" Style="{StaticResource RightAlign}" /> | ||
<TextBlock Grid.Row="3" Text="Window size:" /> | ||
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding WindowSize}" Style="{StaticResource RightAlign}" /> | ||
</Grid> | ||
</StackPanel> | ||
</ScrollViewer> | ||
</Grid> | ||
</UserControl> |
30 changes: 30 additions & 0 deletions
30
1.0/FirstFloor.ModernUI/FirstFloor.ModernUI.App/Pages/DpiAwareness.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,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace FirstFloor.ModernUI.App.Pages | ||
{ | ||
/// <summary> | ||
/// Interaction logic for DpiAwareness.xaml | ||
/// </summary> | ||
public partial class DpiAwareness : UserControl | ||
{ | ||
public DpiAwareness() | ||
{ | ||
InitializeComponent(); | ||
|
||
this.DataContext = new DpiAwarenessViewModel(); | ||
} | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
1.0/FirstFloor.ModernUI/FirstFloor.ModernUI.App/Pages/DpiAwarenessViewModel.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,88 @@ | ||
using FirstFloor.ModernUI.Presentation; | ||
using FirstFloor.ModernUI.Windows.Controls; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace FirstFloor.ModernUI.App.Pages | ||
{ | ||
public class DpiAwarenessViewModel | ||
: NotifyPropertyChanged | ||
{ | ||
private DpiAwareWindow wnd; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DpiAwarenessViewModel" /> class. | ||
/// </summary> | ||
public DpiAwarenessViewModel() | ||
{ | ||
this.wnd = (DpiAwareWindow)App.Current.MainWindow; | ||
this.wnd.DpiChanged += OnWndDpiChanged; | ||
this.wnd.SizeChanged += OnWndSizeChanged; | ||
} | ||
|
||
private void OnWndDpiChanged(object sender, EventArgs e) | ||
{ | ||
OnPropertyChanged(null); // refresh all properties | ||
} | ||
|
||
private void OnWndSizeChanged(object sender, SizeChangedEventArgs e) | ||
{ | ||
OnPropertyChanged(null); // refresh all properties | ||
} | ||
|
||
public string DpiAwareMessage | ||
{ | ||
get | ||
{ | ||
return string.Format(CultureInfo.InvariantCulture, "The DPI awareness of this process is [b]{0}[/b]", ModernUIHelper.GetDpiAwereness()); | ||
} | ||
} | ||
|
||
public string WpfDpi | ||
{ | ||
get | ||
{ | ||
var info = this.wnd.DpiInformation; | ||
return string.Format(CultureInfo.InvariantCulture, "{0} x {1}", info.WpfDpiX, info.WpfDpiY); | ||
} | ||
} | ||
|
||
public string MonitorDpi | ||
{ | ||
get | ||
{ | ||
var info = this.wnd.DpiInformation; | ||
if (info.MonitorDpiX.HasValue) { | ||
return string.Format(CultureInfo.InvariantCulture, "{0} x {1}", info.MonitorDpiX, info.MonitorDpiY); | ||
} | ||
return "n/a"; | ||
} | ||
} | ||
|
||
public string LayoutScale | ||
{ | ||
get | ||
{ | ||
var info = this.wnd.DpiInformation; | ||
return string.Format(CultureInfo.InvariantCulture, "{0} x {1}", info.ScaleX, info.ScaleY); | ||
} | ||
} | ||
|
||
public string WindowSize | ||
{ | ||
get | ||
{ | ||
var info = this.wnd.DpiInformation; | ||
var width = this.wnd.ActualWidth * info.WpfDpiX / 96D; | ||
var height = this.wnd.ActualHeight * info.WpfDpiY / 96D; | ||
|
||
return string.Format(CultureInfo.InvariantCulture, "{0} x {1}", width, height); | ||
} | ||
} | ||
} | ||
} |
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.