Develop #10
40
Hashing/WPFStuff/FocusAdvancement.cs
Normal file
40
Hashing/WPFStuff/FocusAdvancement.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Util.WPF
|
||||
{
|
||||
public static class FocusAdvancement
|
||||
{
|
||||
public static bool GetAdvancesByEnterKey(DependencyObject obj)
|
||||
{
|
||||
return (bool)obj.GetValue(AdvancesByEnterKeyProperty);
|
||||
}
|
||||
|
||||
public static void SetAdvancesByEnterKey(DependencyObject obj, bool value)
|
||||
{
|
||||
obj.SetValue(AdvancesByEnterKeyProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AdvancesByEnterKeyProperty =
|
||||
DependencyProperty.RegisterAttached("AdvancesByEnterKey", typeof(bool), typeof(FocusAdvancement),
|
||||
new UIPropertyMetadata(OnAdvancesByEnterKeyPropertyChanged));
|
||||
|
||||
static void OnAdvancesByEnterKeyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var element = d as UIElement;
|
||||
if (element == null) return;
|
||||
|
||||
if ((bool)e.NewValue) element.KeyDown += Keydown;
|
||||
else element.KeyDown -= Keydown;
|
||||
}
|
||||
|
||||
static void Keydown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (!e.Key.Equals(Key.Enter)) return;
|
||||
|
||||
var element = sender as UIElement;
|
||||
if (element != null) element.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
|
||||
}
|
||||
}
|
||||
}
|
||||
65
Hashing/WPFStuff/Styles/Buttons.xaml
Normal file
65
Hashing/WPFStuff/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
Hashing/WPFStuff/Styles/Colors.xaml
Normal file
25
Hashing/WPFStuff/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
Hashing/WPFStuff/Styles/Fonts.xaml
Normal file
5
Hashing/WPFStuff/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
Hashing/WPFStuff/Styles/Texts.xaml
Normal file
11
Hashing/WPFStuff/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
Hashing/WPFStuff/Styles/Windows.xaml
Normal file
5
Hashing/WPFStuff/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>
|
||||
Reference in New Issue
Block a user