Merge branch 'window-restyle' into develop
This commit is contained in:
@@ -6,13 +6,25 @@
|
|||||||
xmlns:views="clr-namespace:ClientApp.Views"
|
xmlns:views="clr-namespace:ClientApp.Views"
|
||||||
StartupUri="Views/MainWindow.xaml">
|
StartupUri="Views/MainWindow.xaml">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<DataTemplate DataType="{x:Type viewModels:MainViewModel}">
|
|
||||||
<views:MainView />
|
|
||||||
<!-- This is a UserControl -->
|
<ResourceDictionary>
|
||||||
</DataTemplate>
|
<DataTemplate DataType="{x:Type viewModels:MainViewModel}">
|
||||||
<DataTemplate DataType="{x:Type viewModels:LoginViewModel}">
|
<views:MainView />
|
||||||
<views:LoginView />
|
<!-- This is a Page -->
|
||||||
<!-- This is a UserControl -->
|
</DataTemplate>
|
||||||
</DataTemplate>
|
<DataTemplate DataType="{x:Type viewModels:LoginViewModel}">
|
||||||
|
<views:LoginView />
|
||||||
|
<!-- This is a Page -->
|
||||||
|
</DataTemplate>
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="Styles/Fonts.xaml"/>
|
||||||
|
<ResourceDictionary Source="Styles/Colors.xaml"/>
|
||||||
|
<ResourceDictionary Source="Styles/Buttons.xaml"/>
|
||||||
|
<ResourceDictionary Source="Styles/Texts.xaml"/>
|
||||||
|
<ResourceDictionary Source="Styles/Windows.xaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
|
|||||||
@@ -7,6 +7,28 @@
|
|||||||
<ApplicationIcon>Images\Logo\icon1.ico</ApplicationIcon>
|
<ApplicationIcon>Images\Logo\icon1.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Images\CoolBackground.jpg" />
|
||||||
|
<None Remove="Images\Logo\icon1.ico" />
|
||||||
|
<None Remove="Images\re15.jpg" />
|
||||||
|
<None Remove="Images\stone.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Images\CoolBackground.jpg">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Images\Logo\icon1.ico">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Images\re15.jpg">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Images\stone.png">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AsyncAwaitBestPractices.MVVM" Version="4.3.0" />
|
<PackageReference Include="AsyncAwaitBestPractices.MVVM" Version="4.3.0" />
|
||||||
<PackageReference Include="MvvmLightLibsStd10" Version="5.4.1.1" />
|
<PackageReference Include="MvvmLightLibsStd10" Version="5.4.1.1" />
|
||||||
@@ -19,6 +41,10 @@
|
|||||||
<ProjectReference Include="..\RH-Engine\RH-Engine.csproj" />
|
<ProjectReference Include="..\RH-Engine\RH-Engine.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Properties\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<Import Project="..\Hashing\Hashing.projitems" Label="Shared" />
|
<Import Project="..\Hashing\Hashing.projitems" Label="Shared" />
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 66 KiB |
BIN
ClientApp/Images/Logo/icon1_small.ico
Normal file
BIN
ClientApp/Images/Logo/icon1_small.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
212
ClientApp/MagicCode/WindowResizer.cs
Normal file
212
ClientApp/MagicCode/WindowResizer.cs
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
|
||||||
|
namespace ClientApp.MagicCode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fixes the issue with Windows of Style <see cref="WindowStyle.None"/> covering the taskbar
|
||||||
|
/// </summary>
|
||||||
|
public class WindowResizer
|
||||||
|
{
|
||||||
|
#region Private Members
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The window to handle the resizing for
|
||||||
|
/// </summary>
|
||||||
|
private Window mWindow;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Dll Imports
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
static extern bool GetCursorPos(out POINT lpPoint);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
static extern IntPtr MonitorFromPoint(POINT pt, MonitorOptions dwFlags);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="window">The window to monitor and correctly maximize</param>
|
||||||
|
/// <param name="adjustSize">The callback for the host to adjust the maximum available size if needed</param>
|
||||||
|
public WindowResizer(Window window)
|
||||||
|
{
|
||||||
|
mWindow = window;
|
||||||
|
|
||||||
|
// Listen out for source initialized to setup
|
||||||
|
mWindow.SourceInitialized += Window_SourceInitialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Initialize
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize and hook into the windows message pump
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void Window_SourceInitialized(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
// Get the handle of this window
|
||||||
|
var handle = (new WindowInteropHelper(mWindow)).Handle;
|
||||||
|
var handleSource = HwndSource.FromHwnd(handle);
|
||||||
|
|
||||||
|
// If not found, end
|
||||||
|
if (handleSource == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Hook into it's Windows messages
|
||||||
|
handleSource.AddHook(WindowProc);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Windows Proc
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Listens out for all windows messages for this window
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hwnd"></param>
|
||||||
|
/// <param name="msg"></param>
|
||||||
|
/// <param name="wParam"></param>
|
||||||
|
/// <param name="lParam"></param>
|
||||||
|
/// <param name="handled"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||||
|
{
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
// Handle the GetMinMaxInfo of the Window
|
||||||
|
case 0x0024:/* WM_GETMINMAXINFO */
|
||||||
|
WmGetMinMaxInfo(hwnd, lParam);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IntPtr)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the min/max window size for this window
|
||||||
|
/// Correctly accounting for the taskbar size and position
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hwnd"></param>
|
||||||
|
/// <param name="lParam"></param>
|
||||||
|
private void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
|
||||||
|
{
|
||||||
|
POINT lMousePosition;
|
||||||
|
GetCursorPos(out lMousePosition);
|
||||||
|
|
||||||
|
IntPtr lPrimaryScreen = MonitorFromPoint(new POINT(0, 0), MonitorOptions.MONITOR_DEFAULTTOPRIMARY);
|
||||||
|
MONITORINFO lPrimaryScreenInfo = new MONITORINFO();
|
||||||
|
if (GetMonitorInfo(lPrimaryScreen, lPrimaryScreenInfo) == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IntPtr lCurrentScreen = MonitorFromPoint(lMousePosition, MonitorOptions.MONITOR_DEFAULTTONEAREST);
|
||||||
|
|
||||||
|
MINMAXINFO lMmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
|
||||||
|
|
||||||
|
if (lPrimaryScreen.Equals(lCurrentScreen) == true)
|
||||||
|
{
|
||||||
|
lMmi.ptMaxPosition.X = lPrimaryScreenInfo.rcWork.Left;
|
||||||
|
lMmi.ptMaxPosition.Y = lPrimaryScreenInfo.rcWork.Top;
|
||||||
|
lMmi.ptMaxSize.X = lPrimaryScreenInfo.rcWork.Right - lPrimaryScreenInfo.rcWork.Left;
|
||||||
|
lMmi.ptMaxSize.Y = lPrimaryScreenInfo.rcWork.Bottom - lPrimaryScreenInfo.rcWork.Top;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lMmi.ptMaxPosition.X = lPrimaryScreenInfo.rcMonitor.Left;
|
||||||
|
lMmi.ptMaxPosition.Y = lPrimaryScreenInfo.rcMonitor.Top;
|
||||||
|
lMmi.ptMaxSize.X = lPrimaryScreenInfo.rcMonitor.Right - lPrimaryScreenInfo.rcMonitor.Left;
|
||||||
|
lMmi.ptMaxSize.Y = lPrimaryScreenInfo.rcMonitor.Bottom - lPrimaryScreenInfo.rcMonitor.Top;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we have the max size, allow the host to tweak as needed
|
||||||
|
Marshal.StructureToPtr(lMmi, lParam, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Dll Helper Structures
|
||||||
|
|
||||||
|
enum MonitorOptions : uint
|
||||||
|
{
|
||||||
|
MONITOR_DEFAULTTONULL = 0x00000000,
|
||||||
|
MONITOR_DEFAULTTOPRIMARY = 0x00000001,
|
||||||
|
MONITOR_DEFAULTTONEAREST = 0x00000002
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||||
|
public class MONITORINFO
|
||||||
|
{
|
||||||
|
public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
|
||||||
|
public Rectangle rcMonitor = new Rectangle();
|
||||||
|
public Rectangle rcWork = new Rectangle();
|
||||||
|
public int dwFlags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct Rectangle
|
||||||
|
{
|
||||||
|
public int Left, Top, Right, Bottom;
|
||||||
|
|
||||||
|
public Rectangle(int left, int top, int right, int bottom)
|
||||||
|
{
|
||||||
|
this.Left = left;
|
||||||
|
this.Top = top;
|
||||||
|
this.Right = right;
|
||||||
|
this.Bottom = bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct MINMAXINFO
|
||||||
|
{
|
||||||
|
public POINT ptReserved;
|
||||||
|
public POINT ptMaxSize;
|
||||||
|
public POINT ptMaxPosition;
|
||||||
|
public POINT ptMinTrackSize;
|
||||||
|
public POINT ptMaxTrackSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct POINT
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// x coordinate of point.
|
||||||
|
/// </summary>
|
||||||
|
public int X;
|
||||||
|
/// <summary>
|
||||||
|
/// y coordinate of point.
|
||||||
|
/// </summary>
|
||||||
|
public int Y;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Construct a point of coordinates (x,y).
|
||||||
|
/// </summary>
|
||||||
|
public POINT(int x, int y)
|
||||||
|
{
|
||||||
|
this.X = x;
|
||||||
|
this.Y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
65
ClientApp/Styles/Buttons.xaml
Normal file
65
ClientApp/Styles/Buttons.xaml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="Colors.xaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Button}" x:Key="Hoverless">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type Button}">
|
||||||
|
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
|
||||||
|
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Button}" x:Key="SystemIconButton" BasedOn="{StaticResource Hoverless}" >
|
||||||
|
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
|
||||||
|
<Setter Property="Padding" Value="4"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Button}" x:Key="WindowControlButton">
|
||||||
|
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource ForegroundMainBrush}"/>
|
||||||
|
<Setter Property="Padding" Value="6"/>
|
||||||
|
|
||||||
|
<Setter Property="LayoutTransform">
|
||||||
|
<Setter.Value>
|
||||||
|
<ScaleTransform ScaleX="2"/>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type Button}">
|
||||||
|
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
|
||||||
|
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" Value="{StaticResource BackgroundSemiLightBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Button}" x:Key="WindowCloseButton" BasedOn="{StaticResource WindowControlButton}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" Value="Red"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
25
ClientApp/Styles/Colors.xaml
Normal file
25
ClientApp/Styles/Colors.xaml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
<Color x:Key="BackgroundLight">#efefef</Color>
|
||||||
|
<SolidColorBrush x:Key="BackgroundLightBrush" Color="{StaticResource BackgroundLight}"/>
|
||||||
|
|
||||||
|
|
||||||
|
<Color x:Key="BackgroundVeryLight">#fafafa</Color>
|
||||||
|
<SolidColorBrush x:Key="BackgroundVeryLightBrush" Color="{StaticResource BackgroundVeryLight}"/>
|
||||||
|
|
||||||
|
<Color x:Key="BackgroundSemiLight">#d7d7d7</Color>
|
||||||
|
<SolidColorBrush x:Key="BackgroundSemiLightBrush" Color="{StaticResource BackgroundSemiLight}"/>
|
||||||
|
|
||||||
|
<Color x:Key="ForegroundMain">#686868</Color>
|
||||||
|
<SolidColorBrush x:Key="ForegroundMainBrush" Color="{StaticResource ForegroundMain}"/>
|
||||||
|
|
||||||
|
<Color x:Key="ForegroundVeryDark">#000</Color>
|
||||||
|
<SolidColorBrush x:Key="ForegroundVeryDarkBrush" Color="{StaticResource ForegroundVeryDark}"/>
|
||||||
|
|
||||||
|
<Color x:Key="ForegroundWhite">#fff</Color>
|
||||||
|
<SolidColorBrush x:Key="ForegroundWhiteBrush" Color="{StaticResource ForegroundWhite}"/>
|
||||||
|
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
5
ClientApp/Styles/Fonts.xaml
Normal file
5
ClientApp/Styles/Fonts.xaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
11
ClientApp/Styles/Texts.xaml
Normal file
11
ClientApp/Styles/Texts.xaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type TextBlock}" x:Key="HeaderText">
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource ForegroundMainBrush}"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Margin" Value="0 4"/>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
5
ClientApp/Styles/Windows.xaml
Normal file
5
ClientApp/Styles/Windows.xaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -1,27 +1,135 @@
|
|||||||
using ClientApp.Models;
|
using ClientApp.MagicCode;
|
||||||
|
using ClientApp.Models;
|
||||||
using ClientApp.Utils;
|
using ClientApp.Utils;
|
||||||
|
using GalaSoft.MvvmLight.Command;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Util;
|
using Util;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace ClientApp.ViewModels
|
namespace ClientApp.ViewModels
|
||||||
{
|
{
|
||||||
class MainWindowViewModel : ObservableObject
|
class MainWindowViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
|
#region private members
|
||||||
|
|
||||||
|
private Window mWindow;
|
||||||
|
|
||||||
|
private int mOuterMarginSize = 10;
|
||||||
|
private int mWindowRadius = 10;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region commands
|
||||||
|
|
||||||
|
public ICommand MinimizeCommand { get; set; }
|
||||||
|
|
||||||
|
public ICommand MaximizeCommand { get; set; }
|
||||||
|
|
||||||
|
public ICommand CloseCommand { get; set; }
|
||||||
|
|
||||||
|
public ICommand MenuCommand { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public properties
|
||||||
public Info InfoModel { get; set; }
|
public Info InfoModel { get; set; }
|
||||||
|
|
||||||
public ObservableObject SelectedViewModel { get; set; }
|
public ObservableObject SelectedViewModel { get; set; }
|
||||||
|
|
||||||
public Client client { get; }
|
public Client client { get; }
|
||||||
|
|
||||||
public MainWindowViewModel(Client client)
|
/// <summary>
|
||||||
|
/// size of the resize border around the window
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public double MinimumWidth { get; set; } = 250;
|
||||||
|
|
||||||
|
public double MinimumHeight { get; set; } = 250;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public int ResizeBorder { get; set; } = 6;
|
||||||
|
|
||||||
|
public Thickness ResizeBorderThickness { get { return new Thickness(ResizeBorder + OuterMarginSize); } }
|
||||||
|
|
||||||
|
public Thickness InnerContentPadding { get { return new Thickness(ResizeBorder); } }
|
||||||
|
|
||||||
|
|
||||||
|
public Thickness OuterMarginThickness { get { return new Thickness(OuterMarginSize); } }
|
||||||
|
|
||||||
|
public CornerRadius WindowCornerRadius { get { return new CornerRadius(WindowRadius); } }
|
||||||
|
|
||||||
|
public int OuterMarginSize
|
||||||
{
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mWindow.WindowState == WindowState.Maximized ? 0 : mOuterMarginSize;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mOuterMarginSize = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int WindowRadius
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mWindow.WindowState == WindowState.Maximized ? 0 : mWindowRadius;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mWindowRadius = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TitleHeight { get; set; } = 42;
|
||||||
|
|
||||||
|
public GridLength TitleHeightGridLegth { get { return new GridLength(TitleHeight + ResizeBorder); } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public MainWindowViewModel(Window window, Client client)
|
||||||
|
{
|
||||||
|
this.mWindow = window;
|
||||||
|
|
||||||
|
this.mWindow.StateChanged += (sender, e) =>
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(ResizeBorderThickness));
|
||||||
|
OnPropertyChanged(nameof(OuterMarginThickness));
|
||||||
|
OnPropertyChanged(nameof(WindowCornerRadius));
|
||||||
|
OnPropertyChanged(nameof(OuterMarginSize));
|
||||||
|
OnPropertyChanged(nameof(WindowRadius));
|
||||||
|
};
|
||||||
|
|
||||||
this.InfoModel = new Info();
|
this.InfoModel = new Info();
|
||||||
this.client = client;
|
this.client = client;
|
||||||
LoginViewModel loginViewModel = new LoginViewModel(this);
|
LoginViewModel loginViewModel = new LoginViewModel(this);
|
||||||
SelectedViewModel = loginViewModel;
|
SelectedViewModel = loginViewModel;
|
||||||
this.client.SetLoginViewModel(loginViewModel);
|
this.client.SetLoginViewModel(loginViewModel);
|
||||||
|
|
||||||
|
this.MinimizeCommand = new RelayCommand(() => this.mWindow.WindowState = WindowState.Minimized);
|
||||||
|
this.MaximizeCommand = new RelayCommand(() => this.mWindow.WindowState ^= WindowState.Maximized);
|
||||||
|
this.CloseCommand = new RelayCommand(() => this.mWindow.Close());
|
||||||
|
this.MenuCommand = new RelayCommand(() => SystemCommands.ShowSystemMenu(this.mWindow, GetMousePosition()));
|
||||||
|
|
||||||
|
var resizer = new WindowResizer(this.mWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region helper
|
||||||
|
|
||||||
|
private Point GetMousePosition()
|
||||||
|
{
|
||||||
|
Debug.WriteLine("getmousePosition called");
|
||||||
|
var p = Mouse.GetPosition(this.mWindow);
|
||||||
|
return new Point(p.X + this.mWindow.Left, p.Y + this.mWindow.Top);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
xmlns:local="clr-namespace:ClientApp.Views"
|
xmlns:local="clr-namespace:ClientApp.Views"
|
||||||
xmlns:viewModels="clr-namespace:ClientApp.ViewModels"
|
xmlns:viewModels="clr-namespace:ClientApp.ViewModels"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
ShowsNavigationUI="False"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
<DockPanel Background="Lime">
|
<DockPanel>
|
||||||
<!--<DockPanel.Background>
|
<DockPanel.Background>
|
||||||
<ImageBrush TileMode="Tile" ViewportUnits="Absolute" Viewport="0 0 256 256" ImageSource="\images\stone.png"/>
|
<ImageBrush TileMode="Tile" ViewportUnits="Absolute" Viewport="0 0 64 64" ImageSource="\images\stone.png"/>
|
||||||
</DockPanel.Background>-->
|
</DockPanel.Background>
|
||||||
<StackPanel VerticalAlignment="Center" Width="auto">
|
<StackPanel VerticalAlignment="Center" Width="auto">
|
||||||
<Label Content="Username" HorizontalContentAlignment="Center" />
|
<Label Content="Username" HorizontalContentAlignment="Center" />
|
||||||
<TextBox x:Name="Username" Text="{Binding Username}" TextWrapping="Wrap" Width="120"/>
|
<TextBox x:Name="Username" Text="{Binding Username}" TextWrapping="Wrap" Width="120"/>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:ClientApp.Views"
|
xmlns:local="clr-namespace:ClientApp.Views"
|
||||||
|
ShowsNavigationUI="False"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
|
|||||||
@@ -5,12 +5,124 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:ClientApp"
|
xmlns:local="clr-namespace:ClientApp"
|
||||||
xmlns:views="clr-namespace:ClientApp.Views"
|
xmlns:views="clr-namespace:ClientApp.Views"
|
||||||
|
xmlns:images="clrnamespace.Images"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Whaazzzzuuuuuuuup" Height="450" Width="800">
|
WindowStyle="None"
|
||||||
|
AllowsTransparency="True"
|
||||||
|
x:Name="applicatonWindow"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
MinHeight="{Binding MinimumHeight}"
|
||||||
|
MinWidth="{Binding MinimumWidth}"
|
||||||
|
Title="Whaazzzzuuuuuuuup">
|
||||||
|
<!--Icon="/Images/Logo/icon1_small.ico"-->
|
||||||
|
<!--Icon="pack://application:,,,/Images/Log/icon1_small.ico"-->
|
||||||
|
|
||||||
|
<Window.Resources>
|
||||||
|
<Style TargetType="{x:Type local:MainWindow}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type Window}">
|
||||||
|
<Border Padding="{Binding OuterMarginThickness, FallbackValue=10}" >
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
<!-- opacity mask -->
|
||||||
|
<Border x:Name="Container"
|
||||||
|
Background="{StaticResource BackgroundLightBrush}"
|
||||||
|
CornerRadius="{Binding WindowCornerRadius, FallbackValue=10}"/>
|
||||||
|
|
||||||
|
|
||||||
|
<Border CornerRadius="{Binding WindowCornerRadius, FallbackValue=10}"
|
||||||
|
Background="{StaticResource BackgroundVeryLightBrush}">
|
||||||
|
<Border.Effect>
|
||||||
|
<DropShadowEffect ShadowDepth="0" Opacity="0.2"/>
|
||||||
|
</Border.Effect>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
<Grid.OpacityMask>
|
||||||
|
<VisualBrush Visual="{Binding ElementName=Container}"/>
|
||||||
|
</Grid.OpacityMask>
|
||||||
|
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="{Binding TitleHeightGridLength, FallbackValue=42}"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- Title bar -->
|
||||||
|
<Grid Grid.Column="0" Grid.Row="0" Panel.ZIndex="1" Background="{StaticResource BackgroundLightBrush}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<!-- icon -->
|
||||||
|
<Button Grid.Column="0" Style="{StaticResource SystemIconButton}" Command="{Binding MenuCommand}">
|
||||||
|
<Image Source="/Images/Logo/icon1.ico"/>
|
||||||
|
<!--<TextBlock Text="icon"/>-->
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<!-- Title -->
|
||||||
|
<Viewbox Grid.Column="1" Margin="0">
|
||||||
|
<TextBlock Style="{StaticResource HeaderText}" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title, FallbackValue=failed}"/>
|
||||||
|
</Viewbox>
|
||||||
|
|
||||||
|
<!-- Window buttons -->
|
||||||
|
<StackPanel Grid.Column="2" Orientation="Horizontal">
|
||||||
|
<Button Style="{StaticResource WindowControlButton}" Content="_" Command="{Binding MinimizeCommand}"/>
|
||||||
|
<Button Style="{StaticResource WindowControlButton}" Content="[]" Command="{Binding MaximizeCommand}"/>
|
||||||
|
<Button Style="{StaticResource WindowCloseButton}" Content="X" Command="{Binding CloseCommand}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Page content -->
|
||||||
|
<Border Grid.Row="1" Grid.Column="0">
|
||||||
|
<ContentPresenter Content="{TemplateBinding Content}"/>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- shadow? -->
|
||||||
|
<Border Grid.Row="1" Height="6" BorderThickness="0 0.2 0 0" VerticalAlignment="Top">
|
||||||
|
<!--<Border.BorderBrush>
|
||||||
|
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||||||
|
<GradientStop Color="{StaticResource BackgroundSemiLight}" Offset="0.0"/>
|
||||||
|
<GradientStop Color="{StaticResource BackgroundVeryLight}" Offset="1.0"/>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
</Border.BorderBrush>-->
|
||||||
|
|
||||||
|
|
||||||
|
<Border.Background>
|
||||||
|
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
|
||||||
|
<GradientStop Color="Transparent" Offset="1.0"/>
|
||||||
|
<GradientStop Color="#7000" Offset="0.0"/>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
</Border.Background>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
|
<WindowChrome.WindowChrome>
|
||||||
|
<WindowChrome
|
||||||
|
ResizeBorderThickness="{Binding ResizeBorderThickness}"
|
||||||
|
CaptionHeight="{Binding TitleHeight}"
|
||||||
|
CornerRadius="0"
|
||||||
|
GlassFrameThickness="0"/>
|
||||||
|
</WindowChrome.WindowChrome>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Frame Content="{Binding SelectedViewModel}" Focusable="False"/>
|
<Frame Content="{Binding SelectedViewModel}" Focusable="False" NavigationUIVisibility="Hidden"/>
|
||||||
<Label Content="gemaakt door: mensen" DockPanel.Dock="Bottom" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontStyle="Italic" Foreground="Gray"/>
|
<Label Content="gemaakt door: mensen" DockPanel.Dock="Bottom" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontStyle="Italic" Foreground="Gray"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace ClientApp
|
|||||||
Client client = new Client();
|
Client client = new Client();
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = new MainWindowViewModel(client);
|
DataContext = new MainWindowViewModel(this, client);
|
||||||
|
|
||||||
//BLEHandler bLEHandler = new BLEHandler(client);
|
//BLEHandler bLEHandler = new BLEHandler(client);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ namespace Util
|
|||||||
{
|
{
|
||||||
public abstract class ObservableObject : INotifyPropertyChanged
|
public abstract class ObservableObject : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged = (sender, e) => { };
|
||||||
|
|
||||||
|
public void OnPropertyChanged(string name)
|
||||||
|
{
|
||||||
|
PropertyChanged(this, new PropertyChangedEventArgs(name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user