From 62970a1fb91f0567414d04a4c12eefc57a3c68c4 Mon Sep 17 00:00:00 2001 From: flifloo Date: Wed, 6 Apr 2022 11:39:36 +0200 Subject: [PATCH] Default App structure --- App.xaml | 4 ++-- App.xaml.cs | 8 +++----- AssemblyInfo.cs | 2 +- Tetris.csproj | 2 +- Tetris.sln | 6 ++++++ MainWindow.xaml => Views/MainWindow.xaml | 6 ++++-- MainWindow.xaml.cs => Views/MainWindow.xaml.cs | 13 ++++++------- ViewsModels/ViewModel.cs | 12 ++++++++++++ 8 files changed, 35 insertions(+), 18 deletions(-) rename MainWindow.xaml => Views/MainWindow.xaml (67%) rename MainWindow.xaml.cs => Views/MainWindow.xaml.cs (75%) create mode 100644 ViewsModels/ViewModel.cs diff --git a/App.xaml b/App.xaml index f0358dc..5ac26ee 100644 --- a/App.xaml +++ b/App.xaml @@ -2,8 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Tetris" - StartupUri="MainWindow.xaml"> + StartupUri="Views/MainWindow.xaml"> - + diff --git a/App.xaml.cs b/App.xaml.cs index e1c6e50..3213dd3 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -6,12 +6,10 @@ using System.Linq; using System.Threading.Tasks; using System.Windows; -namespace Tetris -{ +namespace Tetris { /// /// Interaction logic for App.xaml /// - public partial class App : Application - { + public partial class App : Application { } -} \ No newline at end of file +} diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs index 4a05c7d..b9d746b 100644 --- a/AssemblyInfo.cs +++ b/AssemblyInfo.cs @@ -7,4 +7,4 @@ using System.Windows; 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) -)] \ No newline at end of file +)] diff --git a/Tetris.csproj b/Tetris.csproj index 9d8b401..d9bfab2 100644 --- a/Tetris.csproj +++ b/Tetris.csproj @@ -2,9 +2,9 @@ WinExe - net6.0-windows enable true + net6.0-windows diff --git a/Tetris.sln b/Tetris.sln index 2a0830a..58649b9 100644 --- a/Tetris.sln +++ b/Tetris.sln @@ -2,6 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tetris", "Tetris.csproj", "{1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestTetris", "..\TestTetris\TestTetris\TestTetris.csproj", "{9F341BB7-7176-4DD4-8CE3-528C31F616F4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -12,5 +14,9 @@ Global {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Debug|Any CPU.Build.0 = Debug|Any CPU {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Release|Any CPU.ActiveCfg = Release|Any CPU {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Release|Any CPU.Build.0 = Release|Any CPU + {9F341BB7-7176-4DD4-8CE3-528C31F616F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F341BB7-7176-4DD4-8CE3-528C31F616F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F341BB7-7176-4DD4-8CE3-528C31F616F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F341BB7-7176-4DD4-8CE3-528C31F616F4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/MainWindow.xaml b/Views/MainWindow.xaml similarity index 67% rename from MainWindow.xaml rename to Views/MainWindow.xaml index 0bb1dfb..805184a 100644 --- a/MainWindow.xaml +++ b/Views/MainWindow.xaml @@ -1,12 +1,14 @@ - - + diff --git a/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs similarity index 75% rename from MainWindow.xaml.cs rename to Views/MainWindow.xaml.cs index 3639001..6deee64 100644 --- a/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -12,17 +12,16 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tetris.ViewsModels; -namespace Tetris -{ +namespace Tetris.Views { /// /// Interaction logic for MainWindow.xaml /// - public partial class MainWindow : Window - { - public MainWindow() - { + public partial class MainWindow : Window { + public MainWindow() { + DataContext = new ViewModel(); InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/ViewsModels/ViewModel.cs b/ViewsModels/ViewModel.cs new file mode 100644 index 0000000..7d12ac7 --- /dev/null +++ b/ViewsModels/ViewModel.cs @@ -0,0 +1,12 @@ +using System.ComponentModel; + +namespace Tetris.ViewsModels; + +public class ViewModel : INotifyPropertyChanged { + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged(string propertyName) { + if (PropertyChanged != null) + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } +}