public IImageInformation NextImage() { int currentIndex = fileInfos.FindIndex(tmpFileInfo => tmpFileInfo == CurrentLargeImage.fileInfo); if (currentIndex == -1) { return(null); } int nextIndex = currentIndex += 1; FileInfo nextFileInfo; try { nextFileInfo = fileInfos[nextIndex]; } catch (ArgumentOutOfRangeException ex) { return(null); } IImageInformation nextImage = new ImageInformation("testUid", nextFileInfo); CurrentLargeImage = nextImage; return(nextImage); }
public IImageInformation PreviousImage() { int currentIndex = fileInfos.FindIndex(tmpFileInfo => tmpFileInfo == CurrentLargeImage.fileInfo); if (currentIndex == -1) { return(null); } int previousIndex = currentIndex -= 1; FileInfo previousFileInfo; try { previousFileInfo = fileInfos[previousIndex]; } catch (ArgumentOutOfRangeException ex) { return(null); } IImageInformation previousImage = new ImageInformation("testUid", previousFileInfo); CurrentLargeImage = previousImage; return(previousImage); }
public virtual IEnumerable <IImageInformation> RetrieveImagesUpTo(IImageInformation image) { int index = fileInfos.FindIndex(tmp => tmp.FullName == image.fileInfo.FullName); int from = 0; int to = index + 1; return(RetrieveImages(from, to)); }
//private async void OnNewImage(IImageInformation imageInformation) //{ // await imageInformation.RetrieveThumb(); // Images.Add(imageInformation); // // Force this to run on UI thread because this method is called from events working on other threads // //await Application // // .Current // // ?.Dispatcher // // ?.BeginInvoke(new Action(() => // //{ // // Images.Add(imageInformation); // //})); //} private void cmdChooseImage(IImageInformation image) { if (image == null) { return; } imageRepositoryCache.CurrentLargeImage = image; NavigateToPage(AVAILABLE_PAGES.ViewImage, imageRepositoryCache); }
public void NextImage_null() { // Arrange IImageInformation[] imageInformations = imageRepositoryMediator.RetrieveImages(0, 3).ToArray(); imageRepositoryMediator.CurrentLargeImage = imageInformations[2]; // Act IImageInformation nullImage = imageRepositoryMediator.NextImage(); //Assert Assert.IsNull(nullImage); }
public void NextImage() { // Arrange IImageInformation[] imageInformations = imageRepositoryMediator.RetrieveImages(0, 3).ToArray(); imageRepositoryMediator.CurrentLargeImage = imageInformations[1]; // Act IImageInformation nextImage = imageRepositoryMediator.NextImage(); //Assert Assert.IsNotNull(nextImage); Assert.AreEqual(nextImage.fileInfo, imageInformations[2].fileInfo); }
public Unit2DTemplate(IImageInformation info, IImageMatrixListLoader loader) { ClassName = info.ClassName.Trim().ToUpper(); UnitName = info.UnitName.Trim().ToUpper(); Description = info.Description.Trim(); PhysicalCenter = info.PhysicalCenter; BlockingSize = info.BlockingSize; int animVCount = 0; Animations = new List <IImageAnimationInformation>(); Dictionary <string, IBitmapImageCollection> tmp = loader.ReadBitmapCollection(info); foreach (ImageAnimationInformation item in info.Animations) { Animations.Add((IImageAnimationInformation)tmp[item.AnimationName.Trim().ToUpper()]); animVCount = item.VariableCount; } UnitOrientation = new Orientation(animVCount); Actions = new Dictionary <string, IActions>(); }
public Dictionary <string, IBitmapImageCollection> ReadBitmapCollection(IImageInformation item) { Dictionary <string, IBitmapImageCollection> result = new Dictionary <string, IBitmapImageCollection>(); for (int k = 0; k < item.Animations.Count; k++) { AnimationBitmapInformation tmp = new AnimationBitmapInformation(item.Animations[k].AnimationCount, item.Animations[k].VariableCount); tmp.AnimationCount = item.Animations[k].AnimationCount; tmp.AnimationName = item.Animations[k].AnimationName; tmp.VariableCount = item.Animations[k].VariableCount; for (int i = 0; i < item.Animations[k].AnimationCount; i++) { for (int j = 0; j < item.Animations[k].VariableCount; j++) { string fileName = $"{RootPath}{item.ClassName}\\{item.UnitName}\\{item.Animations[k].AnimationName}\\{item.UnitName}_{item.Animations[k].AnimationName}_p{i}_v{j}.{Ext}"; tmp.Collection[i, j] = new Bitmap(fileName); } } result.Add(item.Animations[k].AnimationName.Trim().ToUpper(), tmp); } return(result); }
public override IEnumerable <IImageInformation> RetrieveImagesUpTo(IImageInformation image) { IEnumerable <IImageInformation> images = base.RetrieveImagesUpTo(image); IList <IImageInformation> imagesToReturn = new List <IImageInformation>(images.Count()); // Check if images exist in cache already, if not add them to cache foreach (var tmpImage in images) { if (DoesImageExistInCache(tmpImage) == false) { ImagesCache.Add(tmpImage); imagesToReturn.Add(tmpImage); } else { IImageInformation result = ImagesCache.Find(tmp => tmp.fileInfo.FullName == tmpImage.fileInfo.FullName); imagesToReturn.Add(result); } } return(imagesToReturn); }
private bool DoesImageExistInCache(IImageInformation image) { IImageInformation result = ImagesCache.Find(tmp => tmp.fileInfo.FullName == image.fileInfo.FullName); return(result == null ? false : true); }
public static IUnit2DTemplate Build(IImageInformation info, IImageMatrixListLoader loader) => info.ClassName switch { //"Background" => new ImageUnitTemplateBackground(info, loader), "ImageUnit" => new Unit2DTemplate(info, loader),