Esempio n. 1
0
        public MenuLinkEditorContext(StatusControlContext statusContext)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            AddItemCommand    = new Command(() => StatusContext.RunBlockingTask(AddItem));
            DeleteItemCommand = new Command(() => StatusContext.RunBlockingTask(DeleteItems));
            MoveItemUpCommand =
                new Command <MenuLinkListItem>(x => StatusContext.RunNonBlockingTask(() => MoveItemUp(x)));
            MoveItemDownCommand =
                new Command <MenuLinkListItem>(x => StatusContext.RunNonBlockingTask(() => MoveItemDown(x)));
            SaveCommand = new Command(x => StatusContext.RunNonBlockingTask(Save));
            InsertIndexTagIndexCommand = new Command <MenuLinkListItem>(x =>
                                                                        StatusContext.RunNonBlockingTask(() => InsertIntoLinkTag(x, "{{index; text Main;}}")));
            InsertTagSearchCommand = new Command <MenuLinkListItem>(x =>
                                                                    StatusContext.RunNonBlockingTask(() => InsertIntoLinkTag(x, "{{tagspage; text Tags;}}")));
            InsertPhotoGalleryCommand = new Command <MenuLinkListItem>(x =>
                                                                       StatusContext.RunNonBlockingTask(() => InsertIntoLinkTag(x, "{{photogallerypage; text Photos;}}")));
            InsertSearchPageCommand = new Command <MenuLinkListItem>(x =>
                                                                     StatusContext.RunNonBlockingTask(() => InsertIntoLinkTag(x, "{{searchpage; text Search;}}")));
            InsertLinkListCommand = new Command <MenuLinkListItem>(x =>
                                                                   StatusContext.RunNonBlockingTask(() => InsertIntoLinkTag(x, "{{linklistpage; text Links;}}")));

            HelpMarkdown = MenuLinksHelpMarkdown.HelpBlock;

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(LoadData);
        }
        public LinkStreamEditorContext(StatusControlContext statusContext, LinkStream linkContent,
                                       bool extractDataOnLoad = false)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            SaveUpdateDatabaseCommand = new Command(() =>
                                                    StatusContext.RunBlockingTask(() => SaveToDbWithValidation(StatusContext?.ProgressTracker())));
            SaveUpdateDatabaseAndCloseCommand = new Command(() =>
                                                            StatusContext.RunBlockingTask(() => SaveToDbWithValidationAndClose(StatusContext?.ProgressTracker())));
            ExtractDataCommand = new Command(() =>
                                             StatusContext.RunBlockingTask(() => ExtractDataFromLink(StatusContext?.ProgressTracker())));
            OpenUrlInBrowserCommand = new Command(() =>
            {
                try
                {
                    var ps = new ProcessStartInfo(LinkUrl)
                    {
                        UseShellExecute = true, Verb = "open"
                    };
                    Process.Start(ps);
                }
                catch (Exception e)
                {
                    StatusContext.ToastWarning($"Trouble opening link - {e.Message}");
                }
            });

            StatusContext.RunFireAndForgetTaskWithUiToastErrorReturn(async() =>
                                                                     await LoadData(linkContent, extractDataOnLoad));
        }
Esempio n. 3
0
        private LinkContentEditorContext(StatusControlContext statusContext)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            SaveCommand             = StatusContext.RunBlockingTaskCommand(async() => await SaveAndGenerateHtml(false));
            SaveAndCloseCommand     = StatusContext.RunBlockingTaskCommand(async() => await SaveAndGenerateHtml(true));
            ExtractDataCommand      = StatusContext.RunBlockingTaskCommand(ExtractDataFromLink);
            OpenUrlInBrowserCommand = StatusContext.RunNonBlockingActionCommand(() =>
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(LinkUrlEntry.UserValue))
                    {
                        StatusContext.ToastWarning("Link is Blank?");
                    }
                    var ps = new ProcessStartInfo(LinkUrlEntry.UserValue)
                    {
                        UseShellExecute = true, Verb = "open"
                    };
                    Process.Start(ps);
                }
                catch (Exception e)
                {
                    StatusContext.ToastWarning($"Trouble opening link - {e.Message}");
                }
            });
        }
