Exemplo n.º 1
0
		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);
				}
			}
		}
Exemplo n.º 2
0
        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.FormatStr(
                                activeMsg.ID, folder.Name),
                            ApplicationInfo.ApplicationName,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void ExecuteMoveItem(ICommandContext context)
        {
            var favFormSvc = context.GetRequiredService <IFavoritesDummyFormService>();

            using (var selForm =
                       new FavoritesSelectFolderForm(
                           context,
                           _favManager.RootFolder,
                           false))
            {
                var windowParent = context.GetRequiredService <IUIShell>().GetMainWindowParent();

                if (selForm.ShowDialog(windowParent) != DialogResult.OK)
                {
                    return;
                }

                _favManager.RootFolder.ShowLinks = true;

                if (selForm.SelectedFolder == null)
                {
                    return;
                }

                var notMoved = false;
                foreach (var entry in favFormSvc.SelectedEntries)
                {
                    notMoved = !entry.Move(selForm.SelectedFolder);
                }

                favFormSvc.LastActiveNode = null;
                favFormSvc.Refresh();

                if (notMoved)
                {
                    MessageBox.Show(
                        windowParent,
                        SR.Favorites.ElementExists.FormatStr(selForm.SelectedFolder.Name),
                        ApplicationInfo.ApplicationName,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 4
0
        public void ExecuteMoveItem(ICommandContext context)
        {
            var favFormSvc = context.GetRequiredService<IFavoritesDummyFormService>();
            using (var selForm =
                new FavoritesSelectFolderForm(
                    context,
                    _favManager.RootFolder,
                    false))
            {
                var windowParent = context.GetRequiredService<IUIShell>().GetMainWindowParent();

                if (selForm.ShowDialog(windowParent) != DialogResult.OK)
                    return;

                _favManager.RootFolder.ShowLinks = true;

                if (selForm.SelectedFolder == null)
                    return;

                var notMoved = false;
                foreach (var entry in favFormSvc.SelectedEntries)
                    notMoved = !entry.Move(selForm.SelectedFolder);

                favFormSvc.LastActiveNode = null;
                favFormSvc.Refresh();

                if (notMoved)
                    MessageBox.Show(
                        windowParent,
                        SR.Favorites.ElementExists.FormatStr(selForm.SelectedFolder.Name),
                        ApplicationInfo.ApplicationName,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
            }
        }