本文整理汇总了C#中TaskDialog.ShowModal方法的典型用法代码示例。如果您正苦于以下问题:C# TaskDialog.ShowModal方法的具体用法?C# TaskDialog.ShowModal怎么用?C# TaskDialog.ShowModal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskDialog
的用法示例。
在下文中一共展示了TaskDialog.ShowModal方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WarnAboutPythonSymbols
private void WarnAboutPythonSymbols(string moduleName) {
const string content =
"Python/native mixed-mode debugging requires symbol files for the Python interpreter that is being debugged. Please add the folder " +
"containing those symbol files to your symbol search path, and force a reload of symbols for {0}.";
var dialog = new TaskDialog(_serviceProvider);
var openSymbolSettings = new TaskDialogButton("Open symbol settings dialog");
var downloadSymbols = new TaskDialogButton("Download symbols for my interpreter");
dialog.Buttons.Add(openSymbolSettings);
dialog.Buttons.Add(downloadSymbols);
dialog.Buttons.Add(TaskDialogButton.Close);
dialog.UseCommandLinks = true;
dialog.Title = "Python Symbols Required";
dialog.Content = string.Format(content, moduleName);
dialog.Width = 0;
dialog.ShowModal();
if (dialog.SelectedButton == openSymbolSettings) {
var cmdId = new CommandID(VSConstants.GUID_VSStandardCommandSet97, VSConstants.cmdidToolsOptions);
_serviceProvider.GlobalInvoke(cmdId, "1F5E080F-CBD2-459C-8267-39fd83032166");
} else if (dialog.SelectedButton == downloadSymbols) {
PythonToolsPackage.OpenWebBrowser(
string.Format("http://go.microsoft.com/fwlink/?LinkId=308954&clcid=0x{0:X}", CultureInfo.CurrentCulture.LCID));
}
}
示例2: ShouldIncludeNodeModulesFolderInProject
private bool ShouldIncludeNodeModulesFolderInProject() {
var includeNodeModulesButton = new TaskDialogButton(Resources.IncludeNodeModulesIncludeTitle, Resources.IncludeNodeModulesIncludeDescription);
var cancelOperationButton = new TaskDialogButton(Resources.IncludeNodeModulesCancelTitle);
var taskDialog = new TaskDialog(_project.ProjectMgr.Site) {
AllowCancellation = true,
EnableHyperlinks = true,
Title = SR.ProductName,
MainIcon = TaskDialogIcon.Warning,
Content = Resources.IncludeNodeModulesContent,
Buttons = {
cancelOperationButton,
includeNodeModulesButton
},
FooterIcon = TaskDialogIcon.Information,
Footer = Resources.IncludeNodeModulesInformation,
SelectedButton = cancelOperationButton
};
var button = taskDialog.ShowModal();
return button == includeNodeModulesButton;
}
示例3: CheckForLongPaths
public async Task CheckForLongPaths(string npmArguments = null) {
if (_isCheckingForLongPaths || !NodejsPackage.Instance.GeneralOptionsPage.CheckForLongPaths) {
return;
}
if (npmArguments != null && _uninstallRegex.IsMatch(npmArguments)) {
return;
}
try {
_isCheckingForLongPaths = true;
TaskDialogButton dedupeButton, ignoreButton, disableButton;
var taskDialog = new TaskDialog(NodejsPackage.Instance) {
AllowCancellation = true,
EnableHyperlinks = true,
Title = Resources.LongPathWarningTitle,
MainIcon = TaskDialogIcon.Warning,
Content = Resources.LongPathWarningText,
CollapsedControlText = Resources.LongPathShowPathsExceedingTheLimit,
ExpandedControlText = Resources.LongPathHidePathsExceedingTheLimit,
Buttons = {
(dedupeButton = new TaskDialogButton(Resources.LongPathNpmDedupe, Resources.LongPathNpmDedupeDetail)),
(ignoreButton = new TaskDialogButton(Resources.LongPathDoNothingButWarnNextTime)),
(disableButton = new TaskDialogButton(Resources.LongPathDoNothingAndDoNotWarnAgain, Resources.LongPathDoNothingAndDoNotWarnAgainDetail))
},
FooterIcon = TaskDialogIcon.Information,
Footer = Resources.LongPathFooter
};
taskDialog.HyperlinkClicked += (sender, e) => {
switch (e.Url) {
case "#msdn":
Process.Start("https://go.microsoft.com/fwlink/?LinkId=454508");
break;
case "#uservoice":
Process.Start("https://go.microsoft.com/fwlink/?LinkID=456509");
break;
case "#help":
Process.Start("https://go.microsoft.com/fwlink/?LinkId=456511");
break;
default:
System.Windows.Clipboard.SetText(e.Url);
break;
}
};
recheck:
var longPaths = await Task.Factory.StartNew(() =>
GetLongSubPaths(ProjectHome)
.Concat(GetLongSubPaths(_intermediateOutputPath))
.Select(lpi => string.Format(CultureInfo.InvariantCulture, "• {1}\u00A0<a href=\"{0}\">{2}</a>", lpi.FullPath, lpi.RelativePath, Resources.LongPathClickToCopy))
.ToArray());
if (longPaths.Length == 0) {
return;
}
taskDialog.ExpandedInformation = string.Join("\r\n", longPaths);
var button = taskDialog.ShowModal();
if (button == dedupeButton) {
var repl = NodejsPackage.Instance.OpenReplWindow(focus: false);
await repl.ExecuteCommand(".npm dedupe").HandleAllExceptions(SR.ProductName);
taskDialog.Content += "\r\n\r\n" + Resources.LongPathNpmDedupeDidNotHelp;
taskDialog.Buttons.Remove(dedupeButton);
goto recheck;
} else if (button == disableButton) {
var page = NodejsPackage.Instance.GeneralOptionsPage;
page.CheckForLongPaths = false;
page.SaveSettingsToStorage();
}
} finally {
_isCheckingForLongPaths = false;
}
}
示例4: if
int IOleCommandTarget.Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) {
if (pguidCmdGroup == GuidList.guidWebPackgeCmdId) {
if (nCmdID == 0x101 /* EnablePublishToWindowsAzureMenuItem*/) {
var shell = (IVsShell)((IServiceProvider)this).GetService(typeof(SVsShell));
var webPublishPackageGuid = GuidList.guidWebPackageGuid;
IVsPackage package;
int res = shell.LoadPackage(ref webPublishPackageGuid, out package);
if (!ErrorHandler.Succeeded(res)) {
return res;
}
var cmdTarget = package as IOleCommandTarget;
if (cmdTarget != null) {
res = cmdTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
if (ErrorHandler.Succeeded(res)) {
// TODO: Check flag to see if we were notified
// about being added as a web role.
if (!AddWebRoleSupportFiles()) {
VsShellUtilities.ShowMessageBox(
this,
Strings.AddWebRoleSupportFiles,
null,
OLEMSGICON.OLEMSGICON_INFO,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST
);
}
}
return res;
}
}
} else if (pguidCmdGroup == PublishCmdGuid) {
if (nCmdID == PublishCmdid) {
// Approximately duplicated in DjangoProject
var opts = _site.GetPythonToolsService().SuppressDialogOptions;
if (string.IsNullOrEmpty(opts.PublishToAzure30)) {
var td = new TaskDialog(_site) {
Title = Strings.ProductTitle,
MainInstruction = Strings.PublishToAzure30,
Content = Strings.PublishToAzure30Message,
VerificationText = Strings.DontShowAgain,
SelectedVerified = false,
AllowCancellation = true,
EnableHyperlinks = true
};
td.Buttons.Add(TaskDialogButton.OK);
td.Buttons.Add(TaskDialogButton.Cancel);
if (td.ShowModal() == TaskDialogButton.Cancel) {
return VSConstants.S_OK;
}
if (td.SelectedVerified) {
opts.PublishToAzure30 = "true";
opts.Save();
}
}
}
}
return _menuService.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
}
示例5: ShouldElevate
public static bool ShouldElevate(IServiceProvider site, InterpreterConfiguration config, string operation) {
var opts = site.GetPythonToolsService().GeneralOptions;
if (opts.ElevatePip) {
return true;
}
try {
// Create a test file and delete it immediately to ensure we can do it.
// If this fails, prompt the user to see whether they want to elevate.
var testFile = PathUtils.GetAvailableFilename(config.PrefixPath, "access-test", ".txt");
using (new FileStream(testFile, FileMode.CreateNew, FileAccess.Write, FileShare.Delete, 4096, FileOptions.DeleteOnClose)) { }
return false;
} catch (IOException) {
} catch (UnauthorizedAccessException) {
}
var td = new TaskDialog(site) {
Title = Strings.ProductTitle,
MainInstruction = Strings.ElevateForInstallPackage_MainInstruction,
AllowCancellation = true,
};
var elevate = new TaskDialogButton(Strings.ElevateForInstallPackage_Elevate, Strings.ElevateForInstallPackage_Elevate_Note) {
ElevationRequired = true
};
var noElevate = new TaskDialogButton(Strings.ElevateForInstallPackage_DoNotElevate, Strings.ElevateForInstallPackage_DoNotElevate_Note);
var elevateAlways = new TaskDialogButton(Strings.ElevateForInstallPackage_ElevateAlways, Strings.ElevateForInstallPackage_ElevateAlways_Note) {
ElevationRequired = true
};
td.Buttons.Add(elevate);
td.Buttons.Add(noElevate);
td.Buttons.Add(elevateAlways);
td.Buttons.Add(TaskDialogButton.Cancel);
var sel = td.ShowModal();
if (sel == TaskDialogButton.Cancel) {
throw new OperationCanceledException();
}
if (sel == noElevate) {
return false;
}
if (sel == elevateAlways) {
opts.ElevatePip = true;
opts.Save();
}
return true;
}
示例6: ProjectFinishedGenerating
public void ProjectFinishedGenerating(Project project) {
if (project.DTE.SuppressUI) {
return;
}
string description = null;
try {
var p = project.Properties.Item("InterpreterDescription");
if (p != null) {
description = p.Value as string;
}
} catch (ArgumentException) {
}
if (string.IsNullOrEmpty(description)) {
bool isValid = false;
try {
var p = project.Properties.Item("InterpreterId");
isValid = p != null && !string.IsNullOrEmpty(p.Value as string);
} catch (ArgumentException) {
}
if (!isValid) {
// We don't have a usable interpreter, so there's no point
// going ahead.
// Fall out - the user will find what they need when they
// try and run or edit, but until then there's no reason to
// block them or duplicate all of our help messages into yet
// another assembly.
return;
}
}
ProjectItem requirementsTxt = null;
try {
requirementsTxt = project.ProjectItems.Item("requirements.txt");
} catch (ArgumentException) {
}
if (requirementsTxt == null) {
return;
}
var txt = requirementsTxt.FileNames[0];
if (!File.Exists(txt)) {
return;
}
var provider = WizardHelpers.GetProvider(project.DTE);
if (provider == null) {
return;
}
var td = new TaskDialog(provider) {
Title = string.Format("{0} - {1}", project.Name, Strings.ProductTitle),
MainInstruction = Strings.InstallRequirementsHeading,
Content = Strings.InstallRequirementsMessage,
EnableHyperlinks = true,
AllowCancellation = true,
};
var venv = new TaskDialogButton(
Strings.InstallRequirementsIntoVirtualEnv,
Strings.InstallRequirementsIntoVirtualEnvTip
);
description = description ?? Strings.DefaultInterpreterDescription;
var install = new TaskDialogButton(
string.Format(Strings.InstallRequirementsIntoGlobalEnv, description),
Strings.InstallRequirementsIntoGlobalEnvTip
);
var goAway = new TaskDialogButton(Strings.InstallRequirementsNowhere);
td.Buttons.Add(venv);
td.Buttons.Add(install);
td.Buttons.Add(goAway);
try {
td.ExpandedInformation = File.ReadAllText(txt);
td.CollapsedControlText = Strings.InstallRequirementsShowPackages;
td.ExpandedControlText = Strings.InstallRequirementsHidePackages;
} catch (IOException) {
} catch (NotSupportedException) {
} catch (UnauthorizedAccessException) {
}
var btn = td.ShowModal();
int cmdId = 0;
if (btn == venv) {
cmdId = (int)PkgCmdIDList.cmdidAddVirtualEnv;
} else if (btn == install) {
cmdId = (int)PkgCmdIDList.cmdidInstallRequirementsTxt;
}
if (cmdId != 0) {
object inObj = (object)true, outObj = null;
try {
project.DTE.Commands.Raise(
GuidList.guidPythonToolsCmdSet.ToString("B"),
cmdId,
ref inObj,
ref outObj
);
} catch (Exception ex) {
//.........这里部分代码省略.........
示例7: RunStarted
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) {
var provider = WizardHelpers.GetProvider(automationObject);
if (_wizard == null) {
try {
Directory.Delete(replacementsDictionary["$destinationdirectory$"]);
Directory.Delete(replacementsDictionary["$solutiondirectory$"]);
} catch {
// If it fails (doesn't exist/contains files/read-only), let the directory stay.
}
var dlg = new TaskDialog(provider) {
Title = SR.ProductName,
MainInstruction = SR.GetString(SR.AzureToolsRequired),
Content = SR.GetString(SR.AzureToolsInstallInstructions),
AllowCancellation = true
};
var download = new TaskDialogButton(SR.GetString(SR.DownloadAndInstall));
dlg.Buttons.Add(download);
dlg.Buttons.Add(TaskDialogButton.Cancel);
if (dlg.ShowModal() == download) {
Process.Start(new ProcessStartInfo(AzureToolsDownload));
throw new WizardCancelledException();
}
// User cancelled, so go back to the New Project dialog
throw new WizardBackoutException();
}
if (_recommendUpgrade) {
var sm = SettingsManagerCreator.GetSettingsManager(provider);
var store = sm.GetReadOnlySettingsStore(SettingsScope.UserSettings);
if (!store.CollectionExists(DontShowUpgradeDialogAgainCollection) ||
!store.GetBoolean(DontShowUpgradeDialogAgainCollection, DontShowUpgradeDialogAgainProperty, false)) {
var dlg = new TaskDialog(provider) {
Title = SR.ProductName,
MainInstruction = SR.GetString(SR.AzureToolsUpgradeRecommended),
Content = SR.GetString(SR.AzureToolsUpgradeInstructions),
AllowCancellation = true,
VerificationText = SR.GetString(SR.DontShowAgain)
};
var download = new TaskDialogButton(SR.GetString(SR.DownloadAndInstall));
dlg.Buttons.Add(download);
var cont = new TaskDialogButton(SR.GetString(SR.ContinueWithoutAzureToolsUpgrade));
dlg.Buttons.Add(cont);
dlg.Buttons.Add(TaskDialogButton.Cancel);
var response = dlg.ShowModal();
if (response != cont) {
try {
Directory.Delete(replacementsDictionary["$destinationdirectory$"]);
Directory.Delete(replacementsDictionary["$solutiondirectory$"]);
} catch {
// If it fails (doesn't exist/contains files/read-only), let the directory stay.
}
}
if (dlg.SelectedVerified) {
var rwStore = sm.GetWritableSettingsStore(SettingsScope.UserSettings);
rwStore.CreateCollection(DontShowUpgradeDialogAgainCollection);
rwStore.SetBoolean(DontShowUpgradeDialogAgainCollection, DontShowUpgradeDialogAgainProperty, true);
}
if (response == download) {
Process.Start(new ProcessStartInfo(AzureToolsDownload));
throw new WizardCancelledException();
} else if (response == TaskDialogButton.Cancel) {
// User cancelled, so go back to the New Project dialog
throw new WizardBackoutException();
}
}
}
// Run the original wizard to get the right replacements
_wizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams);
}
示例8: RunStarted
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) {
var provider = WizardHelpers.GetProvider(automationObject);
if (_wizard == null) {
try {
Directory.Delete(replacementsDictionary["$destinationdirectory$"]);
Directory.Delete(replacementsDictionary["$solutiondirectory$"]);
} catch {
// If it fails (doesn't exist/contains files/read-only), let the directory stay.
}
var dlg = new TaskDialog(provider) {
Title = Strings.ProductTitle,
MainInstruction = Strings.AzureToolsRequired,
Content = Strings.AzureToolsInstallInstructions,
AllowCancellation = true
};
dlg.Buttons.Add(TaskDialogButton.Cancel);
var download = new TaskDialogButton(Strings.DownloadAndInstall);
dlg.Buttons.Insert(0, download);
if (dlg.ShowModal() == download) {
StartDownload(provider);
throw new WizardCancelledException();
}
// User cancelled, so go back to the New Project dialog
throw new WizardBackoutException();
}
OfferUpgrade(provider);
// Run the original wizard to get the right replacements
_wizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams);
}
示例9: OfferUpgrade
private void OfferUpgrade(IServiceProvider provider) {
if (!_recommendUpgrade) {
return;
}
var sm = SettingsManagerCreator.GetSettingsManager(provider);
var store = sm.GetReadOnlySettingsStore(SettingsScope.UserSettings);
if (!store.CollectionExists(PythonConstants.DontShowUpgradeDialogAgainCollection) ||
!store.GetBoolean(PythonConstants.DontShowUpgradeDialogAgainCollection, DontShowUpgradeDialogAgainProperty, false)) {
var dlg = new TaskDialog(provider) {
Title = Strings.ProductTitle,
MainInstruction = Strings.AzureToolsUpgradeRecommended,
Content = Strings.AzureToolsUpgradeInstructions,
AllowCancellation = true,
VerificationText = Strings.DontShowAgain
};
var download = new TaskDialogButton(Strings.DownloadAndInstall);
dlg.Buttons.Add(download);
var cont = new TaskDialogButton(Strings.ContinueWithoutAzureToolsUpgrade);
dlg.Buttons.Add(cont);
dlg.Buttons.Add(TaskDialogButton.Cancel);
var response = dlg.ShowModal();
if (dlg.SelectedVerified) {
var rwStore = sm.GetWritableSettingsStore(SettingsScope.UserSettings);
rwStore.CreateCollection(PythonConstants.DontShowUpgradeDialogAgainCollection);
rwStore.SetBoolean(PythonConstants.DontShowUpgradeDialogAgainCollection, DontShowUpgradeDialogAgainProperty, true);
}
if (response == download) {
Process.Start(new ProcessStartInfo(AzureToolsDownload));
throw new WizardCancelledException();
} else if (response == TaskDialogButton.Cancel) {
// User cancelled, so go back to the New Project dialog
throw new WizardBackoutException();
}
}
}
示例10: ExecuteWorker
private async Task ExecuteWorker(PythonProjectNode project) {
_errorListProvider.Tasks.Clear();
var interpFactory = project.GetInterpreterFactoryOrThrow();
var startInfo = GetStartInfo(project);
var packagesToInstall = new List<string>();
foreach (var pkg in startInfo.RequiredPackages) {
if (!await Pip.IsInstalled(interpFactory, pkg)) {
packagesToInstall.Add(pkg);
}
}
if (packagesToInstall.Any()) {
var installMissingButton = new TaskDialogButton(
Strings.CustomCommandPrerequisitesInstallMissing,
Strings.CustomCommandPrerequisitesInstallMissingSubtext + "\r\n\r\n" + string.Join("\r\n", packagesToInstall));
var runAnywayButton = new TaskDialogButton(Strings.CustomCommandPrerequisitesRunAnyway);
var doNotRunButton = new TaskDialogButton(Strings.CustomCommandPrerequisitesDoNotRun);
var taskDialog = new TaskDialog(project.Site) {
Title = Strings.ProductTitle,
MainInstruction = Strings.CustomCommandPrerequisitesInstruction,
Content = Strings.CustomCommandPrerequisitesContent.FormatUI(DisplayLabelWithoutAccessKeys),
AllowCancellation = true,
Buttons = { installMissingButton, runAnywayButton, doNotRunButton, TaskDialogButton.Cancel }
};
var selectedButton = taskDialog.ShowModal();
if (selectedButton == installMissingButton) {
await Pip.Install(
project.Site,
interpFactory,
string.Join(" ", packagesToInstall),
false,
OutputWindowRedirector.GetGeneral(project.Site));
} else if (selectedButton == runAnywayButton) {
} else {
throw new TaskCanceledException();
}
}
if (startInfo.TargetType == CreatePythonCommandItem.TargetTypePip) {
if (startInfo.ExecuteInOutput) {
await Pip.Install(
_project.Site,
interpFactory,
string.IsNullOrEmpty(startInfo.Arguments) ?
startInfo.Filename :
string.Format("{0} {1}", startInfo.Filename, startInfo.Arguments),
project.Site,
false,
OutputWindowRedirector.GetGeneral(project.Site)
);
return;
}
// Rewrite start info to execute
startInfo.TargetType = CreatePythonCommandItem.TargetTypeModule;
startInfo.AddArgumentAtStart(startInfo.Filename);
startInfo.Filename = "pip";
}
if (startInfo.ExecuteInRepl) {
if (await RunInRepl(project, startInfo)) {
return;
}
}
startInfo.AdjustArgumentsForProcessStartInfo(GetInterpreterPath(project, false));
if (startInfo.ExecuteInOutput) {
RunInOutput(project, startInfo);
} else {
RunInConsole(project, startInfo);
}
}
示例11: ResolveAppNameCollisionWithUser
private string ResolveAppNameCollisionWithUser(EnvDTE.ProjectItems items, string name, out bool cancel) {
while (true) {
try {
if (items.Item(name) == null) {
break;
}
} catch (ArgumentException) {
break;
}
var td = new TaskDialog(new ServiceProvider(GetSite())) {
Title = Resources.PythonToolsForVisualStudio,
MainInstruction = string.Format(Resources.DjangoAppAlreadyExistsTitle, name),
Content = string.Format(Resources.DjangoAppAlreadyExistsInstruction, name),
AllowCancellation = true
};
var cont = new TaskDialogButton(
Resources.DjangoAppAlreadyExistsCreateAnyway,
Resources.DjangoAppAlreadyExistsCreateAnywaySubtitle
);
var retry = new TaskDialogButton(Resources.SelectAnotherName);
td.Buttons.Add(cont);
td.Buttons.Add(retry);
td.Buttons.Add(TaskDialogButton.Cancel);
var clicked = td.ShowModal();
if (clicked == cont) {
break;
} else if (clicked == retry) {
name = GetNewAppNameFromUser(name);
if (string.IsNullOrEmpty(name)) {
cancel = true;
return null;
}
} else {
cancel = true;
return null;
}
}
cancel = false;
return name;
}