Esempio n. 1
0
        public TimelineEventLongoMatch CreateTimelineEvent()
        {
            TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
            evtType1 = new EventType { Name = "Cat1" };

            evt.EventType = evtType1;
            evt.Notes = "notes";
            evt.Playing = true;
            evt.Teams.Add (new SportsTeam ());
            evt.FieldPosition = new Coordinates ();
            evt.FieldPosition.Points.Add (new Point (1, 2));
            evt.HalfFieldPosition = new Coordinates ();
            evt.HalfFieldPosition.Points.Add (new Point (4, 5));
            evt.GoalPosition = new Coordinates ();
            evt.GoalPosition.Points.Add (new Point (6, 7));
            evt.Rate = 1.5f;
            evt.Name = "Play";
            evt.Start = new Time (1000);
            evt.EventTime = new Time (1500);
            evt.Stop = new Time (2000);
            evt.Rate = 2.3f;

            evt.Tags.Add (new Tag ("test"));
            return evt;
        }
 public void AddPlay(TimelineEventLongoMatch play)
 {
     field.Tagger.AddPlay (play);
     hfield.Tagger.AddPlay (play);
     goal.Tagger.AddPlay (play);
     QueueDraw ();
 }
Esempio n. 3
0
        public void TestAddDefaultPositions()
        {
            TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
            evt.EventType = new EventType ();
            evt.EventType.TagFieldPosition = false;
            evt.EventType.TagHalfFieldPosition = false;
            evt.EventType.TagGoalPosition = false;

            Assert.IsNull (evt.FieldPosition);
            Assert.IsNull (evt.HalfFieldPosition);
            Assert.IsNull (evt.GoalPosition);
            evt.AddDefaultPositions ();
            Assert.IsNull (evt.FieldPosition);
            Assert.IsNull (evt.HalfFieldPosition);
            Assert.IsNull (evt.GoalPosition);

            evt.EventType.TagFieldPosition = true;
            evt.AddDefaultPositions ();
            Assert.IsNotNull (evt.FieldPosition);
            Assert.IsNull (evt.HalfFieldPosition);
            Assert.IsNull (evt.GoalPosition);

            evt.EventType.TagFieldPosition = false;
            evt.EventType.TagHalfFieldPosition = true;
            evt.AddDefaultPositions ();
            Assert.IsNotNull (evt.FieldPosition);
            Assert.IsNotNull (evt.HalfFieldPosition);
            Assert.IsNull (evt.GoalPosition);

            evt.EventType.TagFieldPosition = false;
            evt.EventType.TagHalfFieldPosition = false;
            evt.EventType.TagGoalPosition = true;
            evt.AddDefaultPositions ();
            Assert.IsNotNull (evt.FieldPosition);
            Assert.IsNotNull (evt.HalfFieldPosition);
            Assert.IsNotNull (evt.GoalPosition);

            /* Adding the default positions doesn't not overwrite the existing data */
            evt.EventType.FieldPositionIsDistance = true;
            evt.EventType.HalfFieldPositionIsDistance = true;
            evt.FieldPosition.Points [0].X = 100;
            evt.FieldPosition.Points [0].Y = 100;
            evt.HalfFieldPosition.Points [0].X = 100;
            evt.HalfFieldPosition.Points [0].Y = 100;
            evt.AddDefaultPositions ();
            Assert.AreEqual (1, evt.FieldPosition.Points.Count);
            Assert.AreEqual (1, evt.HalfFieldPosition.Points.Count);
            Assert.AreEqual (100, evt.FieldPosition.Points [0].X);
            Assert.AreEqual (100, evt.HalfFieldPosition.Points [0].X);
        }
        public void LoadPlay(TimelineEventLongoMatch play)
        {
            field.Visible = play.EventType.TagFieldPosition;
            hfield.Visible = play.EventType.TagHalfFieldPosition;
            goal.Visible = play.EventType.TagGoalPosition;

            play.AddDefaultPositions ();

            if (play.FieldPosition != null) {
                field.Tagger.Points = play.FieldPosition.Points;
            }
            if (play.HalfFieldPosition != null) {
                hfield.Tagger.Points = play.HalfFieldPosition.Points;
            }
            if (play.GoalPosition != null) {
                goal.Tagger.Points = play.GoalPosition.Points;
            }
        }
