Ejemplo n.º 1
0
        private void directoryButton_Click(object sender, RoutedEventArgs e)
        {
            Button        button = (Button)sender;
            DirectoryItem item   = (DirectoryItem)button.Tag;

            Location = item.FullPath;
        }
Ejemplo n.º 2
0
        DirectoryItem createDrivesItem()
        {
            DriveInfo[]   drives     = DriveInfo.GetDrives();
            DirectoryItem drivesItem = new DirectoryItem("", "", LocationSelectedCommand);

            drivesItem.Icon = new System.Windows.Controls.Image
            {
                Source = new BitmapImage(new Uri("pack://application:,,,/Resources/Icons/computer.ico"))
            };

            foreach (DriveInfo info in drives)
            {
                String imageUrl    = "";
                String volumeLabel = "";

                getDriveVolumeAndImage(info, out volumeLabel, out imageUrl);

                DirectoryItem driveItem = new DirectoryItem(volumeLabel + " (" + info.Name.Trim('\\') + ")", info.Name, LocationSelectedCommand);
                driveItem.Icon = new System.Windows.Controls.Image
                {
                    Source = new BitmapImage(new Uri(imageUrl))
                };

                driveItem.Icon.Width  = 20;
                driveItem.Icon.Height = 20;

                drivesItem.SubDirectories.Add(driveItem);
            }

            return(drivesItem);
        }
Ejemplo n.º 3
0
        public void setPath(String location)
        {        
            splitPath.Clear();
            
            splitPath.Add(createDrivesItem());

            string[] directories = location.Split(Path.DirectorySeparatorChar);
            String fullPath = "";
            

            for(int i = 0; i < directories.Count(); i++)
            {                                                                
                fullPath += directories[i];

                if (String.IsNullOrEmpty(directories[i])) continue;

                DirectoryItem item;

                if(i == 0) {

                    String volumeLabel;
                    String imageUri;

                    getDriveVolumeAndImage(new DriveInfo(directories[i]), out volumeLabel, out imageUri);

                    item = new DirectoryItem(volumeLabel + " (" + directories[i] + ")", fullPath, LocationSelectedCommand);

                } else {
                    
                    item = new DirectoryItem(directories[i], fullPath, LocationSelectedCommand);
                }
                
                splitPath.Add(item);

                fullPath += Path.DirectorySeparatorChar;

                String[] subDirectories = Directory.GetDirectories(fullPath);

                foreach (String subDirectory in subDirectories)
                {
                    DirectoryInfo info = new DirectoryInfo(subDirectory);
                    if (info.Attributes.HasFlag(FileAttributes.System)) continue;

                    DirectoryItem subDir = new DirectoryItem(Path.GetFileName(subDirectory), subDirectory, LocationSelectedCommand);

                    subDir.Icon = new System.Windows.Controls.Image
                    {
                        Source = new BitmapImage(new Uri("pack://application:,,,/Resources/Icons/Folder_Open.ico"))
                    };

                    subDir.Icon.Width = 20;
                    subDir.Icon.Height = 20;

                    item.SubDirectories.Add(subDir);
                }
            }
        }
Ejemplo n.º 4
0
        private void location_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TextBlock textBlock = sender as TextBlock;

            DirectoryItem item = textBlock.Tag as DirectoryItem;

            if (item.SubDirectories.Count > 0)
            {
                Location = item.FullPath;
                SystemSounds.Question.Play();
            }
        }
Ejemplo n.º 5
0
 private void locationBoxViewModel_LocationSelected(object sender, DirectoryItem e)
 {
     Location = e.FullPath;
 }
Ejemplo n.º 6
0
        DirectoryItem createDrivesItem()
        {
            DriveInfo[] drives = DriveInfo.GetDrives();
            DirectoryItem drivesItem = new DirectoryItem("", "", LocationSelectedCommand);
            drivesItem.Icon = new System.Windows.Controls.Image
            {
                Source = new BitmapImage(new Uri("pack://application:,,,/Resources/Icons/computer.ico"))
            };

            foreach (DriveInfo info in drives)
            {
                String imageUrl = "";
                String volumeLabel = "";

                getDriveVolumeAndImage(info, out volumeLabel, out imageUrl);
                
                DirectoryItem driveItem = new DirectoryItem(volumeLabel + " (" + info.Name.Trim('\\') + ")", info.Name, LocationSelectedCommand);
                driveItem.Icon = new System.Windows.Controls.Image
                {
                    Source = new BitmapImage(new Uri(imageUrl))
                };

                driveItem.Icon.Width = 20;
                driveItem.Icon.Height = 20;

                drivesItem.SubDirectories.Add(driveItem);  
            }

            return (drivesItem);
        }
Ejemplo n.º 7
0
 private void locationBoxViewModel_LocationSelected(object sender, DirectoryItem e)
 {
     Location = e.FullPath;
 }
Ejemplo n.º 8
0
        public void setPath(String location)
        {
            splitPath.Clear();

            splitPath.Add(createDrivesItem());

            string[] directories = location.Split(Path.DirectorySeparatorChar);
            String   fullPath    = "";


            for (int i = 0; i < directories.Count(); i++)
            {
                fullPath += directories[i];

                if (String.IsNullOrEmpty(directories[i]))
                {
                    continue;
                }

                DirectoryItem item;

                if (i == 0)
                {
                    String volumeLabel;
                    String imageUri;

                    getDriveVolumeAndImage(new DriveInfo(directories[i]), out volumeLabel, out imageUri);

                    item = new DirectoryItem(volumeLabel + " (" + directories[i] + ")", fullPath, LocationSelectedCommand);
                }
                else
                {
                    item = new DirectoryItem(directories[i], fullPath, LocationSelectedCommand);
                }

                splitPath.Add(item);

                fullPath += Path.DirectorySeparatorChar;

                String[] subDirectories = Directory.GetDirectories(fullPath);

                foreach (String subDirectory in subDirectories)
                {
                    DirectoryInfo info = new DirectoryInfo(subDirectory);
                    if (info.Attributes.HasFlag(FileAttributes.System))
                    {
                        continue;
                    }

                    DirectoryItem subDir = new DirectoryItem(Path.GetFileName(subDirectory), subDirectory, LocationSelectedCommand);

                    subDir.Icon = new System.Windows.Controls.Image
                    {
                        Source = new BitmapImage(new Uri("pack://application:,,,/Resources/Icons/Folder_Open.ico"))
                    };

                    subDir.Icon.Width  = 20;
                    subDir.Icon.Height = 20;

                    item.SubDirectories.Add(subDir);
                }
            }
        }