public void RemoveDeadLinks() { Dashboard dashboard = new Dashboard(); AnalysisEventButton b1 = dashboard.AddDefaultItem(0); AnalysisEventButton b2 = dashboard.AddDefaultItem(1); b1.ActionLinks.Add(new ActionLink { DestinationButton = b2 }); dashboard.RemoveDeadLinks(b2); Assert.AreEqual(1, b1.ActionLinks.Count); b1.ActionLinks [0].DestinationTags = new List <Tag> { b2.AnalysisEventType.Tags [0] }; dashboard.RemoveDeadLinks(b2); Assert.AreEqual(1, b1.ActionLinks.Count); b2.AnalysisEventType.Tags.Remove(b2.AnalysisEventType.Tags [1]); dashboard.RemoveDeadLinks(b2); Assert.AreEqual(1, b1.ActionLinks.Count); b2.AnalysisEventType.Tags.Remove(b2.AnalysisEventType.Tags [0]); dashboard.RemoveDeadLinks(b2); Assert.AreEqual(0, b1.ActionLinks.Count); }
public void AddButton(string buttontype) { DashboardButton button = null; if (buttontype == "Card") { button = new PenaltyCardButton { PenaltyCard = new PenaltyCard("Red", Color.Red, CardShape.Rectangle) }; } else if (buttontype == "Score") { button = new ScoreButton { Score = new Score("Score", 1) }; } else if (buttontype == "Timer") { button = new TimerButton { Timer = new Timer { Name = "Timer" } }; } else if (buttontype == "Tag") { button = new TagButton { Tag = new Tag("Tag", "") }; } else if (buttontype == "Category") { button = template.AddDefaultItem(template.List.Count); } else { return; } if (buttontype != "Category") { template.List.Add(button); } button.Position = new Point(template.CanvasWidth, 0); edited = true; Refresh(button); }