public StreamPage() { this.InitializeComponent(); var strategy = new HighlightStrategy(12, new List<int> { 0, 7 }); _viewModel = new StreamPageViewModel(strategy); DataContext = _viewModel; _timer.Tick += DispatcherTimer_Tick; Mosaic.LayoutUpdated += Mosaic_LayoutUpdated; }
public StreamPageViewModel(HighlightStrategy highlightStrategy) { HighlightStrategy = highlightStrategy; Thumbnails = new ObservableCollection<ThumbnailViewModel>(); GoBackCommand = CommandFactory.CreateGoBackCommand(); SelectPhotoCommand = new DelegateCommand((parameter) => { var viewModel = (ThumbnailViewModel)parameter; try { var copy = new FilteredPhotoModel(viewModel.Model); SessionModel.Instance.Photo = copy; var frame = (Frame)Window.Current.Content; frame.Navigate(typeof(PhotoPage)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("SelectPhotoCommand failed: " + ex.Message + '\n' + ex.StackTrace); } }); #if WINDOWS_PHONE_APP OpenPhotoCommand = new DelegateCommand( (parameter) => { StartOpenPhotoFile(); }); #else OpenPhotoCommand = new DelegateCommand( async (parameter) => { var file = await PickPhotoFileAsync(); if (file != null) { SessionModel.Instance.Photo = new FilteredPhotoModel(file); var frame = (Frame)Window.Current.Content; frame.Navigate(typeof(PhotoPage)); } }); #endif #if WINDOWS_PHONE_APP OpenFolderCommand = new DelegateCommand( (parameter) => { StartOpenPhotoFolder(); }); #else OpenFolderCommand = new DelegateCommand( async (parameter) => { var folder = await PickPhotoFolderAsync(); if (folder != null && (SessionModel.Instance.Folder == null || folder.Path != SessionModel.Instance.Folder.Path)) { SessionModel.Instance.Folder = folder; await Refresh(); } }); #endif #if !WINDOWS_PHONE_APP CapturePhotoCommand = new DelegateCommand( async (parameter) => { var file = await CapturePhotoFileAsync(); if (file != null) { SessionModel.Instance.Photo = new FilteredPhotoModel(file); var frame = (Frame)Window.Current.Content; frame.Navigate(typeof(PhotoPage)); } }); #endif #if WINDOWS_PHONE_APP ShowAboutCommand = new DelegateCommand((parameter) => { var frame = (Frame)Window.Current.Content; frame.Navigate(typeof(AboutPage)); }); #endif RefreshPhotosCommand = new DelegateCommand( async (parameter) => { await Refresh(); }, () => { return !Processing; }); RefreshSomePhotosCommand = new DelegateCommand( (parameter) => { RefreshSome(); }, () => { return !Processing; }); ChangeHighlightStrategyCommand = new DelegateCommand( async (parameter) => { HighlightStrategy = parameter as HighlightStrategy; await Refresh(); }, () => { return !Processing; }); }