/// <summary>
        ///     Connect to the portable device
        /// </summary>
        /// <param name="appName"></param>
        /// <param name="majorVersionNumber"></param>
        /// <param name="minorVersionNumber"></param>
        public void ConnectToDevice(string appName, float majorVersionNumber, float minorVersionNumber)
        {
            if (string.IsNullOrEmpty(appName))
            {
                throw new ArgumentNullException("appName");
            }

            //Creating propValues for connection
            var clientValues = (IPortableDeviceValues) new PortableDeviceValuesClass();

            //Set the application name
            _tagpropertykey prop = PortableDevicePKeys.WPD_CLIENT_NAME;

            clientValues.SetStringValue(ref prop, appName);
            //Set the App version
            prop = PortableDevicePKeys.WPD_CLIENT_MAJOR_VERSION;
            clientValues.SetFloatValue(ref prop, majorVersionNumber);
            //Set the app minor version
            prop = PortableDevicePKeys.WPD_CLIENT_MINOR_VERSION;
            clientValues.SetFloatValue(ref prop, minorVersionNumber);

            //Open connection
            PortableDeviceClass.Open(DeviceId, clientValues);

            //Extract device capabilities
            ExtractDeviceCapabilities();

            eventCallback = new PortableDeviceEventCallback(this);
            // According to documentation pParameters should be null (see http://msdn.microsoft.com/en-us/library/dd375684%28v=VS.85%29.aspx )
            PortableDeviceClass.Advise(0, eventCallback, null, out adviseCookie);

            IsConnected = true;
        }
        /// <summary>
        /// Disconnect from device
        /// </summary>
        public void Disconnect()
        {
            if (!this.IsConnected)
            {
                return;
            }

            this.portableDeviceClass.Unadvise(this.adviseCookie);
            this.eventCallback = null;
            this.IsConnected   = false;
        }
        /// <summary>
        ///     Disconnect from device
        /// </summary>
        public void Disconnect()
        {
            if (!IsConnected)
            {
                return;
            }

            PortableDeviceClass.Unadvise(adviseCookie);
            eventCallback = null;
            IsConnected   = false;
        }
        /// <summary>
        /// Disconnect from device
        /// </summary>
        public void Disconnect()
        {
            if (!this.IsConnected)
                return;

            this.portableDeviceClass.Unadvise(this.adviseCookie);
            this.eventCallback = null;
            this.IsConnected = false;
        }
        /// <summary>
        /// Connect to the portable device
        /// </summary>
        /// <param name="appName"></param>
        /// <param name="majorVersionNumber"></param>
        /// <param name="minorVersionNumber"></param>
        public void ConnectToDevice(string appName, float majorVersionNumber, float minorVersionNumber)
        {
            if (string.IsNullOrEmpty(appName))
                throw new ArgumentNullException("appName");

          if(IsConnected)
            return;
            //Creating propValues for connection
            IPortableDeviceValues clientValues = (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass();

            //Set the application name
            _tagpropertykey prop = PortableDevicePKeys.WPD_CLIENT_NAME;
            clientValues.SetStringValue(ref prop, appName);
            //Set the App version
            prop = PortableDevicePKeys.WPD_CLIENT_MAJOR_VERSION;
            clientValues.SetFloatValue(ref prop, majorVersionNumber);
            //Set the app minor version
            prop = PortableDevicePKeys.WPD_CLIENT_MINOR_VERSION;
            clientValues.SetFloatValue(ref prop, minorVersionNumber);

            //Open connection
            this.portableDeviceClass.Open(this.DeviceId, clientValues);

            //Extract device capabilities
            //this.ExtractDeviceCapabilities();

            this.eventCallback = new PortableDeviceEventCallback(this);
            // According to documentation pParameters should be null (see http://msdn.microsoft.com/en-us/library/dd375684%28v=VS.85%29.aspx )
            this.portableDeviceClass.Advise(0, this.eventCallback, null, out this.adviseCookie);

            IsConnected = true;
        }
        /// <summary>
        ///     Disconnect from device
        /// </summary>
        public void Disconnect()
        {
            if (!IsConnected)
                return;

            PortableDeviceClass.Unadvise(adviseCookie);
            eventCallback = null;
            IsConnected = false;
        }