コード例 #1
0
        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);
        }