public void TestSetEventVMWithCoordinates()
        {
            Mock <IDrawingToolkit> tkMock = new Mock <IDrawingToolkit> ();
            var timelineEvent             = new LMTimelineEvent {
                EventType = new EventType()
            };

            timelineEvent.EventType.TagFieldPosition = true;
            timelineEvent.AddDefaultPositions();
            var timelineEventVM = new LMTimelineEventVM {
                Model = timelineEvent
            };

            TimelineEventLocationView view = new TimelineEventLocationView {
                FieldPosition    = FieldPositionType.Field,
                BackgroundWidth  = 100,
                BackgroundHeight = 100,
            };

            view.SetViewModel(timelineEventVM);

            view.Draw(tkMock.Object, null);

            tkMock.Verify(tk => tk.DrawCircle(It.IsAny <Point> (), It.IsAny <double> ()), Times.Once());
        }
示例#2
0
        void FillTags(LMProject project, LMTimelineEvent 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();
        }
示例#3
0
        public void TestDeleteProjectItems()
        {
            LMProject p = new LMProject();

            p.Dashboard = LMDashboard.DefaultTemplate(10);
            p.UpdateEventTypesAndTimers();
            p.LocalTeamTemplate = LMTeam.DefaultTemplate(10);

            for (int i = 0; i < 10; i++)
            {
                LMTimelineEvent evt = new LMTimelineEvent {
                    EventType = p.EventTypes [i],
                    Start     = new Time(1000),
                    Stop      = new Time(2000),
                };
                p.Timeline.Add(evt);
            }

            storage.Store(p);
            p = storage.Retrieve <LMProject> (p.ID);

            // Removing this object should not remove the EvenType from the database, which might be referenced by
            // LMTimelineEvent's in the timeline
            EventType evtType = (p.Dashboard.List [0] as AnalysisEventButton).EventType;

            p.Dashboard.List.Remove(p.Dashboard.List [0]);
            storage.Store(p);
            Assert.DoesNotThrow(() => storage.Retrieve <LMProject> (p.ID));

            // Delete an event with a LMPlayer, a Team and an EventType, it should delete only the timeline event
            p.Timeline [0].Teams.Add(p.LocalTeamTemplate);
            p.Timeline [0].Players.Add(p.LocalTeamTemplate.List [0]);
            p.Timeline.Remove(p.Timeline [0]);
            Assert.DoesNotThrow(() => storage.Retrieve <LMProject> (p.ID));
        }
示例#4
0
        public void TestQueryEventsByNoPlayerOrTeam()
        {
            LMPlayer messi = new LMPlayer {
                Name = "Messi"
            };
            LMTimelineEvent evt = new LMTimelineEvent();

            evt.Players.Add(messi);
            storage.Store(evt);
            evt = new LMTimelineEvent();
            storage.Store(evt);

            QueryFilter filter     = new QueryFilter();
            LMPlayer    nullPlayer = null;
            LMTeam      nullTeam   = null;

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

            filter = new QueryFilter();
            filter.Add("Team", nullTeam);
            Assert.AreEqual(2, storage.Retrieve <LMTimelineEvent> (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 <LMTimelineEvent> (filter).Count());
        }
示例#5
0
        public void TestSerialization()
        {
            LMTimelineEvent p = new LMTimelineEvent();

            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);
        }
