This example demonstrates how to create task dialogs in NOV. Click any of the buttons above to show a preconfigured task dialog, which demonstrates different task dialog features.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Dom;
using Nevron.Nov.Editors;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System.Text;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NTaskDialogExample";
// Create the NOV example and its controls
NWidget exampleContent = CreateExampleContent();
NWidget exampleControls = CreateExampleControls();
if (exampleControls != null)
{
exampleControls.PreferredWidth = 300;
}
// Place the example and its controls in a pair box
NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
pairBox.FillMode = ENStackFillMode.First;
pairBox.FitMode = ENStackFitMode.First;
pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);
// Host the example in the form
NNovWidgetHost host = new NNovWidgetHost(pairBox);
host.Dock = DockStyle.Fill;
Controls.Add(host);
}
#endregion
#region Example
public NWidget CreateExampleContent()
{
NStackPanel stack = new NStackPanel();
stack.HorizontalPlacement = ENHorizontalPlacement.Left;
NButton messageBoxLikeButton = new NButton("Message Box Like");
messageBoxLikeButton.Click += OnMessageBoxLikeButtonClick;
stack.Add(messageBoxLikeButton);
NButton customButtonsButton = new NButton("Custom Buttons");
customButtonsButton.Click += OnCustomButtonsButtonClick;
stack.Add(customButtonsButton);
NButton advancedCustomButtonsButton = new NButton("Advanced Custom Buttons");
advancedCustomButtonsButton.Click += OnAdvancedCustomButtonsButtonClick;
stack.Add(advancedCustomButtonsButton);
NButton radioButtonsButton = new NButton("Radio Buttons");
radioButtonsButton.Click += OnRadioButtonsButtonClick;
stack.Add(radioButtonsButton);
NButton verificationButton = new NButton("Verification Check Box");
verificationButton.Click += OnVerificationButtonClick;
stack.Add(verificationButton);
NButton allFeaturesButton = new NButton("All Features");
allFeaturesButton.Click += OnAllFeaturesButtonClick;
stack.Add(allFeaturesButton);
return stack;
}
public NWidget CreateExampleControls()
{
m_EventsLog = new NExampleEventsLog();
return m_EventsLog;
}
public string GetExampleDescription()
{
return @"
This example demonstrates how to create task dialogs in NOV. Click any of the buttons above to show
a preconfigured task dialog, which demonstrates different task dialog features.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Task Dialog", "https://www.nevron.com/docs/openvision/ui-task-dialog.html"),
("Common Dialogs", "https://www.nevron.com/docs/openvision/ui-common-dialogs.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
private void OnMessageBoxLikeButtonClick(NEventArgs arg)
{
NTaskDialog taskDialog = NTaskDialog.Create(DisplayWindow);
taskDialog.Title = "Task Dialog";
taskDialog.Header = new NTaskDialogHeader(ENMessageBoxIcon.Question, "Do you want to save the changes?");
taskDialog.Buttons = ENTaskDialogButton.Yes | ENTaskDialogButton.No | ENTaskDialogButton.Cancel;
// Change the texts of the Yes and No buttons
NStackPanel stack = taskDialog.ButtonStrip.GetPredefinedButtonsStack();
NLabel label = (NLabel)stack[0].GetFirstDescendant(NLabel.NLabelSchema);
label.Text = "Save";
label = (NLabel)stack[1].GetFirstDescendant(NLabel.NLabelSchema);
label.Text = "Don't Save";
// Subscribe to the Closed event and open the task dialog
taskDialog.Closed += OnTaskDialogClosed;
taskDialog.Open();
}
private void OnCustomButtonsButtonClick(NEventArgs arg)
{
NTaskDialog taskDialog = NTaskDialog.Create(DisplayWindow);
taskDialog.Title = "Task Dialog";
taskDialog.Header = new NTaskDialogHeader(ENMessageBoxIcon.Information, "This is a task dialog with custom buttons.");
taskDialog.CustomButtons = new NTaskDialogCustomButtonCollection("Custom Button 1",
"Custom Button 2", "Custom Button 3");
// Subscribe to the Closed event and open the task dialog
taskDialog.Closed += OnTaskDialogClosed;
taskDialog.Open();
}
private void OnAdvancedCustomButtonsButtonClick(NEventArgs arg)
{
NTaskDialog taskDialog = NTaskDialog.Create(DisplayWindow);
taskDialog.Title = "Task Dialog";
taskDialog.Header = new NTaskDialogHeader(ENMessageBoxIcon.Information, "This is a task dialog with custom buttons.");
taskDialog.Content = new NLabel("These custom buttons contain a symbol/image, a title and a description.");
// Create some custom buttons
taskDialog.CustomButtons = new NTaskDialogCustomButtonCollection();
taskDialog.CustomButtons.Add(new NTaskDialogCustomButton("Title Only"));
taskDialog.CustomButtons.Add(new NTaskDialogCustomButton("Title and Description", "This button has a title and a description."));
taskDialog.CustomButtons.Add(new NTaskDialogCustomButton(NTaskDialogCustomButton.CreateDefaultSymbol(),
"Symbol, Title, and Description", "This button has a symbol, a title and a description."));
taskDialog.CustomButtons.Add(new NTaskDialogCustomButton(Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACs0lEQVR4Aa2SA8wtRwBGz+xePtu2bSus7Tao7aBmVEW1bdvus237v76rUad2o/cli8E5Q8G/5IHnl/TMeP4juYyYDbEslaP37rz+HBfVcPPNGyx/yl8E9z21tHne46JmTdJ3jB+RpmfHEMI9rFpdYUNxgFy1cfeVqlR4/OabTw3+Irj5sS9zXZq2nJ7xvLub5LzBh8/Ik04nqFoFL9iPF29Cl3fxwc4j2Liz/KZo0uayy8+asB1APPDEkh7C98/o1FbcOnawT4f2GiKDTkKELCCCA4hwF7gHvZNdyWS+2zPEzF2+7+TmLdt+KR55dunanu1U/9mjKtC07f/C+F1BFtG17XwbXcji3W1eT6VTqf6zhy5F1ZvhBWVE7Kbs1i2S3WACLMoJI2QkMXI1SRjgmYDpmWtZqh87NmWBoJLg9TuG1N921gKJAe0e5R4Ta4xOKJRL1BdfwI4dB0lh4eONg5jaPiSX8dm9v0KzplmEEFgLBovwfIyxlKqSlq1aUIpCPtx83M99UsYY2nbpzxdzdzB7QhdatcjzyQ+7fga0/ukxaGXBCKZN68reAwf45vNN1LvMQe394hfB5GFtmJcWfL1oL77n0Tjnk836GPMTDArBwUKNL77YQakW4HXoRN/BHZk71/wiMMDAfq346oftjBrcmnHDOuE5kbFQk1CWgtZ1yVdfb2bXxiqTZ46mEoGSTuCmSNU9r7y1jsmjOzB8cDsH+kQGImVxnFuzdeUMfUf1JRAp5j8/FztmLFprnEDz4qtrGDagNYOHtKMWCwqRppoIlDFECURSuMeSSOjYq5e71pLK59872LpHaUaM7kzfPi1YX4A9ZaiEPuW6RUkPYwRBoB1sqQcGqSBo1JtaY0Wzov1lCd+9s4TPY0kcJURhTOL+ZSJRTm6t5bfY31/QDMshyY/gFJCcZo3GBQAAAABJRU5ErkJggg==")),
"Image, Title and Description", "This button has an icon, a title and a description."));
// Subscribe to the Closed event and open the task dialog
taskDialog.Closed += OnTaskDialogClosed;
taskDialog.Open();
}
private void OnRadioButtonsButtonClick(NEventArgs arg)
{
NTaskDialog taskDialog = NTaskDialog.Create(DisplayWindow);
taskDialog.Title = "Task Dialog";
taskDialog.Header = new NTaskDialogHeader(ENMessageBoxIcon.Information, "This is a task dialog with radio buttons.");
taskDialog.RadioButtonGroup = new NTaskDialogRadioButtonGroup("Radio Button 1", "Radio Button 2");
taskDialog.Buttons = ENTaskDialogButton.OK;
// Subscribe to the Closed event and open the task dialog
taskDialog.Closed += OnTaskDialogClosed;
taskDialog.Open();
}
private void OnVerificationButtonClick(NEventArgs arg)
{
NTaskDialog taskDialog = NTaskDialog.Create(DisplayWindow);
taskDialog.Title = "Task Dialog";
taskDialog.Header = new NTaskDialogHeader(ENMessageBoxIcon.Information, "This is the header.");
taskDialog.Content = new NLabel("This is the content.");
taskDialog.VerificationCheckBox = new NCheckBox("This is the verification check box.");
taskDialog.Buttons = ENTaskDialogButton.OK | ENTaskDialogButton.Cancel;
// Subscribe to the Closed event and open the task dialog
taskDialog.Closed += OnTaskDialogClosed;
taskDialog.Open();
}
private void OnAllFeaturesButtonClick(NEventArgs arg)
{
NTaskDialog taskDialog = NTaskDialog.Create(DisplayWindow);
taskDialog.Title = "Task Dialog";
// Add header and content
taskDialog.Header = new NTaskDialogHeader(ENMessageBoxIcon.Information, "This is the header.");
taskDialog.Content = new NLabel("This is the content.");
// Add some radio buttons and custom buttons
taskDialog.RadioButtonGroup = new NTaskDialogRadioButtonGroup("Radio Button 1",
"Radio Button 2", "Radio Button 3");
taskDialog.CustomButtons = new NTaskDialogCustomButtonCollection("Custom Button 1",
"Custom Button 2", "Custom Button 3");
// Set the common buttons
taskDialog.Buttons = ENTaskDialogButton.OK | ENTaskDialogButton.Cancel;
// Add a verification check box and a footer
taskDialog.VerificationCheckBox = new NCheckBox("This is the verification check box.");
taskDialog.Footer = new NLabel("This is the footer.");
// Subscribe to the Closed event and open the task dialog
taskDialog.Closed += OnTaskDialogClosed;
taskDialog.Open();
}
private void OnTaskDialogClosed(NEventArgs arg)
{
NTaskDialog taskDialog = (NTaskDialog)arg.TargetNode;
int radioButtonIndex = taskDialog.RadioButtonGroup != null ? taskDialog.RadioButtonGroup.SelectedIndex : -1;
bool verificationChecked = taskDialog.VerificationCheckBox != null ? taskDialog.VerificationCheckBox.Checked : false;
StringBuilder sb = new StringBuilder();
sb.AppendLine("Task result: " + taskDialog.TaskResult.ToString());
sb.AppendLine("Radio button: " + radioButtonIndex.ToString());
sb.AppendLine("Custom button: " + taskDialog.CustomButtonIndex.ToString());
sb.AppendLine("Verification: " + verificationChecked.ToString());
m_EventsLog.LogEvent(sb.ToString());
}
#endregion
#region Fields
private NExampleEventsLog m_EventsLog;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
}