System.Windows.Forms.CommonDialog.ShowDialog(System.Windows.Forms.IWin32Window)

Here are the examples of the csharp api class System.Windows.Forms.CommonDialog.ShowDialog(System.Windows.Forms.IWin32Window) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

1. Example

Project: 0install-win
Source File: PortableCreatorDialog.cs
private void buttonSelectTarget_Click(object sender, System.EventArgs e)
        {
            using (var folderBrowserDialog = new FolderBrowserDialog {SelectedPath = textBoxTarget.Text})
            {
                if (folderBrowserDialog.ShowDialog(this) == DialogResult.OK)
                    textBoxTarget.Text = folderBrowserDialog.SelectedPath;
            }

            textBoxTarget.Focus();
        }

2. Example

Project: 0install-win
Source File: SyncWizard.cs
private void buttonFileShareBrowse_Click(object sender, EventArgs e)
        {
            using (var openFileDialog = new FolderBrowserDialog {RootFolder = Environment.SpecialFolder.MyComputer})
            {
                if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                    textBoxFileShare.Text = openFileDialog.SelectedPath;
            }
        }

3. Example

Project: ContinuousTests
Source File: TestLoaderUI.cs
public static void AddToProject( Form owner, string configName )
		{
			TestLoader loader = Services/n ..... /n //View Source file for more details /n }

4. Example

Project: ContinuousTests
Source File: TestLoaderUI.cs
public static void AddAssembly( Form owner, string configName )
		{
			TestLoader loader = Services.TestLoader;
			ProjectConfig config = configName == null
				? loader.TestProject.ActiveConfig
				: loader.TestProject.Configs[configName];

			OpenFileDialog dlg = new OpenFileDialog();
			dlg.Title = "Add Assembly";
			dlg.InitialDirectory = config.BasePath;
            dlg.Filter = "Assemblies (*.dll,*.exe)|*.dll;*.exe";
			dlg.FilterIndex = 1;
			dlg.FileName = "";

            if (dlg.ShowDialog(owner) == DialogResult.OK)
                config.Assemblies.Add(dlg.FileName);
		}

5. Example

Project: ContinuousTests
Source File: TestLoaderUI.cs
public static void AddVSProject( Form owner )
		{
			TestLoader loader = Services.TestLoader;
			OpenFileDialog dlg = new OpenFileDialog();
			dlg.Title = "Add Visual Studio Project";

			dlg.Filter =
				"All Project Types (*.csproj,*.vjsproj,*.vbproj,*.vcproj)|*.csproj;*.vjsproj;*.vbproj;*.vcproj|" +
				"C# Projects (*.csproj)|*.csproj|" +
				"J# Projects (*.vjsproj)|*.vjsproj|" +
				"VB Projects (*.vbproj)|*.vbproj|" +
				"C++ Projects (*.vcproj)|*.vcproj|" +
				"All Files (*.*)|*.*";

			dlg.FilterIndex = 1;
			dlg.FileName = "";

			if ( dlg.ShowDialog( owner ) == DialogResult.OK ) 
			{
				try
				{
					VSProject vsProject = new VSProject( dlg.FileName );
					loader.TestProject.Add( vsProject );
				}
				catch( Exception ex )
				{
					UserMessage.DisplayFailure( ex.Message, "Invalid VS Project" );
				}
			}
        }

6. Example

Project: ContinuousTests
Source File: TestLoaderUI.cs
public static void NewProject( Form owner )
		{
			TestLoader loader = Services.TestLoader;
			SaveFileDialog dlg = new SaveFileDialog();
			dlg.Title = "New Test Project";
			dlg.Filter = "NUnit Test Project (*.nunit)|*.nunit|All Files (*.*)|*.*";
			dlg.FileName = Services.ProjectService.GenerateProjectName();
			dlg.DefaultExt = "nunit";
			dlg.ValidateNames = true;
			dlg.OverwritePrompt = true;

			if ( dlg.ShowDialog( owner ) == DialogResult.OK )
				loader.NewProject( dlg.FileName );
		}

7. Example

Project: ContinuousTests
Source File: ProjectEditorSettingsPage.cs
private void editorPathBrowseButton_Click(object sender, EventArgs e)
        {
			OpenFileDialog dlg = new OpenFileDialog();
			if ( Site != null ) dlg.Site = Site;
			dlg.Title = "Select Project Editor";

			dlg.Filter = "Executable Files (*.exe)|*.exe";
			dlg.FilterIndex = 1;
			dlg.FileName = "";

			if ( dlg.ShowDialog( this ) == DialogResult.OK ) 
				editorPathTextBox.Text = dlg.FileName;
        }

8. Example

Project: ContinuousTests
Source File: NUnitPresenter.cs
public void AddToProject( string configName )
		{
			ProjectConfig config = configName == null
				?/n ..... /n //View Source file for more details /n }

9. Example

Project: ContinuousTests
Source File: NUnitPresenter.cs
public void AddAssembly( string configName )
		{
			ProjectConfig config = configName == null
				? loader.TestProject.ActiveConfig
				: loader.TestProject.Configs[configName];

			OpenFileDialog dlg = new OpenFileDialog();
			dlg.Title = "Add Assembly";
			dlg.InitialDirectory = config.BasePath;
            dlg.Filter = "Assemblies (*.dll,*.exe)|*.dll;*.exe";
			dlg.FilterIndex = 1;
			dlg.FileName = "";

            if (dlg.ShowDialog(Form) == DialogResult.OK)
                config.Assemblies.Add(dlg.FileName);
		}

10. Example

Project: ContinuousTests
Source File: NUnitPresenter.cs
public void AddVSProject()
		{
			OpenFileDialog dlg = new OpenFileDialog();
			dlg.Title = "Add Visual Studio Project";

			dlg.Filter =
				"All Project Types (*.csproj,*.vjsproj,*.vbproj,*.vcproj)|*.csproj;*.vjsproj;*.vbproj;*.vcproj|" +
				"C# Projects (*.csproj)|*.csproj|" +
				"J# Projects (*.vjsproj)|*.vjsproj|" +
				"VB Projects (*.vbproj)|*.vbproj|" +
				"C++ Projects (*.vcproj)|*.vcproj|" +
				"All Files (*.*)|*.*";

			dlg.FilterIndex = 1;
			dlg.FileName = "";

			if ( dlg.ShowDialog( Form ) == DialogResult.OK ) 
			{
				try
				{
					VSProject vsProject = new VSProject( dlg.FileName );
					loader.TestProject.Add( vsProject );
				}
				catch( Exception ex )
				{
                    Form.MessageDisplay.Error("Invalid VS Project", ex);
				}
			}
        }

11. Example

Project: ContinuousTests
Source File: TestLoaderUI.cs
public static void AddToProject( Form owner, string configName )
		{
			TestLoader loader = Services/n ..... /n //View Source file for more details /n }

12. Example

Project: ContinuousTests
Source File: TestLoaderUI.cs
public static void AddAssembly( Form owner, string configName )
		{
			TestLoader loader = Services.TestLoader;
			ProjectConfig config = configName == null
				? loader.TestProject.ActiveConfig
				: loader.TestProject.Configs[configName];

			OpenFileDialog dlg = new OpenFileDialog();
			dlg.Title = "Add Assembly";
			dlg.InitialDirectory = config.BasePath;
            dlg.Filter = "Assemblies (*.dll,*.exe)|*.dll;*.exe";
			dlg.FilterIndex = 1;
			dlg.FileName = "";

            if (dlg.ShowDialog(owner) == DialogResult.OK)
                config.Assemblies.Add(dlg.FileName);
		}

13. Example

Project: ContinuousTests
Source File: TestLoaderUI.cs
public static void AddVSProject( Form owner )
		{
			TestLoader loader = Services.TestLoader;
			OpenFileDialog dlg = new OpenFileDialog();
			dlg.Title = "Add Visual Studio Project";

			dlg.Filter =
				"All Project Types (*.csproj,*.vjsproj,*.vbproj,*.vcproj)|*.csproj;*.vjsproj;*.vbproj;*.vcproj|" +
				"C# Projects (*.csproj)|*.csproj|" +
				"J# Projects (*.vjsproj)|*.vjsproj|" +
				"VB Projects (*.vbproj)|*.vbproj|" +
				"C++ Projects (*.vcproj)|*.vcproj|" +
				"All Files (*.*)|*.*";

			dlg.FilterIndex = 1;
			dlg.FileName = "";

			if ( dlg.ShowDialog( owner ) == DialogResult.OK ) 
			{
				try
				{
					VSProject vsProject = new VSProject( dlg.FileName );
					loader.TestProject.Add( vsProject );
				}
				catch( Exception ex )
				{
					UserMessage.DisplayFailure( ex.Message, "Invalid VS Project" );
				}
			}
        }

14. Example

Project: ContinuousTests
Source File: TestLoaderUI.cs
public static void NewProject( Form owner )
		{
			TestLoader loader = Services.TestLoader;
			SaveFileDialog dlg = new SaveFileDialog();
			dlg.Title = "New Test Project";
			dlg.Filter = "NUnit Test Project (*.nunit)|*.nunit|All Files (*.*)|*.*";
			dlg.FileName = Services.ProjectService.GenerateProjectName();
			dlg.DefaultExt = "nunit";
			dlg.ValidateNames = true;
			dlg.OverwritePrompt = true;

			if ( dlg.ShowDialog( owner ) == DialogResult.OK )
				loader.NewProject( dlg.FileName );
		}

15. Example

Project: Cyotek.Windows.Forms.ColorPicker
Source File: ColorPickerDialog.cs
private void colorGrid_EditingColor(object sender, EditColorCancelEventArgs e)
    {
      e.Cancel = true;

      using (ColorDialog dialog = new ColorDialog
                                  {
                                    FullOpen = true,
                                    Color = e.Color
                                  })
      {
        if (dialog.ShowDialog(this) == DialogResult.OK)
        {
          colorGrid.Colors[e.ColorIndex] = dialog.Color;
        }
      }
    }

16. Example

Project: diagramnet
Source File: Main.cs
private void File_Open()
		{
            openFileDialog1.FileName = FileName;
            openFileDialog1.Filter = "???dgn???(*.dgn)|*.dgn|??????(*.*)|*.*";
            openFileDialog1.DefaultExt = ".dgn";
            if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
			{
                FileName = openFileDialog1.FileName;

                designer1.Open(openFileDialog1.FileName);
			}
		}

17. Example

Project: CharacterEditor
Source File: Editor.Character.cs
private void ButtonHairColorClick(object sender, EventArgs e)
		{
			ColorDialog colorDialog = new ColorDialog
			{
				Color = buttonHairColor.BackColor,
				FullOpen = true
			};

			colorDialog.ShowDialog(this);

			buttonHairColor.BackColor = colorDialog.Color;
		}

18. Example

Project: ig-memtrace
Source File: OptionsDialog.cs
private void BrowseButton_Click(object sender, EventArgs e)
    {
      using (var dlg = new FolderBrowserDialog())
      {
        dlg.Description = "Select Trace File Directory";
        if (DialogResult.OK == dlg.ShowDialog(this))
        {
          m_TraceDirectory.Text = dlg.SelectedPath;
        }
      }
    }

19. Example

Project: xsddiagram
Source File: DiagramPrinter.cs
public void PageSetup()
        {
            if (_printDocument == null)
            {
                return;
            }

            PageSetupDialog pageSetup = new PageSetupDialog();

            pageSetup.Document = _printDocument;

            pageSetup.ShowDialog(Form.ActiveForm);
        }

20. Example

Project: dp2
Source File: LabelLineFormatDialog.cs
private void button_setForeColor_Click(object sender, EventArgs e)
        {
            Color old_color = Color.Black;
            if (string.IsNullOrEmpty(this.textBox_foreColor.Text) == false)
                old_color = PrintLabelDocument.GetColor(this.textBox_foreColor.Text);

            ColorDialog dlg = new ColorDialog();

            dlg.Color = old_color;
            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel)
                return;

            if (dlg.Color == Color.Black)
                this.textBox_foreColor.Text = "";
            else
                this.textBox_foreColor.Text = PrintLabelDocument.GetColorString(dlg.Color);
        }

21. Example

Project: dp2
Source File: LabelLineFormatDialog.cs
private void button_setBackColor_Click(object sender, EventArgs e)
        {
            Color trans_color = Color.Transparent;  //  Color.FromArgb(192, 192, 193);  // ????????
            Color old_color = trans_color;
            if (string.IsNullOrEmpty(this.textBox_backColor.Text) == false)
                old_color = PrintLabelDocument.GetColor(this.textBox_backColor.Text);

            ColorDialog dlg = new ColorDialog();

            dlg.Color = old_color;
            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel)
                return;

            if (dlg.Color == trans_color)
                this.textBox_backColor.Text = "";
            else
                this.textBox_backColor.Text = PrintLabelDocument.GetColorString(dlg.Color);
        }

22. Example

Project: DotSpatial
Source File: LayoutInsertToolStrip.cs
private void BtnBitmapClick(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog
            {
                Filter = @"Images (*.png, *.jpg, *.bmp, *.gif, *.tif)|*.png;*.jpg;*.bmp;*.gif;*.tif",
                FilterIndex = 1,
                CheckFileExists = true
            })
            {
                if (ofd.ShowDialog(Parent) == DialogResult.OK)
                {
                    var newBitmap = new LayoutBitmap
                    {
                        Size = new SizeF(100, 100),
                        Filename = ofd.FileName
                    };
                    LayoutControl.AddElementWithMouse(newBitmap);
                    SetChecked(_btnBitmap);
                }
            }
        }