示例#6
0
        public LMTimelineEvent CreateTimelineEvent()
        {
            LMTimelineEvent evt = new LMTimelineEvent();

            evtType1 = new EventType {
                Name = "Cat1"
            };

            evt.EventType = evtType1;
            evt.Notes     = "notes";
            evt.Playing   = true;
            evt.Teams.Add(new LMTeam());
            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 TestEventDrawWhenPointChanges()
        {
            int redrawCount = 0;
            Mock <IDrawingToolkit> tkMock = new Mock <IDrawingToolkit> ();
            var timelineEvent             = new LMTimelineEvent {
                EventType = new EventType()
            };
            var timelineEventVM = new LMTimelineEventVM {
                Model = timelineEvent
            };
            TimelineEventLocationView view = new TimelineEventLocationView {
                FieldPosition    = FieldPositionType.Field,
                BackgroundWidth  = 100,
                BackgroundHeight = 100,
            };

            view.SetViewModel(timelineEventVM);
            view.RedrawEvent += (co, area) => redrawCount++;

            timelineEvent.EventType.TagFieldPosition = true;
            timelineEvent.AddDefaultPositions();

            view.Points = timelineEvent.FieldPosition.Points;
            view.Draw(tkMock.Object, null);

            Assert.Greater(redrawCount, 1);
            tkMock.Verify(tk => tk.DrawCircle(It.IsAny <Point> (), It.IsAny <double> ()), Times.Once());
        }
        public void HandleViewModelPropertyChanged_TimeChanged_RedrawNotTriggered()
        {
            int redrawCount = 0;
            Mock <IDrawingToolkit> tkMock = new Mock <IDrawingToolkit> ();
            var timelineEvent             = new LMTimelineEvent {
                EventType = new EventType()
            };
            var timelineEventVM = new LMTimelineEventVM {
                Model = timelineEvent
            };
            TimelineEventLocationView view = new TimelineEventLocationView {
                FieldPosition    = FieldPositionType.Field,
                BackgroundWidth  = 100,
                BackgroundHeight = 100,
            };

            view.SetViewModel(timelineEventVM);
            timelineEvent.EventType.TagFieldPosition = true;
            timelineEvent.AddDefaultPositions();
            view.RedrawEvent += (co, area) => redrawCount++;

            timelineEventVM.Start = new Time();

            Assert.AreEqual(0, redrawCount);
        }
示例#9
0
        public void TestProperties()
        {
            LMTimelineEvent evt = CreateTimelineEvent();

            Assert.AreEqual(evt.HasDrawings, false);
            Assert.AreEqual(evt.Color, evt.EventType.Color);
            Assert.AreEqual(evt.Description,
                            String.Format("Play\ntest\n0:01,000 - 0:02,000 ({0}X)", 2.3));
        }
示例#10
0
        public void TestTimesDescription()
        {
            LMTimelineEvent evt = CreateTimelineEvent();

            Assert.AreEqual(evt.TimesDesription(),
                            String.Format("0:01,000 - 0:02,000 ({0}X)", 2.3));
            evt.Rate = 1;
            Assert.AreEqual(evt.TimesDesription(), "0:01,000 - 0:02,000");
        }
示例#11
0
        public TreePath AddEvent(LMTimelineEvent evt, TreeIter evtTter)
        {
            TreeIter childIter = childModel.AppendValues(evtTter, evt);
            TreePath childPath = childModel.GetPath(childIter);
            TreePath path      = modelSort.ConvertChildPathToPath(
                modelFilter.ConvertChildPathToPath(childPath));

            return(path);
        }
示例#12
0
        //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);
        }
示例#13
0
        void AddTagsGroup(LMTimelineEvent 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());
        }
示例#14
0
        public void TestProjectSetInTimelineEvents()
        {
            LMProject       p   = CreateProject();
            LMTimelineEvent evt = new LMTimelineEvent();

            p.AddEvent(evt);
            LMProject newp = Utils.SerializeDeserialize(p);

            Assert.AreEqual(newp, newp.Timeline [0].Project);
        }
示例#15
0
        public void TestTagsDescription()
        {
            LMTimelineEvent evt = CreateTimelineEvent();

            Assert.AreEqual(evt.TagsDescription(), "test");
            evt.Tags.Add(new Tag("test2"));
            Assert.AreEqual(evt.TagsDescription(), "test-test2");
            evt.Tags.Reset(new ObservableCollection <Tag> ());
            Assert.AreEqual(evt.TagsDescription(), "");
        }
示例#16
0
        protected override TimelineEventVM CreateTimelineEventVM(EventType type, Time start, Time stop, Time eventTime, Image miniature)
        {
            LMTimelineEvent evt = (LMTimelineEvent)project.Model.CreateEvent(type, start, stop, eventTime, miniature,
                                                                             project.Model.EventsByType(type).Count + 1);

            return(new LMTimelineEventVM()
            {
                Model = evt
            });
        }
        public void CreateTimelineVM_ModelIsLMTimelineEvent_CreatesLMTimelineEventVM()
        {
            //Arrange
            TimelineEvent ev = new LMTimelineEvent();

            //Act
            var timelineEventVM = factoryService.CreateViewModel <LMTimelineEventVM, TimelineEvent> (ev);

            //Assert
            Assert.IsTrue(timelineEventVM is LMTimelineEventVM);
        }
