Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.FormClosing += form1_closing;
            drone             = new ARDrone.Control.DroneControl();
            ARDrone.Control.DroneConfig conf = new ARDrone.Control.DroneConfig();
            conf.FirmwareVersion = Control.Data.SupportedFirmwareVersion.Firmware_151;

            drone.Init(conf);

            drone.ConnectToDrone();
            timer1.Interval = 300;
            timer1.Enabled  = true;
            th = new Thread(new ParameterizedThreadStart(this.sender));
            th.Start();
            _running          = true;
            this.FormClosing += delegate { _running = false; };

            this.KeyDown += keydown;
            this.KeyUp   += keyup;

            drone.NewFrame += delegate(object sender2, EventArgs e2) {
                if (drone.BitmapImage != null)
                {
                    currentframe   = CopyBitmap(drone.BitmapImage);
                    centroDeImagen = new Point(currentframe.Width / 2, currentframe.Height / 2);
                    //_currentRectangle = Analyzer.FindColor(currentframe, _selectedColor);
                    _selectedRectangle = ARDrone.Control.Utils.Mio.VideoAnalyzerUtils.CurrentRectangle;
                    follow();
                    pictureBox1.Image = currentframe;
                }
            };


            Pen pen = new Pen(Color.Yellow, 3);

            pictureBox1.Paint += delegate(object sender2, PaintEventArgs args)
            {
                Graphics g = args.Graphics;

                g.DrawRectangle(pen, _selectedRectangle);
            };
            foreach (System.Windows.Forms.Control c in this.Controls)
            {
                c.KeyDown += keydown;
                c.KeyUp   += keyup;
            }

            Thread.Sleep(100);
            sending = true;
        }
        private void OpenDroneSettingsExecute( object param )
        {
            if ( _droneSettingsWindow != null )
            {
                _droneSettingsWindow.Activate();
            }
            else
            {
                bool isPaired = this._droneInit.DroneCommand.IsDronePaired;

                EventHandler<DroneSettingsEventArgs> newDroneConfigDelegate = ( sender, e ) =>
                {
                    isPaired = this._droneInit.DroneCommand.IsDronePaired;
                    this._currentDroneConfig = e.DroneConfig;

                    if ( isPaired != e.IsPaired )
                    {
                        if ( e.IsPaired )
                        {
                            RideOnMotion.Logger.Instance.NewEntry( CK.Core.LogLevel.Info, CKTraitTags.ARDrone, "Pairing drone." );
                            this._droneInit.DroneCommand.Pair();
                        }
                        else
                        {
                            RideOnMotion.Logger.Instance.NewEntry( CK.Core.LogLevel.Info, CKTraitTags.ARDrone, "Unpairing drone." );
                            this._droneInit.DroneCommand.Unpair();
                        }
                    }

                    ReconnectDrone();

                };

                DroneSettingsWindow window = new DroneSettingsWindow( this._currentDroneConfig, isPaired );

                window.DroneConfigAvailable += newDroneConfigDelegate;

                _droneSettingsWindow = window;

                _droneSettingsWindow.Closed += ( object sender, EventArgs args ) =>
                {
                    _droneSettingsWindow = null;
                    window.DroneConfigAvailable -= newDroneConfigDelegate;
                };

                _droneSettingsWindow.Show();
            }
        }
Example #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.FormClosing += form1_closing;
            drone = new ARDrone.Control.DroneControl();
            ARDrone.Control.DroneConfig conf = new ARDrone.Control.DroneConfig();
            conf.FirmwareVersion = Control.Data.SupportedFirmwareVersion.Firmware_151;

            drone.Init(conf);

            drone.ConnectToDrone();
            timer1.Interval = 300;
            timer1.Enabled = true;
            th = new Thread(new ParameterizedThreadStart(this.sender));
            th.Start();
            _running = true;
            this.FormClosing += delegate { _running = false; };

            this.KeyDown += keydown;
            this.KeyUp += keyup;

            drone.NewFrame += delegate(object sender2, EventArgs e2) {
                if (drone.BitmapImage != null)
                {
                    currentframe = CopyBitmap(drone.BitmapImage);
                    centroDeImagen = new Point(currentframe.Width / 2, currentframe.Height / 2);
                    //_currentRectangle = Analyzer.FindColor(currentframe, _selectedColor);
                     _selectedRectangle= ARDrone.Control.Utils.Mio.VideoAnalyzerUtils.CurrentRectangle;
                    follow();
                    pictureBox1.Image = currentframe;
                }
            };

            Pen pen = new Pen(Color.Yellow, 3);
            pictureBox1.Paint += delegate(object sender2, PaintEventArgs args)
            {
                   Graphics g = args.Graphics;

                    g.DrawRectangle(pen, _selectedRectangle);

             };
            foreach (System.Windows.Forms.Control c in this.Controls)
            {
                c.KeyDown += keydown;
                c.KeyUp += keyup;
            }

            Thread.Sleep(100);
            sending = true;
        }