Populate() public method

public Populate ( ) : void
return void
Ejemplo n.º 1
0
        public void RefreshTree()
        {
            BeginInit();
            Items.Clear();

            DriveInfo[] drives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in drives)
            {
                char chDrive = drive.Name.ToUpper()[0];
                DirectoryTreeViewItem item = new DirectoryTreeViewItem(drive.RootDirectory);

                if (chDrive != 'A' && chDrive != 'B' && drive.IsReady && drive.VolumeLabel.Length > 0)
                    item.Text = String.Format("{0}({1})", drive.VolumeLabel, drive.Name);
                else
                    item.Text = String.Format("{0}({1})", drive.DriveType, drive.Name);

                if (chDrive == 'A' || chDrive == 'B')
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(new Uri(Path.Combine(Directory.GetCurrentDirectory(), "35Floppy.bmp")));
                else if (drive.DriveType == DriveType.CDRom)
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(new Uri(Path.Combine(Directory.GetCurrentDirectory(), "CDDrive.bmp")));
                else
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(new Uri(Path.Combine(Directory.GetCurrentDirectory(), "Drive.bmp")));

                Items.Add(item);
                if (chDrive != 'A' && chDrive != 'B' && drive.IsReady)
                    item.Populate();
            }
            EndInit();
        }
Ejemplo n.º 2
0
 protected override void OnExpanded(RoutedEventArgs args)
 {
     base.OnExpanded(args);
     foreach (object obj in Items)
     {
         DirectoryTreeViewItem item = obj as DirectoryTreeViewItem;
         item.Populate();
     }
 }
Ejemplo n.º 3
0
        public void RefreshTree()
        {
            BeginInit();
            Items.Clear();

            // Obtain the disk drives.
            DriveInfo[] drives = DriveInfo.GetDrives();

            foreach (DriveInfo drive in drives)
            {
                char chDrive = drive.Name.ToUpper()[0];
                DirectoryTreeViewItem item =
                    new DirectoryTreeViewItem(drive.RootDirectory);

                // Display VolumeLabel if drive ready; otherwise just DriveType.
                if (chDrive != 'A' && chDrive != 'B' &&
                    drive.IsReady && drive.VolumeLabel.Length > 0)
                {
                    item.Text = String.Format("{0} ({1})", drive.VolumeLabel,
                                              drive.Name);
                }
                else
                {
                    item.Text = String.Format("{0} ({1})", drive.DriveType,
                                              drive.Name);
                }

                // Determine proper bitmap for drive.
                if (chDrive == 'A' || chDrive == 'B')
                {
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(
                        new Uri("pack://application:,,/Images/35FLOPPY.BMP"));
                }

                else if (drive.DriveType == DriveType.CDRom)
                {
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(
                        new Uri("pack://application:,,/Images/CDDRIVE.BMP"));
                }
                else
                {
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(
                        new Uri("pack://application:,,/Images/DRIVE.BMP"));
                }

                Items.Add(item);

                // Populate the drive with directories.
                if (chDrive != 'A' && chDrive != 'B' && drive.IsReady)
                {
                    item.Populate();
                }
            }
            EndInit();
        }
        public void RefreshTree()
        {
            BeginInit();
            Items.Clear();

            // Obtain the disk drives.
            DriveInfo[] drives = DriveInfo.GetDrives();

            foreach (DriveInfo drive in drives)
            {
                char chDrive = drive.Name.ToUpper()[0];
                DirectoryTreeViewItem item =
                            new DirectoryTreeViewItem(drive.RootDirectory);

                // Display VolumeLabel if drive ready; otherwise just DriveType.
                if (chDrive != 'A' && chDrive != 'B' &&
                            drive.IsReady && drive.VolumeLabel.Length > 0)
                    item.Text = String.Format("{0} ({1})", drive.VolumeLabel,
                                                           drive.Name);
                else
                    item.Text = String.Format("{0} ({1})", drive.DriveType,
                                                           drive.Name);

                // Determine proper bitmap for drive.
                if (chDrive == 'A' || chDrive == 'B')
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(
                        new Uri("pack://application:,,/Images/35FLOPPY.BMP"));

                else if (drive.DriveType == DriveType.CDRom)
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(
                        new Uri("pack://application:,,/Images/CDDRIVE.BMP"));
                else
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(
                        new Uri("pack://application:,,/Images/DRIVE.BMP"));

                Items.Add(item);

                // Populate the drive with directories.
                if (chDrive != 'A' && chDrive != 'B' && drive.IsReady)
                    item.Populate();
            }
            EndInit();
        }
