Exemple #1
0
        bool IHookFilter <MouseStruct> .HookProc(IntPtr wParam, IntPtr lParam, MouseStruct data)
        {
            if (Program.OSXCapture.CaptureMode != Core.CaptureMode.Unknown)
            {
                Rectangle screen = Screen.FromPoint(MousePosition).Bounds;

                Point position = ClipPoint(new Point(data.x, data.y), screen);
                Point display  = position;

                switch (Program.OSXCapture.CaptureMode)
                {
                case Core.CaptureMode.Drag:
                    // Drag Layer Update
                    if (Program.OSXCapture.IsDragging)
                    {
                        var rect = RectangleEx.GetRectangle(dWindow.DragStartPosition, MousePosition);

                        display = (Point)rect.Size;

                        dWindow?.UpdateLayout(position);
                    }
                    break;

                    //case Core.CaptureMode.Window:
                    //    IntPtr hwnd = WindowHelper.ChildFromPoint(MousePosition);

                    //    if (hwnd != Program)
                    //    {
                    //        WindowHelper.HideHighlight(focusedWindow);
                    //        WindowHelper.ShowHighlight(hwnd);

                    //        focusedWindow = hwnd;
                    //    }

                    //    break;
                }

                this.UpdateLayout(position, display);
            }

            return(false);
        }
Exemple #2
0
        public void UpdateLayout(Point position)
        {
            var rect = RectangleEx.GetRectangle(startPosition, position);

            this.Location = rect.Location;
            this.Size     = rect.Size;

            if (rect.Width * rect.Height == 0)
            {
                return;
            }

            var bmp = new Bitmap(rect.Width, rect.Height);

            using (var g = Graphics.FromImage(bmp))
            {
                g.Clear(Color.FromArgb((byte)(255 * 0.15), Color.Black));
                g.DrawRectangle(Pens.White, 0, 0, rect.Width - 1, rect.Height - 1);
            }

            DrawBitmap(bmp, 255);
            bmp.Dispose();
        }