Exemplo n.º 1
0
 public void BringToFront()
 {
     var wa = new WindowApi();
     var window = wa.WindowFromPoint(new Point(1000, 500));
     wa.BringToFront(window);
     var frontWindow = wa.GetForegroundWindow();
     Expect(window.Ptr, Is.EqualTo(frontWindow.Ptr));
 }
Exemplo n.º 2
0
        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);
                }
            }
        }