Информация о тег-лайне.
예제 #1
0
		public void ExecuteAdd(ICommandContext context)
		{
			var tagLineListFormSvc = context.GetRequiredService<ITagLineListFormService>();

			var tgi = new TagLineInfo
			{
				Name = FindFittingName(context),
				Forums = !GetExcludeHash(tagLineListFormSvc.TagLines, null)
						.Contains(TagLineInfo.AllForums)
					? new[] { TagLineInfo.AllForums }
					: new int[0]
			};

			if (EditTagLine(context, tgi))
				tagLineListFormSvc.TagLines.Add(tgi);
		}
예제 #2
0
		private static HashSet<int> GetExcludeHash(
			IEnumerable<TagLineInfo> tagLines, TagLineInfo notExclude)
		{
			var ht = new HashSet<int>();
			foreach (var tgi in tagLines)
			{
				if (tgi == notExclude)
					continue;
				foreach (var i in tgi.Forums)
					ht.Add(i);
			}
			return ht;
		}
예제 #3
0
		private static bool EditTagLine(IServiceProvider provider, TagLineInfo tgi)
		{
			using (var tlef = new TagLineEditorForm(
				provider,
				GetExcludeHash(
					provider.GetRequiredService<ITagLineListFormService>().TagLines, tgi)))
			{
				tlef.TagLineName = tgi.Name;
				tlef.TagLineFormat = tgi.Format;
				tlef.Forums = tgi.Forums;
				if (tlef.ShowDialog(
						provider
							.GetRequiredService<IUIShell>()
							.GetMainWindowParent()) == DialogResult.OK)
				{
					tgi.Name = tlef.TagLineName;
					tgi.Format = tlef.TagLineFormat;
					tgi.Forums = tlef.Forums;
					return true;
				}
			}
			return false;
		}