public void GetWindowAtPoint() { var wa = new WindowApi(); var window = wa.WindowFromPoint(new Point(1000, 500)); var newWindow = new Window(window.Ptr, new Rectangle(100, 100, 600, 600)); wa.SetWindow(newWindow); }
public void GetWindowPos() { var wa = new WindowApi(); var window = wa.WindowFromPoint(new Point(1000, 500)); var newWindow = new Window(window.Ptr, new Rectangle(100, 100, 700, 700)); wa.SetWindow(newWindow); var result = wa.WindowFromPoint(new Point(200, 200)); Expect(result.Area, Is.EqualTo(new Rectangle(100, 100, 700, 700))); }
public void Pose(object o, PoseEventArgs e) { var myo = (Myo)o; if (myo.Pose == MyoSharp.Poses.Pose.DoubleTap) { if (!absoluteTL.ContainsKey(myo)) { absoluteTL.Add(myo, Math3D.FromQuaternion(myo.Orientation)); Console.WriteLine("Calibrated Top Left!"); UpdateBlob(myo, new Point(clientRes.Width, clientRes.Height)); } else { absoluteTL.Remove(myo); UpdateBlob(myo, new Point(0, 0)); } } else if (myo.Pose == MyoSharp.Poses.Pose.Fist) { if (absoluteTL.ContainsKey(myo)) { var position = GetPixelPosition(myo); var api = new WindowApi(); var window = api.WindowFromPoint(position); if (window != null) { if (!SelectedWindow.ContainsKey(myo)) { SelectedWindow.Add(myo, api.GetRoot(window)); if (SelectedWindow.ContainsKey(myo)) { if (!DragOffset.ContainsKey(myo)) { DragOffset.Add(myo, new Point(position.X - SelectedWindow[myo].Area.Location.X, position.Y - SelectedWindow[myo].Area.Location.Y)); } } } } } } else { if (absoluteTL != null) { if (SelectedWindow.ContainsKey(myo)) { var position = GetPixelPosition(myo); var api = new WindowApi(); var newWindow = new Window(SelectedWindow[myo].Ptr, new Rectangle(position.X - DragOffset[myo].Value.X, position.Y - DragOffset[myo].Value.Y, SelectedWindow[myo].Area.Width, SelectedWindow[myo].Area.Height)); SelectedWindow.Remove(myo); api.SetWindow(newWindow); api.BringToFront(newWindow); blobs.Add(myo, position); } if (rectangles.ContainsKey(myo)) { DeleteRect(myo); } DragOffset.Remove(myo); } } }