diff --git a/Lectures/Lecture_11/Sample/CookBook.App/App.config b/Lectures/Lecture_11/Sample/CookBook.App/App.config new file mode 100644 index 00000000..217b89a0 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/App.config @@ -0,0 +1,23 @@ + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/App.xaml b/Lectures/Lecture_11/Sample/CookBook.App/App.xaml new file mode 100644 index 00000000..5c39d7dc --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/App.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/Lectures/Lecture_11/Sample/CookBook.App/App.xaml.cs b/Lectures/Lecture_11/Sample/CookBook.App/App.xaml.cs new file mode 100644 index 00000000..6c1c6057 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/App.xaml.cs @@ -0,0 +1,11 @@ +using System.Windows; + +namespace CookBook.App +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Commands/RelayCommand.cs b/Lectures/Lecture_11/Sample/CookBook.App/Commands/RelayCommand.cs new file mode 100644 index 00000000..f71b928e --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Commands/RelayCommand.cs @@ -0,0 +1,40 @@ +using System; +using System.Windows.Input; + +namespace CookBook.App.Commands +{ + public class RelayCommand : ICommand + { + private readonly Action executeAction; + private readonly Func canExecuteAction; + + public RelayCommand(Action executeAction, Func canExecuteAction = null) + { + this.executeAction = executeAction; + this.canExecuteAction = canExecuteAction; + } + + public RelayCommand(Action executeAction, Func canExecuteAction = null) + : this(p => executeAction(), p => canExecuteAction?.Invoke() ?? true) + { + + } + + public bool CanExecute(object parameter) + { + return canExecuteAction?.Invoke(parameter) ?? true; + } + + public void Execute(object parameter) + { + executeAction?.Invoke(parameter); + } + + public void RaiseCanExecuteChanged() + { + CanExecuteChanged?.Invoke(this, EventArgs.Empty); + } + + public event EventHandler CanExecuteChanged; + } +} \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Commands/SaveRecipeCommand.cs b/Lectures/Lecture_11/Sample/CookBook.App/Commands/SaveRecipeCommand.cs new file mode 100644 index 00000000..a8145f02 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Commands/SaveRecipeCommand.cs @@ -0,0 +1,49 @@ +using System; +using System.Windows.Input; +using CookBook.App.ViewModels; +using CookBook.BL; +using CookBook.BL.Messages; +using CookBook.BL.Models; +using CookBook.BL.Repositories; + +namespace CookBook.App.Commands +{ + public class SaveRecipeCommand : ICommand + { + private readonly RecipeRepository recipeRepository; + private readonly RecipeDetailViewModel viewModel; + private readonly IMessenger messenger; + + public SaveRecipeCommand(RecipeRepository recipeRepository, RecipeDetailViewModel viewModel, IMessenger messenger) + { + this.recipeRepository = recipeRepository; + this.viewModel = viewModel; + this.messenger = messenger; + } + + public bool CanExecute(object parameter) + { + return viewModel.Detail?.Duration.TotalMinutes > 0; + } + + public void Execute(object parameter) + { + if (viewModel.Detail.Id == Guid.Empty) + { + viewModel.Detail = recipeRepository.Insert(viewModel.Detail); + } + else + { + recipeRepository.Update(viewModel.Detail); + } + + messenger.Send(new UpdatedRecipeMessage(viewModel.Detail)); + } + + public event EventHandler CanExecuteChanged + { + add { CommandManager.RequerySuggested += value; } + remove { CommandManager.RequerySuggested -= value; } + } + } +} \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Controls/CustomButton.xaml b/Lectures/Lecture_11/Sample/CookBook.App/Controls/CustomButton.xaml new file mode 100644 index 00000000..59dea346 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Controls/CustomButton.xaml @@ -0,0 +1,104 @@ + diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Controls/CustomButton.xaml.cs b/Lectures/Lecture_11/Sample/CookBook.App/Controls/CustomButton.xaml.cs new file mode 100644 index 00000000..af610f33 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Controls/CustomButton.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 CookBook.App.Controls +{ + /// + /// Interaction logic for CustomButton.xaml + /// + public partial class CustomButton + { + public CustomButton() + { + InitializeComponent(); + } + } +} diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Converters/NullToVisibilityConverter.cs b/Lectures/Lecture_11/Sample/CookBook.App/Converters/NullToVisibilityConverter.cs new file mode 100644 index 00000000..4057c4cf --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Converters/NullToVisibilityConverter.cs @@ -0,0 +1,20 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace CookBook.App.Converters +{ + public class NullToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value == null ? Visibility.Collapsed : Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Converters/TimeSpanToMinutesConverter.cs b/Lectures/Lecture_11/Sample/CookBook.App/Converters/TimeSpanToMinutesConverter.cs new file mode 100644 index 00000000..055c902e --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Converters/TimeSpanToMinutesConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace CookBook.App.Converters +{ + public class TimeSpanToMinutesConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var time = value as TimeSpan?; + + return time?.TotalMinutes; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + var minutes = value?.ToString(); + + if (minutes != null) + { + if (int.TryParse(minutes, out var minutesCount)) + { + return TimeSpan.FromMinutes(minutesCount); + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/CookBook.App.csproj b/Lectures/Lecture_11/Sample/CookBook.App/CookBook.App.csproj new file mode 100644 index 00000000..e5dd4af6 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/CookBook.App.csproj @@ -0,0 +1,166 @@ + + + + + Debug + AnyCPU + {9FE5CEF4-1AD0-4B7E-984C-AE908F7B5F3A} + WinExe + Properties + CookBook.App + CookBook.App + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + True + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + True + + + ..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll + + + ..\packages\MaterialDesignThemes.2.4.0.1044\lib\net45\MaterialDesignThemes.Wpf.dll + + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + CustomButton.xaml + + + + + RecipeDetailView.xaml + + + RecipeListView.xaml + + + + + + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + {F48D47ED-6003-4B97-8629-5C6BEC99E779} + CookBook.BL + + + {9247FC0B-1D73-4343-9BE0-6974EC0CD834} + CookBook.DAL + + + + + + \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Properties/AssemblyInfo.cs b/Lectures/Lecture_11/Sample/CookBook.App/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..5d58bc89 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CookBook.App04")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CookBook.App04")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[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) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Properties/Resources.Designer.cs b/Lectures/Lecture_11/Sample/CookBook.App/Properties/Resources.Designer.cs new file mode 100644 index 00000000..5b1d84e5 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CookBook.App.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CookBook.App.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Properties/Resources.resx b/Lectures/Lecture_11/Sample/CookBook.App/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Properties/Settings.Designer.cs b/Lectures/Lecture_11/Sample/CookBook.App/Properties/Settings.Designer.cs new file mode 100644 index 00000000..f1ff1d28 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CookBook.App.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.1.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Properties/Settings.settings b/Lectures/Lecture_11/Sample/CookBook.App/Properties/Settings.settings new file mode 100644 index 00000000..033d7a5e --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/ViewModelLocator.cs b/Lectures/Lecture_11/Sample/CookBook.App/ViewModelLocator.cs new file mode 100644 index 00000000..ee47adb2 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/ViewModelLocator.cs @@ -0,0 +1,32 @@ +using CookBook.App.ViewModels; +using CookBook.BL; +using CookBook.BL.Repositories; + +namespace CookBook.App +{ + public class ViewModelLocator + { + private readonly Messenger messenger = new Messenger(); + private readonly RecipeRepository recipeRepository = new RecipeRepository(); + private readonly Mapper mapper = new Mapper(); + + public RecipeListViewModel RecipeListViewModel => CreateRecipeListViewModel(); + public RecipeDetailViewModel RecipeDetailViewModel => CreateRecipeDetailViewModel(); + public MainViewModel MainViewModel => CreateMainViewModel(); + + private MainViewModel CreateMainViewModel() + { + return new MainViewModel(messenger); + } + + private RecipeDetailViewModel CreateRecipeDetailViewModel() + { + return new RecipeDetailViewModel(recipeRepository, messenger); + } + + private RecipeListViewModel CreateRecipeListViewModel() + { + return new RecipeListViewModel(recipeRepository, messenger, mapper); + } + } +} \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/MainViewModel.cs b/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/MainViewModel.cs new file mode 100644 index 00000000..911416c2 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/MainViewModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Input; +using CookBook.App.Commands; +using CookBook.BL; +using CookBook.BL.Messages; + +namespace CookBook.App.ViewModels +{ + public class MainViewModel : ViewModelBase + { + private readonly IMessenger messenger; + + public string Name { get; set; } = "Nenacteno"; + public ICommand CreateRecipeCommand { get; set; } + + public MainViewModel(IMessenger messenger) + { + this.messenger = messenger; + CreateRecipeCommand = new RelayCommand(AddNewRecipe); + } + + private void AddNewRecipe() + { + messenger.Send(new NewRecipeMessage()); + } + + public void OnLoad() + { + } + } +} \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/RecipeDetailViewModel.cs b/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/RecipeDetailViewModel.cs new file mode 100644 index 00000000..c6702fb6 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/RecipeDetailViewModel.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Input; +using CookBook.App.Commands; +using CookBook.BL; +using CookBook.BL.Messages; +using CookBook.BL.Models; +using CookBook.BL.Repositories; +using CookBook.DAL.Entities; + +namespace CookBook.App.ViewModels +{ + public class RecipeDetailViewModel : ViewModelBase + { + private readonly RecipeRepository recipeRepository; + private readonly IMessenger messenger; + private RecipeDetailModel detail; + + public RecipeDetailModel Detail + { + get { return detail; } + set + { + if (Equals(value, Detail)) return; + + detail = value; + OnPropertyChanged(); + } + } + + public IList FoodTypes => Enum.GetValues(typeof(FoodType)).Cast().ToList(); + public ICommand SaveRecipeCommand { get; set; } + public ICommand DeleteRecipeCommand { get; set; } + + public RecipeDetailViewModel(RecipeRepository recipeRepository, IMessenger messenger) + { + this.recipeRepository = recipeRepository; + this.messenger = messenger; + + SaveRecipeCommand = new SaveRecipeCommand(recipeRepository, this, messenger); + DeleteRecipeCommand = new RelayCommand(DeleteRecipe); + + this.messenger.Register(SelectedRecipe); + this.messenger.Register(NewRecipeMessageReceived); + } + + private void DeleteRecipe() + { + if(Detail.Id != Guid.Empty) + { + var recipeId = Detail.Id; + + Detail = new RecipeDetailModel(); + recipeRepository.Remove(recipeId); + messenger.Send(new DeletedRecipeMessage(recipeId)); + } + } + + private void NewRecipeMessageReceived(NewRecipeMessage obj) + { + Detail = new RecipeDetailModel(); + } + + private void SelectedRecipe(SelectedRecipeMessage message) + { + Detail = recipeRepository.GetById(message.Id); + } + } +} \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/RecipeListViewModel.cs b/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/RecipeListViewModel.cs new file mode 100644 index 00000000..249d7d26 --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/RecipeListViewModel.cs @@ -0,0 +1,68 @@ +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows.Input; +using CookBook.App.Commands; +using CookBook.BL; +using CookBook.BL.Messages; +using CookBook.BL.Models; +using CookBook.BL.Repositories; + +namespace CookBook.App.ViewModels +{ + public class RecipeListViewModel : ViewModelBase + { + private readonly RecipeRepository recipeRepository; + private readonly IMessenger messenger; + private readonly Mapper mapper; + + public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + + public ICommand SelectRecipeCommand { get; } + public ICommand OnLoadCommand { get; set; } + + public RecipeListViewModel(RecipeRepository recipeRepository, IMessenger messenger, Mapper mapper) + { + this.recipeRepository = recipeRepository; + this.messenger = messenger; + this.mapper = mapper; + + SelectRecipeCommand = new RelayCommand(RecipeSelectionChanged); + OnLoadCommand = new RelayCommand(OnLoad); + this.messenger.Register(UpdatedRecipeMessageReceived); + } + + private void UpdatedRecipeMessageReceived(UpdatedRecipeMessage recipeMessage) + { + var existingRecipe = Recipes.SingleOrDefault(recipe => recipe.Id == recipeMessage.Model.Id); + var newRecipe = mapper.MapDetailModelToListModel(recipeMessage.Model); + if (existingRecipe == null) + { + Recipes.Add(newRecipe); + } + else + { + var recipeIndex = Recipes.IndexOf(existingRecipe); + Recipes[recipeIndex] = newRecipe; + } + } + + public void OnLoad() + { + Recipes.Clear(); + + var recipes = recipeRepository.GetAll(); + foreach (var recipe in recipes) + { + Recipes.Add(recipe); + } + } + + private void RecipeSelectionChanged(object parameter) + { + if (parameter is RecipeListModel recipe) + { + messenger.Send(new SelectedRecipeMessage { Id = recipe.Id }); + } + } + } +} \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/ViewModelBase.cs b/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/ViewModelBase.cs new file mode 100644 index 00000000..3753dafd --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/ViewModels/ViewModelBase.cs @@ -0,0 +1,17 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; +using CookBook.App.Properties; + +namespace CookBook.App.ViewModels +{ + public abstract class ViewModelBase : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + } +} \ No newline at end of file diff --git a/Lectures/Lecture_11/Sample/CookBook.App/Views/MainWindow.xaml b/Lectures/Lecture_11/Sample/CookBook.App/Views/MainWindow.xaml new file mode 100644 index 00000000..63ccc5fc --- /dev/null +++ b/Lectures/Lecture_11/Sample/CookBook.App/Views/MainWindow.xaml @@ -0,0 +1,134 @@ + + + #0000FF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +