public PhotoListContext(StatusControlContext statusContext, PhotoListLoadMode photoListLoadMode)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            SortListCommand = new Command <string>(x => StatusContext.RunNonBlockingTask(() => SortList(x)));
            ToggleListSortDirectionCommand = new Command(() => StatusContext.RunNonBlockingTask(async() =>
            {
                SortDescending = !SortDescending;
                await SortList(_lastSortColumn);
            }));

            ToggleLoadRecentLoadAllCommand = new Command(x =>
            {
                if (LoadMode == PhotoListLoadMode.All)
                {
                    LoadMode = PhotoListLoadMode.Recent;
                    StatusContext.RunBlockingTask(LoadData);
                }
                else if (LoadMode == PhotoListLoadMode.Recent)
                {
                    LoadMode = PhotoListLoadMode.All;
                    StatusContext.RunBlockingTask(LoadData);
                }
            });

            LoadMode = photoListLoadMode;

            DataNotifications.DataNotificationChannel().MessageReceived += OnDataNotificationReceived;
        }
예제 #2
0
        public PhotoListContext(StatusControlContext statusContext, PhotoListLoadMode photoListLoadMode)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            DataNotificationsProcessor = new DataNotificationsWorkQueue {
                Processor = DataNotificationReceived
            };

            ViewImageCommand      = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(ViewImage);
            EditContentCommand    = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(EditContent);
            ApertureSearchCommand = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(async x =>
                                                                                           await RunReport(async() => await ApertureSearch(x), $"Aperture - {x.Aperture}"));
            LensSearchCommand = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(async x =>
                                                                                       await RunReport(async() => await LensSearch(x), $"Lens - {x.Lens}"));
            CameraMakeSearchCommand = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(async x =>
                                                                                             await RunReport(async() => await CamerMakeSearch(x), $"Camera Make - {x.CameraMake}"));
            CameraModelSearchCommand = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(async x =>
                                                                                              await RunReport(async() => await CameraModelSearch(x), $"Camera Model - {x.CameraModel}"));
            FocalLengthSearchCommand = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(async x =>
                                                                                              await RunReport(async() => await FocalLengthSearch(x), $"Focal Length - {x.FocalLength}"));
            IsoSearchCommand = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(async x =>
                                                                                      await RunReport(async() => await IsoSearch(x), $"Iso - {x.Iso}"));
            ShutterSpeedSearchCommand = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(async x =>
                                                                                               await RunReport(async() => await ShutterSpeedSearch(x), $"Shutter Speed - {x.ShutterSpeed}"));
            PhotoTakenOnSearchCommand = StatusContext.RunNonBlockingTaskCommand <PhotoContent>(async x =>
                                                                                               await RunReport(async() => await PhotoTakenOnSearch(x),
                                                                                                               $"Photo Created On - {x.PhotoCreatedOn.Date:D}"));


            SortListCommand = StatusContext.RunNonBlockingTaskCommand <string>(SortList);
            ToggleListSortDirectionCommand = StatusContext.RunNonBlockingTaskCommand(async() =>
            {
                SortDescending = !SortDescending;
                await SortList(_lastSortColumn);
            });

            ToggleLoadRecentLoadAllCommand = new Command(() =>
            {
                if (LoadMode == PhotoListLoadMode.All)
                {
                    LoadMode = PhotoListLoadMode.Recent;
                    StatusContext.RunBlockingTask(LoadData);
                }
                else if (LoadMode == PhotoListLoadMode.Recent)
                {
                    LoadMode = PhotoListLoadMode.All;
                    StatusContext.RunBlockingTask(LoadData);
                }
            });

            LoadMode = photoListLoadMode;
        }