23. Example

Project: DotSpatial
Source File: FontBox.cs
private void CmdShowDialogClick(object sender, EventArgs e)
        {
            if (_fontDialog.ShowDialog(ParentForm) != DialogResult.OK) return;

            Value = _fontDialog.Font;
        }

24. Example

Project: DotSpatial
Source File: JoinDialog.cs
private void CmdSaveClick(object sender, EventArgs e)
        {
            using (SaveFileDialog ofd = new SaveFileDialog { Filter = DataManager.DefaultDataManager.VectorWriteFilter })
            {
                if (ofd.ShowDialog(this) != DialogResult.OK) return;
                tbSave.Text = ofd.FileName;
            }
        }

25. Example

Project: DotSpatial
Source File: LegendItemActionsBase.cs
protected DialogResult ShowDialog(CommonDialog dlg)
        {
            if (dlg == null) throw new ArgumentNullException(nameof(dlg));
            return dlg.ShowDialog(Owner);
        }

26. Example

Project: sharpshell
Source File: FileDialogPlacesEditor.cs
private void browseButton_Click(object sender, EventArgs e)
            {
                FolderBrowserDialog dlg = new FolderBrowserDialog();
                if (dlg.ShowDialog(this) == DialogResult.OK)
                    customPathTextBox.Text = dlg.SelectedPath;
            }