Ejemplo n.º 5
0
        public void RefreshTree()
        {
            BeginInit();
            Items.Clear();

            DriveInfo[] drives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in drives)
            {
                char chDrive = drive.Name.ToUpper()[0];
                DirectoryTreeViewItem item = new DirectoryTreeViewItem(drive.RootDirectory);

                if (chDrive != 'A' && chDrive != 'B' && drive.IsReady && drive.VolumeLabel.Length > 0)
                {
                    item.Text = String.Format("{0}({1})", drive.VolumeLabel, drive.Name);
                }
                else
                {
                    item.Text = String.Format("{0}({1})", drive.DriveType, drive.Name);
                }

                if (chDrive == 'A' || chDrive == 'B')
                {
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(new Uri(Path.Combine(Directory.GetCurrentDirectory(), "35Floppy.bmp")));
                }
                else if (drive.DriveType == DriveType.CDRom)
                {
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(new Uri(Path.Combine(Directory.GetCurrentDirectory(), "CDDrive.bmp")));
                }
                else
                {
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(new Uri(Path.Combine(Directory.GetCurrentDirectory(), "Drive.bmp")));
                }

                Items.Add(item);
                if (chDrive != 'A' && chDrive != 'B' && drive.IsReady)
                {
                    item.Populate();
                }
            }
            EndInit();
        }
        public void RefreshTree()
        {
            //Указывает, что скоро начнется инициализация объекта System.Windows.Controls.ItemsControl.
            BeginInit();
            //Очищает коллекцию и освобождает ссылки на все элементы коллекции
            Items.Clear();

            // Obtain the disk drives.
            //Получите диски.
            DriveInfo[] drives = DriveInfo.GetDrives();

            foreach (DriveInfo drive in drives)
            {
                // Получает имя диска и переводит его с верхний регистр (Заглавные буквы)
                char chDrive = drive.Name.ToUpper()[0];

                // Запускает конструктор класса DirectoryTreeViewItem
                // передает в него текущее имя дикска
                // Переходим в класс DirectoryTreeViewItem
                DirectoryTreeViewItem item =
                    new DirectoryTreeViewItem(drive.RootDirectory);

                // Display VolumeLabel if drive ready; otherwise just DriveType.
                //Отображать VolumeLabel, если диск готов; иначе просто DriveType.
                if (chDrive != 'A' && chDrive != 'B' &&
                    drive.IsReady && drive.VolumeLabel.Length > 0)
                {
                    item.Text = String.Format("{0} ({1})", drive.VolumeLabel,
                                              drive.Name);
                }
                else
                {
                    item.Text = String.Format("{0} ({1})", drive.DriveType,
                                              drive.Name);
                }

                // Determine proper bitmap for drive.
                //Определите правильное растровое изображение для диска.
                if (chDrive == 'A' || chDrive == 'B')
                {
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(
                        new Uri("pack://application:,,/Images/35FLOPPY.BMP"));
                }

                else if (drive.DriveType == DriveType.CDRom)
                {
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(
                        new Uri("pack://application:,,/Images/CDDRIVE.BMP"));
                }
                else
                {
                    item.SelectedImage = item.UnselectedImage = new BitmapImage(
                        new Uri("pack://application:,,/Images/DRIVE.BMP"));
                }

                Items.Add(item);

                // Populate the drive with directories.
                //Заполните накопитель каталогами.
                if (chDrive != 'A' && chDrive != 'B' && drive.IsReady)
                {
                    item.Populate();
                }
            }
            EndInit();
        }