Exemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="usb"></param>
 public USBLauncher(UsbHidPort port)
 {
     _port = port;
     _horizontalStatus = Status.Normal;
     _verticalStatus = Status.Normal;
     _firingStatus = Status.DoneFiring;
     //_timer.Tick += new EventHandler(timer_Tick);
     //_timer.Interval = 100;
     //_timer.Start();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="usb"></param>
 public DreamCheekyLauncher(UsbHidPort port)
     : base(port)
 {
     _data = new byte[_dataSize];
     Port.VendorId = VendorId;
     Port.ProductId = ProductId;
     Port.CheckDevicePresent();
     if(Port.SpecifiedDevice != null)
         Port.SpecifiedDevice.DataRecieved += new LibHid.DataRecievedEventHandler(onDataReceived);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="usb"></param>
 public RocketBabyLauncher(UsbHidPort port)
     : base(port)
 {
     _data = new byte[_dataSize];
     Port.VendorId = VendorId;
     Port.ProductId = ProductId;
     Port.CheckDevicePresent();
     if (Port.SpecifiedDevice != null)
     {
         Port.SpecifiedDevice.DataRecieved += new LibHid.DataRecievedEventHandler(onDataReceived);
         _requestStatusTimer.AutoReset = true;
         _requestStatusTimer.Enabled = true;
         _requestStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(_requestStatusTimer_Elapsed);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor.  Put additional events here.
        /// </summary>
        public MainForm()
        {
            InitializeComponent();
            this.CheckSettings();
            this.Width = _regWidth;
            this.Height = _regHeight;
            this.btnDown.MouseUp += new MouseEventHandler(btn_Unclicked);
            this.btnDownLeft.MouseUp += new MouseEventHandler(btn_Unclicked);
            this.btnDownRight.MouseUp += new MouseEventHandler( btn_Unclicked);
            this.btnLeft.MouseUp += new MouseEventHandler(btn_Unclicked);
            this.btnRight.MouseUp += new MouseEventHandler(btn_Unclicked);
            this.btnUpLeft.MouseUp += new MouseEventHandler(btn_Unclicked);
            this.btnUp.MouseUp += new MouseEventHandler(btn_Unclicked);
            this.btnUpRight.MouseUp += new MouseEventHandler(btn_Unclicked);
            this.btnRight.MouseDown += new MouseEventHandler(BtnRightClick);
            this.btnLeft.MouseDown += new MouseEventHandler(BtnLeftClick);
            this.btnUp.MouseDown += new MouseEventHandler(BtnUpClick);
            this.btnDown.MouseDown += new MouseEventHandler(BtnDownClick);
            this.btnUpLeft.MouseDown += new MouseEventHandler(BtnUpLeftClick);
            this.btnUpRight.MouseDown += new MouseEventHandler(BtnUpRightClick);
            this.btnDownLeft.MouseDown += new MouseEventHandler(BtnDownLeftClick);
            this.btnDownRight.MouseDown += new MouseEventHandler(BtnDownRightClick);
            this.pictureBox1.VisibleChanged += new EventHandler(WebCamVisibilityChanged);
            _camera.ImageCaptured += new WebCamCapture.WebCamEventHandler(this.WebCamCapture_ImageCaptured);
            this.contextMenuStrip1.Opening += new CancelEventHandler(contextMenuStrip1_Opening);

            UsbHidPort dreamCheeky = new UsbHidPort();
            UsbHidPort rocketBaby = new UsbHidPort();

            dreamCheeky.OnSpecifiedDeviceArrived += new EventHandler(DreamCheekyArrived);
            dreamCheeky.OnSpecifiedDeviceRemoved += new EventHandler(DreamCheekyRemoved);
            rocketBaby.OnSpecifiedDeviceArrived += new EventHandler(RocketBabyArrived);
            rocketBaby.OnSpecifiedDeviceRemoved += new EventHandler(RocketBabyRemoved);

            if(this._manager.Connect(dreamCheeky, rocketBaby))
            {
                //TODO: put logic if(settings[rocket_start] == "Y") then recalibrate launcher
                this.updateLaunchersMenu();
            }
            else
            {
                this.AddText("No USB Launchers Found, check log");
            }

            this.chkFire.Checked = _config.AppSettings.Settings[Constants.Settings.FIRE_WHILE_MOVING].Value == "Y" ? true : false;
            this.chkSlow.Checked = _config.AppSettings.Settings[Constants.Settings.SLOW].Value == "Y" ? true : false;
            bool primeAfterFire = _config.AppSettings.Settings[Constants.Settings.PRIME_AIRTANK].Value == "Y" ? true : false;

            foreach (USBLauncher l in _manager.Launchers)
            {
                if (l is DreamCheekyLauncher)
                    (l as DreamCheekyLauncher).PrimeAfterFire = primeAfterFire;
                else if (l is RocketBabyLauncher)
                    (l as RocketBabyLauncher).PrimeAfterFire = primeAfterFire;
            }

            DirectoryInfo dInfo = new DirectoryInfo("images");
            if(!dInfo.Exists)
                dInfo.Create();

            _timer.Interval = 5000;
            _timer.Tick += new EventHandler(timer_Tick);
            _timer.Start();
        }