protected void RendererAddedSink(AVRendererDiscovery sender, AVRenderer renderer)
        {
            if (InvokeRequired) { Invoke(new AVRendererDiscovery.DiscoveryHandler(RendererAddedSink), sender, renderer); return; }

            renderer.OnRemovedConnection += new AVRenderer.ConnectionHandler(RemovedConnectionSink);

            TreeNode node = NodeTagSearch(rendererRootNode, renderer);
            if (node == null)
            {
                TreeNode varNode = new TreeNode(renderer.FriendlyName,1,1);
                varNode.Tag = renderer;
                rendererRootNode.Nodes.Add(varNode);
                renderer.OnCreateConnection += new AVRenderer.ConnectionHandler(RendererCreateConnectionSink);
                renderer.OnRecycledConnection += new AVRenderer.ConnectionHandler(RendererRecycledConnectionSink);
                renderer.OnCreateConnectionFailed += new AVRenderer.FailedConnectionHandler(RendererCreateConnectionFailedSink);
                foreach (AVConnection connection in renderer.Connections)
                {
                    RendererCreateConnectionSink(renderer, connection, 0);
                }
            }
            rendererRootNode.Expand();
        }
        protected void RendererRemovedSink(AVRendererDiscovery sender, AVRenderer renderer)
        {
            if (InvokeRequired) { Invoke(new AVRendererDiscovery.DiscoveryHandler(RendererRemovedSink), sender, renderer); return; }

            renderer.OnCreateConnection -= new AVRenderer.ConnectionHandler(RendererCreateConnectionSink);

            foreach (AVConnection connection in renderer.Connections)
            {
                connection.OnVolume -= new AVConnection.VolumeChangedHandler(VolumeChangedHandlerSink);
                connection.OnPlayStateChanged -= new AVConnection.PlayStateChangedHandler(PlayStateChangedHandlerSink);
                connection.OnMute -= new AVConnection.MuteStateChangedHandler(MuteStateChangedHandlerSink);
                connection.OnPositionChanged -= new AVConnection.PositionChangedHandler(PositionChangedHandlerSink);
                connection.OnMediaResourceChanged -= new AVConnection.MediaResourceChangedHandler(MediaResourceChangedHandlerSink);
                connection.OnRemoved -= new AVConnection.RendererHandler(RemovedConnectionHandlerSink);
                connection.OnTrackChanged -= new AVConnection.CurrentTrackChangedHandler(TrackChangedSink);

                connection.OnCurrentMetaDataChanged -= new AVConnection.CurrentMetaDataChangedHandler(MetaDataSink);
            }

            TreeNode node = NodeTagSearch(rendererRootNode,renderer);
            if (node != null)
            {
                if (rendererFormTable.ContainsKey(node.Tag))
                {
                    RendererControlForm form = (RendererControlForm)rendererFormTable[node.Tag];
                    form.Close();
                    rendererFormTable.Remove(node.Tag);
                }
                rendererRootNode.Nodes.Remove(node);
            }
        }
        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            dockedRendererControl = new RendererControl();
            dockedRendererControl.Visible = false;
            dockedRendererControl.Dock = DockStyle.Top;

            mediaPropertyControl = new MediaPropertyControl();
            mediaPropertyControl.Visible = false;
            mediaPropertyControl.Dock = DockStyle.Bottom;
            mediaPropertyControlSplitter = new System.Windows.Forms.Splitter();
            mediaPropertyControlSplitter.Visible = false;
            mediaPropertyControlSplitter.Dock = DockStyle.Bottom;

            this.Controls.Add(dockedRendererControl);
            this.Controls.Add(mediaPropertyControl);
            this.Controls.Add(mediaPropertyControlSplitter);
            this.Controls.SetChildIndex(dockedRendererControl,0);
            this.Controls.SetChildIndex(mediaPropertyControl,0);
            this.Controls.SetChildIndex(mediaPropertyControlSplitter,0);
            this.Controls.SetChildIndex(listInfo,0);
            this.Controls.SetChildIndex(mediaListView,0);

            deviceTree.Nodes.Add(rendererRootNode);
            containerDiscovery = ContainerDiscovery.GetInstance();
            cdsRootNode.Tag = containerDiscovery.AllRoots;
            deviceTree.Nodes.Add(cdsRootNode);
            containerDiscovery.AllRoots.OnContainerChanged += new CpRootContainer.Delegate_OnContainerChanged(ContainerChangedSink);

            eventPanel.Visible = false;
            splitter2.Visible = false;

            rendererDiscovery = new AVRendererDiscovery((new AVRendererDiscovery.DiscoveryHandler(RendererAddedSink)));
            rendererDiscovery.OnRendererRemoved += new AVRendererDiscovery.DiscoveryHandler(new AVRendererDiscovery.DiscoveryHandler(RendererRemovedSink));

            this.m_SpiderTimer = new System.Timers.Timer();
            this.m_SpiderTimer.Interval = 10000;
            this.m_SpiderTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimeToClearSpiderCache);
            this.m_SpiderTimer.Enabled = true;
        }