Esempio n. 5
0
        public void TestAddEvent()
        {
            ProjectLongoMatch p = CreateProject (false);
            TimelineEventLongoMatch evt = p.AddEvent (p.EventTypes [0], new Time (1000), new Time (2000),
                                              null, null, false) as TimelineEventLongoMatch;
            Assert.AreEqual (p, evt.Project);

            Assert.AreEqual (p.Timeline.Count, 0);
            p.AddEvent (p.EventTypes [0], new Time (1000), new Time (2000), null, null);
            Assert.AreEqual (p.Timeline.Count, 1);
            p.AddEvent (p.EventTypes [0], new Time (1000), new Time (2000), null, null);
            Assert.AreEqual (p.Timeline.Count, 2);

            evt = new TimelineEventLongoMatch ();
            p.AddEvent (evt);
            Assert.AreEqual (p, evt.Project);
            Assert.AreEqual (p.Description.FileSet, evt.FileSet);
            Assert.AreEqual (p.Timeline.Count, 3);
            p.AddEvent (new TimelineEventLongoMatch ());
            Assert.AreEqual (p.Timeline.Count, 4);
            /*FIXME: add test for score event updating pd score */
        }
Esempio n. 6
0
        public void LoadPlay(TimelineEventLongoMatch play, ProjectLongoMatch project, bool editTags, bool editPos,
		                      bool editPlayers, bool editNotes)
        {
            this.play = play;
            notesframe.Visible = editNotes;
            tagger.Visible = editPos && (play.EventType.TagFieldPosition ||
            play.EventType.TagHalfFieldPosition ||
            play.EventType.TagGoalPosition);
            drawingarea3.Visible = editPlayers;
            nameframe.Visible = editTags;
            tagsvbox.Visible = editTags;

            nameentry.Text = play.Name;
            nameentry.GrabFocus ();

            if (editPos) {
                tagger.LoadBackgrounds (project);
                tagger.LoadPlay (play);
            }

            if (editNotes) {
                notes.Play = play;
            }
            if (editPlayers) {
                teamtagger.Project = project;
                teamtagger.LoadTeams (project.LocalTeamTemplate, project.VisitorTeamTemplate,
                    project.Dashboard.FieldBackground);
                /* Force lineup update */
                teamtagger.CurrentTime = play.EventTime;
                teamtagger.Select (play.Players.Cast<PlayerLongoMatch> ().ToList (),
                    play.Teams.Cast<SportsTeam> ().ToList ());
            }

            if (editTags) {
                FillTags (project, play);
            }
        }
Esempio n. 7
0
 void AddTagsGroup(TimelineEventLongoMatch evt, string grp, List<Tag> tags, SizeGroup sgroup)
 {
     HBox box = new HBox ();
     Label label = new Label (String.IsNullOrEmpty (grp) ? Catalog.GetString ("Common tags") : grp);
     Table tagstable = new Table ((uint)(tags.Count / TAGS_PER_ROW), TAGS_PER_ROW, true);
     RadioButton first = null;
     Tag noneTag = new Tag (Catalog.GetString ("None"));
     label.WidthRequest = 200;
     if (!String.IsNullOrEmpty (grp)) {
         tags.Insert (0, noneTag);
     }
     for (int i = 0; i < tags.Count; i++) {
         uint row_top, row_bottom, col_left, col_right;
         Tag t = tags [i];
         CheckButton tb;
         if (String.IsNullOrEmpty (grp)) {
             tb = new CheckButton (t.Value);
         } else {
             if (first == null) {
                 tb = first = new RadioButton (t.Value);
             } else {
                 tb = new RadioButton (first, t.Value);
             }
         }
         tb.Active = evt.Tags.Contains (t);
         tb.Toggled += (sender, e) => {
             if (tb.Active && t != noneTag) {
                 evt.Tags.Add (t);
             } else {
                 evt.Tags.Remove (t);
             }
         };
         row_top = (uint)(i / tagstable.NColumns);
         row_bottom = (uint)row_top + 1;
         col_left = (uint)i % tagstable.NColumns;
         col_right = (uint)col_left + 1;
         tagstable.Attach (tb, col_left, col_right, row_top, row_bottom);
     }
     sgroup.AddWidget (label);
     box.PackStart (label, false, true, 0);
     box.PackEnd (tagstable, true, true, 0);
     box.Spacing = 5;
     tagsvbox.PackStart (box, false, true, 0);
     tagsvbox.PackStart (new HSeparator ());
 }
