mediarendererdiscovery.cs

来自「zwave 无线通讯协议 PC controller 控制器源码」· CS 代码 · 共 108 行

CS
108
字号
//////////////////////////////////////////////////////////////////////////////////////////////// 
//
//          #######
//          #   ##    ####   #####    #####  ##  ##   #####
//             ##    ##  ##  ##  ##  ##      ##  ##  ##
//            ##  #  ######  ##  ##   ####   ##  ##   ####
//           ##  ##  ##      ##  ##      ##   #####      ##
//          #######   ####   ##  ##  #####       ##  #####
//                                           #####
//          Z-Wave, the wireless language.
//
//          Copyright Zensys A/S, 2003,2004
//
//          All Rights Reserved
//
//          Description:   This source file is the sourcefile for the
//                         MediaRendererDiscovery class
//
//                         Source is generated by the Intel DeviceBuilder Tool
//
// Intel's UPnP .NET Framework Control Point Stack, Discovery Module
// Intel StackBuilder Build#1.0.1725.27554
//
//          Author:   Johann Sigfredsson
//
//          Last Changed By:  $Author: jch $
//          Revision:         $Revision: 1.2 $
//          Last Changed:     $Date: 2006/04/26 08:57:06 $
//
//////////////////////////////////////////////////////////////////////////////////////////////

using System;
using Intel.UPNP;
using Intel.Utilities;
using MicroStack;

namespace MicroStack
{
	/// <summary>
	/// Summary description for MediaRendererDiscovery.
	/// </summary>
	class MediaRendererDiscovery
	{
		private UPnPSmartControlPoint scp;
		private WeakEvent AddEvent = new WeakEvent();
		private WeakEvent RemoveEvent = new WeakEvent();
		
		public delegate void DiscoveryHandler(MediaRendererDiscovery sender, UPnPDevice dev);
		public event DiscoveryHandler OnAddedDevice
		{
			add
			{
				AddEvent.Register(value);
			}
			remove
			{
				AddEvent.UnRegister(value);
			}
		}
		public event DiscoveryHandler OnRemovedDevice
		{
			add
			{
				RemoveEvent.Register(value);
			}
			remove
			{
				RemoveEvent.UnRegister(value);
			}
		}
		
		public MediaRendererDiscovery()
		{
		}
		
		public void Start()
		{
			scp = new UPnPSmartControlPoint(new UPnPSmartControlPoint.DeviceHandler(OnAddSink),null,"urn:schemas-upnp-org:device:MediaRenderer:1");
			scp.OnRemovedDevice += new UPnPSmartControlPoint.DeviceHandler(OnRemoveSink);
		}
		public void ReScan()
		{
			scp.Rescan();
		}
		public void ForceDisposeDevice(UPnPDevice dev)
		{
			if(dev.ParentDevice!=null)
			{
				ForceDisposeDevice(dev.ParentDevice);
			}
			else
			{
				scp.ForceDisposeDevice(dev);
			}
		}
		
		private void OnAddSink(UPnPSmartControlPoint sender, UPnPDevice d)
		{
			AddEvent.Fire(this,d);
		}
		private void OnRemoveSink(UPnPSmartControlPoint sender, UPnPDevice d)
		{
			RemoveEvent.Fire(this,d);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?