/// <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");
            }

            Native.Rect bounds;
            Native.GetWindowRect(parent, out 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);
        }
示例#2
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");
            }

            Native.Rect bounds;
            Native.GetWindowRect(parent, out 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");
            }
            //var gwl = Native.GetWindowLongPtr(Handle, -20);

            //Native.SetWindowLongPtr(Handle, -20, (Native.GetWindowLongPtr(Handle, -20 | 0x80000 | 0x20)));

            //Native.SetLayeredWindowAttributes(Handle, 0, 255, 0x2);


            Graphics = new Direct2DRenderer(Handle, limitFps);

            SetBounds(X, Y, Width, Height);

            Task.Run(() => ParentServiceThread());
        }
        /// <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  = Native.GetSystemMetrics(WindowConstants.SmCxScreen);
            Height = Native.GetSystemMetrics(WindowConstants.SmCyScreen);

            ParentWindow = IntPtr.Zero;

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

            Graphics = new Direct2DRenderer(Handle, limitFps);

            SetBounds(X, Y, Width, Height);
        }
示例#4
0
 /// <inheritdoc />
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:GameOverlay.Graphics.D2DFont" /> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="options">The options.</param>
 public D2DFont(Direct2DRenderer device, FontOptions options) : this(device.GetFontFactory(), options.FontFamilyName,
                                                                     options.FontSize, options.Bold, options.Italic)
 {
 }
示例#5
0
 /// <inheritdoc />
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:GameOverlay.Graphics.D2DFont" /> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="fontFamilyName">Name of the font family.</param>
 /// <param name="size">The size.</param>
 /// <param name="bold">if set to <c>true</c> [bold].</param>
 /// <param name="italic">if set to <c>true</c> [italic].</param>
 public D2DFont(Direct2DRenderer device, string fontFamilyName, float size, bool bold = false, bool italic = false) :
     this(device.GetFontFactory(), fontFamilyName, size, bold, italic)
 {
 }
示例#6
0
 /// <inheritdoc />
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:GameOverlay.Graphics.D2DSolidColorBrush" /> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="color">The color.</param>
 public D2DSolidColorBrush(Direct2DRenderer device, D2DColor color) : this(device.GetRenderTarget(), color)
 {
 }
示例#7
0
 /// <inheritdoc />
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:GameOverlay.Graphics.D2DSolidColorBrush" /> class.
 /// </summary>
 /// <param name="device">The device.</param>
 public D2DSolidColorBrush(Direct2DRenderer device) : this(device.GetRenderTarget())
 {
 }