Inheritance: System.EventArgs
コード例 #1
0
        /// <summary>
        /// Raises the <see cref="E:DeviceStateChanged"/> event.
        /// </summary>
        /// <param name="e">The <see cref="DroidExplorer.Core.DeviceEventArgs"/> instance containing the event data.</param>
        protected void OnDeviceStateChanged(DeviceEventArgs e)
        {
            if(this.DeviceStateChanged != null) {
                this.DeviceStateChanged(this, e);
            }

            switch(e.State) {
                case CommandRunner.DeviceState.Device:
                    DeviceExplorerRegistration.Instance.Register(e.Device);
                    break;
                case CommandRunner.DeviceState.Unknown:
                case CommandRunner.DeviceState.Offline:
                case CommandRunner.DeviceState.Bootloader:
                    DeviceExplorerRegistration.Instance.Unregister(e.Device);
                    break;
            }
            this.LogInfo("Device State Changed: {0}:{1}", e.Device, e.State);
        }
コード例 #2
0
ファイル: Installer.cs プロジェクト: camalot/droidexplorer
 /// <summary>
 /// Handles the DeviceStateChanged event of the CommandRunner control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="DeviceEventArgs" /> instance containing the event data.</param>
 void CommandRunner_DeviceStateChanged( object sender, DeviceEventArgs e )
 {
     if ( string.Compare ( e.Device, this.PluginHost.CommandRunner.DefaultDevice, true ) == 0 ) {
     if ( ToolStripMenuItem != null ) {
       ToolStripMenuItem.Enabled = e.State != CommandRunner.DeviceState.Offline && e.State != CommandRunner.DeviceState.Unknown;
     }
     if ( ToolStripButton != null ) {
       ToolStripButton.Enabled = e.State == CommandRunner.DeviceState.Offline && e.State != CommandRunner.DeviceState.Unknown;
     }
       }
 }
コード例 #3
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);
        }
コード例 #4
0
        /// <summary>
        /// Raises the <see cref="E:DeviceRemoved"/> event.
        /// </summary>
        /// <param name="e">The <see cref="DroidExplorer.Core.DeviceEventArgs"/> instance containing the event data.</param>
        protected void OnDeviceRemoved(DeviceEventArgs e)
        {
            if(this.DeviceRemoved != null) {
                this.DeviceRemoved(this, e);
            }

            if(DeviceStatusChangedListeners.ContainsKey(e.Device)) {
                CommandRunner.Instance.DeviceStateChanged -= DeviceStatusChangedListeners[e.Device];
                DeviceStatusChangedListeners.Remove(e.Device);
            }

            OnDeviceStateChanged(new DeviceEventArgs(e.Device, CommandRunner.DeviceState.Offline));
            this.LogInfo("Device Removed: {0}:{1}", e.Device, e.State);
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: camalot/droidexplorer
        void CommandRunner_DeviceStateChanged( object sender, DeviceEventArgs e )
        {
            string title = CommandRunner.Instance.State.ToString ( );

            if ( CommandRunner.Instance.State == CommandRunner.DeviceState.Device ) {
                title = KnownDeviceManager.Instance.GetDeviceFriendlyName ( string.IsNullOrEmpty ( CommandRunner.Instance.DefaultDevice ) ? CommandRunner.Instance.GetSerialNumber ( ) : CommandRunner.Instance.DefaultDevice );
            }

            if ( this.InvokeRequired ) {
                this.Invoke ( new SetWindowTitleDelegate ( SetWindowTitle ), new object[] { string.Format ( Resources.Strings.TitleFormat, title ) } );
            } else {
                SetWindowTitle ( string.Format ( Resources.Strings.TitleFormat, title ) );
            }
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: camalot/droidexplorer
 void CommandRunner_Disconnected( object sender, DeviceEventArgs e )
 {
     this.InvokeIfRequired ( ( ) => {
         breadcrumbBar.Nodes.Clear ( );
         directoryTree.Nodes.Clear ( );
         itemsList.Items.Clear ( );
         rootNode.Nodes.Clear ( );
         foreach ( Control p in this.toolStripContainer1.TopToolStripPanel.Controls ) {
             if ( !p.Equals ( menuStrip ) ) {
                 p.Enabled = false;
             } else {
                 foreach ( var msi in menuStrip.Items ) {
                     if ( !msi.Equals ( connectToDeviceToolStripMenuItem ) && !msi.Is<ImageLinkToolStripItem> ( ) ) {
                         ( (ToolStripMenuItem)msi ).Enabled = false;
                     }
                 }
             }
         }
         objectsToolStripStatusLabel.Text = string.Empty;
         sizeToolStripStatusLabel.Text = string.Empty;
     } );
 }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: camalot/droidexplorer
        void CommandRunner_Connected( object sender, DeviceEventArgs e )
        {
            this.InvokeIfRequired ( ( ) => {
                directoryTree.Nodes.Clear ( );
                itemsList.Items.Clear ( );
                rootNode.Nodes.Clear ( );

                foreach ( Control p in this.toolStripContainer1.TopToolStripPanel.Controls ) {
                    if ( !p.Equals ( menuStrip ) ) {
                        p.Enabled = true;
                    } else {
                        foreach ( var msi in menuStrip.Items ) {
                            if ( !msi.Equals ( connectToDeviceToolStripMenuItem ) && !msi.Is<ImageLinkToolStripItem> ( ) ) {
                                ( (ToolStripMenuItem)msi ).Enabled = true;
                            }
                        }
                    }
                }
            } );

            BuildTree ( );

            // this fails because the BreadcrumbBar doesn't handle the invoke correctly.
            // this.NavigateToPath ( new LinuxDirectoryInfo ( initialPath ) );
        }
コード例 #8
0
 /// <summary>
 /// Handles the DeviceStateChanged event of the CommandRunner control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="DeviceEventArgs" /> instance containing the event data.</param>
 void CommandRunner_DeviceStateChanged( object sender, DeviceEventArgs e )
 {
     bool enabled =  e.State != CommandRunner.DeviceState.Offline && e.State != CommandRunner.DeviceState.Unknown;
       if ( string.Compare ( e.Device, CommandRunner.Instance.DefaultDevice, true ) == 0 ) {
     if ( ToolStripMenuItem != null ) {
       ToolStripMenuItem.SetEnabled ( enabled );
     }
     if ( ToolStripButton != null ) {
       ToolStripButton.SetEnabled ( enabled );
     }
       }
 }
コード例 #9
0
 void Monitor_DeviceStateChanged( object sender, DeviceEventArgs e )
 {
 }
コード例 #10
0
 void Monitor_DeviceRemoved( object sender, DeviceEventArgs e )
 {
 }
コード例 #11
0
 void Monitor_DeviceAdded( object sender, DeviceEventArgs e )
 {
 }