예제 #4
0
 protected void RemoveSink(AVRendererDiscovery sender, AVRenderer r)
 {
     RendererList.Remove(r);
     if (CurrentRenderer.UniqueDeviceName == r.UniqueDeviceName)
     {
         CurrentRenderer = null;
         CurrentConnection = null;
         if (RendererList.Count > 0) CurrentRenderer = (AVRenderer)RendererList[0];
         ShowRenderer();
     }
 }
예제 #5
0
        protected void DiscoSink(AVRendererDiscovery sender, AVRenderer r)
        {
            r.OnEventRenewalFailure += new AVRenderer.EventRenewalFailureHandler(EventFailSink);
            lock (this)
            {
                r.OnCreateConnection += new AVRenderer.ConnectionHandler(NewConnectionsSink);
                r.OnRecycledConnection += new AVRenderer.ConnectionHandler(RecycledConnectionsSink);
                r.OnRemovedConnection += new AVRenderer.ConnectionHandler(RemovedConnectionSink);
                r.OnCreateConnectionFailed += new AVRenderer.FailedConnectionHandler(FailedConnectionSink);

                RendererList.Add(r);

                if (CurrentRenderer == null)
                {
                    CurrentRenderer = r;
                    if (CurrentRenderer.Connections.Count != 0)
                    {
                        CurrentConnection = (AVConnection)CurrentRenderer.Connections[0];

                        foreach (AVConnection c in CurrentRenderer.Connections)
                        {
                            c.OnPlayStateChanged += new AVConnection.PlayStateChangedHandler(PlayStateSink);
                            c.OnVolume += new AVConnection.VolumeChangedHandler(VolumeChangeSink);
                            c.OnPositionChanged += new AVConnection.PositionChangedHandler(PositionChangeSink);
                            c.OnTrackChanged += new AVConnection.CurrentTrackChangedHandler(TrackChangedSink);
                            c.OnNumberOfTracksChanged += new AVConnection.NumberOfTracksChangedHandler(NumberOfTracksChangedSink);
                            c.OnTrackURIChanged += new AVConnection.TrackURIChangedHandler(TrackURIChangedSink);
                            c.OnCurrentPlayModeChanged += new AVConnection.CurrentPlayModeChangedHandler(PlayModeChangedSink);
                        }

                    }
                    else
                    {
                        CurrentConnection = null;
                    }
                    ShowRenderer();
                }
            }
        }
예제 #6
0
 private void MainForm_Load(object sender, System.EventArgs e)
 {
     AVDisco = new AVRendererDiscovery(new AVRendererDiscovery.DiscoveryHandler(DiscoSink));
     AVDisco.OnRendererRemoved += new AVRendererDiscovery.DiscoveryHandler(RemoveSink);
 }