static void TrackClicks(MongoCollection storageTarget) { Console.WriteLine("Start moving the mouse around (random positions will be tracked). To stop tracking, press any key on the keyboard"); while (!Console.KeyAvailable) { if (randGen.Next(5000) < 1) { var cursorPos = System.Windows.Forms.Cursor.Position; var clickGeoRegion = GetRandomizedRegion(); Click clickData = new Click(new ScreenPoint(cursorPos.X, cursorPos.Y), clickGeoRegion); Console.WriteLine("tracked at: " + clickData.Location.X + " " + clickData.Location.Y); storageTarget.Insert(clickData); } } Console.WriteLine("Finished tracking clicks"); Console.ReadKey(); }
static void DeleteClick(Click click, MongoCollection clicks) { var query = Query.EQ("_id", click.Id); clicks.Remove(query); }
static void EditClick(Click click, MongoCollection clicks) { Console.WriteLine("Enter new click name:"); string clickName = Console.ReadLine(); var update = Update.Set("Name", clickName); var query = Query.EQ("_id", click.Id); clicks.Update(query, update); }