Esempio n. 8
0
 public void AddPlay(TimelineEventLongoMatch play)
 {
     if (projectType == ProjectType.FileProject) {
         timeline.AddPlay (play);
     } else if (projectType == ProjectType.FakeCaptureProject) {
         eventslistwidget.AddPlay (play);
     }
     playspositionviewer1.AddPlay (play);
 }
Esempio n. 9
0
        public override TimelineEvent AddEvent(EventType type, Time start, Time stop, Time eventTime, Image miniature,
		                                        bool addToTimeline = true)
        {
            TimelineEventLongoMatch evt;
            string count;
            string name;

            count = String.Format ("{0:000}", EventsByType (type).Count + 1);
            name = String.Format ("{0} {1}", type.Name, count);
            evt = new TimelineEventLongoMatch ();

            evt.Name = name;
            evt.Start = start;
            evt.Stop = stop;
            evt.EventTime = eventTime;
            evt.EventType = type;
            evt.Notes = "";
            evt.Miniature = miniature;
            evt.CamerasConfig = new ObservableCollection<CameraConfig> { new CameraConfig (0) };
            evt.FileSet = Description.FileSet;
            evt.Project = this;

            if (addToTimeline) {
                Timeline.Add (evt);
            }

            if (addToTimeline) {
                if (evt.EventType is ScoreEventType) {
                    UpdateScore ();
                }
            }
            return evt;
        }
Esempio n. 10
0
 public void AddPlay(TimelineEventLongoMatch play)
 {
     playsList.AddPlay (play);
     localPlayersList.AddEvent (play);
     visitorPlayersList.AddEvent (play);
 }
Esempio n. 11
0
 public void TestIsChanged()
 {
     TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.EventType = new EventType ();
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.Notes = "test";
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.Rate = 2f;
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.Teams.Add (new SportsTeam ());
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.FieldPosition = new Coordinates ();
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.HalfFieldPosition = new Coordinates ();
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.GoalPosition = new Coordinates ();
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.Tags.Add (new Tag ("2"));
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.Tags = null;
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.CamerasConfig.Add (new CameraConfig (2));
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.CamerasConfig = null;
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
     evt.Players.Add (new PlayerLongoMatch ());
     Assert.IsTrue (evt.IsChanged);
     evt.IsChanged = false;
 }
Esempio n. 12
0
 public void TestEquals()
 {
     TimelineEventLongoMatch evt1 = new TimelineEventLongoMatch ();
     TimelineEventLongoMatch evt2 = new TimelineEventLongoMatch ();
     Assert.AreNotEqual (evt1, evt2);
     evt2.ID = evt1.ID;
     Assert.AreEqual (evt1, evt2);
     evt2.ID = Guid.Parse (evt1.ID.ToString ());
     Assert.AreEqual (evt1, evt2);
 }
