示例#1
0
        private void SelectContentInContentManager(ContentIconAndName content)
        {
            var type = service.GetTypeOfContent(content.Name);

            if (type == ContentType.ImageAnimation)
            {
                var newAnimation = ContentLoader.Load <ImageAnimation>(content.Name);
                AnimationName = content.Name;
                var imageNames = newAnimation.MetaData.Get("ImageNames", "").SplitAndTrim(',');
                ImageList.Clear();
                foreach (var imageName in imageNames)
                {
                    ImageList.Add(imageName);
                }
                Duration = float.Parse(newAnimation.MetaData.Get("DefaultDuration", ""));
            }
            if (type == ContentType.SpriteSheetAnimation)
            {
                var spritesheet = ContentLoader.Load <SpriteSheetAnimation>(content.Name);
                AnimationName = content.Name;
                var imageNames = spritesheet.MetaData.Get("ImageName", "").SplitAndTrim(',');
                ImageList.Clear();
                foreach (var imageName in imageNames)
                {
                    ImageList.Add(imageName);
                }
                Duration     = float.Parse(animation.MetaData.Get("DefaultDuration", ""));
                SubImageSize = spritesheet.MetaData.Get("SubImageSize", Size.Zero);
            }
        }
示例#2
0
        private void InitializeData()
        {
            for (int i = 1; i <= ImageCount; i++)
            {
                int id    = i;
                var order = EnumOrder.Next;
                if (id < NowPageIndex)
                {
                    order = EnumOrder.Prev;
                }
                else if (id == NowPageIndex)
                {
                    order = EnumOrder.Center;
                }

                var model = new ImageListModel
                {
                    Id = id,
                    //Index = i.ToString(),
                    Order = order,
                };
                //model.Loaded += ModelLoaded;
                ImageList.Add(model);
            }
        }
 private void GenerateImageList()
 {
     ImageList.Add(new BitmapImage(new Uri("../Images/Avatar1.jpg", UriKind.Relative)));
     ImageList.Add(new BitmapImage(new Uri("../Images/Avatar2.png", UriKind.Relative)));
     ImageList.Add(new BitmapImage(new Uri("../Images/Avatar3.png", UriKind.Relative)));
     ImageList.Add(new BitmapImage(new Uri("../Images/Avatar4.png", UriKind.Relative)));
 }
