コード例 #1
0
ファイル: WpdObject.cs プロジェクト: gtaglang/WpdLib
        /// インスタンスを初期化します。
        /// </summary>
        /// <param name="id">オブジェクトの識別子。</param>
        /// <param name="client">デバイスに接続しているクライアント情報。</param>
        /// <param name="content">デバイスのコンテンツ情報。</param>
        /// <param name="properties">プロパティ。</param>
        internal WpdObject( string id, WpdClient client, IPortableDeviceContent content, IPortableDeviceProperties properties )
        {
            this.Id          = id;
            this._client     = client;
            this._content    = content;
            this._properties = properties;

            // プロパティ更新
            this.UpdateValues();
        }
コード例 #2
0
ファイル: WpdObject.cs プロジェクト: GitTongZQ/WpdLib
        /// インスタンスを初期化します。
        /// </summary>
        /// <param name="id">オブジェクトの識別子。</param>
        /// <param name="client">デバイスに接続しているクライアント情報。</param>
        /// <param name="content">デバイスのコンテンツ情報。</param>
        /// <param name="properties">プロパティ。</param>
        internal WpdObject(string id, WpdClient client, IPortableDeviceContent content, IPortableDeviceProperties properties)
        {
            this.Id          = id;
            this._client     = client;
            this._content    = content;
            this._properties = properties;

            // プロパティ更新
            this.UpdateValues();
        }
コード例 #3
0
        /// <summary>
        /// デバイスを開きます。
        /// </summary>
        /// <param name="client">クライアント情報。</param>
        /// <param name="deviceEventHandler">デバイス上で発生したイベントのハンドラー。</param>
        public void Open(WpdClient client, Action <WpdEventArgs> deviceEventHandler)
        {
            if (client == null)
            {
                throw new ArgumentNullException("'client' is null.");
            }

            if (this.IsOpened)
            {
                return;
            }

            // 接続
            this._device.Open(this.Id, client.CreateDeviceValue());
            this._client  = client;
            this.IsOpened = true;

            // プロパティ更新
            this.UpdateValues();

            // イベント ハンドラの設定
            this._deviceEventHandler = new WpdEventCallback(deviceEventHandler);
            this._device.Advise(0, this._deviceEventHandler, null, out this._deviceEventCookie);
        }
コード例 #4
0
ファイル: WpdDevice.cs プロジェクト: gtaglang/WpdLib
        /// <summary>
        /// デバイスを開きます。
        /// </summary>
        /// <param name="client">クライアント情報。</param>
        /// <param name="deviceEventHandler">デバイス上で発生したイベントのハンドラー。</param>
        public void Open( WpdClient client, Action< WpdEventArgs > deviceEventHandler )
        {
            if( client == null ) { throw new ArgumentNullException( "'client' is null." ); }

            if( this.IsOpened ) { return; }

            // 接続
            this._device.Open( this.Id, client.CreateDeviceValue() );
            this._client  = client;
            this.IsOpened = true;

            // プロパティ更新
            this.UpdateValues();

            // イベント ハンドラの設定
            this._deviceEventHandler = new WpdEventCallback( deviceEventHandler );
            this._device.Advise( 0, this._deviceEventHandler, null, out this._deviceEventCookie );
        }
コード例 #5
0
ファイル: WpdDevice.cs プロジェクト: gtaglang/WpdLib
        /// <summary>
        /// デバイスを閉じます。
        /// </summary>
        public void Close()
        {
            if( !this.IsOpened ) { return; }

            this._device.Unadvise( this._deviceEventCookie );
            this._deviceEventHandler = null;
            this._deviceEventCookie  = null;

            this._device.Close();
            this._client  = null;
            this.IsOpened = false;
        }