public MainWindow() { InitializeComponent(); //MessageBox.Show(imgLeft.Source.GetType().FullName); _pictureDataLeft = new PictureData(); _pictureDataLeft.PropertyChanged += new PropertyChangedEventHandler(OnLeftPictureDataPropertyChanged); _pictureDataRight = new PictureData(); _pictureDataRight.PropertyChanged += new PropertyChangedEventHandler(OnRightPictureDataPropertyChanged); }
private void UpdateImage(TextBox textBox, TextBlock textBlock, Image image, PictureData pictureData) { var filepath = textBox.Text; FileInfo[] files = null; if (!string.IsNullOrEmpty(filepath)) { var dirInfo = new DirectoryInfo(filepath); if (dirInfo.Exists) { files = dirInfo.GetFiles("*.jpg"); } } if (files != null && files.Count() > 0) { // problème de mémoire sur une grande quantité d'images //imgListLeft = new ImageList(); //imgListLeft.Images.Clear(); //var toto = files.Select(img => System.Drawing.Image.FromFile(img.FullName)).ToArray(); //imgListLeft.Images.AddRange(toto); //var titi = imgListLeft.Images[imgListLeftIndex]; pictureData.PathList = files.Select(img => img.FullName).ToArray(); pictureData.CurrentIndex = 0; } else { pictureData.PathList = null; pictureData.CurrentIndex = -1; } }