27. Example

Project: sharpshell
Source File: TestShellForm.cs
private void toolStripButtonShellOpenDialog_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();
            openFileDialog.ShowDialog(this);
        }

28. Example

Project: sharpshell
Source File: ServerManagerForm.cs
private void toolStripButtonOpenShellDialog_Click(object sender, EventArgs e)
        {
            //  Show a shell dialog.
            var openFileDialog = new OpenFileDialog();
            openFileDialog.ShowDialog(this);
        }

29. Example

Project: sharpgl
Source File: SceneBuilderForm.cs
private void menuItemRender_Click(object sender, System.EventArgs e)
		{
			//	Take the last render and save it to file.
			SaveFileDialog dialog = new SaveFileDialog();
			dialog.Filter = "Image Files (*.bmp,*.jpg,*.gif)|*.jpg;*.bmp;*.gif";

			if(dialog.ShowDialog(this) == DialogResult.OK)
			{
                //  TODO: Render to bitmap.
				//	Save the file.
                //Bitmap bitmap = openGLCtrlScene.OpenGL.OpenGLBitmap;
				//bitmap.Save(dialog.FileName);
			}
		}

30. Example

Project: EDDiscovery
Source File: WaveConfigureDialog.cs
private void buttonExtBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.DefaultExt = "mp3";
            dlg.AddExtension = true;
            dlg.Filter = "MP3 Files (*.mp3)|*.mp3|WAV files (*.wav)|*.wav|Audio Files (*.mp3;*.wav)|*.mp3;*.wav|All files (*.*)|*.*";

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                textBoxBorderText.Text = dlg.FileName;
            }
        }

