From 3568b0bf475539e187eb7a7b6bcad537c9d281ab Mon Sep 17 00:00:00 2001 From: syneffort Date: Mon, 3 Jul 2023 09:56:25 +0900 Subject: [PATCH] keyboard input --- PacticeSolution/KeyboardInputSample/App.xaml | 9 ++++ .../KeyboardInputSample/App.xaml.cs | 17 ++++++ .../KeyboardInputSample/AssemblyInfo.cs | 10 ++++ .../KeyboardInputSample.csproj | 10 ++++ .../KeyboardInputSample/MainWindow.xaml | 13 +++++ .../KeyboardInputSample/MainWindow.xaml.cs | 52 +++++++++++++++++++ PacticeSolution/PacticeSolution.sln | 12 +++-- 7 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 PacticeSolution/KeyboardInputSample/App.xaml create mode 100644 PacticeSolution/KeyboardInputSample/App.xaml.cs create mode 100644 PacticeSolution/KeyboardInputSample/AssemblyInfo.cs create mode 100644 PacticeSolution/KeyboardInputSample/KeyboardInputSample.csproj create mode 100644 PacticeSolution/KeyboardInputSample/MainWindow.xaml create mode 100644 PacticeSolution/KeyboardInputSample/MainWindow.xaml.cs diff --git a/PacticeSolution/KeyboardInputSample/App.xaml b/PacticeSolution/KeyboardInputSample/App.xaml new file mode 100644 index 0000000..9abdc8e --- /dev/null +++ b/PacticeSolution/KeyboardInputSample/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/PacticeSolution/KeyboardInputSample/App.xaml.cs b/PacticeSolution/KeyboardInputSample/App.xaml.cs new file mode 100644 index 0000000..009f325 --- /dev/null +++ b/PacticeSolution/KeyboardInputSample/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace KeyboardInputSample +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/PacticeSolution/KeyboardInputSample/AssemblyInfo.cs b/PacticeSolution/KeyboardInputSample/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/PacticeSolution/KeyboardInputSample/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/PacticeSolution/KeyboardInputSample/KeyboardInputSample.csproj b/PacticeSolution/KeyboardInputSample/KeyboardInputSample.csproj new file mode 100644 index 0000000..4106cb0 --- /dev/null +++ b/PacticeSolution/KeyboardInputSample/KeyboardInputSample.csproj @@ -0,0 +1,10 @@ + + + + WinExe + net6.0-windows + enable + true + + + diff --git a/PacticeSolution/KeyboardInputSample/MainWindow.xaml b/PacticeSolution/KeyboardInputSample/MainWindow.xaml new file mode 100644 index 0000000..45064a0 --- /dev/null +++ b/PacticeSolution/KeyboardInputSample/MainWindow.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/PacticeSolution/KeyboardInputSample/MainWindow.xaml.cs b/PacticeSolution/KeyboardInputSample/MainWindow.xaml.cs new file mode 100644 index 0000000..227215f --- /dev/null +++ b/PacticeSolution/KeyboardInputSample/MainWindow.xaml.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace KeyboardInputSample +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + + private void tbxMain_KeyDown(object sender, KeyEventArgs e) + { + string msg = ""; + switch(e.Key) + { + case Key.O: + msg = "O"; + break; + case Key.LeftCtrl: + msg = "Ctrl"; + break; + case Key.LeftAlt: + msg = "Alt"; + break; + } + + // composite keys + if (Keyboard.IsKeyDown(Key.LeftAlt) && Keyboard.IsKeyDown(Key.Enter)) + msg = "Alt + Enter"; + + if (!string.IsNullOrEmpty(msg)) + MessageBox.Show(msg); + } + } +} diff --git a/PacticeSolution/PacticeSolution.sln b/PacticeSolution/PacticeSolution.sln index 9e1536e..739f0aa 100644 --- a/PacticeSolution/PacticeSolution.sln +++ b/PacticeSolution/PacticeSolution.sln @@ -41,11 +41,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContentProperty", "ContentP EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BindingSample", "BindingSample\BindingSample.csproj", "{E7E2D1BF-97F5-4C77-8F96-D2882805EFF5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridSharedSample", "GridSharedSample\GridSharedSample.csproj", "{32927DD0-81D5-48C7-BA39-3446651DF897}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GridSharedSample", "GridSharedSample\GridSharedSample.csproj", "{32927DD0-81D5-48C7-BA39-3446651DF897}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LabelTextBlockTextBoxSample", "LabelTextBlockTextBoxSample\LabelTextBlockTextBoxSample.csproj", "{C1375ECE-FDD2-4C7B-B3F8-1A24F3CF051D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LabelTextBlockTextBoxSample", "LabelTextBlockTextBoxSample\LabelTextBlockTextBoxSample.csproj", "{C1375ECE-FDD2-4C7B-B3F8-1A24F3CF051D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListBoxBindingSample", "ListBoxBindingSample\ListBoxBindingSample.csproj", "{71B7E9C4-C73B-4701-B702-A91AB5630580}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ListBoxBindingSample", "ListBoxBindingSample\ListBoxBindingSample.csproj", "{71B7E9C4-C73B-4701-B702-A91AB5630580}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeyboardInputSample", "KeyboardInputSample\KeyboardInputSample.csproj", "{B6A7E0D5-A2C7-4083-A060-1672E6FBDC82}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -141,6 +143,10 @@ Global {71B7E9C4-C73B-4701-B702-A91AB5630580}.Debug|Any CPU.Build.0 = Debug|Any CPU {71B7E9C4-C73B-4701-B702-A91AB5630580}.Release|Any CPU.ActiveCfg = Release|Any CPU {71B7E9C4-C73B-4701-B702-A91AB5630580}.Release|Any CPU.Build.0 = Release|Any CPU + {B6A7E0D5-A2C7-4083-A060-1672E6FBDC82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B6A7E0D5-A2C7-4083-A060-1672E6FBDC82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6A7E0D5-A2C7-4083-A060-1672E6FBDC82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B6A7E0D5-A2C7-4083-A060-1672E6FBDC82}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE