From 0ec24ba4e16723df0589dfe5acd1cd1080a85c84 Mon Sep 17 00:00:00 2001 From: syneffort Date: Wed, 21 Jun 2023 11:33:15 +0900 Subject: [PATCH] textinput mvvm detection --- .../ViewModel/ViewModelMain.cs | 2 + .../MVVMTextInputDetection/App.xaml | 9 ++++ .../MVVMTextInputDetection/App.xaml.cs | 17 +++++++ .../MVVMTextInputDetection/AssemblyInfo.cs | 10 ++++ .../MVVMTextInputDetection.csproj | 10 ++++ .../MVVMTextInputDetection/MainWindow.xaml | 19 ++++++++ .../MVVMTextInputDetection/MainWindow.xaml.cs | 28 +++++++++++ .../MVVMTextInputDetection/Model/Calculate.cs | 13 ++++++ .../ViewModel/CalculateViewModel.cs | 46 +++++++++++++++++++ PacticeSolution/PacticeSolution.sln | 14 ++++-- 10 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 PacticeSolution/MVVMTextInputDetection/App.xaml create mode 100644 PacticeSolution/MVVMTextInputDetection/App.xaml.cs create mode 100644 PacticeSolution/MVVMTextInputDetection/AssemblyInfo.cs create mode 100644 PacticeSolution/MVVMTextInputDetection/MVVMTextInputDetection.csproj create mode 100644 PacticeSolution/MVVMTextInputDetection/MainWindow.xaml create mode 100644 PacticeSolution/MVVMTextInputDetection/MainWindow.xaml.cs create mode 100644 PacticeSolution/MVVMTextInputDetection/Model/Calculate.cs create mode 100644 PacticeSolution/MVVMTextInputDetection/ViewModel/CalculateViewModel.cs diff --git a/PacticeSolution/MVVMDatabaseSample/ViewModel/ViewModelMain.cs b/PacticeSolution/MVVMDatabaseSample/ViewModel/ViewModelMain.cs index 4b5aafd..5ec098f 100644 --- a/PacticeSolution/MVVMDatabaseSample/ViewModel/ViewModelMain.cs +++ b/PacticeSolution/MVVMDatabaseSample/ViewModel/ViewModelMain.cs @@ -122,6 +122,8 @@ namespace MVVMDatabaseSample.ViewModel private void Select() { + _sampleData.Clear(); + DataSet ds = new DataSet(); string qry = "SELECT * FROM Student"; SqlDBManager.Instance.ExecuteQuery(ds, qry); diff --git a/PacticeSolution/MVVMTextInputDetection/App.xaml b/PacticeSolution/MVVMTextInputDetection/App.xaml new file mode 100644 index 0000000..758f7f9 --- /dev/null +++ b/PacticeSolution/MVVMTextInputDetection/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/PacticeSolution/MVVMTextInputDetection/App.xaml.cs b/PacticeSolution/MVVMTextInputDetection/App.xaml.cs new file mode 100644 index 0000000..2b1c743 --- /dev/null +++ b/PacticeSolution/MVVMTextInputDetection/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 MVVMTextInputDetection +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/PacticeSolution/MVVMTextInputDetection/AssemblyInfo.cs b/PacticeSolution/MVVMTextInputDetection/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/PacticeSolution/MVVMTextInputDetection/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/MVVMTextInputDetection/MVVMTextInputDetection.csproj b/PacticeSolution/MVVMTextInputDetection/MVVMTextInputDetection.csproj new file mode 100644 index 0000000..4106cb0 --- /dev/null +++ b/PacticeSolution/MVVMTextInputDetection/MVVMTextInputDetection.csproj @@ -0,0 +1,10 @@ + + + + WinExe + net6.0-windows + enable + true + + + diff --git a/PacticeSolution/MVVMTextInputDetection/MainWindow.xaml b/PacticeSolution/MVVMTextInputDetection/MainWindow.xaml new file mode 100644 index 0000000..5d63829 --- /dev/null +++ b/PacticeSolution/MVVMTextInputDetection/MainWindow.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/PacticeSolution/MVVMTextInputDetection/MainWindow.xaml.cs b/PacticeSolution/MVVMTextInputDetection/MainWindow.xaml.cs new file mode 100644 index 0000000..658c1af --- /dev/null +++ b/PacticeSolution/MVVMTextInputDetection/MainWindow.xaml.cs @@ -0,0 +1,28 @@ +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 MVVMTextInputDetection +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/PacticeSolution/MVVMTextInputDetection/Model/Calculate.cs b/PacticeSolution/MVVMTextInputDetection/Model/Calculate.cs new file mode 100644 index 0000000..5a05e64 --- /dev/null +++ b/PacticeSolution/MVVMTextInputDetection/Model/Calculate.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MVVMTextInputDetection.Model +{ + class Calculate + { + public int Number { get; set; } + } +} diff --git a/PacticeSolution/MVVMTextInputDetection/ViewModel/CalculateViewModel.cs b/PacticeSolution/MVVMTextInputDetection/ViewModel/CalculateViewModel.cs new file mode 100644 index 0000000..9501034 --- /dev/null +++ b/PacticeSolution/MVVMTextInputDetection/ViewModel/CalculateViewModel.cs @@ -0,0 +1,46 @@ +using MVVMTextInputDetection.Model; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace MVVMTextInputDetection.ViewModel +{ + class CalculateViewModel : INotifyPropertyChanged + { + public Calculate CalculateModel { get; set; } + + public event PropertyChangedEventHandler? PropertyChanged; + + public CalculateViewModel() + { + this.CalculateModel = new Calculate(); + } + + public int Number + { + get { return this.CalculateModel.Number; } + set + { + CalculateModel.Number = value; + OnPropertyChanged("Number"); + + CheckNumberRange(this.CalculateModel.Number); + } + } + + private void CheckNumberRange(int number) + { + if (number > 99 || number < 0) + MessageBox.Show("Number range exceeded!"); + } + + protected void OnPropertyChanged(string propertyName) + { + this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/PacticeSolution/PacticeSolution.sln b/PacticeSolution/PacticeSolution.sln index bf40cb8..9a164e9 100644 --- a/PacticeSolution/PacticeSolution.sln +++ b/PacticeSolution/PacticeSolution.sln @@ -9,13 +9,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClockGadget", "ClockGadget\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapFinder", "MapFinder\MapFinder.csproj", "{4FCEAEAA-6A26-492F-95D1-9695F386DAB5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataBindingSample", "DataBindingSample\DataBindingSample.csproj", "{8A3E4E38-6E95-4955-8BFE-6E58F4AECE27}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataBindingSample", "DataBindingSample\DataBindingSample.csproj", "{8A3E4E38-6E95-4955-8BFE-6E58F4AECE27}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMSample", "MVVMSample\MVVMSample.csproj", "{FFD799B6-18C5-413B-8984-B44C803473B0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMSample", "MVVMSample\MVVMSample.csproj", "{FFD799B6-18C5-413B-8984-B44C803473B0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceSample", "ResourceSample\ResourceSample.csproj", "{858EC308-9ABD-44C1-92E1-59911F60FEB9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResourceSample", "ResourceSample\ResourceSample.csproj", "{858EC308-9ABD-44C1-92E1-59911F60FEB9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMDatabaseSample", "MVVMDatabaseSample\MVVMDatabaseSample.csproj", "{B0A8E6DE-C6A2-488E-A148-9E7812F615F2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMDatabaseSample", "MVVMDatabaseSample\MVVMDatabaseSample.csproj", "{B0A8E6DE-C6A2-488E-A148-9E7812F615F2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMTextInputDetection", "MVVMTextInputDetection\MVVMTextInputDetection.csproj", "{C55A5081-B142-4120-8F62-3991276EF5C2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -51,6 +53,10 @@ Global {B0A8E6DE-C6A2-488E-A148-9E7812F615F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {B0A8E6DE-C6A2-488E-A148-9E7812F615F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0A8E6DE-C6A2-488E-A148-9E7812F615F2}.Release|Any CPU.Build.0 = Release|Any CPU + {C55A5081-B142-4120-8F62-3991276EF5C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C55A5081-B142-4120-8F62-3991276EF5C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C55A5081-B142-4120-8F62-3991276EF5C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C55A5081-B142-4120-8F62-3991276EF5C2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE