コード例 #1
0
        private void ListView1_Selected(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("!");
            this.ImageSmall.Items.Clear();
            TreeViewItem tmp = (TreeViewItem)e.OriginalSource;
            DirItem      DI  = (DirItem)tmp.Header;

            String[] files = Directory.GetFiles(DI.fullPath);
            foreach (String file in files)
            {
                String extension = System.IO.Path.GetExtension(DI.fullPath);
                if (extension == ".png" || extension == ".bmp" || extension == ".jpg" || extension == ".svg")
                {
                    // MessageBox.Show(DI.fullPath);
                    // this.ImageSmall.Items.Add(new DirItem(System.IO.Path.GetFileName(file), file));
                    //// ImageNameGL(System.IO.Path.GetFileName(new ));
                    BitmapImage bm1 = new BitmapImage();
                    bm1.BeginInit();
                    bm1.UriSource         = new Uri(file, UriKind.Relative);
                    bm1.CacheOption       = BitmapCacheOption.OnLoad;
                    bm1.DecodePixelHeight = 100;
                    bm1.EndInit();

                    this.ImageSmall.Items.Add(new ImgBlock(bm1));
                }
            }
        }
コード例 #2
0
 public MainWindow()
 {
     InitializeComponent();
     String[] drives = Directory.GetLogicalDrives();
     foreach (String drive in drives)
     {
         DirItem DI = new DirItem(drive, drive);
         fillTree(drive, DI);
         this.treeView1.Items.Add(DI);
     }
 }
コード例 #3
0
        private void treeView1_Expanded(object sender, RoutedEventArgs e)
        {
            // MessageBox.Show( e.OriginalSource.GetType().Name+":"+((TreeViewItem)e.OriginalSource).Header.GetType().Name);
            DirItem DI = ((TreeViewItem)e.OriginalSource).Header as DirItem;

            if (DI == null)
            {
                return;
            }
            DI.Nodes.Clear();          // очищает дочерние узлы распахиваемого узла
            fillTree(DI.fullPath, DI); // заполняем реальными дочерними узлами распахиваемый узел
        }
コード例 #4
0
        private void fillTree(String fullPath, DirItem parent)
        {
            try
            {
                String[] dirs = Directory.GetDirectories(fullPath);
                foreach (String dir in dirs)
                {
                    DirItem DI = new DirItem(System.IO.Path.GetFileName(dir), dir);
                    parent.Nodes.Add(DI);

                    // нужно ли добавлять обманный дочерний узел
                    try
                    {
                        String[] a = Directory.GetDirectories(dir);
                        if (a.Length > 0)
                        {
                            DI.Nodes.Add(new DirItem("?", "?"));
                        }
                    }
                    catch { }
                }
            }
            catch { }
            //string fileName = @"D:/1.png";
            //BitmapImage bm1 = new BitmapImage(new Uri(fileName));
            ////bm1.BeginInit();
            ////bm1.UriSource = new Uri(fileName, UriKind.Relative);
            ////bm1.CacheOption = BitmapCacheOption.OnLoad;
            ////bm1.EndInit();
            //this.ImageBig.Source = bm1;
            // // ListViewItem lvi = new ListViewItem();
            // Image im = new Image();
            // im.Source = new BitmapImage(new Uri(fileName));
            //// this.ImageSmall.Items.Add(im);
            // this.ImageSmall.Items.Add(im);
            // ImageList imageListSmall = new ImageList();
            // this.ImageSmall
            //Image image = new Image();
            //image.;

            //string fileName1 = @"D:/1.png";
            //BitmapImage bm2 = new BitmapImage();
            //bm2.BeginInit();
            //bm2.UriSource = new Uri(fileName1, UriKind.Relative);
            //bm2.CacheOption = BitmapCacheOption.OnLoad;
            //bm2.EndInit();
            // this.ImageSmall.Items.i
        }
コード例 #5
0
        private void treeView1_Selected(object sender, RoutedEventArgs e)
        {
            //ImageBig.Source = null;
            //try
            //{
            TreeViewItem tmp = (TreeViewItem)e.OriginalSource;
            DirItem      DI  = (DirItem)tmp.Header;

            path = DI.fullPath;
            //  MessageBox.Show(DI.fullPath);
            //   this.ListView1.Items.Clear();
            //    this.ListView1.Items.Add(new DirectoryInfo(DI.fullPath).Name);
            //    String[] files = Directory.GetFiles(DI.fullPath);
            //    foreach (String file in files)
            //    {
            //        String extension = System.IO.Path.GetExtension(file);
            //        if (extension == ".png" || extension == ".bmp" || extension == ".jpg" || extension == ".svg")
            //            this.ListView1.Items.Add(new DirItem(System.IO.Path.GetFileName(file), file));

            //    }
            //}
            //catch { }
        }