-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Windows.Forms.App to UnitTest to help test visual controls
- Loading branch information
Showing
11 changed files
with
887 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Windows.Forms; | ||
|
||
namespace Windows.Forms.App | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
private object currentDlg; | ||
|
||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
FillComboWithDialogs(dlgCombo); | ||
} | ||
|
||
private static void FillComboWithDialogs(ComboBox cb) => cb.Items.AddRange(Assembly.GetAssembly(typeof(Vanara.Windows.Forms.AccessControlEditorDialog)).GetTypes().Where(t => !t.IsNested && typeof(CommonDialog).IsAssignableFrom(t) || typeof(Form).IsAssignableFrom(t)).ToArray()); | ||
|
||
private void button1_Click(object sender, EventArgs e) | ||
{ | ||
if (currentDlg is null) return; | ||
try | ||
{ | ||
if (currentDlg is CommonDialog c) | ||
c.ShowDialog(); | ||
else if (currentDlg is Form f) | ||
f.ShowDialog(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
MessageBox.Show(ex.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
} | ||
} | ||
|
||
private void dlgCombo_SelectedIndexChanged(object sender, EventArgs e) | ||
{ | ||
currentDlg = dlgCombo.SelectedItem is null ? null : Activator.CreateInstance((Type)dlgCombo.SelectedItem); | ||
propertyGrid1.SelectedObject = currentDlg; | ||
} | ||
} | ||
} |
Oops, something went wrong.