Skip to content

Commit

Permalink
Added CompositingWindow, began work on Glass/Accent/Acrylic
Browse files Browse the repository at this point in the history
  • Loading branch information
Splitwirez committed Aug 24, 2018
1 parent 62d9d9c commit 05f5104
Show file tree
Hide file tree
Showing 75 changed files with 4,545 additions and 96 deletions.
Binary file added .vs/Start9.UI.Wpf/DesignTimeBuild/.dtbcache
Binary file not shown.
Binary file added .vs/Start9.UI.Wpf/v15/.suo
Binary file not shown.
Empty file.
Binary file added .vs/Start9.UI.Wpf/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions Start9.UI.Wpf.sln
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27703.2035
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Start9.UI.Wpf", "Start9.UI.Wpf\Start9.UI.Wpf.csproj", "{727669AC-3F83-41E1-AEFD-13A8F0C1FDAD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontEndTest", "front-end-test\FrontEndTest\FrontEndTest.csproj", "{7F90447D-3E3A-4114-AFBD-3171C1A6693C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{727669AC-3F83-41E1-AEFD-13A8F0C1FDAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{727669AC-3F83-41E1-AEFD-13A8F0C1FDAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{727669AC-3F83-41E1-AEFD-13A8F0C1FDAD}.Release|Any CPU.Build.0 = Release|Any CPU
{7F90447D-3E3A-4114-AFBD-3171C1A6693C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F90447D-3E3A-4114-AFBD-3171C1A6693C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F90447D-3E3A-4114-AFBD-3171C1A6693C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F90447D-3E3A-4114-AFBD-3171C1A6693C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
792 changes: 792 additions & 0 deletions Start9.UI.Wpf/DecoratableWindow - Copy (2).cs

Large diffs are not rendered by default.

891 changes: 891 additions & 0 deletions Start9.UI.Wpf/DecoratableWindow - Copy (3).cs

Large diffs are not rendered by default.

891 changes: 891 additions & 0 deletions Start9.UI.Wpf/DecoratableWindow - Copy.cs

Large diffs are not rendered by default.

232 changes: 232 additions & 0 deletions Start9.UI.Wpf/MonitorInfo.cs
@@ -0,0 +1,232 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
//using System.Windows;
using static Start9.UI.Wpf.MonitorInfo.NativeMethods;

namespace Start9.UI.Wpf
{
/// <summary>
/// This class and Start9.UI.Wpf.Windows.AppBarWindow were derived from https://github.com/mgaffigan/WpfAppBar
/// </summary>
public class MonitorInfo : IEquatable<MonitorInfo>
{
/// <summary>
/// Gets the bounds of the viewport.
/// </summary>
public Rect ViewportBounds { get; }

/// <summary>
/// Gets the bounds of the work area.
/// </summary>
public Rect WorkAreaBounds { get; }

/// <summary>
/// Gets a value that determines if the monitor is the primary monitor or not.
/// </summary>
public Boolean IsPrimary { get; }

/// <summary>
/// Gets the device ID of the monitor.
/// </summary>
public String DeviceId { get; }

internal MonitorInfo(MonitorInfoEx mex)
{
this.ViewportBounds = mex.rcMonitor;
this.WorkAreaBounds = (Rect)mex.rcWork;
this.IsPrimary = mex.dwFlags.HasFlag(MonitorInfoF.Primary);
this.DeviceId = mex.szDevice;
}

/// <summary>
/// Gets a collection of all monitors.
/// </summary>
public static ObservableCollection<MonitorInfo> AllMonitors
{
get
{
var monitors = new ObservableCollection<MonitorInfo>();
MonitorEnumDelegate callback = delegate (IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData)
{
MonitorInfoEx mi = new MonitorInfoEx
{
cbSize = Marshal.SizeOf(typeof(MonitorInfoEx))
};
if (!GetMonitorInfo(hMonitor, ref mi))
{
throw new System.ComponentModel.Win32Exception();
}

monitors.Add(new MonitorInfo(mi));
return true;
};

EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, callback, IntPtr.Zero);

return monitors;
}
}

public override String ToString() => DeviceId;

public override Boolean Equals(Object obj) => Equals(obj as MonitorInfo);

public override Int32 GetHashCode() => DeviceId.GetHashCode();

public Boolean Equals(MonitorInfo other) => this.DeviceId == other?.DeviceId;

public static Boolean operator ==(MonitorInfo a, MonitorInfo b)
{
if (ReferenceEquals(a, b))
{
return true;
}

if (a is null)
{
return false;
}

return a.Equals(b);
}

public static Boolean operator !=(MonitorInfo a, MonitorInfo b) => !(a == b);

public static class NativeMethods
{
public delegate Boolean MonitorEnumDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData);

[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern Boolean GetMonitorInfo(IntPtr hMonitor, ref MonitorInfoEx lpmi);

[DllImport("user32.dll")]
public static extern Boolean EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData);

private const Int32 CchDeviceName = 32;

[Flags]
public enum MonitorInfoF
{
Primary = 0x1
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MonitorInfoEx
{
public Int32 cbSize;
public Rect rcMonitor;
public Rect rcWork;
public MonitorInfoF dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CchDeviceName)]
public String szDevice;
}

public enum ABM
{
New = 0,
Remove,
QueryPos,
SetPos,
GetState,
GetTaskbarPos,
Activate,
GetAutoHideBar,
SetAutoHideBar,
WindowPosChanged,
SetState
}

public enum ABN
{
StateChange = 0,
PosChanged,
FullScreenApp,
WindowArrange
}

[StructLayout(LayoutKind.Sequential)]
public struct WindowPos
{
public IntPtr hwnd;
public IntPtr hwndInsertAfter;
public Int32 x;
public Int32 y;
public Int32 cx;
public Int32 cy;
public Int32 flags;

public System.Windows.Rect Bounds
{
get { return new System.Windows.Rect(x, y, cx, cy); }
set
{
x = (Int32)value.X;
y = (Int32)value.Y;
cx = (Int32)value.Width;
cy = (Int32)value.Height;
}
}
}

public const Int32
SwpNoMove = 0x0002,
SwpNoSize = 0x0001;

public const Int32
WmActivate = 0x0006,
WmWindowPosChanged = 0x0047,
WmSysCommand = 0x0112,
WmWindowPosChanging = 0x0046;

public const Int32
ScMove = 0xF010;

[DllImport("shell32.dll", ExactSpelling = true)]
public static extern UInt32 SHAppBarMessage(ABM dwMessage, ref AppBarData pData);

[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public Rect(Int32 left, Int32 top, Int32 right, Int32 bottom)
{
Left = left;
Top = top;
Right = right;
Bottom = bottom;
}

public Int32 Left;
public Int32 Top;
public Int32 Right;
public Int32 Bottom;
}

[StructLayout(LayoutKind.Sequential)]
public struct AppBarData
{
public Int32 cbSize;
public IntPtr hWnd;
public Int32 uCallbackMessage;
public Int32 uEdge;
public Rect rc;
public IntPtr lParam;
}

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern Int32 RegisterWindowMessage(String msg);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, Int32 wParam, Int32 lParam);

/*public static Rect SysWinRectToNativeRect(SysWinRect rect)
{
return new Rect((int)rect.Left, (int)rect.Top, (int)rect.Right, (int)rect.Bottom);
}*/
}
}
}
5 changes: 4 additions & 1 deletion Start9.UI.Wpf/Start9.UI.Wpf.csproj
Expand Up @@ -67,12 +67,15 @@
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="MonitorInfo.cs" />
<Compile Include="Windows\AppBarWindow.cs" />
<Compile Include="Windows\CompositingWindow.cs" />
<Compile Include="Converters\DoubleToFractionOfDoubleConverter.cs" />
<Compile Include="Converters\DoubleToThicknessConverter.cs" />
<Compile Include="Converters\ThicknessToDoubleConverter.cs" />
<Compile Include="Converters\WidthToOffsetMarginConverter.cs" />
<Compile Include="CutCornerBorder.cs" />
<Compile Include="DecoratableWindow.cs" />
<Compile Include="Windows\DecoratableWindow.cs" />
<Compile Include="Planerator.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
Expand Down
7 changes: 4 additions & 3 deletions Start9.UI.Wpf/Themes/AeroConcept.xaml
@@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Start9.UI.Wpf"
xmlns:win="clr-namespace:Start9.UI.Wpf.Windows"
xmlns:conv="clr-namespace:Start9.UI.Wpf.Converters">
<conv:ThicknessToDoubleConverter x:Key="ThicknessToDoubleConverter"/>

Expand Down Expand Up @@ -636,7 +637,7 @@
</Setter>
</Style>

<Style x:Key="AeroMediaWindowStyle" TargetType="{x:Type local:DecoratableWindow}">
<Style x:Key="AeroMediaWindowStyle" TargetType="{x:Type win:DecoratableWindow}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="WindowStyle" Value="None" />
<Setter Property="ResizeMode" Value="NoResize" />
Expand Down Expand Up @@ -682,7 +683,7 @@
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:DecoratableWindow}">
<ControlTemplate TargetType="{x:Type win:DecoratableWindow}">
<Border ClipToBounds="True" CornerRadius="4">
<Border.OpacityMask>
<VisualBrush>
Expand All @@ -696,7 +697,7 @@
<Border.OpacityMask>
<VisualBrush>
<VisualBrush.Visual>
<Grid Width="{Binding Width, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:DecoratableWindow}}}" Height="{Binding Height, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:DecoratableWindow}}}">
<Grid Width="{Binding Width, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type win:DecoratableWindow}}}" Height="{Binding Height, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type win:DecoratableWindow}}}">
<Border HorizontalAlignment="Right" VerticalAlignment="Top" Width="92" Height="14" CornerRadius="0,0,3,3" BorderThickness="2" BorderBrush="Black" Margin="5,0"/>
<Rectangle Fill="Black" Stroke="Transparent" StrokeThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Width="7" Height="15" Margin="0"/>
<Rectangle Fill="Black" Stroke="Transparent" StrokeThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="15" Margin="0,0,96,0"/>
Expand Down
28 changes: 16 additions & 12 deletions Start9.UI.Wpf/Themes/Generic.xaml
Expand Up @@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Start9.UI.Wpf"
xmlns:win="clr-namespace:Start9.UI.Wpf.Windows"
xmlns:conv="clr-namespace:Start9.UI.Wpf.Converters">
<!--#region Converters -->

