Esempio n. 1
0
        public OpenDataSourceDialog(IEnumerable <string> fileTypes)
        {
            InitializeComponent();
            foreach (var item in fileTypes)
            {
                sourceTypeComboBox.Items.Add(item);
            }
            SetUpDialog();
            var recent = FolderHistoryInterface.GetRecentFolders().Where(x => !string.IsNullOrEmpty(x)).ToList();

            _startLocation = recent.Any()
                                 ? recent.FirstOrDefault()
                                 : Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        }
Esempio n. 2
0
        private void CreateManualFileEntryControl(object sender, EventArgs e)
        {
            if (_fileCombo != null && _fileCombo.Visible)
            {
                _fileCombo.Visible = false;
                Controls.Remove(_fileCombo);
                return;
            }

            string currentDirectory;

            if (BreadCrumbTrail.Items.Count > 2)
            {
                currentDirectory = (string)BreadCrumbTrail.Items[BreadCrumbTrail.Items.Count - 1].Tag;
            }
            else if (_overflowStack.Any())
            {
                currentDirectory = (string)_overflowStack.Peek().Tag;
            }
            else
            {
                currentDirectory = string.Empty;
            }

            _fileCombo = new ComboBox
            {
                Text   = currentDirectory,
                Anchor =
                    AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                Width              = BreadCrumbTrail.Width - BreadCrumbTrail.Items[0].Width + HistoryButton.Width - 1,
                Location           = new Point(BreadCrumbTrail.Items[0].Width, 0),
                FlatStyle          = FlatStyle.Flat,
                AutoCompleteMode   = AutoCompleteMode.SuggestAppend,
                AutoCompleteSource = AutoCompleteSource.FileSystemDirectories
            };
            _fileCombo.Items.Add(currentDirectory);
            var history = FolderHistoryInterface.GetRecentFolders();

            foreach (var item in history.Where(item => !string.IsNullOrEmpty(item) && item != currentDirectory))
            {
                _fileCombo.Items.Add(item);
            }

            _fileCombo.KeyDown += (x, y) =>
            {
                if (y.KeyCode == Keys.Return)
                {
                    y.Handled = true;
                    if (Directory.Exists(_fileCombo.Text))
                    {
                        _fileCombo.Visible = false;
                        Controls.Remove(_fileCombo);
                        Navigate(_fileCombo.Text.TrimEnd('\\'), null);
                    }
                    else
                    {
                        MessageBox.Show("Directory does not exist");
                    }
                }
                else if (y.KeyCode == Keys.Escape)
                {
                    _fileCombo.Visible = false;
                    Controls.Remove(_fileCombo);
                    return;
                }
            };

            Controls.Add(_fileCombo);
            _fileCombo.Select();
            _fileCombo.SelectionStart = _fileCombo.Text.Length;

            if (sender == HistoryButton)
            {
                _fileCombo.DroppedDown = true;
            }
            _fileCombo.BringToFront();
        }
Esempio n. 3
0
        public static string GetMostRecentLocation()
        {
            var history = FolderHistoryInterface.GetRecentFolders();

            return(history.Count > 0 ? history.First() : Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
        }