示例#1
0
        private void pathComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Displays selected entry
            DirectoryComboEntry selectedEntry = pathComboBox.SelectedItem as DirectoryComboEntry;

            if (selectedEntry != null)
            {
                try
                {
                    Cursor = Cursors.WaitCursor;

                    _RefreshFileView(selectedEntry.Info.FullName);
                    CurrentFolder     = selectedEntry.Info.FullName;
                    pathComboBox.Text = CurrentFolder;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message);
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Actualizes combo contents
        /// </summary>
        /// <param name="path"></param>
        private void _RefreshPathCombo(string path)
        {
            pathComboBox.Items.Clear();

            // Current hierarchy first
            DirectoryInfo dirInfo = new DirectoryInfo(path);
            List <DirectoryComboEntry> hierarchy = new List <DirectoryComboEntry>();

            string[] pathItems   = dirInfo.FullName.Split('\\');
            int      level       = 0;
            string   currentPath = "";

            foreach (var pathItem in pathItems)
            {
                level++;
                currentPath += (pathItem + @"\\");

                DirectoryInfo       di    = new DirectoryInfo(currentPath);
                DirectoryComboEntry entry = new DirectoryComboEntry(di.FullName, level);

                pathComboBox.Items.Add(entry);
            }

            // TDU root
            pathComboBox.Items.Add(new DirectoryComboEntry(@"D:\Jeux\Test Drive Unlimited"));

            // System folders
            string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            pathComboBox.Items.Add(new DirectoryComboEntry(desktopPath, Environment.SpecialFolder.DesktopDirectory));
            string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            pathComboBox.Items.Add(new DirectoryComboEntry(docPath, Environment.SpecialFolder.MyDocuments));

            // Logical drives
            string[] drives = Environment.GetLogicalDrives();
            foreach (var drive in drives)
            {
                pathComboBox.Items.Add(new DirectoryComboEntry(drive));
            }
        }