Ejemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:DeviceAdded"/> event.
        /// </summary>
        /// <param name="e">The <see cref="DroidExplorer.Core.DeviceEventArgs"/> instance containing the event data.</param>
        protected void OnDeviceAdded(DeviceEventArgs e)
        {
            if (this.DeviceAdded != null)
            {
                this.DeviceAdded(this, e);
            }

            if (!DeviceStatusChangedListeners.ContainsKey(e.Device))
            {
                DeviceStatusChangedListeners.Add(e.Device, delegate(object sender, DeviceEventArgs e1) {
                    OnDeviceStateChanged(e1);
                });
                CommandRunner.Instance.DeviceStateChanged += DeviceStatusChangedListeners[e.Device];
            }



            if (e.State == CommandRunner.DeviceState.Device)
            {
                OnDeviceStateChanged(e);
            }

            var deviceId = e.Device;

            if (!String.IsNullOrEmpty(deviceId))
            {
                var info = CommandRunner.Instance.GetDevices().SingleOrDefault(m => m.SerialNumber == deviceId);
                // cache the device icon and images
                if (!String.IsNullOrEmpty(info.DeviceName))
                {
                    var ico = CloudImage.Instance.GetIcon(info.DeviceName);
                    var png = CloudImage.Instance.GetImage(info.DeviceName);
                }

                if (Settings.Instance.SystemSettings.RecordDeviceInformationToCloud)
                {
                    DroidExplorer.Core.Adb.Device d = new Core.Adb.Device(deviceId, Core.Adb.DeviceState.Online);
                    if (d != null)
                    {
                        CommandRunner.Instance.GetProperties(deviceId).ToList().ForEach(x => {
                            d.Properties.Add(x.Key, x.Value);
                        });

                        // this will register devices when plugged in, if the user has opt'd to do so
                        // and if the service is running
                        CloudStatistics.Instance.RegisterDevice(d, info);
                    }
                }
            }
            this.LogInfo("Device Added: {0}:{1}", e.Device, e.State);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Raises the <see cref="E:DeviceAdded"/> event.
        /// </summary>
        /// <param name="e">The <see cref="DroidExplorer.Core.DeviceEventArgs"/> instance containing the event data.</param>
        protected void OnDeviceAdded(DeviceEventArgs e)
        {
            if(this.DeviceAdded != null) {
                this.DeviceAdded(this, e);
            }

            if(!DeviceStatusChangedListeners.ContainsKey(e.Device)) {
                DeviceStatusChangedListeners.Add(e.Device, delegate(object sender, DeviceEventArgs e1) {
                    OnDeviceStateChanged(e1);
                });
                CommandRunner.Instance.DeviceStateChanged += DeviceStatusChangedListeners[e.Device];
            }

            if(e.State == CommandRunner.DeviceState.Device) {
                OnDeviceStateChanged(e);
            }

            var deviceId = e.Device;
            if(!String.IsNullOrEmpty(deviceId)) {
                var info = CommandRunner.Instance.GetDevices().SingleOrDefault(m => m.SerialNumber == deviceId);
                // cache the device icon and images
                if(!String.IsNullOrEmpty(info.DeviceName)) {
                    var ico = CloudImage.Instance.GetIcon(info.DeviceName);
                    var png = CloudImage.Instance.GetImage(info.DeviceName);
                }

                if(Settings.Instance.SystemSettings.RecordDeviceInformationToCloud) {
                    DroidExplorer.Core.Adb.Device d = new Core.Adb.Device(deviceId, Core.Adb.DeviceState.Online);
                    if(d != null) {
                        CommandRunner.Instance.GetProperties(deviceId).ToList().ForEach(x => {
                            d.Properties.Add(x.Key, x.Value);
                        });

                        // this will register devices when plugged in, if the user has opt'd to do so
                        // and if the service is running
                        CloudStatistics.Instance.RegisterDevice(d, info);
                    }
                }
            }
            this.LogInfo("Device Added: {0}:{1}", e.Device, e.State);
        }