Esempio n. 4
0
        public LinkStreamListContext(StatusControlContext statusContext)
        {
            StatusContext = statusContext ?? new StatusControlContext();

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

                Clipboard.SetText(x);

                StatusContext.ToastSuccess($"To Clipboard {x}");
            }));
            ListSelectedLinksNotOnPinboardCommand = new Command(x =>
                                                                StatusContext.RunBlockingTask(async() =>
                                                                                              await ListSelectedLinksNotOnPinboard(StatusContext.ProgressTracker())));

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(LoadData);

            DataNotifications.DataNotificationChannel().MessageReceived += OnDataNotificationReceived;
        }
 public TagsEditorContext(StatusControlContext statusContext, ITag dbEntry)
 {
     StatusContext = statusContext ?? new StatusControlContext();
     DbEntry       = dbEntry;
     Tags          = dbEntry?.Tags ?? string.Empty;
     Tags          = TagListString();
 }
        public TagListContext(StatusControlContext context)
        {
            StatusContext = context ?? new StatusControlContext();

            RefreshDataCommand     = new Command(() => StatusContext.RunBlockingTask(LoadData));
            TagDetailRenameCommand = new Command(() => StatusContext.RunBlockingTask(async() =>
            {
                await RenameTag();
                await LoadData();
            }));

            TagDetailRemoveCommand = new Command(() => StatusContext.RunBlockingTask(async() =>
            {
                await RemoveTag();
                await LoadData();
            }));

            TagsToClipboardCommand = new Command(() => StatusContext.RunBlockingTask(TagsToClipboard));
            ShowDetailsCommand     = new Command <TagListListItem>(x =>
                                                                   StatusContext.RunBlockingTask(async() => await ShowDetails(x)));
            EditContentCommand = new Command <object>(x =>
                                                      StatusContext.RunBlockingTask(async() => await EditContent(x)));

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(LoadData);
        }
 public ShowInMainSiteFeedEditorContext(StatusControlContext statusContext, IShowInSiteFeed dbEntry,
                                        bool defaultSetting)
 {
     StatusContext   = statusContext ?? new StatusControlContext();
     _defaultSetting = defaultSetting;
     StatusContext.RunFireAndForgetTaskWithUiToastErrorReturn(() => LoadData(dbEntry));
 }
        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;
        }
        public PhotoListWithActionsContext(StatusControlContext statusContext)
        {
            SetupContextAndCommands(statusContext);

            ListContext = new PhotoListContext(StatusContext, PhotoListContext.PhotoListLoadMode.Recent);

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(ListContext.LoadData);
        }
        public WindowAccidentalClosureHelper(Window toClose, StatusControlContext context, IHasUnsavedChanges toCheck)
        {
            StatusContext             = context;
            _hasUnsavedChangesToCheck = toCheck;
            _toClose = toClose;

            _toClose.Closing += FileContentEditorWindow_OnClosing;
        }
Esempio n. 11
0
        private FileContentEditorContext(StatusControlContext statusContext, FileInfo initialFile = null)
        {
            if (initialFile != null && initialFile.Exists)
            {
                _initialFile = initialFile;
            }

            SetupStatusContextAndCommands(statusContext);
        }
Esempio n. 12
0
        public FileContentEditorWindow(FileInfo initialFile)
        {
            InitializeComponent();
            StatusContext = new StatusControlContext();
            FileContent   = new FileContentEditorContext(StatusContext, initialFile);

            DataContext            = this;
            AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, FileContent);
        }
Esempio n. 13
0
        public PostContentEditorWindow(PostContent toLoad)
        {
            InitializeComponent();
            StatusContext = new StatusControlContext();
            PostContent   = new PostContentEditorContext(StatusContext, toLoad);

            DataContext            = this;
            AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, PostContent);
        }
 private TagsEditorContext(StatusControlContext statusContext, ITag dbEntry)
 {
     StatusContext = statusContext ?? new StatusControlContext();
     DbEntry       = dbEntry;
     HelpText      =
         "Comma separated tags - only a-z 0-9 _ - [space] are valid, each tag must be less than 200 characters long.";
     Tags = dbEntry?.Tags ?? string.Empty;
     Tags = TagListString();
 }
        public PhotoContentEditorContext(StatusControlContext statusContext, bool skipInitialLoad)
        {
            SetupContextAndCommands(statusContext);

            if (!skipInitialLoad)
            {
                StatusContext.RunFireAndForgetTaskWithUiToastErrorReturn(async() => await LoadData(null));
            }
        }
        public BodyContentEditorContext(StatusControlContext statusContext, IBodyContent dbEntry)
        {
            StatusContext = statusContext ?? new StatusControlContext();
            BodyContentFormat = new ContentFormatChooserContext(StatusContext);

            RemoveLineBreaksFromSelectedCommand =
                new Command(() => StatusContext.RunBlockingAction(RemoveLineBreaksFromSelected));

            StatusContext.RunFireAndForgetTaskWithUiToastErrorReturn(() => LoadData(dbEntry));
        }