示例#18
0
        public void TestCoordinatesInFieldPosition()
        {
            LMTimelineEvent evt = CreateTimelineEvent();

            Assert.AreEqual(evt.CoordinatesInFieldPosition(FieldPositionType.Field),
                            evt.FieldPosition);
            Assert.AreEqual(evt.CoordinatesInFieldPosition(FieldPositionType.HalfField),
                            evt.HalfFieldPosition);
            Assert.AreEqual(evt.CoordinatesInFieldPosition(FieldPositionType.Goal),
                            evt.GoalPosition);
        }
示例#19
0
        public void TestEquals()
        {
            LMTimelineEvent evt1 = new LMTimelineEvent();
            LMTimelineEvent evt2 = new LMTimelineEvent();

            Assert.AreNotEqual(evt1, evt2);
            evt2.ID = evt1.ID;
            Assert.AreEqual(evt1, evt2);
            evt2.ID = Guid.Parse(evt1.ID.ToString());
            Assert.AreEqual(evt1, evt2);
        }
示例#20
0
        public void TestQueryEventsByPlayer()
        {
            LMPlayer andoni = new LMPlayer {
                Name = "Andoni"
            };
            LMPlayer jorge = new LMPlayer {
                Name = "Jorge"
            };
            LMPlayer victor = new LMPlayer {
                Name = "Victor"
            };
            LMPlayer josep = new LMPlayer {
                Name = "Josep"
            };
            LMPlayer davide = new LMPlayer {
                Name = "Davide"
            };
            LMPlayer messi = new LMPlayer {
                Name = "Messi"
            };
            LMPlayer ukelele = new LMPlayer {
                Name = "ukelele"
            };

            var players = new List <LMPlayer> {
                andoni, jorge, victor, josep, davide
            };

            foreach (LMPlayer player in players)
            {
                LMTimelineEvent evt = new LMTimelineEvent();
                evt.Players.Add(player);
                evt.Players.Add(messi);
                storage.Store(evt);
            }

            QueryFilter filter = new QueryFilter();

            filter.Add("Player", messi);
            Assert.AreEqual(5, storage.Retrieve <LMTimelineEvent> (filter).Count());

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

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

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

            filter.Add("Player", players);
            Assert.AreEqual(5, storage.Retrieve <LMTimelineEvent> (filter).Count());
        }
示例#21
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)
            {
                LMTimelineEvent evt = new LMTimelineEvent();
                evt.EventType = evtType;
                storage.Store(evt);
            }

            QueryFilter filter = new QueryFilter();

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

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

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

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

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

            filter.Add("EventType", score);
            Assert.AreEqual(1, storage.Retrieve <LMTimelineEvent> (filter).Count());
        }
示例#22
0
        void LoadTimelineEvent(LMTimelineEvent timelineEvent)
        {
            var viewModel = new LMTimelineEventVM {
                Model = timelineEvent
            };

            fieldDrawingarea.Visible  = timelineEvent.EventType.TagFieldPosition;
            hfieldDrawingarea.Visible = timelineEvent.EventType.TagHalfFieldPosition;
            goalDrawingarea.Visible   = timelineEvent.EventType.TagGoalPosition;
            field.SetViewModel(viewModel);
            hfield.SetViewModel(viewModel);
            goal.SetViewModel(viewModel);
        }
示例#23
0
        public void TestAddDefaultPositions()
        {
            LMTimelineEvent evt = new LMTimelineEvent();

            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 override void GetSize(Widget widget, ref Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
 {
     x_offset = 0;
     y_offset = 0;
     width    = Sizes.ListSelectedWidth + Sizes.ListRowSeparator + Sizes.ListTextWidth;
     height   = Sizes.ListCategoryHeight;
     if (Item is LMTimelineEvent)
     {
         LMTimelineEvent evt = Item as LMTimelineEvent;
         if (evt.Miniature != null)
         {
             width += Sizes.ListImageWidth + Sizes.ListRowSeparator;
         }
         width += (Sizes.ListImageWidth + Sizes.ListRowSeparator) * (evt.Players.Count + evt.Teams.Count);
     }
 }
        public void AddPlay(LMTimelineEvent 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));
        }