31. Example

Project: EDDiscovery
Source File: CommanderForm.cs
private void buttonExtBrowse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "Select folder where Journal*.log files are stored by Frontier in";

            if (fbd.ShowDialog(this) == DialogResult.OK)
                textBoxBorderJournal.Text = fbd.SelectedPath;

        }

32. Example

Project: EDDiscovery
Source File: ExportForm.cs
private void buttonExport_Click(object sender, EventArgs e)
        {
            EliteDangerousCore.DB.SQLiteConnectionUser.PutSettingBool("ExportFormIncludeHeader", checkBoxIncludeHeader.Checked);
            EliteDangerousCore.DB.SQLiteConnectionUser.PutSettingBool("ExportFormOpenExcel", checkBoxCustomAutoOpen.Checked);

            SelectedIndex = comboBoxCustomExportType.SelectedIndex;

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = "CSV export| *.csv";
            dlg.Title = "Export current History view to Excel (csv)";

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                Path = dlg.FileName;
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                DialogResult = DialogResult.Cancel;
                Close();
            }
        }

33. Example

Project: EDDiscovery
Source File: ScreenShotConfigureForm.cs
private void buttonChangeEDScreenshot_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();

            dlg.Description = "Select ED screenshot folder";
            dlg.SelectedPath = textBoxScreenshotsDir.Text;

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                initialssfolder = textBoxScreenshotsDir.Text = dlg.SelectedPath;
            }
        }

