From 3acdc942bcd4a13a3b6a4cdcadccc60b78be22da Mon Sep 17 00:00:00 2001 From: shinichi Date: Mon, 19 Oct 2020 14:53:47 +0200 Subject: [PATCH] move files and copy code from stackoverflow :P --- Hashing/WPFStuff/FocusAdvancement.cs | 40 ++++++++++++ .../{ => WPFStuff}/MagicCode/WindowResizer.cs | 0 Hashing/{ => WPFStuff}/ObservableObject.cs | 0 Hashing/WPFStuff/Styles/Buttons.xaml | 65 +++++++++++++++++++ Hashing/WPFStuff/Styles/Colors.xaml | 25 +++++++ Hashing/WPFStuff/Styles/Fonts.xaml | 5 ++ Hashing/WPFStuff/Styles/Texts.xaml | 11 ++++ Hashing/WPFStuff/Styles/Windows.xaml | 5 ++ 8 files changed, 151 insertions(+) create mode 100644 Hashing/WPFStuff/FocusAdvancement.cs rename Hashing/{ => WPFStuff}/MagicCode/WindowResizer.cs (100%) rename Hashing/{ => WPFStuff}/ObservableObject.cs (100%) create mode 100644 Hashing/WPFStuff/Styles/Buttons.xaml create mode 100644 Hashing/WPFStuff/Styles/Colors.xaml create mode 100644 Hashing/WPFStuff/Styles/Fonts.xaml create mode 100644 Hashing/WPFStuff/Styles/Texts.xaml create mode 100644 Hashing/WPFStuff/Styles/Windows.xaml diff --git a/Hashing/WPFStuff/FocusAdvancement.cs b/Hashing/WPFStuff/FocusAdvancement.cs new file mode 100644 index 0000000..1f34e44 --- /dev/null +++ b/Hashing/WPFStuff/FocusAdvancement.cs @@ -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)); + } + } +} diff --git a/Hashing/MagicCode/WindowResizer.cs b/Hashing/WPFStuff/MagicCode/WindowResizer.cs similarity index 100% rename from Hashing/MagicCode/WindowResizer.cs rename to Hashing/WPFStuff/MagicCode/WindowResizer.cs diff --git a/Hashing/ObservableObject.cs b/Hashing/WPFStuff/ObservableObject.cs similarity index 100% rename from Hashing/ObservableObject.cs rename to Hashing/WPFStuff/ObservableObject.cs diff --git a/Hashing/WPFStuff/Styles/Buttons.xaml b/Hashing/WPFStuff/Styles/Buttons.xaml new file mode 100644 index 0000000..c951dd8 --- /dev/null +++ b/Hashing/WPFStuff/Styles/Buttons.xaml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Hashing/WPFStuff/Styles/Colors.xaml b/Hashing/WPFStuff/Styles/Colors.xaml new file mode 100644 index 0000000..8e4f8ef --- /dev/null +++ b/Hashing/WPFStuff/Styles/Colors.xaml @@ -0,0 +1,25 @@ + + + #efefef + + + + #fafafa + + + #d7d7d7 + + + #686868 + + + #000 + + + #fff + + + + \ No newline at end of file diff --git a/Hashing/WPFStuff/Styles/Fonts.xaml b/Hashing/WPFStuff/Styles/Fonts.xaml new file mode 100644 index 0000000..b0e7544 --- /dev/null +++ b/Hashing/WPFStuff/Styles/Fonts.xaml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/Hashing/WPFStuff/Styles/Texts.xaml b/Hashing/WPFStuff/Styles/Texts.xaml new file mode 100644 index 0000000..4fdba93 --- /dev/null +++ b/Hashing/WPFStuff/Styles/Texts.xaml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/Hashing/WPFStuff/Styles/Windows.xaml b/Hashing/WPFStuff/Styles/Windows.xaml new file mode 100644 index 0000000..b0e7544 --- /dev/null +++ b/Hashing/WPFStuff/Styles/Windows.xaml @@ -0,0 +1,5 @@ + + + \ No newline at end of file