示例#26
0
        public void TestForwardModelChangesToVMWithPlaylists()
        {
            object senderObject = null;
            var    model        = new Playlist();
            var    viewModel    = new PlaylistVM {
                Model = model
            };
            LMTimelineEvent timelineEvent = new LMTimelineEvent();

            model.Elements.Add(new PlaylistPlayElement(timelineEvent));
            viewModel.PropertyChanged += (sender, e) => {
                senderObject = sender;
            };

            timelineEvent.Name = "test";
            Assert.AreEqual(viewModel.ViewModels [0], senderObject);
        }
示例#27
0
        void HandleEditPlayEvent(object sender, EventArgs e)
        {
            LMTimelineEvent selectedEvent = SelectedPlay;
            List <Player>   players       = selectedEvent.Players.ToList();

            App.Current.EventsBroker.Publish <EditEventEvent> (
                new EditEventEvent {
                TimelineEvent = selectedEvent
            });

            if (!players.SequenceEqual(selectedEvent.Players))
            {
                App.Current.EventsBroker.Publish <TeamTagsChangedEvent> ();
            }

            modelSort.SetSortFunc(0, SortFunction);
            modelSort.SetSortColumnId(0, SortType.Ascending);
        }
示例#28
0
        public void TestRemoveEvents()
        {
            LMTimelineEvent        p1, p2, p3;
            List <LMTimelineEvent> plays = new List <LMTimelineEvent> ();
            LMProject p = CreateProject(false);

            p1 = new LMTimelineEvent();
            p2 = new LMTimelineEvent();
            p3 = new LMTimelineEvent();
            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);
        }
        public void RemovePlays(List <LMTimelineEvent> plays)
        {
            TreeIter        iter, child;
            TreeStore       model;
            List <TreeIter> removeIters;

            if (project == null)
            {
                return;
            }

            removeIters = new List <TreeIter> ();
            model       = (TreeStore)treeview.Model;
            model.GetIterFirst(out iter);

            /* Scan all the tree and store the iter of each play
             * we need to delete, but don't delete it yet so that
             * we don't alter the tree */
            do
            {
                if (!model.IterHasChild(iter))
                {
                    continue;
                }

                model.IterChildren(out child, iter);
                do
                {
                    LMTimelineEvent play = (LMTimelineEvent)model.GetValue(child, 0);
                    if (plays.Contains(play))
                    {
                        removeIters.Add(child);
                    }
                } while(model.IterNext(ref child));
            } while(model.IterNext(ref iter));

            /* Remove the selected iters now */
            for (int i = 0; i < removeIters.Count; i++)
            {
                iter = removeIters [i];
                model.Remove(ref iter);
            }
        }
示例#30
0
        public void TestSaveProjectWithEvents()
        {
            LMProject p = new LMProject();

            p.Dashboard = LMDashboard.DefaultTemplate(10);
            p.UpdateEventTypesAndTimers();
            p.LocalTeamTemplate   = LMTeam.DefaultTemplate(10);
            p.VisitorTeamTemplate = LMTeam.DefaultTemplate(12);
            MediaFile mf = new MediaFile("path", 34000, 25, true, true, "mp4", "h264",
                                         "aac", 320, 240, 1.3, null, "Test asset");
            var pd = new ProjectDescription();

            pd.FileSet = new MediaFileSet();
            pd.FileSet.Add(mf);
            p.Description = pd;

            for (int i = 0; i < 10; i++)
            {
                LMTimelineEvent evt = new LMTimelineEvent {
                    EventType = p.EventTypes [i],
                    Start     = new Time(1000),
                    Stop      = new Time(2000),
                };
                evt.Players.Add(p.LocalTeamTemplate.Players [0]);
                p.Timeline.Add(evt);
            }

            storage.Store <LMProject> (p);
            Assert.AreEqual(54, db.DocumentCount);
            storage.Store <LMProject> (p);
            Assert.AreEqual(54, db.DocumentCount);

            LMProject p2 = storage.Retrieve <LMProject> (p.ID);

            Assert.AreEqual(p.Timeline.Count, p2.Timeline.Count);
            Assert.AreEqual(p2.LocalTeamTemplate.List [0], p2.Timeline [0].Players [0]);
            Assert.AreEqual((p2.Dashboard.List [0] as AnalysisEventButton).EventType,
                            p2.Timeline [0].EventType);
            Assert.IsNotNull(p2.DocumentID);

            storage.Delete(p);
            Assert.AreEqual(1, db.DocumentCount);
        }