Example #1
0
        /// <summary>
        /// Makes a transparent window which adjust it's size and position to fit the parent window
        /// </summary>
        /// <param name="parent">HWND/Handle of a window</param>
        /// <param name="limitFPS">VSync</param>
        public OverlayWindow(IntPtr parent, bool limitFPS = true)
        {
            if (parent == IntPtr.Zero)
            {
                throw new Exception("The handle of the parent window isn't valid");
            }

            Native.RECT bounds;
            Native.GetWindowRect(parent, out bounds);

            this.IsDisposing = false;
            this.IsVisible   = true;
            this.IsTopMost   = true;

            this.ParentWindowExists = true;

            this.X = bounds.Left;
            this.Y = bounds.Top;

            this.Width  = bounds.Right - bounds.Left;
            this.Height = bounds.Bottom - bounds.Top;

            this.ParentWindow = parent;

            if (!this.CreateWindow())
            {
                throw new Exception("Could not create OverlayWindow");
            }

            this.Graphics = new Direct2DRenderer(this.Handle, limitFPS);

            this.SetBounds(this.X, this.Y, this.Width, this.Height);

            new Task(new Action(this.ParentServiceThread)).Start();
        }
Example #2
0
        /// <summary>
        /// Makes a transparent Fullscreen window
        /// </summary>
        /// <param name="limitFPS">VSync</param>
        public OverlayWindow(bool limitFPS = true)
        {
            this.IsDisposing = false;
            this.IsVisible   = true;
            this.IsTopMost   = true;

            this.ParentWindowExists = false;

            this.X      = 0;
            this.Y      = 0;
            this.Width  = Native.GetSystemMetrics(WindowConstants.SM_CX_SCREEN);
            this.Height = Native.GetSystemMetrics(WindowConstants.SM_CY_SCREEN);

            this.ParentWindow = IntPtr.Zero;

            if (!this.CreateWindow())
            {
                throw new Exception("Could not create OverlayWindow");
            }

            this.Graphics = new Direct2DRenderer(this.Handle, limitFPS);

            this.SetBounds(this.X, this.Y, this.Width, this.Height);
        }