本文整理汇总了C#中TaskDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# TaskDialog.ShowDialog方法的具体用法?C# TaskDialog.ShowDialog怎么用?C# TaskDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskDialog
的用法示例。
在下文中一共展示了TaskDialog.ShowDialog方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Alert
public override IDisposable Alert(AlertConfig config)
{
var dlg = new TaskDialog
{
WindowTitle = config.Title,
Content = config.Message,
Buttons =
{
new TaskDialogButton(config.OkText)
}
};
dlg.ShowDialog();
return new DisposableAction(dlg.Dispose);
}
示例2: ActionSheet
public override IDisposable ActionSheet(ActionSheetConfig config)
{
var dlg = new TaskDialog
{
AllowDialogCancellation = config.Cancel != null,
WindowTitle = config.Title
};
config
.Options
.ToList()
.ForEach(x =>
dlg.Buttons.Add(new TaskDialogButton(x.Text)
));
dlg.ButtonClicked += (sender, args) =>
{
var action = config.Options.First(x => x.Text.Equals(args.Item.Text));
action.Action();
};
dlg.ShowDialog();
return new DisposableAction(dlg.Dispose);
}
示例3: ShowMessage
/// <summary>Shows either a <c>TaskDialog</c> or a <c>System.Windows.MessageBox</c> if running legacy windows.</summary>
/// <param name="instructionText">The main text to display (Blue 14pt for <c>TaskDialog</c>).</param>
/// <param name="icon">The icon to use.</param>
/// <param name="standardButtons">The standard buttons to use (with or without the custom default button text).</param>
/// <param name="description">A description of the message, supplements the instruction text.</param>
/// <param name="footerText">Text to display as a footer message.</param>
/// <param name="defaultButtonText">Text to display on the button.</param>
/// <param name="displayShieldOnButton">Indicates if a UAC shield is to be displayed on the defaultButton.</param>
static void ShowMessage(
string instructionText,
TaskDialogStandardIcon icon,
TaskDialogStandardButtons standardButtons,
string description = null,
string footerText = null,
string defaultButtonText = null,
bool displayShieldOnButton = false)
{
if (TaskDialog.IsPlatformSupported)
{
using (var td = new TaskDialog())
{
td.Caption = Resources.SevenUpdateSDK;
td.InstructionText = instructionText;
td.Text = description;
td.Icon = icon;
td.FooterText = footerText;
td.FooterIcon = TaskDialogStandardIcon.Information;
td.CanCancel = true;
td.StandardButtons = standardButtons;
if (defaultButtonText != null)
{
var button = new TaskDialogButton(@"btnCustom", defaultButtonText)
{
Default = true, ShowElevationIcon = displayShieldOnButton
};
td.Controls.Add(button);
}
td.ShowDialog(Application.Current.MainWindow);
return;
}
}
string message = instructionText;
var msgIcon = MessageBoxImage.None;
if (description != null)
{
message += Environment.NewLine + description;
}
if (footerText != null)
{
message += Environment.NewLine + footerText;
}
switch (icon)
{
case TaskDialogStandardIcon.Error:
msgIcon = MessageBoxImage.Error;
break;
case TaskDialogStandardIcon.Information:
msgIcon = MessageBoxImage.Information;
break;
case TaskDialogStandardIcon.Warning:
msgIcon = MessageBoxImage.Warning;
break;
}
MessageBoxResult result;
if (standardButtons == TaskDialogStandardButtons.Cancel || defaultButtonText != null)
{
result = MessageBox.Show(message, Resources.SevenUpdateSDK, MessageBoxButton.OKCancel, msgIcon);
}
else
{
result = MessageBox.Show(message, Resources.SevenUpdateSDK, MessageBoxButton.OK, msgIcon);
}
switch (result)
{
case MessageBoxResult.No:
return;
case MessageBoxResult.OK:
return;
case MessageBoxResult.Yes:
return;
default:
return;
}
}
示例4: ShowTaskDialog
private void ShowTaskDialog()
{
if( TaskDialog.OSSupportsTaskDialogs )
{
using( TaskDialog dialog = new TaskDialog() )
{
dialog.WindowTitle = "Task dialog sample";
dialog.MainInstruction = "This is an example task dialog.";
dialog.Content = "Task dialogs are a more flexible type of message box. Among other things, task dialogs support custom buttons, command links, scroll bars, expandable sections, radio buttons, a check box (useful for e.g. \"don't show this again\"), custom icons, and a footer. Some of those things are demonstrated here.";
dialog.ExpandedInformation = "Ookii.org's Task Dialog doesn't just provide a wrapper for the native Task Dialog API; it is designed to provide a programming interface that is natural to .Net developers.";
dialog.Footer = "Task Dialogs support footers and can even include <a href=\"http://www.ookii.org\">hyperlinks</a>.";
dialog.FooterIcon = TaskDialogIcon.Information;
dialog.EnableHyperlinks = true;
TaskDialogButton customButton = new TaskDialogButton("A custom button");
TaskDialogButton okButton = new TaskDialogButton(ButtonType.Ok);
TaskDialogButton cancelButton = new TaskDialogButton(ButtonType.Cancel);
dialog.Buttons.Add(customButton);
dialog.Buttons.Add(okButton);
dialog.Buttons.Add(cancelButton);
dialog.HyperlinkClicked += new EventHandler<HyperlinkClickedEventArgs>(TaskDialog_HyperLinkClicked);
TaskDialogButton button = dialog.ShowDialog(this);
if( button == customButton )
MessageBox.Show(this, "You clicked the custom button", "Task Dialog Sample");
else if( button == okButton )
MessageBox.Show(this, "You clicked the OK button.", "Task Dialog Sample");
}
}
else
{
MessageBox.Show(this, "This operating system does not support task dialogs.", "Task Dialog Sample");
}
}
示例5: ShowTaskDialogWithCommandLinks
private void ShowTaskDialogWithCommandLinks()
{
if( TaskDialog.OSSupportsTaskDialogs )
{
using( TaskDialog dialog = new TaskDialog() )
{
dialog.WindowTitle = "Task dialog sample";
dialog.MainInstruction = "This is a sample task dialog with command links.";
dialog.Content = "Besides regular buttons, task dialogs also support command links. Only custom buttons are shown as command links; standard buttons remain regular buttons.";
dialog.ButtonStyle = TaskDialogButtonStyle.CommandLinks;
TaskDialogButton elevatedButton = new TaskDialogButton("An action requiring elevation");
elevatedButton.CommandLinkNote = "Both regular buttons and command links can show the shield icon to indicate that the action they perform requires elevation. It is up to the application to actually perform the elevation.";
elevatedButton.ElevationRequired = true;
TaskDialogButton otherButton = new TaskDialogButton("Some other action");
TaskDialogButton cancelButton = new TaskDialogButton(ButtonType.Cancel);
dialog.Buttons.Add(elevatedButton);
dialog.Buttons.Add(otherButton);
dialog.Buttons.Add(cancelButton);
dialog.ShowDialog(this);
}
}
else
{
MessageBox.Show(this, "This operating system does not support task dialogs.", "Task Dialog Sample");
}
}