34. Example

Project: EDDiscovery
Source File: ScreenShotConfigureForm.cs
private void buttonChangeOutputFolder_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();

            dlg.Description = "Select converted screenshot folder";
            dlg.SelectedPath = textBoxOutputDir.Text;

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                textBoxOutputDir.Text = dlg.SelectedPath;
            }
        }

35. Example

Project: EDDiscovery
Source File: EDDiscoveryForm.cs
private void Read21Folders(bool force)
        {
            if (Controller.history.CommanderId >= 0)
            {
                EDCommander cmdr = EDCommander.Current;
                if (cmdr != null)
                {
                    FolderBrowserDialog dirdlg = new FolderBrowserDialog();
                    DialogResult dlgResult = dirdlg.ShowDialog(this);

                    if (dlgResult == DialogResult.OK)
                    {
                        string logpath = dirdlg.SelectedPath;

                        Controller.RefreshHistoryAsync(netlogpath: logpath, forcenetlogreload: force, currentcmdr: cmdr.Nr);
                    }
                }
            }
        }

36. Example

Project: EDDiscovery
Source File: ThemeStandardEditor.cs
public bool EditColor(ThemeStandard.Settings.CI ex)
        {
            ColorDialog MyDialog = new ColorDialog();
            MyDialog.AllowFullOpen = true;
            MyDialog.FullOpen = true;
            MyDialog.Color = theme.currentsettings.colors[ex];

            if (MyDialog.ShowDialog(this) == DialogResult.OK)
            {
                theme.currentsettings.colors[ex] = MyDialog.Color;
                theme.SetCustom();
                return true;
            }
            else
                return false;
        }

