当前位置: 首页>>代码示例>>C#>>正文


C# ICommandContext.GetRequiredService方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:permyakov,项目名称:janus,代码行数:35,代码来源:ApplicationCommandTarget.cs

示例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);
				}
			}
		}
开发者ID:rsdn,项目名称:janus,代码行数:31,代码来源:ForumMessageCommandTarget.cs

示例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);
        }
开发者ID:permyakov,项目名称:janus,代码行数:28,代码来源:ForumViewerCommandTarget.cs

示例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);
        }
开发者ID:permyakov,项目名称:janus,代码行数:31,代码来源:ForumViewerCommandTarget.cs

示例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();
                        }
                    });
        }
开发者ID:permyakov,项目名称:janus,代码行数:26,代码来源:SqliteCommandTarget.cs

示例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();
				}
		}
开发者ID:rsdn,项目名称:janus,代码行数:16,代码来源:FavoritesCommandTarget.cs

示例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());
 }
开发者ID:permyakov,项目名称:janus,代码行数:7,代码来源:ForumMessageCommandTarget.cs

示例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);
        }
开发者ID:permyakov,项目名称:janus,代码行数:34,代码来源:MessageEditorCommandTarget.cs

示例9: ExecuteBuildSearchIndex

 public void ExecuteBuildSearchIndex(ICommandContext context)
 {
     using (var bif = new BuildIndexForm(context))
         bif.ShowDialog(
             context
                 .GetRequiredService<IUIShell>()
                 .GetMainWindowParent());
 }
开发者ID:permyakov,项目名称:janus,代码行数:8,代码来源:SearchCommandTarget.cs

示例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();
			}
		}
开发者ID:rsdn,项目名称:janus,代码行数:17,代码来源:ApplicationCommandTarget.cs

示例11: ExecuteEdit

		public void ExecuteEdit(ICommandContext context)
		{
			EditTagLine(
				context,
				context
					.GetRequiredService<ITagLineListFormService>()
					.SelectedTagLines
					.Single());
		}
开发者ID:rsdn,项目名称:janus,代码行数:9,代码来源:TagLineCommandTarget.cs

示例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();
         }
 }
开发者ID:permyakov,项目名称:janus,代码行数:18,代码来源:FavoritesCommandTarget.cs

示例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();
                }
        }
开发者ID:permyakov,项目名称:janus,代码行数:18,代码来源:FavoritesCommandTarget.cs

示例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();
         }
 }
开发者ID:permyakov,项目名称:janus,代码行数:18,代码来源:FavoritesCommandTarget.cs

示例15: ExecuteSendBugReport

		public void ExecuteSendBugReport(ICommandContext context)
		{
			context
				.GetRequiredService<IOutboxManager>()
				.AddBugReport(
					SR.MainForm.BugReport.DefaultName,
					SR.MainForm.BugReport.DefaultDescription,
					SR.MainForm.BugReport.DefaultStackTrace,
					true);
		}
开发者ID:rsdn,项目名称:janus,代码行数:10,代码来源:ApplicationCommandTarget.cs


注:本文中的ICommandContext.GetRequiredService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。