示例#4
0
        private async void OpenImageFolder()
        {
            var source = _uiService.OpenFolderDialog();

            if (string.IsNullOrEmpty(source))
            {
                return;
            }

            var prevImageList = new List <PrevImage>();
            await Task.Factory.StartNew(() => {
                var filters = new[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp" };
                var files   = FileUtils.GetFilesFrom(source, filters, true);
                foreach (var image in files.Select(x => new Models.PrevImage(x)))
                {
                    prevImageList.Add(image);
                }
            });

            if (!prevImageList.Any())
            {
                _uiService.ShowError(Constants.MissingImage);
                return;
            }
            else
            {
                ImageList.Clear();
                foreach (var image in prevImageList)
                {
                    ImageList.Add(image);
                }
                RefreshCommands();
            }
        }
        public void LoadData()
        {
            if (RunState)
            {
                return;
            }
            RunState = true;
            PageIndex++;
            //加载第一页数据
            API.MainPage(PageIndex, new Action <List <Image>, int>((list, pageSize) =>
            {
                //homePage.Dispatcher.Invoke();
                if (!Waterfall)//瀑布
                {
                    Execute.OnUIThread(() => { ImageList.Clear(); });
                }

                foreach (var item in list)
                {
                    Execute.OnUIThread(() => { ImageList.Add(item); });
                }
                Thread.Sleep(500);

                Execute.OnUIThread(() => { PageCount = pageSize; });

                RunState = false;
            }), new Action <Exception>((ex) =>
            {
                Execute.OnUIThread(() => { PageIndex--; });
                RunState = false;
            }));
        }
示例#6
0
        private void loadImages()
        {
            Singleton.getDialogueBox().showSearch(ConfigurationManager.AppSettings["load_message"]);
            Dispose();
            ImageList.Clear();

            //----[ Bill Image ]
            // get invoice image and create listener on image info change
            _billImageDisplay.PropertyChanged += onFilePathChange_updateUIImage;
            _billImageDisplay.PropertyChanged += onImageInfoChange;
            ImageList.Add(_billImageDisplay);

            //----[ Logo Image ]
            // get logo image and create listener on image info change
            _logoImageDisplay.PropertyChanged += onFilePathChange_updateUIImage;
            _logoImageDisplay.PropertyChanged += onImageInfoChange;
            ImageList.Add(_logoImageDisplay);

            //----[ Header Image ]
            // get header image and create listener on image info change
            _headerImageDisplay.PropertyChanged += onFilePathChange_updateUIImage;
            _headerImageDisplay.PropertyChanged += onImageInfoChange;
            ImageList.Add(_headerImageDisplay);

            Singleton.getDialogueBox().IsDialogOpen = false;
        }
示例#7
0
 public void AddImage(object image, int max = 0)
 {
     ImageList.Add(image);
     if (max > 0 && ImageList.Count > max)
     {
         ImageList.RemoveAt(1);
     }
 }
示例#8
0
        private void AbsDiff()
        {
            BinaryOperationImageViewModel imageViewModel = new BinaryOperationImageViewModel(ImageType.ABS_DIFF);

            imageViewModel.AbsDiff(_leftImageViewModel.ImageSource, _rightImageViewModel.ImageSource);
            ImageList.Add(imageViewModel);
            SelectedImage = imageViewModel;
        }
示例#9
0
        private void WeightedSum()
        {
            BinaryOperationImageViewModel weightedSumImageViewModel = new BinaryOperationImageViewModel(ImageType.WEIGHTED_SUM);

            weightedSumImageViewModel.AddWeightedImages(_leftImageViewModel.ImageSource, _rightImageViewModel.ImageSource, 0.5, 0.5);
            ImageList.Add(weightedSumImageViewModel);
            SelectedImage = weightedSumImageViewModel;
        }
示例#10
0
        private void Subtract()
        {
            BinaryOperationImageViewModel imageViewModel = new BinaryOperationImageViewModel(ImageType.SUBTRACT);

            imageViewModel.SubtractImage(_leftImageViewModel.ImageSource, _rightImageViewModel.ImageSource);
            ImageList.Add(imageViewModel);
            SelectedImage = imageViewModel;
        }
示例#11
0
    private void AddImageUrl(string directory)
    {
        DirectoryInfo info = new DirectoryInfo(MapPath(directory));

        foreach (FileInfo fi in info.GetFiles())
        {
            ImageList.Add("~/" + info.Name + "/" + fi.Name);
        }
    }
示例#12
0
        public void AddRandomImage()
        {
            Random rnd = new Random();
            int    x   = rnd.Next(100, 1000);
            int    y   = rnd.Next(100, 600);

            Bitmap image = new Bitmap(new Bitmap("image.jpg"));

            ImageList.Add(image);
        }
示例#13
0
 private void AddToCollection(List <ImageListJson> list)
 {
     foreach (var image in list)
     {
         ImageList.Add(new ImageList
         {
             Name  = image.Name,
             Image = ImageSource.FromFile(image.ImageSource)
         });
     }
 }
示例#14
0
        private void GetStaticImageList()
        {
            var il = new ImageHelper();

            GlobalSettings.ImagePath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            ImageList = il.CheckForImagesForDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), GlobalSettings);
            if (!ImageList.Any())
            {
                ImageList.Add(@"../Empty.png");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="posts"></param>
        private void GenerateImageListForDownload(HashSet <TumblrPost> posts)
        {
            try
            {
                foreach (var tumblrPost in posts)
                {
                    var post = (PhotoPost)tumblrPost;
                    if (!ParsePhotoSets && post.Photos.Count > 1)
                    {
                        // do not parse images from photoset
                    }
                    else
                    {
                        foreach (PhotoPostImage image in post.Photos)
                        {
                            try
                            {
                                ImageList.Add(image);
                            }
                            catch
                            {
                                return;
                            }
                        }
                    }
                }

                if (ImageList.Count > 0)
                {
                    HashSet <PhotoPostImage> removeHash = new HashSet <PhotoPostImage>();

                    if (!ParseGif)
                    {
                        removeHash.UnionWith(new HashSet <PhotoPostImage>((from p in ImageList where p.Filename.ToLower().EndsWith(".gif", StringComparison.Ordinal) select p)));
                    }

                    if (!ParseJpeg)
                    {
                        removeHash.UnionWith(new HashSet <PhotoPostImage>((from p in ImageList where p.Filename.ToLower().EndsWith(".jpg", StringComparison.Ordinal) || p.Filename.ToLower().EndsWith(".jpeg", StringComparison.Ordinal) select p)));
                    }

                    if (!ParsePng)
                    {
                        removeHash.UnionWith(new HashSet <PhotoPostImage>((from p in ImageList where p.Filename.ToLower().EndsWith(".png", StringComparison.Ordinal) select p)));
                    }

                    ImageList.RemoveWhere(x => removeHash.Contains(x));
                }
            }
            catch
            {
                //ignored
            }
        }
 public void RefreshOnAddedContent(ContentType type, string name)
 {
     if (type == ContentType.Material && !MaterialList.Contains(name))
     {
         MaterialList.Add(name);
     }
     if ((type == ContentType.Image || type == ContentType.ImageAnimation ||
          type == ContentType.SpriteSheetAnimation) && !ImageList.Contains(name))
     {
         ImageList.Add(name);
     }
 }
示例#17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="image"></param>
        public override void LoadImage(Image image)
        {
            // create a list with one texture to pass it in to the common loading method
            ImageList images = new ImageList();

            images.Add(image);

            // load this image
            LoadImages(images);

            // clear the temp list of images
            images.Clear();
        }
示例#18
0
 public void AddImage(string obj)
 {
     if (selectedImage == null)
     {
         return;
     }
     IsDisplayingAnimation = true;
     ImageList.Add(selectedImage);
     CreateNewAnimation();
     UpdateIfCanSave();
     SetButtonEnableStates();
     RaisePropertyChanged("ImageList");
 }
示例#19
0
        protected override void OnChildAdded(Element child)
        {
            base.OnChildAdded(child);

            if (child is Image)
            {
                ImageList.Add((Image)child);

                if (CurrentImage == null)
                {
                    CurrentImage = (Image)child;
                }
            }
        }
        public async void GetAllImagesAsync()
        {
            ImageList.Clear();
            VideoImageList.Clear();
            var folder   = Windows.Storage.ApplicationData.Current.LocalFolder;
            var allFiles = await folder.GetFilesAsync();

            foreach (var file in allFiles)
            {
                if (file.FileType.Equals(".jpg") || file.FileType.Equals(".png") || file.FileType.Equals(".jpeg"))
                {
                    ImageProperties imageProperties = await file.Properties.GetImagePropertiesAsync();

                    StorageItemThumbnail storageItemThumbnail = await file.GetThumbnailAsync(ThumbnailMode.PicturesView, 200, ThumbnailOptions.UseCurrentScale);

                    var Picture = new BitmapImage();
                    Picture.SetSource(storageItemThumbnail);
                    Images p = new Images
                    {
                        Name          = file.Name,
                        imageFileName = file.Name,
                        Collection    = Picture
                    };
                    var imageid = await FileHelper.GetImageIDAsync(p, FILE_NAME);

                    p.ID = imageid;
                    ImageList.Add(p);
                }
                if (file.FileType.Equals(".mp4"))
                {
                    VideoProperties videoProperties = await file.Properties.GetVideoPropertiesAsync();

                    StorageItemThumbnail storageItemThumbnail = await file.GetThumbnailAsync(ThumbnailMode.VideosView, 200, ThumbnailOptions.UseCurrentScale);

                    var video = new BitmapImage();
                    video.SetSource(storageItemThumbnail);
                    Images v = new Images
                    {
                        Name          = file.Name,
                        videoFileName = file.Name,
                        Collection    = video
                    };
                    var videoid = await FileHelper.GetImageIDAsync(v, FILE_NAME);

                    v.ID = videoid;
                    VideoImageList.Add(v);
                }
            }
        }
示例#21
0
        public void DialogMethodAddListImage()
        {
            ObservableCollection <Image> list = new ObservableCollection <Image>();
            FileDialogMethod             fdm  = new FileDialogMethod();

            fdm.ReturnFilesFromDialog(list);
            App.Current.Dispatcher.Invoke(new Action(() =>
            {
                if (list.Count != 0)
                {
                    ImageList.Add(list);
                    _aggregator.GetEvent <FileDialogEvent>().Publish(ImageList);
                }
            }));
        }
        public async Task <bool> GetImagesList(string dirpath = null)
        {
            dirpath ??= imageRootPath;
            foreach (var directory in Directory.GetDirectories(dirpath).AsEnumerable())
            {
                GetImagesList(directory).GetAwaiter().GetResult();
            }
            var files = Directory.GetFiles(dirpath);

            foreach (var file in files)
            {
                ImageList.Add(file, false);
            }
            return(true);
        }
示例#23
0
 void Form1_DragDrop(object sender, DragEventArgs e)
 {
     string[] WhiteExtension = { ".png", ".jpg", ".jpeg" };
     string[] files          = (string[])e.Data.GetData(DataFormats.FileDrop, false);
     foreach (string file in files)
     {
         string ext = Path.GetExtension(file);
         //if its image
         if (WhiteExtension.Where(y => y == ext.ToLower()).Any())
         {
             ImageList.Add(file);
         }
     }
     SourceChanged();
 }
示例#24
0
        protected override void OnChildAdded(Element child)
        {
            base.OnChildAdded(child);

            //each time a child Image is added, add it to the ImageList
            if (child is Image)
            {
                ImageList.Add((Image)child);

                //set a CurrentImage if we don't already have one
                if (CurrentImage == null)
                {
                    CurrentImage = (Image)child;
                }
            }
        }
        private void BtnAddPicture_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Title  = "Select a picture",
                Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"
            };

            if ((bool)openFileDialog.ShowDialog())
            {
                try
                {
                    appendixImage = new BitmapImage(new Uri(openFileDialog.FileName, UriKind.Absolute));
                    AppendixImageList.Add(new OrderItemReportAppendix()
                    {
                        Picture = ImageConverter.ImageToByteArray(appendixImage)
                    });
                    imgImage.Source = appendixImage;
                    ImageList.Add(appendixImage);
                    pictureAdded          = true;
                    btnDialogOk.IsEnabled = true;
                    imageCount++;
                    lblImgCount.Content = imageCount.ToString();
                }
                catch (Exception ex)
                {
                    if (!pictureAdded)
                    {
                        pictureAdded = false;
                        if (!changesMade)
                        {
                            btnDialogOk.IsEnabled = false;
                        }
                        MessageBox.Show("Laden des Bildes fehlgeschlagen!\n" + ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            else
            {
                if (!pictureAdded)
                {
                    MessageBox.Show("Laden des Bildes fehlgeschlagen", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
示例#26
0
        // 3
        protected override void RegisterObservables()
        {
            // 4
            InitializeCommand = ReactiveCommand.CreateFromTask(async _ =>
            {
                // initialization logic goes here
                StatusMessage = "Initializing";

                // maybe we're getting images from a server
                await Task.Delay(1000);

                StatusMessage = "Downloading";

                // simulate a lengthy server response
                await Task.Delay(3000);

                StatusMessage = "Go-Go Random Logos!";

                ImageList.Add("xamagon.png");
                ImageList.Add("eightbot.png");
                ImageList.Add("reactivelogo.png");
                ImageList.Add("codebeaulieu.png");
                ImageList.Add("Rx_Logo_512.png");

                await Task.Delay(1000);
                await Task.FromResult(Unit.Default);
            }).DisposeWith(ViewModelBindings.Value);

            // 5
            Observable
            .Interval(TimeSpan.FromMilliseconds(500))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Select(_ =>
            {
                if (ImageList.Count == 0)
                {
                    return(ImageSource.FromFile("reactivelogo.png"));
                }

                Random random = new Random();
                int number    = random.Next(0, ImageList.Count);

                return(ImageSource.FromFile(ImageList[number]));
            }).BindTo(this, x => x.CurrentImage);
        }
示例#27
0
        public void Advance(string description, WriteableBitmap newBitmap)
        {
            var ih = new ImageHistory(newBitmap, description);

            curStateNo++;
            if (curStateNo == ImageList.Count)
            {
                ImageList.Add(ih);
            }
            else
            {
                ImageList[curStateNo] = ih;
                for (int i = ImageList.Count - 1; i > curStateNo; i--)
                {
                    ImageList.RemoveAt(i);
                }
            }
        }
示例#28
0
        public void DisplayImage(string type = "FengJing", int page = 1)
        {
            if (type == currentType && page == CurrentPage)
            {
                return;
            }
            string pageParam = page > 1 ? $"_{page}" : "";
            var    result    = Utils.GetNetBianImage($"{netbianHost}/4k{type.ToLower()}/index{pageParam}.html");

            TotalPage   = result.TotalPage;
            CurrentPage = page;
            currentType = type;
            ImageList.Clear();
            foreach (var item in result.ImageInfo)
            {
                ImageList.Add(new NetBianImage(item.Name, netbianHost + item.Source, netbianHost + item.Detail));
            }
        }
示例#29
0
        private async void FastCreated()
        {
            var ran = new Random();

            while (true)
            {
                await Task.Delay(100).ContinueWith(_ =>
                {
                    ImageList.Clear();
                    var n = ran.Next(int.MaxValue / 10);
                    for (int i = n; i < n + 1000; i++)
                    {
                        try
                        {
                            DrawingVisual drawingVisual   = new DrawingVisual();
                            DrawingContext drawingContext = drawingVisual.RenderOpen();

                            var text = new FormattedText(i.ToString(),
                                                         CultureInfo.GetCultureInfo("zh-cn"),
                                                         FlowDirection.LeftToRight,
                                                         new Typeface("Verdana"),
                                                         36, Brushes.Black);
                            drawingContext.DrawText(text,
                                                    new Point(0, 0));

                            drawingContext.Close();

                            var image = new RenderTargetBitmap((int)text.Width, (int)text.Height, 96, 96,
                                                               PixelFormats.Pbgra32);
                            image.Render(drawingVisual);

                            ImageList.Add(image);
                        }
                        catch (Exception e)
                        {
                            // RenderTargetBitmap throws COM exception when created too fast: MILERR_WIN32ERROR (Exception from HRESULT: 0x88980003)
                            Console.WriteLine(e);
                        }

                        GC.WaitForPendingFinalizers();
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
        }
        public void ReadImage(string finename)
        {
            using (BinaryReader loader = new BinaryReader(File.Open(finename, FileMode.Open, FileAccess.Read)))
            {
                FileInfo fd     = new FileInfo(finename);
                int      Length = (int)fd.Length;
                byte[]   buf    = new byte[Length];
                buf = loader.ReadBytes((int)fd.Length);

                loader.Close();
                BitmapImage btm = new BitmapImage();
                btm.BeginInit();
                btm.CacheOption  = BitmapCacheOption.OnLoad;
                btm.StreamSource = new MemoryStream(buf);
                btm.EndInit();
                btm.Freeze();
                FileName.Add(fd.Name);
                ImageList.Add(btm);
                GC.Collect();
            }
        }