Esempio n. 13
0
        public void TestQueryEventsByPlayer()
        {
            PlayerLongoMatch andoni = new PlayerLongoMatch { Name = "Andoni" };
            PlayerLongoMatch jorge = new PlayerLongoMatch { Name = "Jorge" };
            PlayerLongoMatch victor = new PlayerLongoMatch { Name = "Victor" };
            PlayerLongoMatch josep = new PlayerLongoMatch { Name = "Josep" };
            PlayerLongoMatch davide = new PlayerLongoMatch { Name = "Davide" };
            PlayerLongoMatch messi = new PlayerLongoMatch { Name = "Messi" };
            PlayerLongoMatch ukelele = new PlayerLongoMatch { Name = "ukelele" };

            var players = new List<PlayerLongoMatch> { andoni, jorge, victor, josep, davide };
            foreach (PlayerLongoMatch player in players) {
                TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
                evt.Players.Add (player);
                evt.Players.Add (messi);
                storage.Store (evt);
            }

            QueryFilter filter = new QueryFilter ();
            filter.Add ("Player", messi);
            Assert.AreEqual (5, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter.Add ("Player", andoni);
            Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter.Add ("Player", andoni, jorge, josep);
            Assert.AreEqual (3, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter.Add ("Player", victor, ukelele);
            Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter.Add ("Player", players);
            Assert.AreEqual (5, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
        }
Esempio n. 14
0
 public void TestProjectSetInTimelineEvents()
 {
     ProjectLongoMatch p = CreateProject ();
     TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
     p.AddEvent (evt);
     ProjectLongoMatch newp = Utils.SerializeDeserialize (p);
     Assert.AreEqual (newp, newp.Timeline [0].Project);
 }
Esempio n. 15
0
        public void TestSerialization()
        {
            TimelineEventLongoMatch p = new TimelineEventLongoMatch ();
            Utils.CheckSerialization (p);

            p = CreateTimelineEvent ();
            var newp = Utils.SerializeDeserialize (p);

            Assert.AreEqual (p.EventType.ID, newp.EventType.ID);
            Assert.AreEqual (p.Notes, newp.Notes);
            Assert.AreEqual (p.Teams, newp.Teams);
            Assert.AreEqual (p.FieldPosition, newp.FieldPosition);
            Assert.AreEqual (p.HalfFieldPosition, newp.HalfFieldPosition);
            Assert.AreEqual (p.GoalPosition, newp.GoalPosition);
            Assert.AreEqual (p.Rate, newp.Rate);
            Assert.AreEqual (p.Name, newp.Name);
            Assert.AreEqual (p.Start, newp.Start);
            Assert.AreEqual (p.Stop, newp.Stop);
            Assert.AreEqual (p.Rate, newp.Rate);
            Assert.AreEqual (p.CamerasConfig, new List<CameraConfig> { new CameraConfig (0) });
            Assert.IsNull (p.CamerasLayout);
        }
Esempio n. 16
0
        void FillTags(ProjectLongoMatch project, TimelineEventLongoMatch evt)
        {
            Dictionary<string, List<Tag>> tagsByGroup;
            SizeGroup sgroup = new SizeGroup (SizeGroupMode.Horizontal);

            if (evt.EventType is AnalysisEventType) {
                tagsByGroup = (evt.EventType as AnalysisEventType).TagsByGroup;
            } else {
                tagsByGroup = new Dictionary<string, List<Tag>> ();
            }

            tagsvbox.PackStart (new HSeparator ());
            foreach (var kv in project.Dashboard.CommonTagsByGroup) {
                AddTagsGroup (evt, kv.Key, kv.Value, sgroup);
            }
            foreach (var kv in tagsByGroup) {
                AddTagsGroup (evt, kv.Key, kv.Value, sgroup);
            }
            tagsvbox.ShowAll ();
        }
Esempio n. 17
0
 protected override void SelectionChanged(List<Selection> selections)
 {
     if (selections.Count > 0) {
         TimelineEventLongoMatch p = (selections.Last ().Drawable as PositionObject).Play;
         playSelected = p;
         if (EmitSignals) {
             App.Current.EventsBroker.Publish<LoadEventEvent> (
                 new LoadEventEvent {
                     TimelineEvent = p
                 }
             );
         }
     }
 }
Esempio n. 18
0
        public void SelectPlay(TimelineEventLongoMatch play)
        {
            PositionObject po;

            if (play == playSelected) {
                playSelected = null;
                return;
            }
            playSelected = null;
            ClearSelection ();
            var tpo = Objects.FirstOrDefault (o => (o as PositionObject).Play == play);
            if (tpo != null) {
                po = tpo as PositionObject;
                po.Selected = true;
                widget?.ReDraw ();
            }
        }
Esempio n. 19
0
        public void AddPlay(TimelineEventLongoMatch play)
        {
            PositionObject po;
            Coordinates coords;

            coords = play.CoordinatesInFieldPosition (FieldPosition);
            if (coords == null)
                return;

            po = new PositionObject (coords.Points, Background.Width,
                Background.Height);
            po.Play = play;
            po.Project = Project;
            if (Filter != null) {
                po.Visible = Filter.IsVisible (play);
            }
            AddObject (po);
        }
Esempio n. 20
0
 public TreePath AddEvent(TimelineEventLongoMatch evt, TreeIter evtTter)
 {
     TreeIter childIter = childModel.AppendValues (evtTter, evt);
     TreePath childPath = childModel.GetPath (childIter);
     TreePath path = modelSort.ConvertChildPathToPath (
                         modelFilter.ConvertChildPathToPath (childPath));
     return path;
 }
Esempio n. 21
0
        public void AddPlay(TimelineEventLongoMatch play)
        {
            TreePath path;

            if (project == null)
                return;

            path = treeview.AddEvent (play, itersDic [play.EventType]);
            treeview.ExpandToPath (path);
            treeview.SetCursor (path, null, false);
            var cellRect = treeview.GetBackgroundArea (path, null);
            treeview.ScrollToPoint (cellRect.X, Math.Max (cellRect.Y, 0));
        }
Esempio n. 22
0
        public void TestQueryEventsByEventType()
        {
            AnalysisEventType evtType1 = new AnalysisEventType { Name = "Ball lost" };
            AnalysisEventType evtType2 = new AnalysisEventType { Name = "PC" };
            AnalysisEventType evtType3 = new AnalysisEventType { Name = "Recovery" };
            AnalysisEventType evtType4 = new AnalysisEventType { Name = "Throw-in" };
            AnalysisEventType evtType5 = new AnalysisEventType { Name = "Unused" };
            ScoreEventType score = new ScoreEventType { Name = "Goal" };

            var eventTypes = new List<EventType> { evtType1, evtType2, evtType3, evtType4, score };
            foreach (EventType evtType in eventTypes) {
                TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
                evt.EventType = evtType;
                storage.Store (evt);
            }

            QueryFilter filter = new QueryFilter ();
            filter.Add ("EventType", evtType1);
            Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter.Add ("EventType", evtType4);
            Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter.Add ("EventType", evtType2, evtType3);
            Assert.AreEqual (2, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter.Add ("EventType", eventTypes);
            Assert.AreEqual (5, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter.Add ("EventType", evtType5);
            Assert.AreEqual (0, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter.Add ("EventType", score);
            Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
        }
Esempio n. 23
0
        public void TestRemoveEvents()
        {
            TimelineEventLongoMatch p1, p2, p3;
            List<TimelineEventLongoMatch> plays = new List<TimelineEventLongoMatch> ();
            ProjectLongoMatch p = CreateProject (false);

            p1 = new TimelineEventLongoMatch ();
            p2 = new TimelineEventLongoMatch ();
            p3 = new TimelineEventLongoMatch ();
            p.AddEvent (p1);
            p.AddEvent (p2);
            p.AddEvent (p3);
            plays.Add (p1);
            plays.Add (p2);
            p.RemoveEvents (plays);
            Assert.AreEqual (p.Timeline.Count, 1);
            Assert.AreEqual (p.Timeline [0], p3);
        }
Esempio n. 24
0
        public void TestQueryEventsByNoPlayerOrTeam()
        {
            PlayerLongoMatch messi = new PlayerLongoMatch { Name = "Messi" };
            TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
            evt.Players.Add (messi);
            storage.Store (evt);
            evt = new TimelineEventLongoMatch ();
            storage.Store (evt);

            QueryFilter filter = new QueryFilter ();
            PlayerLongoMatch nullPlayer = null;
            SportsTeam nullTeam = null;

            filter.Add ("Player", nullPlayer);
            Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter = new QueryFilter ();
            filter.Add ("Team", nullTeam);
            Assert.AreEqual (2, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());

            filter = new QueryFilter ();
            QueryFilter teamsAndPlayersFilter = new QueryFilter { Operator = QueryOperator.Or };
            filter.Children.Add (teamsAndPlayersFilter);
            teamsAndPlayersFilter.Add ("Team", nullTeam);
            teamsAndPlayersFilter.Add ("Player", nullPlayer);
            filter.Operator = QueryOperator.Or;
            Assert.AreEqual (2, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
        }
        public void AddEvent(TimelineEventLongoMatch evt)
        {
            TreeIter piter;

            if (evt.Players == null) {
                return;
            }
            team.GetIterFirst (out piter);
            while (team.IterIsValid (piter)) {
                PlayerLongoMatch player = team.GetValue (piter, 0) as PlayerLongoMatch;
                if (evt.Players.Contains (player)) {
                    team.AppendValues (piter, evt);
                }
                team.IterNext (ref piter);
            }
        }
 public void AddPlay(TimelineEventLongoMatch play)
 {
     eventslistwidget.AddPlay (play);
 }