public ItemDetailsModel() { ItemBase = new ItemLibraryModel(); Item = new UserItem(); PaneBackground = new CafeineProperty <Brush>(new SolidColorBrush(Windows.UI.Colors.Transparent)); IsPaneOpened = new ReactiveProperty <bool>(false); IsPaneOpened.Subscribe((ipo) => { PaneBackground.Value = ipo ? Application.Current.Resources["SystemControlBackgroundChromeMediumLowBrush"] as SolidColorBrush : new SolidColorBrush(Windows.UI.Colors.Transparent); }); #region Set initial value ImageSource = new CafeineProperty <StorageFile>(); ItemDetailsProgressRing = new CafeineProperty <bool>(); LoadItemDetails = new ReactiveProperty <bool>(false); LoadItemDetails.Subscribe(x => ItemDetailsProgressRing.Value = !x); TitleTextBlock = new CafeineProperty <string>(); ScorePlaceHolderRating = new CafeineProperty <double>(); StatusTextBlock = new CafeineProperty <string>(); DescriptionTextBlock = new CafeineProperty <string>(); ScoreTextBlock = new CafeineProperty <string>(); Episodelist = new ObservableCollection <Episode>(); LoadEpisodeLists = new CafeineProperty <Visibility>(Visibility.Collapsed); LoadEpisodeSettings = new CafeineProperty <bool>(false); LoadEpisodeNotFound = new CafeineProperty <bool>(false); LoadEpisodesListConfiguration = new CafeineProperty <Visibility>(Visibility.Visible); SetAddButtonLoad = new CafeineProperty <bool>(false); SetDeleteButtonLoad = new ReactiveProperty <bool>(true); SetDeleteButtonLoad.Subscribe(sdb => { SetAddButtonLoad.Value = !sdb; }); #endregion #region TwoWay Initial Value TotalSeenTextBox = new CafeineProperty <int>(); UserStatusComboBox = new CafeineProperty <int>(); #endregion PlusOneTotalSeenTextBlock = new CafeineCommand(() => TotalSeenTextBox.Value += 1); EpisodeListsClicked = new CafeineCommand(() => { if (ItemBase.Episodes.Count == 0) { LoadEpisodeNotFound.Value = true; LoadEpisodeLists.Value = Visibility.Collapsed; } else { LoadEpisodeNotFound.Value = false; LoadEpisodeLists.Value = Visibility.Visible; } LoadEpisodeSettings.Value = false; LoadEpisodesListConfiguration.Value = Visibility.Visible; }); EpisodeSettingsClicked = new CafeineCommand(() => { LoadEpisodeLists.Value = Visibility.Collapsed; LoadEpisodeNotFound.Value = false; LoadEpisodeSettings.Value = true; LoadEpisodesListConfiguration.Value = Visibility.Collapsed; }); UserItemDetailsClicked = new CafeineCommand(() => IsPaneOpened.Value = !IsPaneOpened.Value); AddButtonClicked = new AsyncReactiveCommand(); AddButtonClicked.Subscribe(async _ => { await Database.AddItem(ItemBase); Item = ItemBase.Item; RaisePropertyChanged(nameof(Item)); SetDeleteButtonLoad.Value = true; }); DeleteButtonClicked = new AsyncReactiveCommand(); DeleteButtonClicked.Subscribe(async _ => { MessageDialog popup = new MessageDialog($"You are going to delete {Item.Title} from your list.\n" + $"Removing this item will also unlink your local directory in this item.\n" + $"Do you really want to Remove it?", $"Remove this item?"); popup.Commands.Add(new UICommand("Remove") { Id = 0 }); popup.Commands.Add(new UICommand("Cancel") { Id = 1 }); popup.DefaultCommandIndex = 0; popup.CancelCommandIndex = 1; var result = await popup.ShowAsync(); if ((int)result.Id == 0) { await Database.DeleteItem(ItemBase); await navigationService.GoBack(); } }); }
public ItemDetailsModel(ItemLibraryModel Item) : base() { }
public ItemLibraryModel SetItem(ItemLibraryModel item) { ItemBase = item; Item = ItemBase.Item; return(item); }