public void Click_AnalysisEventButtonVM_NotifiesOk() { // Arrange AnalysisEventButton button = new AnalysisEventButton { EventType = new AnalysisEventType() }; AnalysisEventButtonVM sut = new AnalysisEventButtonVM { Model = button }; sut.CurrentTime = new Time(); sut.SelectedTags.Add(new TagVM { Model = new Tag("hola") }); bool notified = false; List <Tag> tags = null; App.Current.EventsBroker.Subscribe <NewTagEvent> ((e) => { notified = true; tags = e.Tags.ToList(); }); // Act sut.Click(); // Assert Assert.IsTrue(notified); Assert.AreEqual(1, tags.Count()); Assert.AreEqual(0, sut.SelectedTags.Count()); }
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); }
/// <summary> /// Adds a new <see cref="AnalysisEventButton"/> with the default values /// </summary> /// <returns>A new button.</returns> /// <param name="index">Index of this button used to name it</param> public AnalysisEventButton AddDefaultItem(int index) { AnalysisEventButton button = CreateDefaultItem(index); List.Insert(index, button); return(button); }
public void UpdateEventTypesAndTimers_NewProjectWithEventTypesAndTimers_ProjectWithoutEventInDashboardAndTimeline() { ///Arrange var targetProject = new Utils.ProjectDummy(); targetProject.Timers.Clear(); targetProject.EventTypes.Clear(); AnalysisEventButton button = targetProject.Dashboard.List.OfType <AnalysisEventButton> ().First(); targetProject.Timeline.Add(new TimelineEvent { EventType = button.EventType }); targetProject.UpdateEventTypesAndTimers(); ///Act targetProject.Dashboard.List.Remove(button); targetProject.Timeline.Clear(); targetProject.UpdateEventTypesAndTimers(); ///Assert Assert.IsNotNull(targetProject); Assert.AreEqual(1, targetProject.Timers.Count); Assert.AreEqual(4, targetProject.EventTypes.Count); }
public void SetUp() { // load model EventType e = new AnalysisEventType { Tags = new RangeObservableCollection <Tag> { new Tag("Success", "Test") } }; A = new AnalysisEventButton { Name = "A", EventType = e }; B = new AnalysisEventButton { Name = "B", EventType = e }; C = new AnalysisEventButton { Name = "C", EventType = e }; model = new RangeObservableCollection <DashboardButton> (); model.AddRange(new List <DashboardButton> { A, B, C }); CreateLink(A, B); CreateLink(B, C); }
/// <summary> /// Create a new <see cref="AnalysisEventButton"/> with the default values /// </summary> /// <returns>A new button.</returns> /// <param name="index">Index of this button used to name it</param> public override AnalysisEventButton CreateDefaultItem(int index) { AnalysisEventButton button; AnalysisEventType evtype; Color c = Colors.ButtonEventColor; HotKey h = new HotKey(); evtype = new AnalysisEventType { Name = "Event Type " + index, SortMethod = SortMethodType.SortByStartTime, Color = c }; AddDefaultTags(evtype); button = new AnalysisEventButton { EventType = evtype, Start = new Time { TotalSeconds = 10 }, Stop = new Time { TotalSeconds = 10 }, HotKey = h, /* Leave the first row for the timers and score */ Position = new Point(10 + (index % 7) * (CAT_WIDTH + 10), 10 + (index / 7 + 1) * (CAT_HEIGHT + 10)), Width = CAT_WIDTH, Height = CAT_HEIGHT, ShowIcon = true, }; return(button); }
public void RemoveDeadLinks() { Utils.DashboardDummy dashboard = new Utils.DashboardDummy(); AnalysisEventButton b1 = dashboard.AddDefaultItem(0); AnalysisEventButton b2 = dashboard.AddDefaultItem(1); dashboard.AddDefaultTags(b1.AnalysisEventType); dashboard.AddDefaultTags(b2.AnalysisEventType); b1.ActionLinks.Add(new ActionLink { SourceButton = b1, DestinationButton = b2 }); dashboard.RemoveDeadLinks(b2); Assert.AreEqual(1, b1.ActionLinks.Count); b1.ActionLinks [0].DestinationTags = new RangeObservableCollection <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 ViewModelFactoryBaseService_CreateAnalysisEventButtonVM() { var model = new AnalysisEventButton(); var vm = factoryService.CreateViewModel <DashboardButtonVM, DashboardButton> (model); Assert.IsTrue(vm is AnalysisEventButtonVM); }
public void TestAnalysisEventButton() { AnalysisEventButton ab = new AnalysisEventButton(); ab.EventType = new AnalysisEventType(); Assert.AreEqual(ab.EventType, ab.AnalysisEventType); }
//Specific LongoMatch objects public static LMProject CreateProject(bool withEvents = true) { LMTimelineEvent pl; LMProject p = new LMProject(); p.Dashboard = LMDashboard.DefaultTemplate(10); p.LocalTeamTemplate = LMTeam.DefaultTemplate(5); p.LocalTeamTemplate.FormationStr = "2-2"; p.VisitorTeamTemplate = LMTeam.DefaultTemplate(5); p.VisitorTeamTemplate.FormationStr = "2-2"; var pd = new ProjectDescription(); pd.FileSet = new MediaFileSet(); pd.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264", "aac", 320, 240, 1.3, null, "Test asset 1")); pd.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264", "aac", 320, 240, 1.3, null, "Test asset 2")); p.Description = pd; p.UpdateEventTypesAndTimers(); if (withEvents) { AnalysisEventButton b = p.Dashboard.List [0] as AnalysisEventButton; /* No tags, no players */ pl = new LMTimelineEvent { EventType = b.EventType, Start = new Time(0), Stop = new Time(100), FileSet = pd.FileSet }; p.Timeline.Add(pl); /* tags, but no players */ b = p.Dashboard.List [1] as AnalysisEventButton; pl = new LMTimelineEvent { EventType = b.EventType, Start = new Time(0), Stop = new Time(100), FileSet = pd.FileSet }; pl.Tags.Add(b.AnalysisEventType.Tags [0]); p.Timeline.Add(pl); /* tags and players */ b = p.Dashboard.List [2] as AnalysisEventButton; pl = new LMTimelineEvent { EventType = b.EventType, Start = new Time(0), Stop = new Time(100), FileSet = pd.FileSet }; pl.Tags.Add(b.AnalysisEventType.Tags [1]); pl.Players.Add(p.LocalTeamTemplate.List [0]); p.Timeline.Add(pl); } return(p); }
void CreateLink(AnalysisEventButton source, AnalysisEventButton target) { ActionLink link = new ActionLink { SourceButton = source, DestinationButton = target }; link.SourceTags.Add(source.AnalysisEventType.Tags.First()); link.DestinationTags.Add(target.AnalysisEventType.Tags.First()); source.ActionLinks.Add(link); }
void HandleEditEventSubcategories(DashboardButton dashboardButton) { AnalysisEventButton button = (dashboardButton as AnalysisEventButton); AnalysisEventType evt = button.AnalysisEventType; EventTypeTagsEditor dialog = new EventTypeTagsEditor(this.Toplevel as Window); dialog.EventType = evt; dialog.Run(); dialog.Destroy(); ViewModel.Model.RemoveDeadLinks(button); }
/// <summary> /// Removes dead links for this button, called after the event tags /// have been edited. /// </summary> /// <param name="button">Dashboard button.</param> public void RemoveDeadLinks(AnalysisEventButton button) { /* Remove all links pointing to a tag that does not exists anymore */ foreach (DashboardButton b in List) { b.ActionLinks.RemoveAll(l => l.DestinationButton == button && l.DestinationTags != null && l.DestinationTags.Count > 0 && !l.DestinationTags.Intersect(button.AnalysisEventType.Tags).Any()); } }
void EditEventSubcategories(DashboardButton dashboardButton) { AnalysisEventButton button = (dashboardButton as AnalysisEventButton); AnalysisEventType evt = button.AnalysisEventType; EventTypeTagsEditor dialog = new EventTypeTagsEditor(this.Toplevel as Window); dialog.EventType = evt; dialog.Run(); dialog.Destroy(); template.RemoveDeadLinks(button); Edited = true; Refresh(); }
void HandleTimeout(object state) { Config.DrawingToolkit.Invoke(delegate { if (pendingButton != null) { analysisWindow.ClickButton(pendingButton); pendingButton = null; } else if (inPlayerTagging) { TagPlayer(); } }); }
public void TestSerialization() { DashboardButton db = new DashboardButton(); Utils.CheckSerialization(db); db = new TimedDashboardButton(); Utils.CheckSerialization(db); db = new TagButton(); Utils.CheckSerialization(db); db = new TimerButton(); Utils.CheckSerialization(db); db = new EventButton(); Utils.CheckSerialization(db); db = new AnalysisEventButton(); Utils.CheckSerialization(db); }
public void TestCopy() { LMDashboard dashboard = LMDashboard.DefaultTemplate(10); LMDashboard copy = dashboard.Copy("newName") as LMDashboard; Assert.AreNotEqual(dashboard.ID, copy.ID); for (int i = 0; i < dashboard.List.Count; i++) { AnalysisEventButton button = copy.List [i] as AnalysisEventButton; if (button != null) { Assert.AreNotEqual((dashboard.List [i] as AnalysisEventButton).EventType.ID, button.EventType.ID); } } Assert.AreEqual("newName", copy.Name); Assert.AreNotEqual(dashboard.Name, copy.Name); }
void CategoryClicked(AnalysisEventButton category) { if (Button.TagMode == TagMode.Predefined) { emitEvent = true; Active = true; } else if (Button.TagMode == TagMode.Free) { if (!Recording) { StartRecording(); } else { emitEvent = true; } } }
public CategoryObject(AnalysisEventButton category) : base(category) { Button = category; rects = new Dictionary <Rectangle, object> (); buttonsRects = new Dictionary <Rectangle, object> (); SelectedTags = new List <Tag> (); cancelRect = new Rectangle(new Point(0, 0), 0, 0); editRect = new Rectangle(new Point(0, 0), 0, 0); applyRect = new Rectangle(new Point(0, 0), 0, 0); if (iconImage == null) { iconImage = new Image(Path.Combine(Config.ImagesDir, StyleConf.ButtonEventIcon)); } if (recImage == null) { recImage = new Image(Path.Combine(Config.IconsDir, StyleConf.RecordButton)); } if (editImage == null) { editImage = new Image(Path.Combine(Config.IconsDir, StyleConf.EditButton)); } if (cancelImage == null) { cancelImage = new Image(Path.Combine(Config.IconsDir, StyleConf.CancelButton)); } if (applyImage == null) { applyImage = new Image(Path.Combine(Config.IconsDir, StyleConf.ApplyButton)); } MinWidth = 100; MinHeight = HeaderHeight * 2; subcatAnchors = new Dictionary <Tag, LinkAnchorObject> (); foreach (Tag tag in category.AnalysisEventType.Tags) { AddSubcatAnchor(tag, new Point(0, 0), 100, HeaderHeight); } }
public void TestUpdateEventTypesAndTimers() { LMProject p = new LMProject(); p.Dashboard = LMDashboard.DefaultTemplate(5); Assert.AreEqual(0, p.Timers.Count); Assert.AreEqual(0, p.EventTypes.Count); p.UpdateEventTypesAndTimers(); Assert.AreEqual(1, p.Timers.Count); Assert.AreEqual(10, p.EventTypes.Count); // Delete a category button with no events p.Dashboard.List.Remove(p.Dashboard.List.OfType <AnalysisEventButton> ().First()); p.UpdateEventTypesAndTimers(); Assert.AreEqual(1, p.Timers.Count); Assert.AreEqual(9, p.EventTypes.Count); // Delete a category button with events in the timeline AnalysisEventButton button = p.Dashboard.List.OfType <AnalysisEventButton> ().First(); p.Timeline.Add(new LMTimelineEvent { EventType = button.EventType }); p.UpdateEventTypesAndTimers(); Assert.AreEqual(1, p.Timers.Count); Assert.AreEqual(9, p.EventTypes.Count); p.Dashboard.List.Remove(button); p.UpdateEventTypesAndTimers(); Assert.AreEqual(1, p.Timers.Count); Assert.AreEqual(9, p.EventTypes.Count); // Remove the event from the timeline, the event type is no longuer in the dashboard or the timeline p.Timeline.Clear(); p.UpdateEventTypesAndTimers(); Assert.AreEqual(1, p.Timers.Count); Assert.AreEqual(8, p.EventTypes.Count); }
public void ModifyEventType_AddTags_PropertyChangedEmitted() { // Arrange AnalysisEventButton button = new AnalysisEventButton { EventType = new AnalysisEventType() }; AnalysisEventButtonVM buttonVM = new AnalysisEventButtonVM { Model = button }; bool propertyChanged = false; string propertyName = ""; buttonVM.PropertyChanged += (sender, e) => { propertyChanged = true; propertyName = e.PropertyName; }; // Act ((AnalysisEventType)button.EventType).Tags.Add(new Tag("tag", "group")); // Assert Assert.IsTrue(propertyChanged); Assert.AreEqual("Collection_Tags", propertyName); }
//Specific LongoMatch objects public static LMProject CreateProject(bool withEvents = true, bool withLineupEvent = false) { LMTimelineEvent pl; LMProject p = new LMProject(); p.Dashboard = LMDashboard.DefaultTemplate(10); p.LocalTeamTemplate = LMTeam.DefaultTemplate(5); p.LocalTeamTemplate.FormationStr = "2-2"; p.VisitorTeamTemplate = LMTeam.DefaultTemplate(5); p.VisitorTeamTemplate.FormationStr = "2-2"; var pd = new ProjectDescription(); pd.FileSet = new MediaFileSet(); pd.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264", "aac", 320, 240, 1.3, null, "Test asset 1")); pd.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264", "aac", 320, 240, 1.3, null, "Test asset 2")); p.Description = pd; p.Periods.Replace(new RangeObservableCollection <Period> { new Period { Name = "First Period", Nodes = new RangeObservableCollection <TimeNode> { new TimeNode { Start = new Time(10), Stop = new Time(50) } } }, new Period { Name = "Second Period", Nodes = new RangeObservableCollection <TimeNode> { new TimeNode { Start = new Time(50), Stop = new Time(90) } } }, }); p.UpdateEventTypesAndTimers(); if (withLineupEvent) { p.CreateLineupEvent(); } if (withEvents) { AnalysisEventButton b = p.Dashboard.List [0] as AnalysisEventButton; /* No tags, no players */ pl = new LMTimelineEvent { EventType = b.EventType, Start = new Time(0), Stop = new Time(50), FileSet = pd.FileSet }; p.Timeline.Add(pl); /* tags, but no players */ b = p.Dashboard.List [1] as AnalysisEventButton; pl = new LMTimelineEvent { EventType = b.EventType, Start = new Time(20), Stop = new Time(60), FileSet = pd.FileSet }; pl.Tags.Add(b.AnalysisEventType.Tags [0]); p.Timeline.Add(pl); /* tags and players */ b = p.Dashboard.List [2] as AnalysisEventButton; pl = new LMTimelineEvent { EventType = b.EventType, Start = new Time(70), Stop = new Time(100), FileSet = pd.FileSet }; pl.Tags.Add(b.AnalysisEventType.Tags [1]); pl.Players.Add(p.LocalTeamTemplate.List [0]); p.Timeline.Add(pl); } return(p); }
public void DashboardKeyListener(object sender, HotKey key) { KeyAction action; DashboardButton button; if (openedProject == null) { return; } try { action = Config.Hotkeys.ActionsHotkeys.GetKeyByValue(key); } catch { return; } if (action == KeyAction.LocalPlayer || action == KeyAction.VisitorPlayer) { if (inPlayerTagging) { TagPlayer(); } if (pendingButton != null) { analysisWindow.ClickButton(pendingButton); } inPlayerTagging = true; taggedTeam = action == KeyAction.LocalPlayer ? TeamType.LOCAL : TeamType.VISITOR; playerNumber = ""; analysisWindow.TagTeam(taggedTeam); timer.Change(TIMEOUT_MS, 0); } else if (action == KeyAction.None) { if (pendingButton != null) { Tag tag = pendingButton.AnalysisEventType.Tags.FirstOrDefault(t => t.HotKey == key); if (tag != null) { analysisWindow.ClickButton(pendingButton, tag); timer.Change(TIMEOUT_MS, 0); } } else if (dashboardHotkeys.TryGetValue(key, out button)) { if (inPlayerTagging) { TagPlayer(); } if (button is AnalysisEventButton) { AnalysisEventButton evButton = button as AnalysisEventButton; /* Finish tagging for the pending button */ if (pendingButton != null) { analysisWindow.ClickButton(pendingButton); } if (evButton.AnalysisEventType.Tags.Count == 0) { analysisWindow.ClickButton(button); } else { pendingButton = evButton; timer.Change(TIMEOUT_MS, 0); } } else { analysisWindow.ClickButton(button); } } else if (inPlayerTagging) { int number; string name = Keyboard.NameFromKeyval((uint)key.Key); if (name.StartsWith("KP_")) { name = name.Replace("KP_", ""); } if (int.TryParse(name, out number)) { playerNumber += number.ToString(); timer.Change(TIMEOUT_MS, 0); } return; } } }
public static Project CreateProject(bool withEvents = true) { TimelineEvent pl; Project p = new ProjectDummy(); p.Dashboard = DashboardDummy.Default(); p.FileSet = new MediaFileSet(); p.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264", "aac", 320, 240, 1.3, null, "Test asset 1")); p.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264", "aac", 320, 240, 1.3, null, "Test asset 2")); p.Periods.Replace(new RangeObservableCollection <Period> { new Period { Name = "First Period", Nodes = new RangeObservableCollection <TimeNode> { new TimeNode { Start = new Time(10), Stop = new Time(50) } } }, new Period { Name = "Second Period", Nodes = new RangeObservableCollection <TimeNode> { new TimeNode { Start = new Time(50), Stop = new Time(90) } } }, }); p.UpdateEventTypesAndTimers(); p.IsLoaded = true; if (withEvents) { AnalysisEventButton b = p.Dashboard.List [0] as AnalysisEventButton; /* No tags, no players */ pl = new TimelineEvent { EventType = b.EventType, Start = new Time(0), Stop = new Time(50), FileSet = p.FileSet }; p.Timeline.Add(pl); /* tags, but no players */ b = p.Dashboard.List [1] as AnalysisEventButton; pl = new TimelineEvent { EventType = b.EventType, Start = new Time(20), Stop = new Time(60), FileSet = p.FileSet }; pl.Tags.Add(b.AnalysisEventType.Tags [0]); p.Timeline.Add(pl); /* tags and players */ b = p.Dashboard.List [2] as AnalysisEventButton; pl = new TimelineEvent { EventType = b.EventType, Start = new Time(70), Stop = new Time(100), FileSet = p.FileSet }; pl.Tags.Add(b.AnalysisEventType.Tags [1]); p.Timeline.Add(pl); } return(p); }
public void TestIsChanged() { DashboardButton db = new DashboardButton(); Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.Name = "name"; Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.ActionLinks.Add(new ActionLink()); Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.ActionLinks = null; Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.BackgroundColor = Color.Black; Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.BackgroundImage = new Image(5, 5); Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.Height = 100; Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.HotKey = new HotKey { Key = 3 }; Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.Position = new Point(1, 2); Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.TextColor = Color.Green; Assert.IsTrue(db.IsChanged); db.IsChanged = false; db.Width = 200; Assert.IsTrue(db.IsChanged); db.IsChanged = false; var tb = new TimedDashboardButton(); Assert.IsTrue(tb.IsChanged); tb.IsChanged = false; tb.TagMode = TagMode.Free; Assert.IsTrue(tb.IsChanged); tb.IsChanged = false; tb.Start = new Time(29); Assert.IsTrue(tb.IsChanged); tb.IsChanged = false; tb.Stop = new Time(29); Assert.IsTrue(tb.IsChanged); tb.IsChanged = false; var tgb = new TagButton(); Assert.IsTrue(tgb.IsChanged); tgb.IsChanged = false; tgb.Tag = new Tag("test"); Assert.IsTrue(tgb.IsChanged); tgb.IsChanged = false; var eb = new EventButton(); Assert.IsTrue(eb.IsChanged); eb.IsChanged = false; eb.EventType = new EventType(); Assert.IsTrue(eb.IsChanged); eb.IsChanged = false; var aeb = new AnalysisEventButton(); Assert.IsTrue(aeb.IsChanged); aeb.IsChanged = false; aeb.ShowSubcategories = false; Assert.IsTrue(aeb.IsChanged); aeb.IsChanged = false; aeb.TagsPerRow = 4; Assert.IsTrue(aeb.IsChanged); aeb.IsChanged = false; }