本文整理汇总了C#中ICommandContext.GetRequiredService方法的典型用法代码示例。如果您正苦于以下问题:C# ICommandContext.GetRequiredService方法的具体用法?C# ICommandContext.GetRequiredService怎么用?C# ICommandContext.GetRequiredService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICommandContext
的用法示例。
在下文中一共展示了ICommandContext.GetRequiredService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteShowAppOptions
public void ExecuteShowAppOptions(ICommandContext context)
{
var oldValue = Config.Instance.ForumDisplayConfig.ShowUnreadThreadsOnly;
using (var of = new OptionsForm())
{
var owner = context.GetRequiredService<IUIShell>().GetMainWindowParent();
var res = of.ShowDialog(owner);
if ((of.ActionType & ChangeActionType.Refresh) == ChangeActionType.Refresh
&& res == DialogResult.OK)
{
if (oldValue != Config.Instance.ForumDisplayConfig.ShowUnreadThreadsOnly)
Forums.Instance.Refresh();
Features.Instance.ConfigChanged();
if (Config.Instance.TickerConfig.ShowTicker)
Ticker.ShowTicker(context);
else
Ticker.HideTicker();
context.GetRequiredService<IMainWindowService>().Refresh();
}
if ((of.ActionType & ChangeActionType.Restart) == ChangeActionType.Restart
&& res == DialogResult.OK)
MessageBox.Show(
owner,
SR.MainForm.AppNeedRestart,
ApplicationInfo.ApplicationName,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
示例2: ExecuteAddForumMessageToFavorites
public void ExecuteAddForumMessageToFavorites(
ICommandContext context, int? messageId)
{
var manager = context.GetRequiredService<IFavoritesManager>();
var activeMsg = ForumMessageCommandHelper.GetMessage(context, messageId);
using (var selForm =
new FavoritesSelectFolderForm(
context,
manager.RootFolder,
true))
{
selForm.Comment = activeMsg.Subject;
var windowParent = context.GetRequiredService<IUIShell>().GetMainWindowParent();
if (selForm.ShowDialog(windowParent) == DialogResult.OK)
{
var folder = selForm.SelectedFolder ?? manager.RootFolder;
if (!manager.AddMessageLink(activeMsg.ID, selForm.Comment, folder))
//сообщения уже есть в разделе
MessageBox.Show(
windowParent,
SR.Favorites.ItemExists.FormatWith(
activeMsg.ID, folder.Name),
ApplicationInfo.ApplicationName,
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
}
示例3: ExecuteGoToMessageWithPrompt
public void ExecuteGoToMessageWithPrompt(ICommandContext context)
{
var parentWindow = context.GetRequiredService<IUIShell>().GetMainWindowParent();
int mid;
using (var etf = new EnterTopicMessageIdForm())
if (etf.ShowDialog(parentWindow) == DialogResult.OK)
mid = etf.MessageId;
else
return;
if (ApplicationManager.Instance.ForumNavigator.SelectMessage(mid))
{
var mainWindowSvc = context.GetService<IMainWindowService>();
if (mainWindowSvc != null)
mainWindowSvc.EnsureVisible();
}
else if (MessageBox.Show(
parentWindow,
SR.Forum.GoToMessage.NotFound.FormatStr(mid),
SR.Search.Error,
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button2) == DialogResult.Yes)
context
.GetRequiredService<IOutboxManager>()
.AddTopicForDownload(mid);
}
示例4: ExecuteGoToMessage
public void ExecuteGoToMessage(
ICommandContext context, int? messageId)
{
var parentWindow = context
.GetRequiredService<IUIShell>()
.GetMainWindowParent();
if (Config.Instance.ConfirmationConfig.ConfirmJump
&& MessageBox.Show(
parentWindow,
SR.Search.JumpRequest,
SR.Search.Confirmation,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) != DialogResult.Yes)
return;
if (ApplicationManager.Instance.ForumNavigator.SelectMessage(
ForumCommandHelper.GetMessageId(context, messageId)))
{
var mainWindowSvc = context.GetService<IMainWindowService>();
if (mainWindowSvc != null)
mainWindowSvc.EnsureVisible();
}
else
MessageBox.Show(
parentWindow,
SR.Search.NotFound,
SR.Search.Error,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
示例5: ExecuteCompactDb
public void ExecuteCompactDb(ICommandContext context)
{
ProgressWorker.Run(
context,
false,
progressVisualizer =>
{
progressVisualizer.SetProgressText(Resources.CompactDbProgressText);
var janusDatabaseManager = context.GetRequiredService<IJanusDatabaseManager>();
using(janusDatabaseManager.GetLock().GetWriterLock())
using (var con = new SQLiteConnection(janusDatabaseManager.GetCurrentConnectionString()))
using (var cmd = con.CreateCommand())
{
con.Open();
// This is a REALLY long operation
cmd.CommandTimeout = Int32.MaxValue;
// Clean up the backend database file
cmd.CommandText = @"pragma page_size=" + SqliteSchemaDriver.PageSize + @"; VACUUM; ANALYZE;";
cmd.ExecuteNonQuery();
}
});
}
示例6: ExecuteRenameFolder
public void ExecuteRenameFolder(ICommandContext context)
{
var favFormSvc = context.GetRequiredService<IFavoritesDummyFormService>();
var activeFolder = (FavoritesFolder)favFormSvc.SelectedEntries.Single();
using (var pb = new FavoritesFolderForm(activeFolder.Name, activeFolder.Comment))
if (pb.ShowDialog(
context.
GetRequiredService<IUIShell>().
GetMainWindowParent()) == DialogResult.OK)
{
activeFolder.Name = pb.FolderName;
activeFolder.Comment = pb.FolderComment;
activeFolder.Update();
favFormSvc.Refresh();
}
}
示例7: ExecuteModerating
public void ExecuteModerating(ICommandContext context, int? messageId)
{
using (var frm = new ModeratingForm(
context,
ForumCommandHelper.GetMessageId(context, messageId)))
frm.ShowDialog(context.GetRequiredService<IUIShell>().GetMainWindowParent());
}
示例8: ExecuteInsertPairTag
public void ExecuteInsertPairTag(
ICommandContext context, string start, string end, bool newLine)
{
if (start == "url=" && Clipboard.ContainsText())
{
var clipboardText = Clipboard.GetText();
if (clipboardText.StartsWith("www."))
start += "http://" + clipboardText;
else if (Uri.IsWellFormedUriString(clipboardText, UriKind.Absolute))
start += clipboardText;
}
switch (start)
{
case "c#":
case "nemerle":
case "msil":
case "midl":
case "asm":
case "ccode":
case "code":
case "pascal":
case "vb":
case "sql":
case "java":
case "perl":
case "php":
Config.Instance.LastLanguageTag = start;
break;
}
context.GetRequiredService<IMessageEditorService>().SurroundText(
"[" + start + "]", "[/" + end + "]", newLine);
}
示例9: ExecuteBuildSearchIndex
public void ExecuteBuildSearchIndex(ICommandContext context)
{
using (var bif = new BuildIndexForm(context))
bif.ShowDialog(
context
.GetRequiredService<IUIShell>()
.GetMainWindowParent());
}
示例10: ExecuteShowUserOptions
public void ExecuteShowUserOptions(ICommandContext context)
{
var orgdbp = LocalUser.DatabasePath;
using (var ouf = new OptionsUserForm(context, false))
{
if (ouf.ShowDialog(
context
.GetRequiredService<IUIShell>()
.GetMainWindowParent()) != DialogResult.OK)
return;
if (orgdbp == LocalUser.DatabasePath)
return;
Forums.Instance.Refresh();
context.GetRequiredService<IMainWindowService>().UpdateText();
}
}
示例11: ExecuteEdit
public void ExecuteEdit(ICommandContext context)
{
EditTagLine(
context,
context
.GetRequiredService<ITagLineListFormService>()
.SelectedTagLines
.Single());
}
示例12: ExecuteCreateFolder
public void ExecuteCreateFolder(ICommandContext context)
{
using (var pb = new FavoritesFolderForm(string.Empty, string.Empty, true))
if (pb.ShowDialog(
context
.GetRequiredService<IUIShell>()
.GetMainWindowParent()) == DialogResult.OK)
{
var favFormSvc = context.GetRequiredService<IFavoritesDummyFormService>();
_favManager.AddFolder(
pb.FolderName,
pb.FolderComment,
favFormSvc.SelectedEntries.Any() && !pb.CreateAsRoot
? (FavoritesFolder)favFormSvc.SelectedEntries.Single()
: _favManager.RootFolder);
favFormSvc.Refresh();
}
}
示例13: ExecuteDeleteItem
public void ExecuteDeleteItem(ICommandContext context)
{
var favFormSvc = context.GetRequiredService<IFavoritesDummyFormService>();
if (favFormSvc.SelectedEntries.Any())
if (MessageBox.Show(
context.GetRequiredService<IUIShell>().GetMainWindowParent(),
SR.Favorites.DeleteItemPrompt,
ApplicationInfo.ApplicationName,
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning) == DialogResult.Yes)
{
foreach (var entry in favFormSvc.SelectedEntries)
entry.Delete();
favFormSvc.LastActiveNode = null;
favFormSvc.Refresh();
}
}
示例14: ExecuteAddLink
public void ExecuteAddLink(ICommandContext context)
{
var favFormSvc = context.GetRequiredService<IFavoritesDummyFormService>();
using (var fi = new FavoritesLinkForm())
if (fi.ShowDialog(
context
.GetRequiredService<IUIShell>()
.GetMainWindowParent()) == DialogResult.OK)
{
_favManager.AddUrlLink(
fi.Url,
fi.Comment,
favFormSvc.SelectedEntries.Any()
? (FavoritesFolder)favFormSvc.SelectedEntries.Single()
: _favManager.RootFolder);
favFormSvc.Refresh();
}
}
示例15: ExecuteSendBugReport
public void ExecuteSendBugReport(ICommandContext context)
{
context
.GetRequiredService<IOutboxManager>()
.AddBugReport(
SR.MainForm.BugReport.DefaultName,
SR.MainForm.BugReport.DefaultDescription,
SR.MainForm.BugReport.DefaultStackTrace,
true);
}