-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turned on "Allow Unsafe Blocks". Added KeyConstants (will be used lat…
…er for hotkey bindings). Added SystemHelper and NativeUtilities. Added RECT struct. Added BorderlessWindow and BorderlessReactiveWindow base classes. Added Animations, Brushes, Controls, and Converters resource dictionaries. Added WindowDefinition. Changed Workspace to BorderlessReactiveWindow. Added design instance of viewmodel to Workspace. #12
- Loading branch information
1 parent
e926b57
commit 8e12b23
Showing
14 changed files
with
892 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
<Application x:Class="Horizon.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:Horizon"> | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/UI/Brushes.xaml" /> | ||
<ResourceDictionary Source="Resources/UI/Controls.xaml" /> | ||
<ResourceDictionary Source="Resources/UI/Animations.xaml" /> | ||
<ResourceDictionary Source="Resources/UI/Converters.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
</ResourceDictionary> |
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,25 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<!-- Defined Colors --> | ||
<Color x:Key="Shark">#2A2A2D</Color> | ||
<Color x:Key="Black">#000000</Color> | ||
<Color x:Key="White">#FFFFFF</Color> | ||
<Color x:Key="Light Crimson">#990000</Color> | ||
<Color x:Key="Crimson">#770000</Color> | ||
<Color x:Key="Malibu">#7AC1FF</Color> | ||
<Color x:Key="Abbey">#4A4A4D</Color> | ||
<Color x:Key="Mid Gray">#8A8A8D</Color> | ||
<Color x:Key="Burnt Orange">#C95100</Color> | ||
|
||
<!-- Theme Bindings --> | ||
<SolidColorBrush x:Key="BaseBackgroundColor" Color="{StaticResource Shark}" /> | ||
<SolidColorBrush x:Key="AccentBackgroundColor" Color="{StaticResource Crimson}" /> | ||
<SolidColorBrush x:Key="AccentHighlightColor" Color="{StaticResource Light Crimson}" /> | ||
<SolidColorBrush x:Key="BaseBorderColor" Color="{StaticResource Black}" /> | ||
<SolidColorBrush x:Key="BaseHighlightColor" Color="{StaticResource Abbey}" /> | ||
<SolidColorBrush x:Key="BorderHighlightColor" Color="{StaticResource Mid Gray}" /> | ||
<SolidColorBrush x:Key="BaseFontColor" Color="{StaticResource White}" /> | ||
<SolidColorBrush x:Key="AccentIconColor" Color="{StaticResource Malibu}" /> | ||
<SolidColorBrush x:Key="ScrollBarGlyphColor" Color="{StaticResource Crimson}" /> | ||
<SolidColorBrush x:Key="StatusBarActiveColor" Color="{StaticResource Burnt Orange}" /> | ||
</ResourceDictionary> |
94 changes: 94 additions & 0 deletions
94
Horizon/Resources/UI/ControlDefinitions/WindowDefinition.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,94 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="clr-namespace:Horizon.View.Controls" | ||
xmlns:windows="clr-namespace:Horizon.View.Windows"> | ||
<Style TargetType="{x:Type windows:BorderlessWindow}" x:Key="BorderlessWindowStyle"> | ||
<Setter Property="Background" Value="{DynamicResource BaseBackgroundColor}" /> | ||
<Setter Property="BorderBrush" Value="{DynamicResource BaseBorderColor}" /> | ||
<Setter Property="MinHeight" Value="320" /> | ||
<Setter Property="MinWidth" Value="480" /> | ||
<Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality" /> | ||
<Setter Property="Title" Value="{Binding Title}" /> | ||
<Setter Property="WindowChrome.WindowChrome"> | ||
<Setter.Value> | ||
<WindowChrome GlassFrameThickness="1" | ||
ResizeBorderThickness="4" | ||
CaptionHeight="0" /> | ||
</Setter.Value> | ||
</Setter> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type windows:BorderlessWindow}"> | ||
<Grid Background="Transparent" x:Name="WindowRoot"> | ||
<Grid x:Name="LayoutRoot" Background="{TemplateBinding Background}"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
|
||
<!-- Title Bar --> | ||
<Grid x:Name="PART_HeaderBar"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Image Source="/Deus;component/Resources/Images/Horizon.png" Margin="12,0,0,0" Width="32" Height="32" /> | ||
<controls:MainMenu x:Name="WindowMainMenu" Grid.Column="1" Margin="12,4,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" /> | ||
<Border Grid.Column="2" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{DynamicResource BaseBackgroundColor}" Panel.ZIndex="0"> | ||
<Border Margin="12,8,0,0" VerticalAlignment="Top" Background="{DynamicResource AccentBackgroundColor}" BorderBrush="{DynamicResource BaseBorderColor}" BorderThickness="1" HorizontalAlignment="Left" Height="32" Padding="6,0,6,0"> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="{TemplateBinding Title}" TextTrimming="CharacterEllipsis" FontSize="14" TextAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Center" Foreground="{DynamicResource BaseFontColor}" IsEnabled="{TemplateBinding IsActive}" /> | ||
</StackPanel> | ||
</Border> | ||
</Border> | ||
<Grid x:Name="WindowControlsGrid" Grid.Column="3" Background="{TemplateBinding Background}"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="36" /> | ||
<ColumnDefinition Width="36" /> | ||
<ColumnDefinition Width="36" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Button x:Name="MinimizeButton" Style="{DynamicResource WindowButtonStyle}" | ||
Content="l" | ||
FontFamily="Wingdings 3" | ||
TextElement.FontSize="22" | ||
Margin="0,1,0,0" | ||
VerticalAlignment="Top" | ||
Grid.Column="0" /> | ||
<Button x:Name="MaximizeButton" Style="{DynamicResource WindowButtonStyle}" | ||
Content="1" | ||
TextElement.FontSize="18" | ||
Margin="0,3,0,0" | ||
VerticalAlignment="Top" | ||
Grid.Column="1" /> | ||
|
||
<Button x:Name="RestoreButton" Style="{DynamicResource WindowButtonStyle}" | ||
Content="2" | ||
Visibility="Collapsed" | ||
TextElement.FontSize="18" | ||
VerticalAlignment="Top" | ||
Grid.Column="1" /> | ||
|
||
<Button x:Name="CloseButton" Style="{DynamicResource WindowButtonStyle}" | ||
Content="r" | ||
TextElement.FontSize="18" | ||
Margin="0,4,0,0" | ||
VerticalAlignment="Top" | ||
Grid.Column="2" /> | ||
</Grid> | ||
</Grid> | ||
|
||
<Grid x:Name="PART_MainContentGrid" | ||
Grid.Row="1" | ||
Panel.ZIndex="10"> | ||
<ContentPresenter x:Name="PART_MainContentPresenter" Grid.Row="1" /> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</ResourceDictionary> |
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,15 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="ControlDefinitions/WindowDefinition.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
|
||
<Style TargetType="xctk:PropertyGrid"> | ||
<Setter Property="HideInheritedProperties" Value="True" /> | ||
</Style> | ||
|
||
<Style TargetType="FlowDocument" BasedOn="{StaticResource {x:Type FlowDocument}}"> | ||
<Setter Property="Background" Value="{StaticResource BaseHighlightColor}" /> | ||
</Style> | ||
</ResourceDictionary> |
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,3 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
</ResourceDictionary> |
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,138 @@ | ||
using System.Windows.Input; | ||
|
||
namespace Horizon.Utilities; | ||
|
||
/// <summary> | ||
/// Contains constants for handling key codes. | ||
/// </summary> | ||
public static class KeyConstants | ||
{ | ||
/// <summary> | ||
/// Contains a list of keys that should be rendered as medium size. | ||
/// </summary> | ||
public static List<Key> MediumSizeKeys { get; } = | ||
[ | ||
Key.Tab, | ||
Key.CapsLock, | ||
Key.LeftShift, | ||
Key.RightShift, | ||
Key.LeftAlt, | ||
Key.RightAlt, | ||
Key.LeftCtrl, | ||
Key.RightCtrl, | ||
Key.Back, | ||
Key.Apps, | ||
Key.Enter, | ||
Key.Add, | ||
Key.Insert | ||
]; | ||
|
||
/// <summary> | ||
/// Contains the friendly names for each defined key on the keyboard. | ||
/// </summary> | ||
public static Dictionary<Key, string> KeyNames { get; } = new() | ||
{ | ||
[Key.Escape] = "Esc", | ||
[Key.F1] = "F1", | ||
[Key.F2] = "F2", | ||
[Key.F3] = "F3", | ||
[Key.F4] = "F4", | ||
[Key.F5] = "F5", | ||
[Key.F6] = "F6", | ||
[Key.F7] = "F7", | ||
[Key.F8] = "F8", | ||
[Key.F9] = "F9", | ||
[Key.F10] = "F10", | ||
[Key.F11] = "F11", | ||
[Key.F12] = "F12", | ||
[Key.PrintScreen] = "Print Sc", | ||
[Key.Scroll] = "Scroll Lock", | ||
[Key.Pause] = "Pause", | ||
[Key.Oem3] = "`", | ||
[Key.D1] = "1", | ||
[Key.D2] = "2", | ||
[Key.D3] = "3", | ||
[Key.D4] = "4", | ||
[Key.D5] = "5", | ||
[Key.D6] = "6", | ||
[Key.D7] = "7", | ||
[Key.D8] = "8", | ||
[Key.D9] = "9", | ||
[Key.D0] = "0", | ||
[Key.OemMinus] = "-", | ||
[Key.OemPlus] = "+", | ||
[Key.Back] = "Backspace", | ||
[Key.Tab] = "Tab", | ||
[Key.Q] = "Q", | ||
[Key.W] = "W", | ||
[Key.E] = "E", | ||
[Key.R] = "R", | ||
[Key.T] = "T", | ||
[Key.Y] = "Y", | ||
[Key.U] = "U", | ||
[Key.I] = "I", | ||
[Key.O] = "O", | ||
[Key.P] = "P", | ||
[Key.Oem4] = "[", | ||
[Key.Oem6] = "]", | ||
[Key.Oem5] = "\\", | ||
[Key.CapsLock] = "Caps Lock", | ||
[Key.A] = "A", | ||
[Key.S] = "S", | ||
[Key.D] = "D", | ||
[Key.F] = "F", | ||
[Key.G] = "G", | ||
[Key.H] = "H", | ||
[Key.J] = "J", | ||
[Key.K] = "K", | ||
[Key.L] = "L", | ||
[Key.Oem1] = ";", | ||
[Key.Oem7] = "'", | ||
[Key.Enter] = "Enter", | ||
[Key.LeftShift] = "Shift", | ||
[Key.Z] = "Z", | ||
[Key.X] = "X", | ||
[Key.C] = "C", | ||
[Key.V] = "V", | ||
[Key.B] = "B", | ||
[Key.N] = "N", | ||
[Key.M] = "M", | ||
[Key.OemComma] = ",", | ||
[Key.OemPeriod] = ".", | ||
[Key.Oem2] = "/", | ||
[Key.RightShift] = "Shift", | ||
[Key.LeftCtrl] = "Ctrl", | ||
[Key.LWin] = "Win", | ||
[Key.LeftAlt] = "Alt", | ||
[Key.Space] = "Space", | ||
[Key.RightAlt] = "Alt", | ||
[Key.Apps] = "≣", | ||
[Key.RightCtrl] = "Ctrl", | ||
[Key.Insert] = "Insert", | ||
[Key.Home] = "Home", | ||
[Key.PageUp] = "Pg Up", | ||
[Key.Delete] = "Delete", | ||
[Key.End] = "End", | ||
[Key.PageDown] = "Pg Dn", | ||
[Key.Up] = "↑", | ||
[Key.Down] = "↓", | ||
[Key.Left] = "←", | ||
[Key.Right] = "→", | ||
[Key.NumLock] = "Num Lock", | ||
[Key.Divide] = "Numpad /", | ||
[Key.Multiply] = "Numpad *", | ||
[Key.Subtract] = "Numpad -", | ||
[Key.Add] = "Numpad +", | ||
[Key.Decimal] = "Numpad .", | ||
[Key.NumPad1] = "N1", | ||
[Key.NumPad2] = "N2", | ||
[Key.NumPad3] = "N3", | ||
[Key.NumPad4] = "N4", | ||
[Key.NumPad5] = "N5", | ||
[Key.NumPad6] = "N6", | ||
[Key.NumPad7] = "N7", | ||
[Key.NumPad8] = "N8", | ||
[Key.NumPad9] = "N9", | ||
[Key.NumPad0] = "N0" | ||
}; | ||
} |
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,32 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Horizon.Utilities; | ||
|
||
/// <summary> | ||
/// Magic native methods used for windows and popups. | ||
/// </summary> | ||
internal static partial class NativeUtilities | ||
{ | ||
internal static uint TPM_LEFTALIGN; | ||
|
||
internal static uint TPM_RETURNCMD; | ||
|
||
static NativeUtilities() | ||
{ | ||
TPM_LEFTALIGN = 0; | ||
TPM_RETURNCMD = 256; | ||
} | ||
|
||
[LibraryImport("user32.dll")] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
internal static partial bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable); | ||
|
||
[LibraryImport("user32.dll", SetLastError = true)] | ||
internal static partial IntPtr GetSystemMenu(IntPtr hWnd, [MarshalAs(UnmanagedType.Bool)] bool bRevert); | ||
|
||
[LibraryImport("user32.dll")] | ||
internal static partial IntPtr PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); | ||
|
||
[LibraryImport("user32.dll")] | ||
internal static partial int TrackPopupMenuEx(IntPtr hmenu, uint fuFlags, int x, int y, IntPtr hwnd, IntPtr lptpm); | ||
} |
Oops, something went wrong.