From 554fd393a7251936cdaca0abc08ce00ccb6c7188 Mon Sep 17 00:00:00 2001 From: Sergey <53861218+Stan-Kudri@users.noreply.github.com> Date: Sun, 8 Dec 2024 11:13:13 +0300 Subject: [PATCH] Feature/#100 (#101) * WatchList - Add window "AddCinemaWindow" and fixed bug. Incomplete implementation of the task functionality. * WatchList.WPF - Fixed bug and remove unused classes. * WatchItem.WPF - Moved properties from "CinemaModel" to "AddCinemaViewModel". * WatchList.WPF - Implemented the ability to add an item. --- .../Load/Components/TypeLoadingCinema.cs | 15 +- WatchList.Core/Model/Load/Grade.cs | 4 + WatchList.WPF/App.xaml | 3 + WatchList.WPF/App.xaml.cs | 12 +- WatchList.WPF/Data/ViewModelLocator.cs | 10 +- .../Extension/AppServiceDIExtension.cs | 9 +- WatchList.WPF/Models/CinemaModel.cs | 100 --------- .../{FiileLoaderDB.cs => FileLoaderDB.cs} | 4 +- .../LoadModel/ModelDownloadMoreGrade.cs | 28 --- .../LoadModel/ModelTypeCinemaUpload.cs | 28 --- WatchList.WPF/Models/WatchItemCreator.cs | 30 +++ .../ViewModel/CinemaPageViewModel.cs | 17 +- ...geViewModel.cs => DataReplaceMessageVM.cs} | 4 +- .../ViewModel/ItemsView/AddCinemaViewModel.cs | 202 ++++++++++++++++++ .../ViewModel/MergeDatabaseViewModel.cs | 26 ++- WatchList.WPF/Views/CinemaPage.xaml | 37 ++-- .../Views/CinemaView/AddCinemaWindow.xaml | 150 +++++++++++++ .../Views/CinemaView/AddCinemaWindow.xaml.cs | 15 ++ WatchList.WPF/Views/MergeDatabaseWindow.xaml | 21 +- .../Message/DataReplaceMessageWindow.xaml | 2 +- .../Message/DataReplaceMessageWindow.xaml.cs | 2 +- WatchList.WPF/Views/Message/MessageWindow.cs | 2 +- WatchList.WPF/WatchList.WPF.csproj | 2 +- 23 files changed, 504 insertions(+), 219 deletions(-) delete mode 100644 WatchList.WPF/Models/CinemaModel.cs rename WatchList.WPF/Models/ModelDataLoad/{FiileLoaderDB.cs => FileLoaderDB.cs} (89%) delete mode 100644 WatchList.WPF/Models/ModelDataLoad/LoadModel/ModelDownloadMoreGrade.cs delete mode 100644 WatchList.WPF/Models/ModelDataLoad/LoadModel/ModelTypeCinemaUpload.cs create mode 100644 WatchList.WPF/Models/WatchItemCreator.cs rename WatchList.WPF/ViewModel/{DataReplaceMessageViewModel.cs => DataReplaceMessageVM.cs} (92%) create mode 100644 WatchList.WPF/ViewModel/ItemsView/AddCinemaViewModel.cs create mode 100644 WatchList.WPF/Views/CinemaView/AddCinemaWindow.xaml create mode 100644 WatchList.WPF/Views/CinemaView/AddCinemaWindow.xaml.cs diff --git a/WatchList.Core/Model/Load/Components/TypeLoadingCinema.cs b/WatchList.Core/Model/Load/Components/TypeLoadingCinema.cs index 88fb4ae..139a70c 100644 --- a/WatchList.Core/Model/Load/Components/TypeLoadingCinema.cs +++ b/WatchList.Core/Model/Load/Components/TypeLoadingCinema.cs @@ -3,7 +3,7 @@ namespace WatchList.Core.Model.Load.Components { - public class TypeLoadingCinema : SmartEnumBaseWrapper + public class TypeLoadingCinema : SmartEnumBaseWrapper, IEquatable { public static ObservableCollection GetItemsType = GetItems(TypeCinema.List, e => new TypeLoadingCinema(e)); @@ -13,6 +13,19 @@ public TypeLoadingCinema(TypeCinema? value = null) public override string Name => Value != null ? Value.Name : "All Type"; + public bool Equals(TypeLoadingCinema? other) + { + return ReferenceEquals(other, null) + ? false + : Value == other.Value && Name == other.Name; + } + + public override bool Equals(object? obj) + => Equals(obj as TypeLoadingCinema); + + public override int GetHashCode() + => HashCode.Combine(Name, Value); + public override string ToString() => Name; } } diff --git a/WatchList.Core/Model/Load/Grade.cs b/WatchList.Core/Model/Load/Grade.cs index 2adf68b..0632599 100644 --- a/WatchList.Core/Model/Load/Grade.cs +++ b/WatchList.Core/Model/Load/Grade.cs @@ -1,3 +1,4 @@ +using System.Collections.ObjectModel; using Ardalis.SmartEnum; using WatchList.Core.Enums; @@ -23,5 +24,8 @@ public Grade(string name, Grades grade) } public static Grade FromValue(Grades grade) => FromValue((int)grade); + + public static ObservableCollection GetItems() + => new ObservableCollection(List.OrderBy(x => x.Value)); } } diff --git a/WatchList.WPF/App.xaml b/WatchList.WPF/App.xaml index a3d60ed..d87614f 100644 --- a/WatchList.WPF/App.xaml +++ b/WatchList.WPF/App.xaml @@ -11,6 +11,9 @@ + + + diff --git a/WatchList.WPF/App.xaml.cs b/WatchList.WPF/App.xaml.cs index ded8593..e7113de 100644 --- a/WatchList.WPF/App.xaml.cs +++ b/WatchList.WPF/App.xaml.cs @@ -23,7 +23,8 @@ public App() var serviceCollection = new ServiceCollection(); ViewModelLocator.AddViewModels(serviceCollection) .AppServiceContainer() - .AppServicePageContainer(); + .AppServicePageContainer() + .AddSerilog(Log.Logger); _serviceProvider = serviceCollection.BuildServiceProvider(); } @@ -41,14 +42,13 @@ private void OnStartup(object sender, StartupEventArgs e) { Log.Fatal(ex, "Application terminated unexpectedly"); } - finally - { - Log.CloseAndFlush(); - } } private void OnExit(object sender, ExitEventArgs e) - => _serviceProvider.Dispose(); + { + _serviceProvider.Dispose(); + Log.CloseAndFlush(); + } private static Logger CreateLogger(string logDirectory = "log") { diff --git a/WatchList.WPF/Data/ViewModelLocator.cs b/WatchList.WPF/Data/ViewModelLocator.cs index e6e4583..d000013 100644 --- a/WatchList.WPF/Data/ViewModelLocator.cs +++ b/WatchList.WPF/Data/ViewModelLocator.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using WatchList.WPF.ViewModel; +using WatchList.WPF.ViewModel.ItemsView; namespace WatchList.WPF.Data { @@ -16,15 +17,18 @@ public CinemaPageViewModel CinemaPageViewModel public MergeDatabaseViewModel MergeDatabaseViewModel => _provider!.GetRequiredService(); - public DataReplaceMessageViewModel DataReplaceMessageViewModel - => _provider!.GetRequiredService(); + public DataReplaceMessageVM DataReplaceMessageVM + => _provider!.GetRequiredService(); + public AddCinemaViewModel AddCinemaViewModel + => _provider!.GetRequiredService(); public static IServiceCollection AddViewModels(ServiceCollection serviceCollection) => serviceCollection .AddTransient() .AddTransient() .AddTransient() - .AddTransient(); + .AddTransient() + .AddTransient(); public static void Init(ServiceProvider provider) => _provider = provider; } diff --git a/WatchList.WPF/Extension/AppServiceDIExtension.cs b/WatchList.WPF/Extension/AppServiceDIExtension.cs index 1a6675b..4b2dada 100644 --- a/WatchList.WPF/Extension/AppServiceDIExtension.cs +++ b/WatchList.WPF/Extension/AppServiceDIExtension.cs @@ -1,11 +1,12 @@ +using DevExpress.Mvvm.POCO; using Microsoft.Extensions.DependencyInjection; -using Serilog; using WatchList.Core.Repository; using WatchList.Core.Service; using WatchList.Core.Service.Component; using WatchList.Core.Service.DataLoading; using WatchList.Migrations.SQLite; using WatchList.WPF.Data; +using WatchList.WPF.Models; using WatchList.WPF.Models.Filter; using WatchList.WPF.Models.ModelDataLoad; using WatchList.WPF.Models.Sorter; @@ -21,15 +22,15 @@ public static IServiceCollection AppServiceContainer(this IServiceCollection ser .AddScoped(e => e.GetRequiredService().Create()) .AddScoped() .AddScoped() + .AddScoped() .AddScoped() .AddScoped() .AddScoped() .AddScoped() .AddSingleton() .AddScoped() - .AddScoped() - .AddLogging() - .AddSerilog(); + .AddScoped() + .AddLogging(); public static IServiceCollection AppServicePageContainer(this IServiceCollection serviceCollection) => serviceCollection.AddTransient() diff --git a/WatchList.WPF/Models/CinemaModel.cs b/WatchList.WPF/Models/CinemaModel.cs deleted file mode 100644 index a8f59d5..0000000 --- a/WatchList.WPF/Models/CinemaModel.cs +++ /dev/null @@ -1,100 +0,0 @@ -using DevExpress.Mvvm; -using WatchList.Core.Model.ItemCinema; -using WatchList.Core.Model.ItemCinema.Components; - -namespace WatchList.WPF.Models -{ - public class CinemaModel : BindableBase - { - private Guid _id; - private string _title; - private TypeCinema _type; - private int _sequel; - private StatusCinema _status; - private DateTime? _date; - private int? _grade; - - private CinemaModel(string title, decimal? sequel, DateTime? date, decimal? grade, StatusCinema status, TypeCinema type, Guid? id = null) - { - _id = id ?? Guid.NewGuid(); - _title = title ?? throw new ArgumentNullException(nameof(title)); - _sequel = sequel == null ? 0 : Convert.ToInt32((decimal)sequel); - _type = type; - _status = status; - _date = date; - _grade = grade != null ? Convert.ToInt32((decimal)grade) : null; - } - - public Guid Id - { - get => _id; - set => SetValue(ref _id, value); - } - - public string Title - { - get => _title; - set => SetValue(ref _title, value); - } - - public TypeCinema Type - { - get => _type; - set => SetValue(ref _type, value); - } - - public StatusCinema Status - { - get => _status; - set => SetValue(ref _status, value); - } - - public int Sequel - { - get => _sequel; - set => SetValue(ref _sequel, value); - } - - public DateTime? Date - { - get => _date; - set => SetValue(ref _date, value); - } - - public int? Grade - { - get => _grade; - set => SetValue(ref _grade, value); - } - - public static CinemaModel CreateNonPlanned( - string title, - decimal? sequel, - DateTime? date, - decimal? grade, - StatusCinema status, - TypeCinema type, - Guid? id = null) - => new CinemaModel(title, sequel, date, grade, status, type, id); - - public static CinemaModel CreatePlanned(string title, decimal? sequel, StatusCinema status, TypeCinema type, Guid? id) - => new CinemaModel(title, sequel, null, null, status, type, id); - - public WatchItem ToWatchItem() - => new WatchItem(Title, Sequel, Status, Type, Id, Date ?? null, Grade); - - public bool TryGetWatchDate(out DateTime date) - { - if (_status == StatusCinema.Viewed && Date != null) - { - date = Date.Value; - return true; - } - - date = default; - return false; - } - - public bool HasGrade() => _status != StatusCinema.Planned; - } -} diff --git a/WatchList.WPF/Models/ModelDataLoad/FiileLoaderDB.cs b/WatchList.WPF/Models/ModelDataLoad/FileLoaderDB.cs similarity index 89% rename from WatchList.WPF/Models/ModelDataLoad/FiileLoaderDB.cs rename to WatchList.WPF/Models/ModelDataLoad/FileLoaderDB.cs index 20e1696..7225612 100644 --- a/WatchList.WPF/Models/ModelDataLoad/FiileLoaderDB.cs +++ b/WatchList.WPF/Models/ModelDataLoad/FileLoaderDB.cs @@ -6,12 +6,12 @@ namespace WatchList.WPF.Models.ModelDataLoad { - public class FiileLoaderDB + public class FileLoaderDB { private readonly DownloadDataService _downloadDataService; private readonly ILogger _logger; - public FiileLoaderDB(DownloadDataService downloadDataService, ILogger logger) + public FileLoaderDB(DownloadDataService downloadDataService, ILogger logger) { _downloadDataService = downloadDataService; _logger = logger; diff --git a/WatchList.WPF/Models/ModelDataLoad/LoadModel/ModelDownloadMoreGrade.cs b/WatchList.WPF/Models/ModelDataLoad/LoadModel/ModelDownloadMoreGrade.cs deleted file mode 100644 index e14a416..0000000 --- a/WatchList.WPF/Models/ModelDataLoad/LoadModel/ModelDownloadMoreGrade.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.ObjectModel; -using DevExpress.Mvvm; -using WatchList.Core.Model.Load; - -namespace WatchList.WPF.Models.ModelDataLoad.LoadModel -{ - public class ModelDownloadMoreGrade : BindableBase - { - private Grade _value = Grade.AnyGrade; - - public ModelDownloadMoreGrade() - : this(Grade.AnyGrade) - { - } - - public ModelDownloadMoreGrade(Grade value) - => _value = value; - - public ObservableCollection Items { get; set; } - = new ObservableCollection(Grade.List.OrderBy(x => x.Value)); - - public Grade Value - { - get => _value; - set => SetValue(ref _value, value); - } - } -} diff --git a/WatchList.WPF/Models/ModelDataLoad/LoadModel/ModelTypeCinemaUpload.cs b/WatchList.WPF/Models/ModelDataLoad/LoadModel/ModelTypeCinemaUpload.cs deleted file mode 100644 index 2d01a7f..0000000 --- a/WatchList.WPF/Models/ModelDataLoad/LoadModel/ModelTypeCinemaUpload.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.ObjectModel; -using DevExpress.Mvvm; -using WatchList.Core.Model.Load.Components; - -namespace WatchList.WPF.Models.ModelDataLoad.LoadModel -{ - public class ModelTypeCinemaUpload : BindableBase - { - private TypeLoadingCinema _type = new TypeLoadingCinema(); - - public ModelTypeCinemaUpload() - : this(new TypeLoadingCinema()) - { - } - - public ModelTypeCinemaUpload(TypeLoadingCinema type) - => SelectedValue = type; - - public ObservableCollection Items { get; set; } - = TypeLoadingCinema.GetItemsType; - - public TypeLoadingCinema SelectedValue - { - get => _type; - set => SetValue(ref _type, value); - } - } -} diff --git a/WatchList.WPF/Models/WatchItemCreator.cs b/WatchList.WPF/Models/WatchItemCreator.cs new file mode 100644 index 0000000..3ebb8d4 --- /dev/null +++ b/WatchList.WPF/Models/WatchItemCreator.cs @@ -0,0 +1,30 @@ +using WatchList.Core.Model.ItemCinema; +using WatchList.Core.Model.ItemCinema.Components; + +namespace WatchList.WPF.Models +{ + public class WatchItemCreator + { + public WatchItemCreator() + { + } + + public WatchItem CreateNonPlanned( + string title, + int sequel, + StatusCinema status, + TypeCinema type, + DateTime? date = null, + int? grade = null, + Guid? id = null) + => new WatchItem(title, sequel, status, type, id, date, grade); + + public WatchItem CreatePlanned( + string title, + int sequel, + StatusCinema status, + TypeCinema type, + Guid? id) + => new WatchItem(title, sequel, status, type, id, null, null); + } +} diff --git a/WatchList.WPF/ViewModel/CinemaPageViewModel.cs b/WatchList.WPF/ViewModel/CinemaPageViewModel.cs index 3a72a6a..5e07b5a 100644 --- a/WatchList.WPF/ViewModel/CinemaPageViewModel.cs +++ b/WatchList.WPF/ViewModel/CinemaPageViewModel.cs @@ -14,6 +14,7 @@ using WatchList.WPF.Models.Filter; using WatchList.WPF.Models.Sorter; using WatchList.WPF.Views; +using WatchList.WPF.Views.CinemaView; namespace WatchList.WPF.ViewModel { @@ -70,7 +71,7 @@ public ObservableCollection WatchItems public string PageDisplayText => $"Page {CurPage} of {_pagedList.PageCount}"; - public List PageWatchItems { get; set; } + public List PageWatchItems { get; set; } public RelayCommandApp MoveToPreviousPage => new RelayCommandApp(async _ => await LoadDataAsyncPage(--Page.Number), _ => _pagedList.HasPreviousPage); @@ -82,9 +83,23 @@ public RelayCommandApp MoveToNextPage public RelayCommandApp MoveToLastPage => new RelayCommandApp(async _ => await LoadDataAsyncPage(_pagedList.PageCount), _ => _pagedList.HasNextPage); + public RelayCommandApp AddItemCommand + => new RelayCommandApp(async async => await MoveAddItem()); + public RelayCommandApp MoveAddDataDB => new RelayCommandApp(_ => new MergeDatabaseWindow().Show()); + private async Task MoveAddItem() + { + var addWindow = new AddCinemaWindow(); + if (addWindow.ShowDialog() != true) + { + return; + } + + await LoadDataAsync(); + } + /// /// Load data in table. /// diff --git a/WatchList.WPF/ViewModel/DataReplaceMessageViewModel.cs b/WatchList.WPF/ViewModel/DataReplaceMessageVM.cs similarity index 92% rename from WatchList.WPF/ViewModel/DataReplaceMessageViewModel.cs rename to WatchList.WPF/ViewModel/DataReplaceMessageVM.cs index fd90439..b0740df 100644 --- a/WatchList.WPF/ViewModel/DataReplaceMessageViewModel.cs +++ b/WatchList.WPF/ViewModel/DataReplaceMessageVM.cs @@ -5,13 +5,13 @@ namespace WatchList.WPF.ViewModel { - public class DataReplaceMessageViewModel + public class DataReplaceMessageVM { public const string Question = "The append item is a duplicate.Replace element?"; private readonly string _titleLabel; - public DataReplaceMessageViewModel(string titleItem, DialogReplaceQuestionManager questionResult) + public DataReplaceMessageVM(string titleItem, DialogReplaceQuestionManager questionResult) { _titleLabel = titleItem; ResultQuestion = questionResult; diff --git a/WatchList.WPF/ViewModel/ItemsView/AddCinemaViewModel.cs b/WatchList.WPF/ViewModel/ItemsView/AddCinemaViewModel.cs new file mode 100644 index 0000000..ebec83d --- /dev/null +++ b/WatchList.WPF/ViewModel/ItemsView/AddCinemaViewModel.cs @@ -0,0 +1,202 @@ +using System.Windows; +using CommunityToolkit.Mvvm.Input; +using DevExpress.Mvvm; +using WatchList.Core.Model.ItemCinema; +using WatchList.Core.Model.ItemCinema.Components; +using WatchList.Core.Repository; +using WatchList.Core.Service.Component; +using WatchList.WPF.Models; + +namespace WatchList.WPF.ViewModel.ItemsView +{ + public class AddCinemaViewModel : BindableBase + { + private readonly IMessageBox _messageBox; + private readonly WatchItemRepository _watchItemRepository; + private readonly WatchItemCreator _watchItemCreator; + + private bool _isWatch; + + private DateTime _maxDateWatched; + private DateTime _minDateWatched; + private string _labelSequelType; + + private Guid _id; + private string _title; + private TypeCinema _type; + private int _sequel; + private StatusCinema _status; + private DateTime? _date; + private int? _grade; + + public AddCinemaViewModel(IMessageBox messageBox, WatchItemRepository watchItemRepository, WatchItemCreator watchItemCreator) + : this(messageBox, watchItemRepository, watchItemCreator, null) + { + } + + public AddCinemaViewModel(IMessageBox messageBox, WatchItemRepository watchItemRepository, WatchItemCreator watchItemCreator, WatchItem? watchItem = null) + { + _messageBox = messageBox; + _watchItemRepository = watchItemRepository; + _watchItemCreator = watchItemCreator; + SetValueCinema(watchItem); + MaxDateWatched = DateTime.Now; + MinDateWatched = new DateTime(1945, 1, 1); + LabelSequelType = SelectedTypeCinema.TypeSequel; + AddItemCommand = new RelayCommand(MoveAddCinema); + SetDefoultValueCommand = new RelayCommand(SetDefaultValues); + CloseWindowCommand = new RelayCommand(CloseWindow); + } + + public DateTime MaxDateWatched + { + get => _maxDateWatched; + set => _maxDateWatched = value; + } + + public DateTime MinDateWatched + { + get => _minDateWatched; + set => _minDateWatched = value; + } + + public string LabelSequelType + { + get => _labelSequelType; + set => SetValue(ref _labelSequelType, value); + } + + public bool IsWatch + { + get => _isWatch; + set + { + SetGrade = value ? 1 : null; + SetDateTime = value ? DateTime.Now : null; + SetValue(ref _isWatch, value); + } + } + + public IEnumerable ListStatus => StatusCinema.List; + public IEnumerable ListType => TypeCinema.List; + + public RelayCommand AddItemCommand { get; private set; } + public RelayCommand SetDefoultValueCommand { get; private set; } + public RelayCommand CloseWindowCommand { get; private set; } + + public TypeCinema SelectedTypeCinema + { + get => _type; + set + { + LabelSequelType = value.TypeSequel; + SetValue(ref _type, value); + } + } + + public StatusCinema SelectedStatusCinema + { + get => _status; + set + { + IsWatch = value != StatusCinema.Planned ? true : false; + SetValue(ref _status, value); + } + } + public string SetTitle + { + get => _title; + set => SetValue(ref _title, value); + } + + public int? SetGrade + { + get => _grade; + set => SetValue(ref _grade, value); + } + + public DateTime? SetDateTime + { + get => _date; + set => SetValue(ref _date, value); + } + + public int SetSequel + { + get => _sequel; + set => SetValue(ref _sequel, value); + } + + public Guid SetId + { + get => _id; + set => SetValue(ref _id, value); + } + + private async void MoveAddCinema(Window currentWindowAdd) + { + if (!ValidateFields(out var errorMessage)) + { + await _messageBox.ShowWarning(errorMessage); + return; + } + + currentWindowAdd.DialogResult = true; + _watchItemRepository.Add(GetCinema()); + currentWindowAdd.Close(); + } + + private void CloseWindow(Window window) => window?.Close(); + + private void SetDefaultValues() + { + SetTitle = string.Empty; + SetSequel = 1; + SelectedTypeCinema = TypeCinema.Movie; + SelectedStatusCinema = StatusCinema.Planned; + } + + private bool ValidateFields(out string errorMessage) + { + if (SetTitle.Length <= 0) + { + errorMessage = $"Enter {SelectedTypeCinema.Name} title"; + return false; + } + else if (SetSequel == 0) + { + errorMessage = $"Enter number {SelectedTypeCinema.Name}"; + return false; + } + else if (SetGrade == 0) + { + errorMessage = "Grade cinema above in zero"; + return false; + } + + errorMessage = string.Empty; + return true; + } + + private void SetValueCinema(WatchItem? watchItem) + { + if (watchItem == null) + { + SetDefaultValues(); + return; + } + + SetId = watchItem.Id; + SetTitle = watchItem.Title; + SetGrade = watchItem.Grade; + SetDateTime = watchItem.Date; + SelectedStatusCinema = watchItem.Status; + SelectedTypeCinema = watchItem.Type; + } + + public WatchItem GetCinema() + => SelectedStatusCinema == StatusCinema.Planned + ? _watchItemCreator.CreatePlanned(SetTitle, SetSequel, SelectedStatusCinema, SelectedTypeCinema, SetId) + : _watchItemCreator.CreateNonPlanned(SetTitle, SetSequel, SelectedStatusCinema, SelectedTypeCinema, SetDateTime, SetGrade, SetId); + } +} diff --git a/WatchList.WPF/ViewModel/MergeDatabaseViewModel.cs b/WatchList.WPF/ViewModel/MergeDatabaseViewModel.cs index 72b4172..185552c 100644 --- a/WatchList.WPF/ViewModel/MergeDatabaseViewModel.cs +++ b/WatchList.WPF/ViewModel/MergeDatabaseViewModel.cs @@ -1,7 +1,6 @@ using System.Windows; using CommunityToolkit.Mvvm.Input; using DevExpress.Mvvm; -using WatchList.Core.Model.ItemCinema.Components; using WatchList.Core.Model.Load; using WatchList.Core.Model.Load.Components; using WatchList.Core.Model.Load.ItemActions; @@ -14,11 +13,11 @@ namespace WatchList.WPF.ViewModel { public class MergeDatabaseViewModel : BindableBase { - private readonly FiileLoaderDB _fiileLoader; + private readonly FileLoaderDB _fiileLoader; private readonly IMessageBox _messageBox; - private readonly ModelTypeCinemaUpload _modelTypeCinemaUpload = new ModelTypeCinemaUpload(); - private readonly ModelDownloadMoreGrade _modelDownloadMoreGrade = new ModelDownloadMoreGrade(); + private TypeLoadingCinema _selectTypeLoadCinema; + private Grade _selectGradeLoadCinema; private bool _isExistGrade; @@ -26,27 +25,26 @@ public class MergeDatabaseViewModel : BindableBase private bool _isUpdateDuplicateItem; private bool _isCaseSensitive; - public MergeDatabaseViewModel(IMessageBox messageBox, FiileLoaderDB fiileLoader) + public MergeDatabaseViewModel(IMessageBox messageBox, FileLoaderDB fiileLoader) { _messageBox = messageBox; _fiileLoader = fiileLoader; - SelectGradeLoadCinema = Grade.AnyGrade; - SelectTypeLoadCinema = new TypeLoadingCinema(); MergeDateFromDB = new RelayCommand(MoveLoadDB); CloseWindowCommand = new RelayCommand(CloseWindow); SetDefoultValueWindow = new RelayCommandApp(_ => SetupDefaultValues()); + SetupDefaultValues(); } public TypeLoadingCinema SelectTypeLoadCinema { - get => _modelTypeCinemaUpload.SelectedValue; - set => SetValue(_modelTypeCinemaUpload.SelectedValue); + get => _selectTypeLoadCinema; + set => SetValue(ref _selectTypeLoadCinema, value); } public Grade SelectGradeLoadCinema { - get => _modelDownloadMoreGrade.Value; - set => SetValue(_modelDownloadMoreGrade.Value); + get => _selectGradeLoadCinema; + set => SetValue(ref _selectGradeLoadCinema, value); } public bool IsExistGrade @@ -73,8 +71,8 @@ public bool IsCaseSensitive set => SetValue(ref _isCaseSensitive, value); } - public IEnumerable TypeLoadingCinemas => _modelTypeCinemaUpload.Items; - public IEnumerable GradeLoadingCinemas => _modelDownloadMoreGrade.Items; + public IEnumerable ListTypeLoadingCinema => TypeLoadingCinema.GetItemsType; + public IEnumerable GradeLoadingCinema => Grade.GetItems(); public RelayCommand MergeDateFromDB { get; private set; } public RelayCommand CloseWindowCommand { get; private set; } @@ -93,7 +91,7 @@ private async void MoveLoadDB(Window window) private void SetupDefaultValues() { - SelectTypeLoadCinema = new TypeLoadingCinema(TypeCinema.Movie); + SelectTypeLoadCinema = new TypeLoadingCinema(null); SelectGradeLoadCinema = Grade.AnyGrade; IsExistGrade = IsConsiderDuplicate = IsCaseSensitive = IsUpdateDuplicateItem = false; diff --git a/WatchList.WPF/Views/CinemaPage.xaml b/WatchList.WPF/Views/CinemaPage.xaml index b83c59c..24c77f2 100644 --- a/WatchList.WPF/Views/CinemaPage.xaml +++ b/WatchList.WPF/Views/CinemaPage.xaml @@ -54,6 +54,7 @@ MaxWidth="70" MaxHeight="45" HorizontalAlignment="Center" VerticalAlignment="Center" + Focusable="False" ><< diff --git a/WatchList.WPF/Views/CinemaView/AddCinemaWindow.xaml.cs b/WatchList.WPF/Views/CinemaView/AddCinemaWindow.xaml.cs new file mode 100644 index 0000000..989af0d --- /dev/null +++ b/WatchList.WPF/Views/CinemaView/AddCinemaWindow.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows; + +namespace WatchList.WPF.Views.CinemaView +{ + /// + /// Interaction logic for AddCinemaWindow.xaml + /// + public partial class AddCinemaWindow : Window + { + public AddCinemaWindow() + { + InitializeComponent(); + } + } +} diff --git a/WatchList.WPF/Views/MergeDatabaseWindow.xaml b/WatchList.WPF/Views/MergeDatabaseWindow.xaml index 1b2daa9..703cd2a 100644 --- a/WatchList.WPF/Views/MergeDatabaseWindow.xaml +++ b/WatchList.WPF/Views/MergeDatabaseWindow.xaml @@ -18,7 +18,7 @@ d:DesignHeight="240" d:DesignWidth="420" Title="Loading data" Foreground="Black" DataContext="{Binding MergeDatabaseViewModel, Source={StaticResource ViewModelLocator}}"> - + @@ -41,6 +41,7 @@ HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="8" + Margin="15" IsChecked="{Binding IsExistGrade, Mode=TwoWay}"/> + ItemsSource="{Binding GradeLoadingCinema}" + SelectedValue="{Binding SelectGradeLoadCinema, Mode=TwoWay}"/>