private static void NewPoint(object sender, PenPositionEventArgs e) { Console.WriteLine("Pen found at: " + e.Frame.Point.X + " / " + e.Frame.Point.Y); if (!e.Frame.Point.IsEmpty) { ; } //Mouse.MoveMouseAbsolute(e.Frame.Point.X,e.Frame.Point.Y); var r = new Random(); //_virtualCam.AddRect(e.Frame.Point.X + r.Next(-5,5)*20, e.Frame.Point.Y + r.Next(-5,5)*20,25,25, Color.Red); //_virtualCam.Draw(); }
//[DllImport("User32.dll")] //public static extern IntPtr GetDC(IntPtr hwnd); //[DllImport("User32.dll")] //public static extern void ReleaseDC(IntPtr dc); //protected override void OnPaint(PaintEventArgs e) //{ // IntPtr desktopDC = GetDC(IntPtr.Zero); // using (Graphics g = Graphics.FromHdc(desktopDC)) // { // using (SolidBrush brush = new SolidBrush(Color.Green)) // { // Point previousPoint = Point.Empty; // foreach (PointFrame f in penDrawingBuffer) // { // g.DrawEllipse(Pens.Green, f.Point.X - 3, f.Point.Y - 3, 3, 3); // if (!previousPoint.IsEmpty && PointTools.CalculateDistance(previousPoint, f.Point) < 50) // { // g.DrawLine(Pens.Red, previousPoint, f.Point); // } // previousPoint = f.Point; // } // } // } // //ReleaseDC(desktopDC); //} private void parser_PenPositionChanged(object sender, PenPositionEventArgs e) { if (e.Frame == null) { _inputEmulator.NoData(); return; } this.foundPointLabel.Text = "Found Point: " + e.Frame.Point.X + ", " + e.Frame.Point.Y; // Write Values to CSV using (var fs = new StreamWriter(new FileStream(@"C:\temp\foundpoints.csv", FileMode.Append, FileAccess.Write))) { fs.WriteLine(e.Frame.Timestamp + ";" + e.Frame.Point.X + ";" + e.Frame.Point.Y); fs.Flush(); } if (InputEnabled) { _inputEmulator.NewPoint(e.Frame.Point); } //Bitmap redaction = (Bitmap)this.cameraPictureBox.Image.Clone(); //if (e.Frame != null) //{ // penDrawingBuffer.Enqueue(e.Frame); //} //// draw points in buffer to image //using (Graphics g = screenForm.CreateGraphics()) //{ // g.Clear(Color.Black); // using (SolidBrush brush = new SolidBrush(Color.Green)) // { // Point previousPoint = Point.Empty; // foreach (PointFrame f in penDrawingBuffer) // { // g.DrawEllipse(Pens.Green, f.Point.X - 3, f.Point.Y - 3, 3, 3); // if (!previousPoint.IsEmpty && PointTools.CalculateDistance(previousPoint, f.Point) < 100) // { // g.DrawLine(Pens.Red, previousPoint, f.Point); // } // previousPoint = f.Point; // } // } // this.cameraPictureBox.Image = redaction; //} //var vc = VisualizerControl.GetVisualizer(); //Task.Factory.StartNew(() => //{ // vc.Clear(); // vc.Show(); // vc.Transparent = true; // //vc.MarkPoint(e.Frame.Point.X, e.Frame.Point.Y); // vc.AddRect(e.Frame.Point.X, e.Frame.Point.Y, 25, 25, Color.Green); // vc.Close(); // // Dispatcher.Run(); //}); //thread2.SetApartmentState(ApartmentState.STA); //thread2.Start(); //VisualizerControl v = VisualizerControl.GetVisualizer(); //v.Transparent = true; //v.Clear(); //v.AddRect(e.Frame.Point.X, e.Frame.Point.Y, 2, 2, Color.Green); //v.Show(); //v.Draw(); //// draw points in buffer to image //using (Graphics g = Graphics.FromImage(redaction)) //{ // using (SolidBrush brush = new SolidBrush(Color.Black)) // { // Point previousPoint = Point.Empty; // foreach (PointFrame f in penDrawingBuffer) // { // g.DrawEllipse(Pens.Green, f.Point.X - 3, f.Point.Y - 3, 3, 3); // if (!previousPoint.IsEmpty && PointTools.CalculateDistance(previousPoint, f.Point) < 50) // { // g.DrawLine(Pens.Red, previousPoint, f.Point); // } // previousPoint = f.Point; // } // } // this.cameraPictureBox.Image = redaction; //} }