public AddButtonEntity(TagPresenter _tagPresenter) { TagPresenter = _tagPresenter; AddNewTag = new Command(new Action(() => { TagPresenter.Entities.Insert(TagPresenter.Entities.Count - 1, new NewTagEntity(_tagPresenter)); })); }
public NewTagEntity(TagPresenter _tagPresenter) { Text = new Observable <string>(); AutoCompleteCollection = _tagPresenter.AvailableTags; IsFocused = new Observable <bool>(); TakeFocusByForce = new Command(new Action(() => { IsFocused.Value = true; })); Submit = new Command(new Action(() => { _tagPresenter.Entities.Remove(this); var newTag = new TagEntity(Text.Value, _tagPresenter.Entities); _tagPresenter.Entities.Insert(_tagPresenter.Entities.Count - 1, newTag); newTag.NotifyPropertyChanged("Added"); //Have to call PropertyChanged after it's added to collection to route event to ListChanged with ItemChanged type })); Cancel = new Command(new Action(() => { _tagPresenter.Entities.Remove(this); })); }
private VideoDetailsPageViewModel() { #region DataAttributes EditMode = new Observable <bool>() { Value = false }; AliasError = new Observable <Visibility>() { Value = Visibility.Hidden }; SeriesError = new Observable <Visibility>() { Value = Visibility.Hidden }; SeriesAutoCompleteEntities = VideoAccesser.GetVideoSeriesAutoComplete(); AltSeriesAutoCompleteEntities = VideoAccesser.GetVideoAltSeriesAutoComplete(); Icon = new Observable <BitmapSource>(); Playlist = new Observable <bool>(); Favorite = new Observable <bool>(); VideoTags = new TagPresenter(); Alias = new Observable <string>(); Series = new Observable <string>(); Alt_Alias = new Observable <string>(); Alt_Series = new Observable <string>(); Duration = new Observable <string>(); Bitrate = new Observable <string>(); Frame = new Observable <string>(); Format = new Observable <string>(); FilePath = new Observable <string>(); FileName = new Observable <string>(); Extention = new Observable <string>(); FileSize = new Observable <string>(); Screenlist = new Observable <BitmapSource>(); LoadingIndicatorVisibility = new Observable <Visibility>() { Value = Visibility.Hidden }; LoadingIndicatorMax = new Observable <int>(); LoadingIndicatorCurrent = new Observable <int>(); #endregion #region Commands SwitchPlaylist = new Command(new Action(() => { Playlist.Value = !Playlist.Value; })); SwitchFavorite = new Command(new Action(() => { if (EditMode.Value) { Favorite.Value = !Favorite.Value; VideoAccesser.UpdateFavorite(vid, Favorite.Value); } })); RefreshMetadata = new Command(new Action(() => { var fileInfo = new FileInfo(FilePath.Value); var mediaInfo = MediaAccessor.GetMetaData(FilePath.Value); VideoAccesser.UpdateDuration(vid, mediaInfo.Metadata.Duration); Duration.Value = mediaInfo.Metadata.Duration.ToString(@"mm\:ss"); Bitrate.Value = Math.Round(fileInfo.Length / mediaInfo.Metadata.Duration.TotalSeconds).ToString() + "bps"; VideoAccesser.UpdateResolution(vid, mediaInfo.Metadata.VideoData.FrameSize); Frame.Value = mediaInfo.Metadata.VideoData.FrameSize; VideoAccesser.UpdateFormat(vid, mediaInfo.Metadata.VideoData.Format); Format.Value = mediaInfo.Metadata.VideoData.Format; })); RefreshFileInfo = new Command(new Action(() => { OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() == true) { var fileInfo = new FileInfo(dialog.FileName); VideoAccesser.UpdateFilePath(vid, fileInfo.FullName); FilePath.Value = fileInfo.FullName; VideoAccesser.UpdateFileName(vid, fileInfo.Name); FileName.Value = fileInfo.Name; VideoAccesser.UpdateFileExtention(vid, fileInfo.Extension); Extention.Value = fileInfo.Extension; VideoAccesser.UpdateFileSize(vid, fileInfo.Length); FileSize.Value = Math.Round(fileInfo.Length / 1048576d, 1).ToString() + "MB"; } })); RefreshScreenlist = new Command(new Action(() => { LoadingIndicatorVisibility.Value = Visibility.Visible; Task.Factory.StartNew(new Action(() => { var mediaInfo = MediaAccessor.GetMetaData(FilePath.Value); BitmapSource result = MediaAccessor.CreateGridScreenlist(mediaInfo, LoadingIndicatorCurrent, LoadingIndicatorMax); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { Screenlist.Value = result; })); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { LoadingIndicatorVisibility.Value = Visibility.Hidden; })); })); })); ShowScreenlist = new Command(new Action(() => { var viewer = new ScreenshotWindow(Screenlist.Value); viewer.Show(); viewer.Activate(); })); EnableEditMode = new Command(new Action(() => { EditMode.Value = true; })); SaveChanges = new Command(new Action(() => { EditMode.Value = false; Accesser.Instance.Commit(); })); RevertChanges = new Command(new Action(() => { EditMode.Value = false; Accesser.Instance.Rollback(); })); #endregion }