Exemple #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>
        /// <exception cref="Exception">
        ///     The handle of the parent window isn't valid
        ///     or
        ///     Could not create OverlayWindow
        /// </exception>
        public DirectXOverlayWindow(IntPtr parent, bool limitFps = true)
        {
            if (parent == IntPtr.Zero)
            {
                throw new Exception("The handle of the parent window isn't valid");
            }

            NativeUtils.GetWindowRect(parent, out var bounds);

            IsDisposing = false;
            IsVisible   = true;
            IsTopMost   = true;

            ParentWindowExists = true;

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

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

            ParentWindow = parent;

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

            Graphics = new Direct2DRenderer(Handle, limitFps);

            SetBounds(X, Y, Width, Height);
        }
Exemple #2
0
        /// <summary>
        ///     Makes a transparent Fullscreen window
        /// </summary>
        /// <param name="limitFps">VSync</param>
        /// <exception cref="Exception">Could not create OverlayWindow</exception>
        public DirectXOverlayWindow(bool limitFps = true)
        {
            IsDisposing = false;
            IsVisible   = true;
            IsTopMost   = true;

            ParentWindowExists = false;

            X      = 0;
            Y      = 0;
            Width  = NativeUtils.GetSystemMetrics(SmCxScreen);
            Height = NativeUtils.GetSystemMetrics(SmCyScreen);

            ParentWindow = IntPtr.Zero;

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

            Graphics = new Direct2DRenderer(Handle, limitFps);

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