Exemplo n.º 1
0
        private void imageListBox_Loaded(object sender, RoutedEventArgs e)
        {
            vm = new ObservableCollection <ListBoxShowImagesViewModel>();


            List <String> temp_pathList = ForeachFile();
            DirectoryInfo dir           = new DirectoryInfo(temp_pathList[0]);

            curPatient.Content = temp_pathList[0];
            foreach (FileInfo dChild in dir.GetFiles("*"))
            {
                imgPath.Add(dChild.FullName); //路径名+文件名
                imgName.Add(dChild.Name);     //文件名
            }

            //用正常人的逻辑排序
            IComparer fileNameComparer = new FilesNameComparerClass();

            imgPath.Sort(fileNameComparer);
            imgName.Sort(fileNameComparer);

            for (int i = 0; i < imgPath.Count; i++)
            {
                vm.Add(new ListBoxShowImagesViewModel()
                {
                    Path = imgPath[i].ToString(), Name = imgName[i].ToString()
                });
            }
            imageListBox.DataContext = vm;//添加数据
        }
Exemplo n.º 2
0
        public void ChangeContent(String path)
        {
            vm = new ObservableCollection <ListBoxShowImagesViewModel>();
            curPatient.Content = path;

            DirectoryInfo dir = new DirectoryInfo(path);

            imgPath.Clear();
            imgName.Clear();
            foreach (FileInfo dChild in dir.GetFiles("*"))
            {
                imgPath.Add(dChild.FullName); //路径名+文件名
                imgName.Add(dChild.Name);     //文件名
            }

            //用正常人的逻辑排序
            IComparer fileNameComparer = new FilesNameComparerClass();

            imgPath.Sort(fileNameComparer);
            imgName.Sort(fileNameComparer);

            for (int i = 0; i < imgPath.Count; i++)
            {
                vm.Add(new ListBoxShowImagesViewModel()
                {
                    Path = imgPath[i].ToString(), Name = imgName[i].ToString()
                });
            }
            imageListBox.DataContext = vm;//添加数据
        }