37. Example

Project: TinyNvidiaUpdateChecker
Source File: FolderSelectDialog.cs
private static ShowDialogResult ShowXpDialog(IntPtr ownerHandle, string initialDirectory, string title)
        {
            var folderBrowserDialog = new FolderBrowserDialog
            {
                Description = title,
                SelectedPath = initialDirectory,
                ShowNewFolderButton = false
            };
            var dialogResult = new ShowDialogResult();
            if (folderBrowserDialog.ShowDialog(new WindowWrapper(ownerHandle)) == DialogResult.OK)
            {
                dialogResult.Result = true;
                dialogResult.FileName = folderBrowserDialog.SelectedPath;
            }
            return dialogResult;
        }

38. Example

Project: InnovatorAdmin
Source File: ColorDialog.cs
private void btnCustom_Click(object sender, EventArgs e)
    {
      try
      {
        using (var dialog = new System.Windows.Forms.ColorDialog())
        {
          dialog.FullOpen = true;
          if (dialog.ShowDialog(this) == DialogResult.OK)
          {
            _selectedColor = dialog.Color;
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
          }
        }
      }
      catch (Exception ex)
      {
        Utils.HandleError(ex);
      }
    }

39. Example

Project: mvvm-dialogs
Source File: FolderBrowserDialogWrapper.cs
public DialogResult ShowDialog(IWin32Window owner)
        {
            if (owner == null)
                throw new ArgumentNullException(nameof(owner));

            DialogResult result = folderBrowserDialog.ShowDialog(owner);

            // Update settings
            settings.SelectedPath = folderBrowserDialog.SelectedPath;

            return result;
        }

40. Example

Project: mbunit-v3
Source File: StartupPreferencePane.cs
private void workingDirBrowse_Click(object sender, EventArgs e)
        {
            using (var dialog = new FolderBrowserDialog())
            {
                dialog.ShowNewFolderButton = true;
                dialog.Description = "Select the working directory for AutoCAD.";
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    workingDir.Text = dialog.SelectedPath;
                }
            }
        }

41. Example

Project: mbunit-v3
Source File: StartupPreferencePane.cs
private void executableBrowse_Click(object sender, EventArgs e)
        {
            using (var dialog = new OpenFileDialog())
            {
                dialog.Filter = "acad.exe|acad.exe|All files (*.*)|*.*";
                dialog.RestoreDirectory = true;
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    executable.Text = dialog.FileName;
                }
            }
        }

42. Example

Project: Enterprise-Architect-Toolpack
Source File: EAMappingAddin.cs
void mappingControl_ExportMappingSet(object sender, EventArgs e)
		{
			MappingSet mappingSet = sender as MappingSet;
			//let the user select a file
            var browseExportFileDialog = new SaveFileDialog();
            browseExportFileDialog.Title = "Save export file";
            browseExportFileDialog.Filter = "Mapping Files|*.csv";
            browseExportFileDialog.FilterIndex = 1;
            var dialogResult = browseExportFileDialog.ShowDialog(this.model.mainEAWindow);
            if (dialogResult == DialogResult.OK)
            {
            	//if the user selected the file then put the filename in the abbreviationsfileTextBox
            	EA_MP.MappingFactory.exportMappingSet((EA_MP.MappingSet)mappingSet,browseExportFileDialog.FileName);
            }
			
		}