Esempio n. 17
0
        public ImageContentEditorWindow(ImageContent toLoad)
        {
            InitializeComponent();

            StatusContext = new StatusControlContext();
            ImageEditor   = new ImageContentEditorContext(StatusContext, toLoad);

            DataContext            = this;
            AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, ImageEditor);
        }
        public PhotoContentEditorWindow(bool forAutomation)
        {
            InitializeComponent();

            StatusContext = new StatusControlContext();
            PhotoEditor   = new PhotoContentEditorContext(StatusContext, forAutomation);

            DataContext            = this;
            AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, PhotoEditor);
        }
        public PhotoContentEditorWindow(FileInfo initialPhoto)
        {
            InitializeComponent();

            StatusContext = new StatusControlContext();
            PhotoEditor   = new PhotoContentEditorContext(StatusContext, initialPhoto);

            DataContext            = this;
            AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, PhotoEditor);
        }
Esempio n. 20
0
        public SettingsFileChooserControlContext(StatusControlContext statusContext, string recentSettingFiles)
        {
            StatusContext           = statusContext ?? new StatusControlContext();
            RecentSettingFilesNames = recentSettingFiles?.Split("|").ToList() ?? new List <string>();

            NewFileCommand          = new Command(NewFile);
            ChooseFileCommand       = new Command(ChooseFile);
            ChooseRecentFileCommand = new Command <SettingsFileListItem>(LaunchRecentFile);

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(LoadData);
        }
        private NoteContentEditorContext(StatusControlContext statusContext)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            SaveCommand            = StatusContext.RunBlockingTaskCommand(async() => await SaveAndGenerateHtml(false));
            SaveAndCloseCommand    = StatusContext.RunBlockingTaskCommand(async() => await SaveAndGenerateHtml(true));
            ViewOnSiteCommand      = StatusContext.RunBlockingTaskCommand(ViewOnSite);
            ExtractNewLinksCommand = StatusContext.RunBlockingTaskCommand(() =>
                                                                          LinkExtraction.ExtractNewAndShowLinkContentEditors(BodyContent.BodyContent,
                                                                                                                             StatusContext.ProgressTracker()));
        }
Esempio n. 22
0
        public LinkStreamEditorWindow(LinkStream toLoad, bool extractDataFromLink = false)
        {
            InitializeComponent();
            StatusContext = new StatusControlContext();
            EditorContent = new LinkStreamEditorContext(StatusContext, toLoad, extractDataFromLink);

            EditorContent.RequestLinkStreamEditorWindowClose += (sender, args) => { Dispatcher?.Invoke(Close); };

            DataContext            = this;
            AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, EditorContent);
        }
        public ImageContentEditorContext(StatusControlContext statusContext, FileInfo initialImage)
        {
            SetupContextAndCommands(statusContext);

            if (initialImage != null && initialImage.Exists)
            {
                _initialImage = initialImage;
            }

            StatusContext.RunFireAndForgetTaskWithUiToastErrorReturn(async() => await LoadData(null));
        }