Expand All @@ -11,8 +12,14 @@

<!--#region Window Styles -->

<Style TargetType="local:DecoratableWindow">
<Setter Property="Background" Value="Transparent" />
<Style TargetType="win:DecoratableWindow">
<Style.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Start9.UI.Wpf;component/Themes/Colors/PlexBlue.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Style.Resources>
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0,24,0,0" />
<Setter Property="Background" Value="{DynamicResource DefaultWindowBodyBrush}"/>
Expand Down Expand Up @@ -160,12 +167,9 @@
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:DecoratableWindow}">
<ControlTemplate TargetType="{x:Type win:DecoratableWindow}">
<ControlTemplate.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Start9.Api;component/Themes/Colors/PlexBlue.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="BorderThumb" TargetType="Thumb">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="OverridesDefaultStyle" Value="true" />
Expand Down Expand Up @@ -234,7 +238,7 @@
Margin="0" Padding="0" UseLayoutRounding="True" SnapsToDevicePixels="True" Opacity="0" />
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:DecoratableWindow}}}" Value="False">
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type win:DecoratableWindow}}}" Value="False">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand Down Expand Up @@ -299,7 +303,7 @@
<Border x:Name="PressedGlyph" Width="6" Height="9" Background="Transparent" BorderThickness="0,0,0,2" BorderBrush="{DynamicResource CaptionButtonActivePressedBrush}" Opacity="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:DecoratableWindow}}}" Value="False">
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type win:DecoratableWindow}}}" Value="False">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand Down Expand Up @@ -364,7 +368,7 @@
<Border x:Name="PressedGlyph" Width="10" Height="9" BorderThickness="1,2,1,1" Background="Transparent" BorderBrush="{DynamicResource CaptionButtonActivePressedBrush}" Opacity="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:DecoratableWindow}}}" Value="False">
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type win:DecoratableWindow}}}" Value="False">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand Down Expand Up @@ -449,7 +453,7 @@
</Grid>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:DecoratableWindow}}}" Value="False">
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type win:DecoratableWindow}}}" Value="False">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand Down Expand Up @@ -522,7 +526,7 @@
</Grid>
</Border>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:DecoratableWindow}}}" Value="False">
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type win:DecoratableWindow}}}" Value="False">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand Down Expand Up @@ -799,7 +803,7 @@
Margin="0" Padding="0" UseLayoutRounding="True" SnapsToDevicePixels="True" Opacity="0" />
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:DecoratableWindow}}}" Value="False">
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type win:DecoratableWindow}}}" Value="False">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand Down

0 comments on commit 05f5104

Please sign in to comment.