43. Example

Project: Enterprise-Architect-Toolpack
Source File: ImportMappingForm.cs
void BrowseMappingFileButtonClick(object sender, EventArgs e)
		{
			//let the user select a file
            OpenFileDialog browseImportFileDialog = new OpenFileDialog();
            browseImportFileDialog.Filter = "Mapping Files|*.csv";
            browseImportFileDialog.FilterIndex = 1;
            browseImportFileDialog.Multiselect = false;
            var dialogResult = browseImportFileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
            	//if the user selected the file then put the filename in the abbreviationsfileTextBox
                this.importFileTextBox.Text = browseImportFileDialog.FileName;
            }
		}

44. Example

Project: trizbort
Source File: SettingsDialog.cs
private Color ShowColorDialog(Color color)
        {
            using (var dialog = new ColorDialog())
            {
                dialog.Color = color;
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    return dialog.Color;
                }
            }
            return color;
        }

45. Example

Project: trizbort
Source File: SettingsDialog.cs
private Font ShowFontDialog(Font font)
        {
            using (var dialog = new FontDialog())
            {
                dialog.Font = new Font(font.Name, font.Size, font.Style);
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    return new Font(dialog.Font.Name, dialog.Font.Size, dialog.Font.Style, GraphicsUnit.World);
                }
            }
            return font;
        }

46. Example

Project: gitextensions
Source File: ColorsSettingsPage.cs
private void PickColor(Control targetColorControl)
        {
            using (var colorDialog = new ColorDialog {Color = targetColorControl.BackColor})
            {
                colorDialog.ShowDialog(this);
                targetColorControl.BackColor = colorDialog.Color;
                targetColorControl.Text = colorDialog.Color.Name;
            }

            targetColorControl.ForeColor =
                ColorHelper.GetForeColorForBackColor(targetColorControl.BackColor);
        }

47. Example

Project: gitextensions
Source File: GitSettingsPage.cs
private void BrowseGitPath_Click(object sender, EventArgs e)
        {
            CheckSettingsLogic.SolveGitCommand(GitPath.Text.Trim());

            using (var browseDialog = new OpenFileDialog
            {
                FileName = AppSettings.GitCommandValue,
                Filter = "Git.cmd (git.cmd)|git.cmd|Git.exe (git.exe)|git.exe|Git (git)|git"
            })
            {

                if (browseDialog.ShowDialog(this) == DialogResult.OK)
                {
                    GitPath.Text = browseDialog.FileName;
                }
            }
        }

48. Example

Project: gitextensions
Source File: ScriptsSettingsPage.cs
private void browseScriptButton_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog
            {
                InitialDirectory = "c:\\",
                Filter = "Executable files (*.exe)|*.exe|All files (*.*)|*.*",
                RestoreDirectory = true
            })
            {
                if (ofd.ShowDialog(this) == DialogResult.OK)
                    commandTextBox.Text = ofd.FileName;
            }
        }

49. Example

Project: gitextensions
Source File: FormApplyPatch.cs
private string SelectPatchFile(string initialDirectory)
        {
            using (var dialog = new OpenFileDialog
                             {
                                 Filter = _selectPatchFileFilter.Text + "|*.patch",
                                 InitialDirectory = initialDirectory,
                                 Title = _selectPatchFileCaption.Text
                             })
            {
                return (dialog.ShowDialog(this) == DialogResult.OK) ? dialog.FileName : PatchFile.Text;
            }
        }

50. Example

Project: gitextensions
Source File: FormRemotes.cs
private void SshBrowseClick(object sender, EventArgs e)
        {
            using (var dialog = new OpenFileDialog
                {
                    Filter = _sshKeyOpenFilter.Text + @"|*.ppk",
                    InitialDirectory = ".",
                    Title = _sshKeyOpenCaption.Text
                })
            {
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    PuttySshKey.Text = dialog.FileName;
                }
            }
        }