public Form1() { folderSelectDialog = new FolderSelectDialog(); fileSelectDialog = new OpenFileDialog(); InitializeComponent(); txtBrowseJava.Enabled = false; }
public AddNewFolderSourceDialog() { _input = new JsonFileInput(); InitializeComponent(); // sigh, too bad reactiveui doesn't support .net 4 Action doValidation = () => { var path = PathTextBox.Text; var count = NumRowsToSampleTextBox.Text; int nr; var pathOk = Directory.Exists(path) || String.IsNullOrEmpty(path); var countOk = Int32.TryParse(count, out nr) && nr > 0; OkButton.IsEnabled = (pathOk && countOk && !String.IsNullOrEmpty(path)); PathTextBox.Background = pathOk ? _goodBrush : _badBrush; NumRowsToSampleTextBox.Background = countOk ? _goodBrush : _badBrush; }; PathTextBox.TextChanged += (sender, args) => doValidation(); NumRowsToSampleTextBox.TextChanged += (sender, args) => doValidation(); BrowseButton.Click += (sender, args) => { var fileDialog = new FolderSelectDialog(); var result = fileDialog.ShowDialog(); if (result) PathTextBox.Text = fileDialog.FileName; }; CancelButton.Click += (sender, args) => DialogResult = false; OkButton.Click += (sender, args) => { _input.InputPath = PathTextBox.Text; _input.Recursive = (bool) RecurseCheckbox.IsChecked; _input.Mask = String.IsNullOrWhiteSpace(FileMaskTextBox.Text) ? "*.*" : FileMaskTextBox.Text; _input.NumRowsToSample = Math.Max(0, Int32.Parse(NumRowsToSampleTextBox.Text)); Input = _input; DialogResult = true; }; doValidation(); PathTextBox.Focus(); }
public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { var project = context.Instance as PipelineProjectProxy; var initialDir = (string)value; if (initialDir == null || !Directory.Exists(initialDir)) { initialDir = project.Location; } var dlg = new FolderSelectDialog() { InitialDirectory = initialDir, Title = "Select Folder", }; if (dlg.ShowDialog(MainView.Form.Handle)) { return(dlg.FileName); } return(value); }
public MainWindow() { InitializeComponent(); FolderSelectDialog dialog = new FolderSelectDialog(); dialog.InitialDirectory = Directory.GetCurrentDirectory(); dialog.Title = "Select patch directory"; if (dialog.ShowDialog()) { var path = dialog.FileName; var name = Path.GetFileName(path); TreeViewItem item = new TreeViewItem(); item.Header = name; item.Tag = path; item.FontWeight = FontWeights.Normal; item.Items.Add(createDummyNode()); item.Expanded += new RoutedEventHandler(folder_Expanded); foldersItem.Items.Add(item); } else { this.Close(); } }