private void HandleTaskLinkCollectionChanged(object sender, CollectionChangeEventArgs e) { switch (e.Action) { case CollectionChangeAction.Add: DiplomacyTaskLink taskLink = (DiplomacyTaskLink)e.Element; taskLink.Location = GetNextTaskLocation(); Controls.Add(taskLink); taskLink.Click += new EventHandler(HandleLinkClick); this.internalLinkCollection.Add(taskLink); break; case CollectionChangeAction.Refresh: foreach (DiplomacyTaskLink link in this.internalLinkCollection) { Controls.Remove(link); } this.internalLinkCollection.Clear(); this.nextTaskLocation = new Point(308, 570); break; case CollectionChangeAction.Remove: break; } }
/// <summary> /// Creates and returns a Windows Client implementation of a <c>IDiplomacyTaskLink</c>. /// </summary> /// <param name="text">The text that the user will see in the link.</param> /// <param name="taskCommand">The command to invoke when the link is clicked by the user.</param> /// <returns>A valid reference to an <c>IDiplomacyTaskLink</c> interface.</returns> public IDiplomacyTaskLink CreateTaskLink(string text, Command taskCommand) { DiplomacyTaskLink taskLink = new DiplomacyTaskLink(); taskLink.LinkText = text; taskLink.DiplomacyCommand = taskCommand; taskLink.LinkBehavior = LinkBehavior.HoverUnderline; taskLink.AutoSize = true; taskLink.LinkColor = Color.CornflowerBlue; taskLink.ActiveLinkColor = Color.CornflowerBlue; return(taskLink); }
private void HandleLinkClick(object sender, EventArgs e) { DiplomacyTaskLink taskLink = (DiplomacyTaskLink)sender; taskLink.DiplomacyCommand.Invoke(); }