Ejemplo n.º 1
0
        public Calibrate()
        {
            InitializeComponent();
            this.Top = 0;
            this.Left = 0;
            this.Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            this.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;

            pc = new PacketCannon(Convert.ToInt16(Properties.Settings.Default["Port"]));
            pa = new PacketAnalyze();

            worker = new BackgroundWorker();
            worker.DoWork += worker_DoWork;

            lbl.Content = instructions[currentStep];

            worker.RunWorkerAsync();
        }
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            string action;
            while (!e.Cancel)
            {
                received_data = pc.Receive();
                action = pa.a(received_data);
                if (!String.IsNullOrWhiteSpace(action))
                {
                    switch (action)
                    {
                        case "leftDown":
                            MouseMovement.MouseEvent(MouseMovement.MouseEventFlags.LeftDown);
                            break;
                        case "leftUp":
                            MouseMovement.MouseEvent(MouseMovement.MouseEventFlags.LeftUp);
                            break;
                        case "calibrate":
                            OnUIThread(() => { pc.Dispose(); new Calibrate().ShowDialog(); pc = new PacketCannon(Convert.ToInt16(Properties.Settings.Default["Port"])); });
                            break;
                    }

                }
            }
        }
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     pc = new PacketCannon(Convert.ToInt16(Properties.Settings.Default["Port"]));
     worker.RunWorkerAsync();
     tmrUpdate.Enabled = true;
 }