예제 #1
0
        /// <summary>
        /// 设置显示的呼叫
        /// </summary>
        /// <param name="call">呼叫</param>
        private void SetCurrentCall(QLCall call)
        {
            if (null != _currentCall)
            {
                _currentCall.PropertyChanged            -= OnCallPropertyChangedHandle;
                _currentCall.Channels.CollectionChanged -= OnChannelsCllectionChangedHandle;
            }
            channelViews.Clear();
            this.Controls.Clear();

            _currentCall   = call;
            localChannel   = null;
            contentChannel = null;
            if (null != _currentCall)
            {
                foreach (var channel in _currentCall.Channels)
                {
                    var channelView = new ChannelView(channel);
                    channelViews.Add(channel, channelView);
                    this.Controls.Add(channelView);
                    switch (channel.MediaType)
                    {
                    case MediaType.LOCAL: localChannel = channel; break;

                    case MediaType.CONTENT: contentChannel = channel; break;

                    case MediaType.LOCALCONTENT: contentChannel = channel; break;
                    }
                }
                _currentCall.PropertyChanged            += OnCallPropertyChangedHandle;
                _currentCall.Channels.CollectionChanged += OnChannelsCllectionChangedHandle;
            }
        }
예제 #2
0
        private void OnChannelsCllectionChangedHandle(object sender, NotifyCollectionChangedEventArgs args)
        {
            #region ChannelView
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Add:
            {
                foreach (var item in args.NewItems)
                {
                    var channel = item as QLChannel;
                    if (null != channel)
                    {
                        var channelView = new ChannelView(channel);
                        channelViews.Add(channel, channelView);
                        this.Controls.Add(channelView);
                        switch (channel.MediaType)
                        {
                        case MediaType.LOCAL: localChannel = channel; break;

                        case MediaType.CONTENT: contentChannel = channel; break;

                        case MediaType.LOCALCONTENT: contentChannel = channel; break;
                        }
                    }
                }
            }
            break;

            case NotifyCollectionChangedAction.Remove:
            {
                foreach (var item in args.OldItems)
                {
                    var channel = item as QLChannel;
                    if (channelViews.ContainsKey(channel))
                    {
                        var channelView = channelViews[channel];
                        if (null != channelView)
                        {
                            this.Controls.Remove(channelView);
                            channelView.Dispose();
                        }
                        channelViews.Remove(channel);
                        switch (channel.MediaType)
                        {
                        case MediaType.LOCAL: localChannel = null; break;

                        case MediaType.CONTENT: contentChannel = null; break;

                        case MediaType.LOCALCONTENT: contentChannel = null; break;
                        }
                    }
                }
            }
            break;

            case NotifyCollectionChangedAction.Reset: break;

            case NotifyCollectionChangedAction.Move: break;

            case NotifyCollectionChangedAction.Replace: break;
            }
            #endregion

            ViewRender();
        }