private void deviceTree_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (InvokeRequired == true)
            {
                int tt = 5;
            }

            m_SelectedContainer = null;
            ArrayList removeThese = new ArrayList();
            foreach (MenuItem mi in this.treeContextMenu.MenuItems)
            {
                if (mi.Text.StartsWith("Send to "))
                {
                    removeThese.Add(mi);
                }
            }
            foreach (MenuItem mi in removeThese)
            {
                this.treeContextMenu.MenuItems.Remove(mi);
            }

            TreeNode node = deviceTree.GetNodeAt(e.X,e.Y);
            if (node == null) return;
            deviceTree.SelectedNode = node;

            rendererControlsMenuItem.Visible = false;
            closeInstanceMenuItem.Visible = false;
            forceRefreshMenuItem.Visible = false;
            menuItem18.Visible = false;
            displayContainerProperties.Visible = false;

            if (node.Tag == null) return;

            if (node.Tag.GetType() == typeof(AVRenderer))
            {
                rendererControlsMenuItem.Visible = true;
                menuItem18.Visible = true;
            }

            if (node.Tag.GetType() == typeof(AVConnection))
            {
                AVConnection connection = (AVConnection)node.Tag;
                if (connection.IsCloseSupported == true)
                {
                    closeInstanceMenuItem.Visible = true;
                    menuItem18.Visible = true;
                }
            }

            if (node.Tag is ICpMedia)
            {
                displayContainerProperties.Visible = true;

                ICpContainer cpc = node.Tag as ICpContainer;

                if (cpc != null)
                {
                    if (cpc.MergedResources.Length > 0)
                    {
                        m_SelectedContainer = cpc;
                        if (rendererRootNode.Nodes.Count > 0)
                        {
                            foreach (TreeNode tn in rendererRootNode.Nodes)
                            {
                                AVRenderer renderer = (AVRenderer)tn.Tag;
                                if (renderer != null)
                                {
                                    MenuItem m = new MenuItem("Send to " + renderer.FriendlyName,new EventHandler(PlayMediaMenuSelectedSink));
                                    PlayToRendererMenuItemMapping.Add(m,renderer);
                                    this.treeContextMenu.MenuItems.Add(m);
                                    //mediaContextMenu.MenuItems.Add(m);
                                }
                            }
                        }
                    }
                }
            }
        }
        private void ResultCreateObjectSink(ICpContainer parent, IUPnPMedia newObject, string newObjectID, string ResultXml, IUPnPMedia returnedObject, object Tag, UPnPInvokeException error, Exception xmlToObjectError)
        {
            if (error != null)
            {
                MessageBox.Show(this,xmlToObjectError.ToString(),"Create Object Server Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            if (xmlToObjectError != null)
            {
                MessageBox.Show(this,xmlToObjectError.ToString(),"Create Object Response Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }

            IUPnPMedia original = (IUPnPMedia) Tag;

            for (int i=0; i < original.Resources.Length; i++)
            {
                parent.RequestImportResource2(new Uri(((IMediaResource)original.Resources[i]).ContentUri), (IMediaResource) returnedObject.Resources[i], null, new OpenSource.UPnP.AV.MediaServer.CP.CpMediaDelegates.Delegate_ResultImportResource2(ResultImportResource2Sink));
            }

            //newObject
            //			foreach (IMediaResource resource in returnedObject.Resources)
            //			{
            //				parent.RequestImportResource2(new Uri(((IMediaResource)original.Resources[0]).ContentUri), resource, null, new OpenSource.UPnP.AV.MediaServer.CP.CpMediaDelegates.Delegate_ResultImportResource2(ResultImportResource2Sink));
            //			}
        }
 public void PopupRendererForm(AVRenderer renderer, ICpContainer container)
 {
     if (rendererFormTable.ContainsKey(renderer) == true)
     {
         RendererControlForm form = (RendererControlForm)rendererFormTable[renderer];
         if (container != null) form.SetupConnection(container);
         form.Activate();
     }
     else
     {
         RendererControlForm form = new RendererControlForm(this,renderer,null);
         rendererFormTable.Add(renderer,form);
         if (container != null) form.SetupConnection(container);
         form.Show();
     }
 }
 public void SetupConnection(ICpContainer container)
 {
     if (container == null) return;
     PendingConnection = DateTime.Now.Ticks;
     renderer.CreateConnection(container, PendingConnection);
 }