Esempio n. 24
0
        public TagExclusionEditorContext(StatusControlContext statusContext)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            HelpMarkdown      = TagExclusionHelpMarkdown.HelpBlock;
            AddNewItemCommand = StatusContext.RunBlockingTaskCommand(async() => await AddNewItem());
            SaveItemCommand   = StatusContext.RunNonBlockingTaskCommand <TagExclusionEditorListItem>(SaveItem);
            DeleteItemCommand = StatusContext.RunNonBlockingTaskCommand <TagExclusionEditorListItem>(DeleteItem);

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(LoadData);
        }
        public PhotoContentEditorContext(StatusControlContext statusContext, FileInfo initialPhoto)
        {
            if (initialPhoto != null && initialPhoto.Exists)
            {
                _initialPhoto = initialPhoto;
            }

            SetupContextAndCommands(statusContext);

            StatusContext.RunFireAndForgetTaskWithUiToastErrorReturn(async() => await LoadData(null));
        }
        public static async Task AllPhotoMetadataToHtml(FileInfo selectedFile, StatusControlContext statusContext)
        {
            await ThreadSwitcher.ResumeBackgroundAsync();

            if (selectedFile == null)
            {
                statusContext.ToastError("No photo...");
                return;
            }

            selectedFile.Refresh();

            if (!selectedFile.Exists)
            {
                statusContext.ToastError($"File {selectedFile.FullName} doesn't exist?");
                return;
            }

            var photoMetaTags = ImageMetadataReader.ReadMetadata(selectedFile.FullName);

            var tagHtml = photoMetaTags.SelectMany(x => x.Tags).OrderBy(x => x.DirectoryName).ThenBy(x => x.Name)
                          .ToList().Select(x => new
            {
                DataType = x.Type.ToString(),
                x.DirectoryName,
                Tag      = x.Name,
                TagValue = ObjectDumper.Dump(x.Description)
            }).ToHtmlTable(new { @class = "pure-table pure-table-striped" });

            var xmpDirectory = ImageMetadataReader.ReadMetadata(selectedFile.FullName).OfType <XmpDirectory>()
                               .FirstOrDefault();

            var xmpMetadata = xmpDirectory?.GetXmpProperties().Select(x => new { XmpKey = x.Key, XmpValue = x.Value })
                              .ToHtmlTable(new { @class = "pure-table pure-table-striped" });

            await ThreadSwitcher.ResumeForegroundAsync();

            var file = new FileInfo(Path.Combine(UserSettingsUtilities.TempStorageDirectory().FullName,
                                                 $"PhotoMetadata-{Path.GetFileNameWithoutExtension(selectedFile.Name)}-{DateTime.Now:yyyy-MM-dd---HH-mm-ss}.htm"));

            var htmlString =
                ($"<h1>Metadata Report:</h1><h1>{HttpUtility.HtmlEncode(selectedFile.FullName)}</h1><br><h1>Metadata - Part 1</h1><br>" +
                 tagHtml + "<br><br><h1>XMP - Part 2</h1><br>" + xmpMetadata)
                .ToHtmlDocumentWithPureCss("Photo Metadata", "body {margin: 12px;}");

            await File.WriteAllTextAsync(file.FullName, htmlString);

            var ps = new ProcessStartInfo(file.FullName)
            {
                UseShellExecute = true, Verb = "open"
            };

            Process.Start(ps);
        }
Esempio n. 27
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;
        }
Esempio n. 28
0
        public S3DeletionsWindow(List <S3DeletionsItem> itemsToDelete)
        {
            InitializeComponent();

            _statusContext = new StatusControlContext();

            DataContext = this;

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(async() =>
            {
                DeletionContext = await S3DeletionsContext.CreateInstance(StatusContext, itemsToDelete);
            });
        }
        public NoteContentEditorContext(StatusControlContext statusContext, NoteContent noteContent)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            SaveAndCreateLocalCommand = new Command(() => StatusContext.RunBlockingTask(SaveAndCreateLocal));
            SaveUpdateDatabaseCommand = new Command(() => StatusContext.RunBlockingTask(SaveToDbWithValidation));
            ViewOnSiteCommand         = new Command(() => StatusContext.RunBlockingTask(ViewOnSite));
            ExtractNewLinksCommand    = new Command(() => StatusContext.RunBlockingTask(() =>
                                                                                        LinkExtraction.ExtractNewAndShowLinkStreamEditors(BodyContent.BodyContent,
                                                                                                                                          StatusContext.ProgressTracker())));

            StatusContext.RunFireAndForgetTaskWithUiToastErrorReturn(async() => await LoadData(noteContent));
        }
        public S3UploadsWindow(List <S3Upload> toLoad)
        {
            InitializeComponent();

            _statusContext = new StatusControlContext();

            DataContext = this;

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(async() =>
            {
                UploadContext = await S3UploadsContext.CreateInstance(StatusContext, toLoad);
            });
        }