Skip to content

Commit

Permalink
Fix maximized behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
BeezBeez committed Feb 6, 2020
1 parent f683e4d commit 1b32a21
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
10 changes: 5 additions & 5 deletions RoundedScreen/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RoundedScreen"
mc:Ignorable="d"
Title="RoundedScreen" Height="450" Width="800" Topmost="True" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" WindowState="Maximized" ShowInTaskbar="False" Focusable="False" IsTabStop="False" Closing="WndRoundedScreen_Closing" WindowStyle="None" AllowsTransparency="True">
Title="RoundedScreen" Loaded="WndRoundedScreen_Loaded" Height="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}" Width="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenWidthKey}}" Topmost="True" ResizeMode="NoResize" WindowStartupLocation="Manual" ShowInTaskbar="False" Focusable="False" IsTabStop="False" Closing="WndRoundedScreen_Closing" WindowStyle="None" AllowsTransparency="True" LostFocus="WndRoundedScreen_LostFocus" Left="0" Top="0">
<Window.Resources>
<Storyboard x:Key="Opening">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="grid">
Expand All @@ -24,8 +24,8 @@
Opacity="0.0" />
</Window.Background>
<Grid x:Name="grid">
<Image x:Name="imgCornerTL" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Top" Width="12" Source="pack://siteoforigin:,,,/Resources/Corner.png"/>
<Image x:Name="imgCornerTR" HorizontalAlignment="Right" Margin="0" VerticalAlignment="Top" Width="12" Source="pack://siteoforigin:,,,/Resources/Corner.png" RenderTransformOrigin="0.5,0.5">
<Image x:Name="imgCornerTL" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Top" Width="16" Source="Resources/Corner.png"/>
<Image x:Name="imgCornerTR" HorizontalAlignment="Right" Margin="0" VerticalAlignment="Top" Width="16" Source="Resources/Corner.png" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform/>
Expand All @@ -35,7 +35,7 @@
</TransformGroup>
</Image.RenderTransform>
</Image>
<Image x:Name="imgCornerBR" HorizontalAlignment="Right" Margin="0" VerticalAlignment="Bottom" Width="12" Source="pack://siteoforigin:,,,/Resources/Corner.png" RenderTransformOrigin="0.5,0.5">
<Image x:Name="imgCornerBR" HorizontalAlignment="Right" Margin="0" VerticalAlignment="Bottom" Width="16" Source="Resources/Corner.png" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform/>
Expand All @@ -45,7 +45,7 @@
</TransformGroup>
</Image.RenderTransform>
</Image>
<Image x:Name="imgCornerBL" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Bottom" Width="12" Source="pack://siteoforigin:,,,/Resources/Corner.png" RenderTransformOrigin="0.5,0.5">
<Image x:Name="imgCornerBL" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Bottom" Width="16" Source="Resources/Corner.png" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform/>
Expand Down
37 changes: 18 additions & 19 deletions RoundedScreen/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@

namespace RoundedScreen
{
public static class PreventTouchToMousePromotion
{
public static void Register(FrameworkElement root)
{
root.PreviewMouseDown += Evaluate;
root.PreviewMouseMove += Evaluate;
root.PreviewMouseUp += Evaluate;
}

private static void Evaluate(object sender, MouseEventArgs e)
{
if (e.StylusDevice != null)
{
e.Handled = true;
}
}
}

public partial class MainWindow : Window
{
public const int WS_EX_TRANSPARENT = 0x00000020;
Expand All @@ -40,7 +22,7 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
SetStartup();
this.SetStartup();
}

private void SetStartup()
Expand All @@ -59,5 +41,22 @@ protected override void OnSourceInitialized(EventArgs e)
}

private void WndRoundedScreen_Closing(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = true; }

private void WndRoundedScreen_LostFocus(object sender, RoutedEventArgs e)
{
this.Activate();
this.Topmost = true;
this.Topmost = false;
this.Focus();
}

private void WndRoundedScreen_Loaded(object sender, RoutedEventArgs e)
{
Point location = this.PointToScreen(new Point(0, 0));
this.WindowStartupLocation = WindowStartupLocation.Manual;

this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
}
}
}
4 changes: 1 addition & 3 deletions RoundedScreen/RoundedScreen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Corner.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Resource Include="Resources\Corner.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 1b32a21

Please sign in to comment.