Exemplo n.º 1
0
 /// <summary>
 /// (0,0) -----
 /// -----------
 /// -----------
 /// -------(10, 10)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonRecordTopLeft_Click(object sender, EventArgs e)
 {
     Win32Interrop.POINT point;
     if (Win32Interrop.GetCursorPos(out point))
     {
         mTopLeft.X = point.X;
         mTopLeft.Y = point.Y;
         buttonRecordBR.Focus();
     }
 }
Exemplo n.º 2
0
 private void buttonRecordBR_Click(object sender, EventArgs e)
 {
     Win32Interrop.POINT point;
     if (Win32Interrop.GetCursorPos(out point))
     {
         mBottomRight.X = point.X;
         mBottomRight.Y = point.Y;
         buttonStartBackDrive.Focus();
     }
 }
Exemplo n.º 3
0
 private void startBackDrive()
 {
     if ((DateTime.Now - mStartBackDriveTime).TotalSeconds < 180)
     {
         buttonNextBest_Click(this, new EventArgs());
         timerShowAnimation.Interval = (int)numericUpDownSpeed.Value;
         mBackDriveStep  = 0;
         mStartBackdrive = true;
     }
     else
     {
         var screenpos = this.PointToScreen(buttonStartBackDrive.Location);
         Win32Interrop.SetCursorPos(screenpos.X + 50, screenpos.Y + 10);
         buttonStartBackDrive.BackColor = Color.Red;
         this.Focus();
         buttonStartBackDrive.Focus();
         buttonStartBackDrive.Focus();
     }
 }
Exemplo n.º 4
0
        private void timerShowAnimation_Tick(object sender, EventArgs e)
        {
            if (mSolvingTask != null && mSolver != null)
            {
                labelResultFound.Text = "Dictionary: " + mDictionary.Count() + " - Result found : " + mSolver.FoundCount + " - Combination Tried : " + mSolver.CombinationsTried;
                if (mSolvingTask.IsCompleted)
                {
                    buttonSolver.Enabled   = true;
                    labelResultFound.Text += " - Completed - " + mSolver.TimeSpent.TotalSeconds + " sec.";
                }
            }

            if (mResultToDisplay != null)
            {
                if (mAnimationPosition < mResultToDisplay.Path.Length)
                {
                    mButtons[mResultToDisplay.Path[mAnimationPosition].Position].Text      = mResultToDisplay.Path[mAnimationPosition].ValueToDisplay.ToString().ToUpper();
                    mButtons[mResultToDisplay.Path[mAnimationPosition].Position].ForeColor = Color.LightYellow;
                    mAnimationPosition++;
                }
                else
                {
                    for (int i = 0; i < mButtons.Length; i++)
                    {
                        mButtons[i].ForeColor = buttonNextBest.ForeColor;
                    }
                    mAnimationPosition = 0;
                }

                if (mStartBackdrive)
                {
                    if (mBackDriveStep < mResultToDisplay.Path.Length)
                    {
                        var step   = mResultToDisplay.Path[mBackDriveStep];
                        int width  = mBottomRight.X - mTopLeft.X;
                        int height = mBottomRight.Y - mTopLeft.Y;
                        int xpos   = mTopLeft.X + width / 4 * step.X + (width / 8);
                        int ypos   = mTopLeft.Y + height / 4 * step.Y + (height / 8);

                        Win32Interrop.POINT win32currentPos;
                        Win32Interrop.GetCursorPos(out win32currentPos);
                        Point currentPos = new Point(win32currentPos.X, win32currentPos.Y);

                        if (mBackDriveStep == 0)
                        {
                            currentPos.X = xpos;
                            currentPos.Y = ypos;
                            Win32Interrop.SetCursorPos(xpos, ypos);
                            System.Threading.Thread.Sleep(10);
                            Win32Interrop.mouse_event(Win32Interrop.MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);
                            System.Threading.Thread.Sleep(10);
                        }

                        var points = getPoints(new Point(currentPos.X, currentPos.Y), new Point(xpos, ypos), 20);
                        foreach (var point in points)
                        {
                            Win32Interrop.mouse_event(Win32Interrop.MOUSEEVENTF_LEFTDOWN, point.X, point.Y, 0, 0);
                            Win32Interrop.SetCursorPos(point.X, point.Y);
                            System.Threading.Thread.Sleep(1);
                        }
                        if (mBackDriveStep == mResultToDisplay.Path.Length - 1)
                        {
                            Win32Interrop.mouse_event(Win32Interrop.MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);
                            Win32Interrop.SetCursorPos(xpos, ypos);
                            mStartBackdrive = false;
                            System.Threading.Thread.Sleep(5);
                            xpos += 10;
                            ypos += 10;
                            Win32Interrop.mouse_event(Win32Interrop.MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);
                            Win32Interrop.SetCursorPos(xpos, ypos);
                            System.Threading.Thread.Sleep(50);
                            startBackDrive();
                        }
                        else
                        {
                            mBackDriveStep++;
                        }
                    }
                }
            }
        }