private void _onEngineEventLocated(object o, EventEventArgs e) // when new event was created
 {
     Debug.WriteLine(e.Event?.EventName, "EventLocated notified");
     if (e.Event == null)
     {
         return;
     }
     OnUiThread(() =>
     {
         var evm = Find(e.Event, true);
         if (evm != null)
         {
             evm.UpdateLocation();
         }
         else
         {
             EventPanelViewmodelBase vm = PlaceEventInRundown(e.Event, false);
             if (vm != null &&
                 e.Event.EventType != TEventType.StillImage &&
                 e.Event == EngineViewmodel.LastAddedEvent)
             {
                 vm.IsSelected = true;
                 EngineViewmodel.ClearSelection();
                 if (e.Event.EventType == TEventType.Rundown)
                 {
                     vm.IsExpanded = true;
                 }
             }
             (vm as EventPanelRundownElementViewmodelBase)?.VerifyIsInvalidInSchedule();
         }
     });
 }
 private void _engine_EventDeleted(object sender, IEventEventArgs e)
 {
     Application.Current.Dispatcher.BeginInvoke((Action) delegate()
     {
         EventPanelViewmodelBase evm = Find(e.Event);
         if (evm != null)
         {
             evm.Dispose();
         }
     });
 }
 public EventPanelRundownViewmodel(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
 {
     CommandAddSubMovie = new UICommand {
         ExecuteDelegate = _addSubMovie, CanExecuteDelegate = o => _event.SubEventsCount == 0
     };
     CommandAddSubRundown = new UICommand {
         ExecuteDelegate = _addSubRundown, CanExecuteDelegate = o => _event.SubEventsCount == 0
     };
     CommandAddSubLive = new UICommand {
         ExecuteDelegate = _addSubLive, CanExecuteDelegate = o => _event.SubEventsCount == 0
     };
 }
Exemple #4
0
        public EventPanelContainerViewmodel(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
        {
            if (ev.EventType != TEventType.Container)
            {
                throw new ApplicationException($"Invalid panel type:{GetType()} for event type:{ev.EventType}");
            }
            _isVisible = !HiddenEventsStorage.Contains(ev);

            CommandHide          = new UiCommand(o => IsVisible = false, o => _isVisible);
            CommandShow          = new UiCommand(o => IsVisible = true, o => !_isVisible);
            CommandAddSubRundown = new UiCommand(_addSubRundown, o => Event.HaveRight(EventRight.Create));
            ev.SubEventChanged  += SubEventChanged;
        }
Exemple #5
0
 protected override void OnDispose()
 {
     if (_parent != null)
     {
         _parent.RemoveChild(this);
         _parent = null;
     }
     ClearChildrens();
     if (Event != null)
     {
         Event.PropertyChanged -= OnEventPropertyChanged;
         EngineViewmodel.RemoveEventPanel(this);
         IsMultiSelected = false;
     }
     Debug.WriteLine(this, "EventPanelViewmodel Disposed");
 }
        public EventPanelContainerViewmodel(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
        {
            if (ev.EventType != TEventType.Container)
            {
                throw new ApplicationException($"Invalid panel type:{GetType()} for event type:{ev.EventType}");
            }
            _isVisible = !HiddenEventsStorage.Contains(ev);

            CommandHide = new UICommand {
                ExecuteDelegate = o => IsVisible = false, CanExecuteDelegate = o => _isVisible
            };
            CommandShow = new UICommand {
                ExecuteDelegate = o => IsVisible = true, CanExecuteDelegate = o => !_isVisible
            };
            CommandAddSubRundown = new UICommand {
                ExecuteDelegate = _addSubRundown
            };
        }
 protected override void OnDispose()
 {
     if (_parent != null)
     {
         _parent._childrens.Remove(this);
         _parent = null;
     }
     ClearChildrens();
     if (_event != null)
     {
         _event.PropertyChanged -= OnEventPropertyChanged;
         _event.SubEventChanged -= OnSubeventChanged;
         _event.Relocated       -= OnRelocated;
         _engineViewmodel?.RemoveMultiSelected(this);
         IsMultiSelected = false;
     }
     Debug.WriteLine(this, "EventPanelViewmodel Disposed");
 }
 private void _onEngineEventSaved(object o, IEventEventArgs e) // when new event was created
 {
     Debug.WriteLine(e.Event, "EventSaved notified");
     Application.Current.Dispatcher.BeginInvoke((Action) delegate()
     {
         EventPanelViewmodelBase vm = _placeEventInRundown(e.Event, false);
         if (vm != null &&
             e.Event.EventType != TEventType.StillImage &&
             e.Event == _engineViewmodel.LastAddedEvent)
         {
             vm.IsSelected = true;
             _engineViewmodel.ClearSelection();
             if (e.Event.EventType == TEventType.Rundown)
             {
                 vm.IsExpanded = true;
             }
         }
         (vm as EventPanelRundownElementViewmodelBase)?.VerifyIsInvalidInSchedule();
     });
 }
Exemple #9
0
 /// <summary>
 /// Constructor for child events
 /// </summary>
 /// <param name="aEvent"></param>
 /// <param name="parent"></param>
 protected EventPanelViewmodelBase(IEvent aEvent, EventPanelViewmodelBase parent)
 {
     if (aEvent == null) // dummy child
     {
         return;
     }
     Engine       = aEvent.Engine;
     _videoFormat = Engine.VideoFormat;
     Event        = aEvent;
     if (parent != null)
     {
         _parent         = parent;
         Root            = parent.Root;
         EngineViewmodel = parent.EngineViewmodel;
         Level           = parent.Level + 1;
         if (aEvent.SubEventsCount > 0)
         {
             Childrens.Add(DummyChild);
         }
     }
     Event.PropertyChanged += OnEventPropertyChanged;
 }
 /// <summary>
 /// Constructor for child events
 /// </summary>
 /// <param name="aEvent"></param>
 /// <param name="parent"></param>
 protected EventPanelViewmodelBase(IEvent aEvent, EventPanelViewmodelBase parent) : base()
 {
     if (aEvent == null) // dummy child
     {
         return;
     }
     _engine      = aEvent.Engine;
     _videoFormat = _engine.VideoFormat;
     _event       = aEvent;
     if (parent != null)
     {
         _parent          = parent;
         _root            = parent._root;
         _engineViewmodel = parent._engineViewmodel;
         _level           = (_parent == null) ? 0 : _parent._level + 1;
         if (aEvent.SubEventsCount > 0)
         {
             _childrens.Add(DummyChild);
         }
     }
     _event.PropertyChanged += OnEventPropertyChanged;
     _event.SubEventChanged += OnSubeventChanged;
     _event.Relocated       += OnRelocated;
 }
Exemple #11
0
        protected EventPanelRundownElementViewmodelBase(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
        {
            Media = ev.Media;
            ev.PositionChanged += EventPositionChanged;
            ev.SubEventChanged += OnSubeventChanged;

            CommandToggleHold = new UICommand
            {
                ExecuteDelegate = o =>
                {
                    Event.IsHold = !Event.IsHold;
                    Event.Save();
                },
                CanExecuteDelegate = _canToggleHold
            };
            CommandToggleEnabled = new UICommand
            {
                ExecuteDelegate = o =>
                {
                    Event.IsEnabled = !Event.IsEnabled;
                    Event.Save();
                },
                CanExecuteDelegate = o => Event.PlayState == TPlayState.Scheduled && Event.HaveRight(EventRight.Modify)
            };
            CommandToggleLayer = new UICommand
            {
                ExecuteDelegate = l =>
                {
                    if (!(l is string layerName) || !Enum.TryParse(layerName, true, out VideoLayer layer))
                    {
                        return;
                    }
                    if (_hasSubItemsOnLayer(layer))
                    {
                        var layerEvent = Event.SubEvents.FirstOrDefault(e => e.Layer == layer);
                        layerEvent?.Delete();
                    }
                    else
                    {
                        EngineViewmodel.AddMediaEvent(Event, TStartType.WithParent, TMediaType.Still, layer, true);
                    }
                },
                CanExecuteDelegate = _canToggleLayer
            };
            CommandAddNextRundown = new UICommand
            {
                ExecuteDelegate    = o => EngineViewmodel.AddSimpleEvent(Event, TEventType.Rundown, false),
                CanExecuteDelegate = _canAddNextItem
            };
            CommandAddNextEmptyMovie = new UICommand
            {
                ExecuteDelegate    = o => EngineViewmodel.AddSimpleEvent(Event, TEventType.Movie, false),
                CanExecuteDelegate = CanAddNextMovie
            };
            CommandAddNextLive = new UICommand
            {
                ExecuteDelegate    = o => EngineViewmodel.AddSimpleEvent(Event, TEventType.Live, false),
                CanExecuteDelegate = CanAddNewLive
            };
            CommandAddNextMovie = new UICommand
            {
                ExecuteDelegate = o => EngineViewmodel.AddMediaEvent(Event, TStartType.After, TMediaType.Movie,
                                                                     VideoLayer.Program, false),
                CanExecuteDelegate = CanAddNextMovie
            };
            CommandAddAnimation = new UICommand
            {
                ExecuteDelegate = o => EngineViewmodel.AddMediaEvent(Event, TStartType.WithParent,
                                                                     TMediaType.Animation, VideoLayer.Animation, true),
                CanExecuteDelegate = o => Event.PlayState == TPlayState.Scheduled && Event.HaveRight(EventRight.Modify)
            };
            CommandAddCommandScript = new UICommand
            {
                ExecuteDelegate    = o => EngineViewmodel.AddCommandScriptEvent(Event),
                CanExecuteDelegate = o => Event.PlayState == TPlayState.Scheduled && Event.HaveRight(EventRight.Modify)
            };
        }
        private EventPanelViewmodelBase PlaceEventInRundown(IEvent e, bool show)
        {
            EventPanelViewmodelBase newVm = null;
            EventPanelViewmodelBase evm   = Find(e, true);

            if (evm == null)
            {
                var vp = e.GetVisualParent();
                if (vp != null)
                {
                    var evmVp = Find(vp, true);
                    if (evmVp != null)
                    {
                        var eventType = e.EventType;
                        if (eventType == TEventType.Movie || eventType == TEventType.Rundown || eventType == TEventType.Live ||
                            evmVp.IsExpanded)
                        {
                            if (evmVp.IsExpanded || show || e == EngineViewmodel.LastAddedEvent)
                            {
                                evmVp.IsExpanded = true;
                                if (evmVp.Find(e, true) == null) // find again after expand
                                {
                                    if (e.Parent == vp)          // StartType = With
                                    {
                                        newVm = evmVp.CreateChildEventPanelViewmodelForEvent(e);
                                        evmVp.Childrens.Insert(0, newVm);
                                    }
                                    else // StartType == After
                                    {
                                        var prior = e.Prior;
                                        if (prior != null)
                                        {
                                            var evmPrior = evmVp.Find(prior, true);
                                            if (evmPrior == null)
                                            {
                                                evmPrior = PlaceEventInRundown(prior, true); // recurrence here
                                            }
                                            if (evmPrior != null)
                                            {
                                                var pos = evmVp.Childrens.IndexOf(evmPrior);
                                                newVm = evmVp.CreateChildEventPanelViewmodelForEvent(e);
                                                evmVp.Childrens.Insert(pos + 1, newVm);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (!evmVp.HasDummyChild)
                            {
                                evmVp.Childrens.Add(DummyChild);
                            }
                        }
                    }
                }
                else //vp == null
                {
                    var prior = e.Prior;
                    if (prior != null)
                    {
                        var evmPrior = Find(prior, true);
                        if (evmPrior != null)
                        {
                            var pos = Childrens.IndexOf(evmPrior);
                            newVm = CreateChildEventPanelViewmodelForEvent(e);
                            Childrens.Insert(pos + 1, newVm);
                        }
                    }
                    else
                    if (e.StartType == TStartType.Manual || e.EventType == TEventType.Container)
                    {
                        newVm = AddRootEvent(e);
                    }
                }
            }
            return(newVm);
        }
Exemple #13
0
        protected internal virtual void UpdateLocation()
        {
            var ev = Event;

            if (ev == null)
            {
                return;
            }
            IEvent prior        = ev.Prior;
            IEvent parent       = ev.Parent;
            IEvent next         = ev.Next;
            IEvent visualParent = ev.GetVisualParent();

            if (prior != null)
            {
                int index = Parent.Childrens.IndexOf(this);
                if (visualParent != Parent.Event ||
                    index <= 0 ||
                    Parent.Childrens[index - 1].Event != prior)
                {
                    EventPanelViewmodelBase priorVm = Root.Find(prior);
                    if (priorVm != null)
                    {
                        EventPanelViewmodelBase newParent = priorVm.Parent;
                        if (Parent == newParent)
                        {
                            int priorIndex = newParent.Childrens.IndexOf(priorVm);
                            if (index >= priorIndex)
                            {
                                newParent.Childrens.Move(index, priorIndex + 1);
                            }
                            else
                            {
                                newParent.Childrens.Move(index, priorIndex);
                            }
                        }
                        else
                        {
                            Parent.Childrens.Remove(this);
                            if (!newParent.HasDummyChild)
                            {
                                newParent.Childrens.Insert(newParent.Childrens.IndexOf(priorVm) + 1, this);
                            }
                            Parent = newParent;
                        }
                    }
                }
            }
            else if (parent == null && next != null)
            {
                int index = Parent.Childrens.IndexOf(this);
                if (visualParent != Parent.Event ||
                    index <= 0 ||
                    Parent.Childrens[index].Event != next)
                {
                    EventPanelViewmodelBase nextVm = Root.Find(next);
                    if (nextVm != null)
                    {
                        EventPanelViewmodelBase newParent = nextVm.Parent;
                        if (Parent == newParent)
                        {
                            int nextIndex = newParent.Childrens.IndexOf(nextVm);
                            if (index >= nextIndex)
                            {
                                newParent.Childrens.Move(index, nextIndex);
                            }
                            else
                            {
                                newParent.Childrens.Move(index, nextIndex - 1);
                            }
                        }
                        else
                        {
                            Parent.Childrens.Remove(this);
                            if (!newParent.HasDummyChild)
                            {
                                newParent.Childrens.Insert(newParent.Childrens.IndexOf(nextVm), this);
                            }
                            Parent = newParent;
                        }
                    }
                }
            }
            else if (parent == null)
            {
                Parent.Childrens.Remove(this);
                Root.Childrens.Add(this);
                Parent = Root;
            }
            else
            {
                EventPanelViewmodelBase parentVm = Root.Find(parent);
                if (parentVm != null)
                {
                    if (parentVm == Parent)
                    {
                        parentVm.Childrens.Move(parentVm.Childrens.IndexOf(this), 0);
                    }
                    else
                    {
                        Parent = parentVm;
                    }
                }
            }
            BringIntoView();
        }
Exemple #14
0
 public EventPanelAnimationViewmodel(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
 {
 }
        public EventPanelRundownElementViewmodelBase(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
        {
            Media = ev.Media;
            ev.PositionChanged += _eventPositionChanged;

            CommandToggleHold = new UICommand()
            {
                ExecuteDelegate = (o) =>
                {
                    _event.IsHold = !_event.IsHold;
                    _event.Save();
                },
                CanExecuteDelegate = (o) => _event.PlayState == TPlayState.Scheduled &&
                                     _event.StartType == TStartType.After
            };
            CommandToggleEnabled = new UICommand()
            {
                ExecuteDelegate = (o) =>
                {
                    _event.IsEnabled = !_event.IsEnabled;
                    _event.Save();
                },
                CanExecuteDelegate = (o) => _event.PlayState == TPlayState.Scheduled
            };
            CommandToggleLayer = new UICommand()
            {
                ExecuteDelegate = (l) =>
                {
                    VideoLayer layer = (VideoLayer)sbyte.Parse((string)l);
                    if (_hasSubItemsOnLayer(layer))
                    {
                        var layerEvent = _event.SubEvents.FirstOrDefault(e => e.Layer == layer);
                        layerEvent?.Delete();
                    }
                    else
                    {
                        _engineViewmodel.AddMediaEvent(_event, TStartType.WithParent, TMediaType.Still, layer, true);
                    }
                },
                CanExecuteDelegate = (o) => _event.PlayState == TPlayState.Scheduled ||
                                     _event.PlayState == TPlayState.Playing ||
                                     _event.PlayState == TPlayState.Paused
            };
            CommandAddNextRundown = new UICommand()
            {
                ExecuteDelegate    = o => _engineViewmodel.AddSimpleEvent(_event, TEventType.Rundown, false),
                CanExecuteDelegate = _canAddNextItem
            };
            CommandAddNextEmptyMovie = new UICommand()
            {
                ExecuteDelegate    = o => _engineViewmodel.AddSimpleEvent(_event, TEventType.Movie, false),
                CanExecuteDelegate = CanAddNextMovie
            };
            CommandAddNextLive = new UICommand()
            {
                ExecuteDelegate    = o => _engineViewmodel.AddSimpleEvent(_event, TEventType.Live, false),
                CanExecuteDelegate = CanAddNewLive
            };
            CommandAddNextMovie = new UICommand()
            {
                ExecuteDelegate = o => _engineViewmodel.AddMediaEvent(_event, TStartType.After, TMediaType.Movie,
                                                                      VideoLayer.Program, false),
                CanExecuteDelegate = CanAddNextMovie
            };
            CommandAddAnimation = new UICommand()
            {
                ExecuteDelegate = o => _engineViewmodel.AddMediaEvent(_event, TStartType.WithParent,
                                                                      TMediaType.Animation, VideoLayer.Animation, true),
                CanExecuteDelegate = o => _event.PlayState == TPlayState.Scheduled
            };
            CommandAddCommandScript = new UICommand
            {
                ExecuteDelegate    = o => _engineViewmodel.AddCommandScriptEvent(_event),
                CanExecuteDelegate = o => _event.PlayState == TPlayState.Scheduled
            };
        }
Exemple #16
0
 public EventPanelCommandScriptViewmodel(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
 {
 }
Exemple #17
0
 public EventPanelStillViewmodel(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
 {
 }
 public EventPanelRundownViewmodel(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
 {
     CommandAddSubMovie   = new UiCommand(_addSubMovie, _canAddSubEvent);
     CommandAddSubRundown = new UiCommand(_addSubRundown, _canAddSubEvent);
     CommandAddSubLive    = new UiCommand(_addSubLive, _canAddSubEvent);
 }
 private void _updateLocation()
 {
     if (_event != null)
     {
         IEvent prior        = _event.Prior;
         IEvent parent       = _event.Parent;
         IEvent next         = _event.Next;
         IEvent visualParent = _event.GetVisualParent();
         if (prior != null)
         {
             int index = _parent._childrens.IndexOf(this);
             if (visualParent != _parent._event ||
                 index <= 0 ||
                 _parent._childrens[index - 1]._event != prior)
             {
                 EventPanelViewmodelBase priorVm = _root.Find(prior);
                 if (priorVm != null)
                 {
                     EventPanelViewmodelBase newParent = priorVm._parent;
                     if (_parent == newParent)
                     {
                         int priorIndex = newParent._childrens.IndexOf(priorVm);
                         if (index >= priorIndex)
                         {
                             newParent._childrens.Move(index, priorIndex + 1);
                         }
                         else
                         {
                             newParent._childrens.Move(index, priorIndex);
                         }
                     }
                     else
                     {
                         _parent._childrens.Remove(this);
                         if (!newParent.HasDummyChild)
                         {
                             newParent._childrens.Insert(newParent._childrens.IndexOf(priorVm) + 1, this);
                         }
                         _parent = newParent;
                     }
                 }
             }
         }
         else
         if (parent == null && next != null)
         {
             int index = _parent._childrens.IndexOf(this);
             if (visualParent != _parent._event ||
                 index <= 0 ||
                 _parent._childrens[index]._event != next)
             {
                 EventPanelViewmodelBase nextVm = _root.Find(next);
                 if (nextVm != null)
                 {
                     EventPanelViewmodelBase newParent = nextVm._parent;
                     if (_parent == newParent)
                     {
                         int nextIndex = newParent._childrens.IndexOf(nextVm);
                         if (index >= nextIndex)
                         {
                             newParent._childrens.Move(index, nextIndex);
                         }
                         else
                         {
                             newParent._childrens.Move(index, nextIndex - 1);
                         }
                     }
                     else
                     {
                         _parent._childrens.Remove(this);
                         if (!newParent.HasDummyChild)
                         {
                             newParent._childrens.Insert(newParent._childrens.IndexOf(nextVm), this);
                         }
                         _parent = newParent;
                     }
                 }
             }
         }
         else
         if (parent == null)
         {
             _parent._childrens.Remove(this);
             _root._childrens.Add(this);
             _parent = _root;
         }
         else
         {
             EventPanelViewmodelBase parentVm = _root.Find(parent);
             if (parentVm != null)
             {
                 if (parentVm == _parent)
                 {
                     parentVm.Childrens.Move(parentVm.Childrens.IndexOf(this), 0);
                 }
                 else
                 {
                     Parent = parentVm;
                 }
             }
         }
         BringIntoView();
     }
 }