public Bookmark AddBookmark(string parentFolderId, string boookmarkName, ImageReferenceElement imgRef)
        {
            BookmarkFolder parentFolder = GetBookmarkFolderById(_bookmarkContainer.RootFolder, parentFolderId);

            if (parentFolder == null)
            {
                return(null);
            }

            var bookmark = new Bookmark
            {
                BoookmarkName  = boookmarkName,
                CompletePath   = imgRef.CompletePath,
                CreationTime   = imgRef.CreationTime,
                Directory      = imgRef.Directory,
                FileName       = imgRef.FileName,
                LastAccessTime = imgRef.LastAccessTime,
                LastWriteTime  = imgRef.LastWriteTime,
                Size           = imgRef.Size,
                SortOrder      = parentFolder.Bookmarks.Count,
                ParentFolderId = parentFolder.Id
            };

            parentFolder.Bookmarks.Add(bookmark);
            BookmarkUpdated(new BookmarkUpdatedEventArgs(BookmarkActions.CreatedBookmark, typeof(Bookmark)));
            return(bookmark);
        }
Exemple #2
0
        private void LoadNewImageFile(ImageReferenceElement imageReference)
        {
            try
            {
                _currentImage = _imageCache.GetImageFromCache(imageReference.CompletePath);

                _imgx = 0;
                _imgy = 0;
                ResetZoom(true);

                pictureBox.Refresh();
                Text = imageReference.FileName;

                //Notify observers
                _imagesViewed++;
                _imageViewFormInfo = new ImageViewFormImageInfo(this, imageReference.FileName, _imagesViewed);
                foreach (var observer in _observers)
                {
                    observer.OnNext(_imageViewFormInfo);
                }

                Log.Verbose("New Image loaded in ImageViewForm FormId = " + FormId);
            }
            catch (Exception ex)
            {
                Log.Error(ex, imageReference != null
                    ? $"FormMain.LoadNewImageFile(string imagePath) Error when trying to load file: {imageReference.CompletePath} : {ex.Message}"
                    : "imgRef was null in FormImageView.LoadNewImageFile()", ex);
            }
        }
 public CreateBookmarkFolder(BookmarkService bookmarkService, BookmarkManager bookmarkManager, ImageReferenceElement imageReference)
 {
     _bookmarkManager = bookmarkManager;
     _imageReference  = imageReference;
     _bookmarkService = bookmarkService;
     InitializeComponent();
 }
Exemple #4
0
 public FormAddBookmarkWithNewFolder(ImageReferenceElement imageReference, BookmarkService bookmarkService, BookmarkManager bookmarkManager)
 {
     _imageReference    = imageReference;
     _bookmarkService   = bookmarkService;
     _bookmarkManager   = bookmarkManager;
     rootBookmarkFolder = _bookmarkManager.RootFolder;
     InitializeComponent();
 }
 private bool CompareBookmarkToImgRef(Bookmark bookmark, ImageReferenceElement imageReference)
 {
     return(imageReference.Size == bookmark.Size &&
            imageReference.CompletePath == bookmark.CompletePath &&
            imageReference.CreationTime == bookmark.CreationTime &&
            imageReference.Directory == bookmark.Directory &&
            imageReference.FileName == bookmark.FileName &&
            imageReference.LastAccessTime == bookmark.LastAccessTime &&
            imageReference.LastWriteTime == bookmark.LastWriteTime);
 }
Exemple #6
0
        private void SetPreviousImage()
        {
            if (!ImageSourceDataAvailable)
            {
                //Try SetImageReference collection
                SetImageReferenceCollection();
                return;
            }

            _imgRef = _imageReferenceCollection.GetPreviousImage();
            LoadNewImageFile(_imgRef);
        }
Exemple #7
0
        private void FormImageView_Load(object sender, EventArgs e)
        {
            //pictureBox.BackColor = _applicationSettingsService.Settings.MainWindowBackgroundColor.ToColor();
            ShowInTaskbar = _applicationSettingsService.Settings.ShowImageViewFormsInTaskBar;
            SetImageReferenceCollection();
            if (!ImageSourceDataAvailable)
            {
                return;
            }

            _imgRef = _imageReferenceCollection.GetNextImage();
            LoadNewImageFile(_imgRef);
        }
Exemple #8
0
        private void menuItemBookmark_Click(object sender, EventArgs e)
        {
            var fi     = new FileInfo(_maximizedImgFilename);
            var imgRef = new ImageReferenceElement
            {
                CompletePath   = _maximizedImgFilename,
                Size           = fi.Length,
                CreationTime   = fi.CreationTime,
                LastAccessTime = fi.LastAccessTime,
                LastWriteTime  = fi.LastWriteTime,
                FileName       = fi.Name,
                Directory      = fi.DirectoryName
            };

            _formAddBookmark.Init(contextMenuFullSizeImg.Location, imgRef);
            _formAddBookmark.ShowDialog(this);
        }
        public static void BookmarkStorageInitialize(TestContext testContext)
        {
            GlobalSettings.UnitTestInitialize(TestDataPath);
            ApplicationBuildConfig.SetOverrideUserDataPath(TestDataPath);

            _genericImageRef = new ImageReferenceElement
            {
                Directory      = TestDataPath,
                FileName       = "testImage.jpg",
                CreationTime   = DateTime.Now,
                Size           = 1024,
                LastAccessTime = DateTime.Now.Date,
                LastWriteTime  = DateTime.Now.Date
            };
            _genericImageRef.CompletePath = Path.Combine(_genericImageRef.Directory, _genericImageRef.FileName);

            _container = ContainerFactory.CreateGenericContainerForApp();
            _scope     = _container.BeginLifetimeScope();
        }
        public Bookmark InsertBookmark(string parentFolderId, string boookmarkName, ImageReferenceElement imgRef, int index)
        {
            BookmarkFolder parentFolder = GetBookmarkFolderById(_bookmarkContainer.RootFolder, parentFolderId);

            if (parentFolder == null)
            {
                return(null);
            }

            if (index < 0 || index > parentFolder.Bookmarks.Count)
            {
                return(null);
            }

            var bookmark = new Bookmark
            {
                BoookmarkName  = boookmarkName,
                CompletePath   = imgRef.CompletePath,
                CreationTime   = imgRef.CreationTime,
                Directory      = imgRef.Directory,
                FileName       = imgRef.FileName,
                LastAccessTime = imgRef.LastAccessTime,
                LastWriteTime  = imgRef.LastWriteTime,
                Size           = imgRef.Size,
                SortOrder      = index,
                ParentFolderId = parentFolder.Id
            };

            var postItems = parentFolder.Bookmarks.Where(b => b.SortOrder >= index).OrderBy(b => b.SortOrder).ToList();

            foreach (Bookmark item in postItems)
            {
                item.SortOrder = item.SortOrder + 1;
            }

            parentFolder.Bookmarks.Add(bookmark);
            parentFolder.Bookmarks.Sort((b1, b2) => b1.SortOrder.CompareTo(b2.SortOrder));
            BookmarkUpdated(new BookmarkUpdatedEventArgs(BookmarkActions.CreatedBookmark, typeof(Bookmark)));
            return(bookmark);
        }
 public void Init(Point startupPosition, ImageReferenceElement imageReference)
 {
     SetDesktopLocation(startupPosition.X, startupPosition.Y);
     _imageReference = imageReference;
 }