Esempio n. 1
0
 private void Trigger(MouseClickCommand cmd)
 {
     if (OnMouseClick != null)
     {
         OnMouseClick(cmd);
     }
 }
Esempio n. 2
0
        private void MouseHook_MouseClick(object sender, MouseEventArgs e)
        {
            if (!isRecording || !settings.clickInsteadOfUpDown)
            {
                return;
            }
            Command newCommand = new MouseClickCommand(DateTime.Now.TimeOfDay - elapsedTime, e.Location.X, e.Location.Y, e.Button);

            elapsedTime = DateTime.Now.TimeOfDay;
            onNewCommand?.Invoke(newCommand);
        }
Esempio n. 3
0
 public void StartPlayback()
 {
     if (Commands == null)
     {
         return;
     }
     CurCommand             = 0;
     CurMouse               = null;
     CurrentTime            = TimeSpan.Zero;
     StartTime              = DateTime.UtcNow;
     TimerPlayback.Interval = UpdateMills;
     TimerPlayback.Elapsed += UpdatePlayback;
     TimerPlayback.Start();
 }
Esempio n. 4
0
        public void LoadCommands()
        {
            var texts = System.IO.File.ReadAllLines(@"WriteLines.txt");

            Commands = new List <AbstractCommand>();
            foreach (var line in texts)
            {
                if (line.StartsWith("C"))
                {
                    Commands.Add(MouseClickCommand.FromString(line));
                }
                else if (line.StartsWith("M"))
                {
                    Commands.Add(MoveCommand.FromString(line));
                }
                else if (line.StartsWith("K"))
                {
                    Commands.Add(KeyboardCommand.FromString(line));
                }
            }
        }
Esempio n. 5
0
        public void AddMouseUp(MouseEventArgs evt)
        {
            IUserCommand lastCommand = GetLastCommand();

            var mouseUp = new MouseUpCommand(evt);

            Commands.Add(mouseUp);
            Dbg <MouseUpCommand>("Added", evt);

            if (lastCommand is MouseDownCommand)
            {
                if (AreCoordinatesClose(mouseUp, lastCommand as MouseDownCommand, 3))
                {
                    var newClick = new MouseClickCommand(evt);
                    Dbg <MouseClickCommand>("Added", evt);
                    Trigger(newClick);
                }
                else
                {
                    Dbg <MouseClickCommand>("MouseClickCommand was not triggered because MouseUp/Down coordinates were not close enough", evt);
                }
            }
        }
 private void OnClick(object sender, RoutedEventArgs e)
 {
     MouseClickCommand?.Execute();
 }