private void btnFolderSelection_Click(object sender, EventArgs e) { Control button = sender as Control; CaptureVariable captureVariable = (CaptureVariable)button.Tag; if (!namingTextBoxes.ContainsKey(captureVariable)) { return; } TextBox tb = namingTextBoxes[captureVariable]; CommonOpenFileDialog dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = true; if (Directory.Exists(tb.Text)) { dialog.InitialDirectory = tb.Text; } else { dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { tb.Text = dialog.FileName; } }
private void btnFolderSelection_Click(object sender, EventArgs e) { Control button = sender as Control; CaptureVariable captureVariable = (CaptureVariable)button.Tag; if (!namingTextBoxes.ContainsKey(captureVariable)) { return; } TextBox tb = namingTextBoxes[captureVariable]; FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); folderBrowserDialog.Description = ""; folderBrowserDialog.ShowNewFolderButton = true; folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop; if (Directory.Exists(tb.Text)) { folderBrowserDialog.SelectedPath = tb.Text; } if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { tb.Text = folderBrowserDialog.SelectedPath; } }
private void WriteVariable(CaptureVariable v, string text) { switch (v) { case CaptureVariable.LeftImageRoot: capturePathConfiguration.LeftImageRoot = text; break; case CaptureVariable.LeftImageSubdir: capturePathConfiguration.LeftImageSubdir = text; break; case CaptureVariable.LeftImageFile: capturePathConfiguration.LeftImageFile = text; break; case CaptureVariable.RightImageRoot: capturePathConfiguration.RightImageRoot = text; break; case CaptureVariable.RightImageSubdir: capturePathConfiguration.RightImageSubdir = text; break; case CaptureVariable.RightImageFile: capturePathConfiguration.RightImageFile = text; break; case CaptureVariable.LeftVideoRoot: capturePathConfiguration.LeftVideoRoot = text; break; case CaptureVariable.LeftVideoSubdir: capturePathConfiguration.LeftVideoSubdir = text; break; case CaptureVariable.LeftVideoFile: capturePathConfiguration.LeftVideoFile = text; break; case CaptureVariable.RightVideoRoot: capturePathConfiguration.RightVideoRoot = text; break; case CaptureVariable.RightVideoSubdir: capturePathConfiguration.RightVideoSubdir = text; break; case CaptureVariable.RightVideoFile: capturePathConfiguration.RightVideoFile = text; break; } }
private void tbNamingVariable_TextChanged(object sender, EventArgs e) { Control tb = sender as Control; if (tb == null) { return; } CaptureVariable v = (CaptureVariable)tb.Tag; WriteVariable(v, tb.Text); }