Add TaskDialog accessibility sample (#3537)

This commit is contained in:
Igor Velikorossov 2020-07-08 11:03:23 +10:00 коммит произвёл GitHub
Родитель 152c8e12b6
Коммит 5f4586df51
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 100 добавлений и 0 удалений

Просмотреть файл

@ -33,6 +33,7 @@
this.FolderBrowserDialog = new System.Windows.Forms.Button();
this.OpenFileDialog = new System.Windows.Forms.Button();
this.SaveFileDialog = new System.Windows.Forms.Button();
this.StartTaskDialog = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// ColorDialog
@ -85,11 +86,22 @@
this.SaveFileDialog.UseVisualStyleBackColor = true;
this.SaveFileDialog.Click += new System.EventHandler(this.SaveFileDialog_Click);
//
// TaskDialog
//
this.StartTaskDialog.Location = new System.Drawing.Point(428, 34);
this.StartTaskDialog.Name = "StartTaskDialog";
this.StartTaskDialog.Size = new System.Drawing.Size(98, 23);
this.StartTaskDialog.TabIndex = 5;
this.StartTaskDialog.Text = "Open TaskDialog";
this.StartTaskDialog.UseVisualStyleBackColor = true;
this.StartTaskDialog.Click += new System.EventHandler(this.StartTaskDialog_Click);
//
// DialogsTesting
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(623, 237);
this.Controls.Add(this.StartTaskDialog);
this.Controls.Add(this.SaveFileDialog);
this.Controls.Add(this.OpenFileDialog);
this.Controls.Add(this.FolderBrowserDialog);
@ -108,6 +120,7 @@
private System.Windows.Forms.Button FolderBrowserDialog;
private System.Windows.Forms.Button OpenFileDialog;
private System.Windows.Forms.Button SaveFileDialog;
private System.Windows.Forms.Button StartTaskDialog;
}
}

Просмотреть файл

@ -42,6 +42,93 @@ namespace AccessibilityTests
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
}
private void StartTaskDialog_Click(object sender, EventArgs e)
{
ShowEventsDemoTaskDialog();
}
private void ShowEventsDemoTaskDialog()
{
var page1 = new TaskDialogPage()
{
Caption = Text,
Heading = "Event Demo",
Text = "Event Demo...",
};
page1.Created += (s, e) => Console.WriteLine("Page1 Created");
page1.Destroyed += (s, e) => Console.WriteLine("Page1 Destroyed");
page1.HelpRequest += (s, e) => Console.WriteLine("Page1 HelpRequest");
page1.Expander = new TaskDialogExpander("Expander")
{
Position = TaskDialogExpanderPosition.AfterFootnote
};
page1.Expander.ExpandedChanged += (s, e) => Console.WriteLine("Expander ExpandedChanged: " + page1.Expander.Expanded);
var buttonOK = TaskDialogButton.OK;
var buttonHelp = TaskDialogButton.Help;
var buttonCancelClose = new TaskDialogCommandLinkButton("C&ancel Close", allowCloseDialog: false);
var buttonShowInnerDialog = new TaskDialogCommandLinkButton("&Show (modeless) Inner Dialog", "(and don't cancel the Close)");
var buttonNavigate = new TaskDialogCommandLinkButton("&Navigate", allowCloseDialog: false);
page1.Buttons.Add(buttonOK);
page1.Buttons.Add(buttonHelp);
page1.Buttons.Add(buttonCancelClose);
page1.Buttons.Add(buttonShowInnerDialog);
page1.Buttons.Add(buttonNavigate);
buttonOK.Click += (s, e) => Console.WriteLine($"Button '{s}' Click");
buttonHelp.Click += (s, e) => Console.WriteLine($"Button '{s}' Click");
buttonCancelClose.Click += (s, e) =>
{
Console.WriteLine($"Button '{s}' Click");
};
buttonShowInnerDialog.Click += (s, e) =>
{
Console.WriteLine($"Button '{s}' Click");
TaskDialog.ShowDialog(new TaskDialogPage()
{
Text = "Inner Dialog"
});
Console.WriteLine($"(returns) Button '{s}' Click");
};
buttonNavigate.Click += (s, e) =>
{
Console.WriteLine($"Button '{s}' Click");
// Navigate to a new page.
var page2 = new TaskDialogPage()
{
Heading = "AfterNavigation.",
Buttons =
{
TaskDialogButton.Close
}
};
page2.Created += (s, e) => Console.WriteLine("Page2 Created");
page2.Destroyed += (s, e) => Console.WriteLine("Page2 Destroyed");
page1.Navigate(page2);
};
page1.Verification = new TaskDialogVerificationCheckBox("&CheckBox1");
page1.Verification.CheckedChanged += (s, e) => Console.WriteLine("CheckBox CheckedChanged: " + page1.Verification.Checked);
var radioButton1 = page1.RadioButtons.Add("Radi&oButton1");
var radioButton2 = page1.RadioButtons.Add("RadioB&utton2");
radioButton1.CheckedChanged += (s, e) => Console.WriteLine("RadioButton1 CheckedChanged: " + radioButton1.Checked);
radioButton2.CheckedChanged += (s, e) => Console.WriteLine("RadioButton2 CheckedChanged: " + radioButton2.Checked);
var dialogResult = TaskDialog.ShowDialog(page1);
Console.WriteLine("---> Dialog Result: " + dialogResult);
}
}
}