public Folder(DirectoryInfo dI, FileInfo fI) { dInfo = dI; images = new List<ImageWithScore>(); nameFolder = dInfo.Name; it = this; images.Add(new ImageWithScore(fI)); }
private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { stackWithRadio.IsEnabled = false; properties.IsExpanded = false; //images.Clear(); //List<FileInfo> fITmp = new List<FileInfo>(); //images.AddRange(folders.IndexOf((DirectoryInfo)(listBox.SelectedValue)) selectedFold = (Folder)e.AddedItems[0]; //fold.Images.Clear(); List<FileInfo> fSI = new List<FileInfo>(); fSI.AddRange(selectedFold.DInfo.GetFiles().ToList()); //foreach (FileInfo fSITmp in fSI) //{ // if (extensions.Contains(fSITmp.Extension)) // { // fold.AddImage(fSITmp); // } //} wrap.Children.Clear(); images.Clear(); //stack2.Visibility = System.Windows.Visibility.Hidden; //wrap.ItemHeight = 100; //wrap.ItemWidth = 100; for (int i = 0; i < selectedFold.Images.Count; i++) { if (File.Exists(selectedFold.Images[i].FileImage.FullName)) { images.Add(FileInfoToImage(selectedFold.Images[i].FileImage)); //imgSc.FileImage.Width = 100; //imgSc.Image.Height = 100; //imgSc.Image.Margin = new Thickness(5); //MessageBox.Show(imgSc.Image.IsMeasureValid.ToString()); //imgSc.Image.Measure(new Size(100, 100)); //MessageBox.Show(imgSc.Image.IsMeasureValid.ToString()); //MessageBox.Show(imgSc.Image.ActualWidth.ToString()); Rectangle rect = new Rectangle(); rect.Margin = new Thickness(10); //rect.MinWidth = imgSc.Image.Width; //rect.MinHeight = imgSc.Image.Height; //rect.Width = imgSc.Image.ActualWidth; //rect.Height = imgSc.Image.ActualHeight; if (images[i].Source.Width >= images[i].Source.Height) { rect.Width = 100; rect.Height = images[i].Source.Height / images[i].Source.Width * 100; } else { rect.Height = 100; rect.Width = images[i].Source.Width / images[i].Source.Height * 100; } rect.Fill = new ImageBrush(images[i].Source); rect.MouseDown += rect_MouseDown; //rect.StrokeThickness = 5; //rect.Stroke = Brushes.Blue; wrap.Children.Add(rect); } else { selectedFold.Images.Remove(selectedFold.Images[i]); i--; } } wrap.Visibility = System.Windows.Visibility.Visible; }