public void ColorMode()
        {
            bool darkMode = Program.tasktraySettingsInstance.darkMode;

            int color = darkMode ? LWA_DARKMODECOLORKEY : LWA_LIGHTMODECOLORKEY;

            NativeImport.SetLayeredWindowAttributes(this.Handle, (uint)color, 1, NativeImport.WindowsStyleModifiers.LWA_ALPHA);

            this.BackColor = darkMode ? Color.FromArgb(1, 2, 3) : Color.FromArgb(255, 254, 253);
            this.Refresh();
        }
        public OverlayWindow()
        {
            InitializeComponent();
            this.TopMost         = true;
            this.WindowState     = FormWindowState.Maximized;
            this.FormBorderStyle = FormBorderStyle.None;

            NativeImport.SetWindowLong(this.Handle, NativeImport.WindowsStyleModifiers.GWL_EXSTYLE,
                                       (IntPtr)(NativeImport.GetWindowLong(this.Handle, NativeImport.WindowsStyleModifiers.GWL_EXSTYLE) | NativeImport.WindowsStyleModifiers.WS_EX_LAYERED | NativeImport.WindowsStyleModifiers.WS_EX_TRANSPARENT));
            NativeImport.SetLayeredWindowAttributes(this.Handle, NativeImport.WindowsStyleModifiers.LWA_COLORKEY, 1, NativeImport.WindowsStyleModifiers.LWA_ALPHA);

            this.BackColor = Color.FromArgb(1, 2, 3);
        }
Ejemplo n.º 3
0
        internal void OnLoad()
        {
            NativeImport.SetWindowLong(this.Handle, DrawFactory.GWL_EXSTYLE, (IntPtr)(NativeImport.GetWindowLong(this.Handle, DrawFactory.GWL_EXSTYLE) ^ (DrawFactory.WS_EX_LAYERED ^ DrawFactory.WS_EX_TRANSPARENT)));/*(IntPtr)(NativeImport.GetWindowLong(this.Handle, DrawFactory.GWL_EXSTYLE) ^*/
            NativeImport.SetLayeredWindowAttributes(this.Handle, 0, 255, DrawFactory.LWA_ALPHA);
            NativeImport.RECT rct = default;
            NativeImport.GetWindowRect(Utils.GetPubgWindow(), out rct);

            this.Width    = rct.Right - rct.Left;
            this.Height   = rct.Bottom - rct.Top;
            this.Location = new System.Drawing.Point(rct.Left, rct.Top);

            if (IsInitialised == false)
            {
                PresentParameters presentParameters = new PresentParameters();
                presentParameters.Windowed         = true;
                presentParameters.SwapEffect       = SwapEffect.Discard;
                presentParameters.BackBufferFormat = Format.A8R8G8B8;

                DrawFactory.device = new Device(DrawFactory.D3D, 0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, presentParameters);

                DrawFactory.drawLine          = new Line(DrawFactory.device);
                DrawFactory.drawBoxLine       = new Line(DrawFactory.device);
                DrawFactory.drawCircleLine    = new Line(DrawFactory.device);
                DrawFactory.drawFilledBoxLine = new Line(DrawFactory.device);
                DrawFactory.drawTriLine       = new Line(DrawFactory.device);

                FontDescription fontDescription = new FontDescription()
                {
                    FaceName        = "Fixedsys Regular",
                    CharacterSet    = FontCharacterSet.Default,
                    Height          = 20,
                    Weight          = FontWeight.Regular,
                    MipLevels       = 0,
                    OutputPrecision = FontPrecision.Default,
                    PitchAndFamily  = FontPitchAndFamily.Default,
                    Quality         = FontQuality.ClearType
                };

                DrawFactory.font = new SharpDX.Direct3D9.Font(DrawFactory.device, fontDescription);
                DrawFactory.InitialiseCircleDrawing(DrawFactory.device);

                IsInitialised = true;

                OnDraw();
            }
        }
Ejemplo n.º 4
0
        internal void OnLoad()
        {
            NativeImport.SetWindowLong(Handle, DrawFactory.GWL_EXSTYLE,
                                       (IntPtr)(NativeImport.GetWindowLong(Handle, DrawFactory.GWL_EXSTYLE) ^ DrawFactory.WS_EX_LAYERED ^
                                                DrawFactory.WS_EX_TRANSPARENT));

            NativeImport.SetLayeredWindowAttributes(Handle, 0, 255, DrawFactory.LWA_ALPHA);

            if (IsInitialised)
            {
                return;
            }
            var presentParameters = new PresentParameters
            {
                Windowed = true, SwapEffect = SwapEffect.Discard, BackBufferFormat = Format.A8R8G8B8
            };

            DrawFactory.device = new Device(DrawFactory.D3D, 0, DeviceType.Hardware, Handle,
                                            CreateFlags.HardwareVertexProcessing, presentParameters);

            DrawFactory.drawLine          = new Line(DrawFactory.device);
            DrawFactory.drawBoxLine       = new Line(DrawFactory.device);
            DrawFactory.drawCircleLine    = new Line(DrawFactory.device);
            DrawFactory.drawFilledBoxLine = new Line(DrawFactory.device);
            DrawFactory.drawTriLine       = new Line(DrawFactory.device);

            var fontDescription = new FontDescription
            {
                FaceName        = "Fixedsys Regular",
                CharacterSet    = FontCharacterSet.Default,
                Height          = 20,
                Weight          = FontWeight.Bold,
                MipLevels       = 0,
                OutputPrecision = FontPrecision.Default,
                PitchAndFamily  = FontPitchAndFamily.Default,
                Quality         = FontQuality.ClearType
            };

            DrawFactory.font = new Font(DrawFactory.device, fontDescription);
            DrawFactory.InitialiseCircleDrawing(DrawFactory.device);

            IsInitialised = true;

            OnDraw();
        }