Esempio n. 1
0
 public bool myUpdateMouseEventsTargetStatus(GhostMouseScript gms, int currentId)
 {
     labelEntryCount.Content = String.Format("{0}/{1}", currentId, gms.MouseEvents.Count());
     TimeSpan ts = DateTime.Now.Subtract(lastUiUpdateTime);
     if (ts.TotalMilliseconds > 250)
     {
         Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { }));
         lastUiUpdateTime = DateTime.Now;
     }
     return false;
 }
Esempio n. 2
0
        public void DrawMouseEventsPath(GhostMouseScript gms, UpdateMouseEventsTargetStatus UpdateStatus)
        {
            // prepare colors
            SolidColorBrush brushMove = new SolidColorBrush();
            brushMove.Color = Color.FromArgb(255, 128, 128, 0);
            SolidColorBrush brushClick = new SolidColorBrush();
            brushClick.Color = Color.FromArgb(255, 0, 0, 255);

            // clear canvas, store events for later use
            canvas1.Children.Clear();
            Rectangle r = new Rectangle();
            r.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            r.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            r.Margin = new Thickness(0, 0, 0, 0);
            r.Fill = this.Background;
            canvas1.Children.Add(r);
            mouseEvents = gms.MouseEvents;

            // state var
            MouseEvent lastMouseEvent;

            /* draw moves */
            lastMouseEvent = gms.MouseEvents[0];
            PathFigure pathFigure = new PathFigure();
            foreach (MouseEvent mouseEvent in gms.MouseEvents)
            {
                if (mouseEvent.IsEqual(lastMouseEvent)) continue;

                LineSegment seg = new LineSegment(new Point(mouseEvent.posX, mouseEvent.posY), true);
                pathFigure.Segments.Add(seg);

                lastMouseEvent = mouseEvent;
            }
            PathFigureCollection pathFigureCollection = new PathFigureCollection();
            pathFigureCollection.Add(pathFigure);
            PathGeometry pathGeometry = new PathGeometry();
            Path p = new Path();
            p.Stroke = brushMove;
            p.StrokeThickness = 1;
            pathGeometry.Figures = pathFigureCollection;
            p.Data = pathGeometry;
            canvas1.Children.Add(p);
            if ((bool)UpdateStatus(gms, 0)) return;

            /* draw clicks */
            int i = 0;
            int ri = 0;
            hashedClickEvents = new Dictionary<ulong, MouseEvent>();
            foreach (MouseEvent mouseEvent in gms.MouseEvents)
            {
                i++;
                //if (i > 500) break;
                if (!mouseEvent.button1) continue;
                if (hashedClickEvents.ContainsKey(makeKey(mouseEvent.posX,mouseEvent.posY))) continue;

                hashedClickEvents.Add(makeKey(mouseEvent.posX , mouseEvent.posY), mouseEvent);

                r = new Rectangle();
                int strokewidth = 1;
                r.Margin = new Thickness(mouseEvent.posX, mouseEvent.posY, mouseEvent.posX + strokewidth, mouseEvent.posY + strokewidth);
                r.Height = strokewidth;
                r.Width = strokewidth;
                r.Fill = brushClick;
                ri++;
                canvas1.Children.Add(r);

                if (ri % 10 == 0)
                {
                    if ((bool)UpdateStatus(gms, i)) break;
                }
            }
        }
Esempio n. 3
0
 private void buttonNew_Click(object sender, RoutedEventArgs e)
 {
     gms = new GhostMouseScript();
     labelEntryCount.Content = gms.MouseEvents.Count();
     datagridMouseEvents.DataContext = gms.MouseEvents;
 }
Esempio n. 4
0
        private void OpenFile(String filename, bool Append)
        {
            textFilename.Text = filename;
            if (gms == null)
                gms = new GhostMouseScript();
            if (!Append)
                gms = new GhostMouseScript();
            gms.appendFromFile(filename);
            labelEntryCount.Content = gms.MouseEvents.Count();

            mouseEventsObservable = new ObservableCollection<MouseEvent>(gms.MouseEvents);
            mouseEventsObservable.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(mouseEventsObservable_CollectionChanged);
            datagridMouseEvents.DataContext = null;
            datagridMouseEvents.DataContext = mouseEventsObservable;
            StartDrawMouseEventsPath();
        }