示例#1
0
        protected internal void ToDefault()
        {
            this.GetColors(out var background, out var foreground);

            WindowComposition.Disable(this);
            this.ChangeProperties(background, foreground, SystemColors.WindowFrameColor, this.GetBordersFlagAsThickness(1));
        }
示例#2
0
        protected internal void ToBlur()
        {
            this.GetColors(out var background, out var foreground);

            background.A = (byte)(background.A * this.BlurOpacity);
            WindowComposition.EnableBlur(this, this.BordersFlag);
            this.ChangeProperties(background, foreground, Colors.Transparent, new Thickness());
        }
示例#3
0
        private void ToAcrylicBlur()
        {
            this.GetColors(out var background, out var foreground);

            background.A = (byte)(background.A * this.BlurOpacity);
            WindowComposition.EnableAcrylicBlur(this, background, this.BordersFlag);
            this.ChangeProperties(Color.FromArgb(1, 0, 0, 0), foreground, Colors.Transparent, new Thickness());
        }
示例#4
0
        public void ApplyWindowComposition(nint windowHandle, WindowComposition windowComposition)
        {
            if (!windows.ContainsKey(windowHandle))
            {
                windows.Add(windowHandle, new Window(windowHandle));
            }

            windows[windowHandle].ApplyWindowComposition(windowComposition);
        }
示例#5
0
        public void ApplyWindowComposition(WindowComposition windowComposition)
        {
            if (windowComposition.Equals(appliedComposition))
            {
                RevertWindowComposition();
                return;
            }

            SetCurrentComposition(windowComposition);
            appliedComposition = windowComposition;
        }
示例#6
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            WindowComposition.Set(this, AccentState.ACCENT_ENABLE_BLURBEHIND, AccentFlags.DrawAllBorders);

            WindowsTheme.HighContrast.Changed    += this.HandleThemeChanged;
            WindowsTheme.Transparency.Changed    += this.HandleThemeChanged;
            WindowsTheme.ColorPrevalence.Changed += this.HandleThemeChanged;

            this.HandleThemeChanged(null, false);
        }
示例#7
0
        public Window(nint windowHandle)
        {
            hwnd = new HWND(windowHandle);
            originalComposition = GetCurrentComposition();

            unsafe
            {
                var processId = 0U;
                PInvoke.GetWindowThreadProcessId(hwnd, &processId);
                processName = Process.GetProcessById((int)processId).ProcessName;
            }
        }
示例#8
0
 protected internal void ToHighContrast()
 {
     if (WindowsVersion.Is10)
     {
         WindowComposition.Disable(this);
     }
     this.ChangeProperties(
         ImmersiveColor.GetColorByTypeName(ImmersiveColorNames.ApplicationBackground),
         ImmersiveColor.GetColorByTypeName(ImmersiveColorNames.SystemText),
         SystemColors.WindowFrameColor,
         this.GetBordersFlagAsThickness(2));
 }
示例#9
0
        private WindowComposition GetCurrentComposition()
        {
            var result = new WindowComposition();

            RECT rect;

            PInvoke.GetWindowRect(hwnd, out rect);

            result.PositionX = rect.left;
            result.Width     = rect.right - rect.left;
            result.PositionY = rect.top;
            result.Height    = rect.bottom - rect.top;

            result.SetWindowStyle((uint)PInvoke.GetWindowLong(hwnd, Constants.GWL_STYLE));
            result.SetExtendedWindowStyle((uint)PInvoke.GetWindowLong(hwnd, Constants.GWL_EXSTYLE));

            return(result);
        }
示例#10
0
        private async void SetCurrentComposition(WindowComposition windowComposition)
        {
            await Task.Delay(windowComposition.DelayMilliseconds);

            if (processName == "mstsc")
            {
                uint uFlags = Constants.SWP_NOSIZE | Constants.SWP_NOMOVE | Constants.SWP_NOZORDER | Constants.SWP_NOACTIVATE | Constants.SWP_NOOWNERZORDER | Constants.SWP_NOSENDCHANGING | Constants.SWP_FRAMECHANGED;

                PInvoke.SetWindowLong(hwnd, Constants.GWL_STYLE, (int)Constants.WS_VISIBLE | (int)Constants.WS_THICKFRAME);
                PInvoke.SetWindowPos(hwnd, new HWND(0), windowComposition.PositionX, windowComposition.PositionY, windowComposition.Width, windowComposition.Height, uFlags);
                PInvoke.SendMessage(hwnd, Constants.WM_EXITSIZEMOVE, new WPARAM(0), new LPARAM(0));

                PInvoke.SetWindowLong(hwnd, Constants.GWL_STYLE, (int)windowComposition.GetWindowStyle());
                PInvoke.SetWindowPos(hwnd, new HWND(0), windowComposition.PositionX, windowComposition.PositionY, windowComposition.Width, windowComposition.Height, uFlags);
                PInvoke.SendMessage(hwnd, Constants.WM_EXITSIZEMOVE, new WPARAM(0), new LPARAM(0));

                PInvoke.MoveWindow(hwnd, windowComposition.PositionX, windowComposition.PositionY, windowComposition.Width, windowComposition.Height, true);
            }
            else
            {
                if (windowComposition.HasWindowStyle)
                {
                    PInvoke.SetWindowLong(hwnd, Constants.GWL_STYLE, (int)windowComposition.GetWindowStyle());
                }

                if (windowComposition.HasExtendedWindowStyle)
                {
                    PInvoke.SetWindowLong(hwnd, Constants.GWL_EXSTYLE, (int)windowComposition.GetExtendedWindowStyle());
                }

                PInvoke.MoveWindow(hwnd, windowComposition.PositionX, windowComposition.PositionY, windowComposition.Width, windowComposition.Height, true);
                PInvoke.SendMessage(hwnd, Constants.WM_EXITSIZEMOVE, new WPARAM(0), new LPARAM(0));
            }

            // attempt at persona 4 workaround

            /*
             * unsafe
             * {
             *  RECT newSize = new RECT();
             *  newSize.left = windowComposition.PositionX;
             *  newSize.right = windowComposition.PositionX + windowComposition.Width;
             *  newSize.top = windowComposition.PositionY;
             *  newSize.bottom = windowComposition.PositionY + windowComposition.Height;
             *
             *  nint newDim = 0;
             *  newDim = (newDim & 0xFFFF0000) + (windowComposition.Width & 0x0000FFFF);
             *  newDim = (newDim & 0x0000FFFF) + (windowComposition.Height << 16);
             *
             *  PInvoke.SendMessage(hwnd, Constants.WM_ENTERSIZEMOVE, new WPARAM(0), new LPARAM(0));
             *  PInvoke.SendMessage(hwnd, Constants.WM_SIZING, new WPARAM(8), new LPARAM((int)&newSize));
             *
             *  PInvoke.MoveWindow(hwnd, windowComposition.PositionX, windowComposition.PositionY, windowComposition.Width, windowComposition.Height, true);
             *
             *  PInvoke.SetWindowLong(hwnd, Constants.GWL_STYLE, windowComposition.GetWindowStyle());
             *  PInvoke.SetWindowLong(hwnd, Constants.GWL_EXSTYLE, windowComposition.GetExtendedWindowStyle());
             *
             *  PInvoke.SendMessage(hwnd, Constants.WM_SIZE, new WPARAM(0), new LPARAM(newDim));
             *  PInvoke.SendMessage(hwnd, Constants.WM_EXITSIZEMOVE, new WPARAM(0), new LPARAM(0));
             * }
             */
        }
示例#11
0
 public void RevertWindowComposition()
 {
     SetCurrentComposition(originalComposition);
     appliedComposition = null;
 }
示例#12
0
 public override void Enable_Fluent_Design_System_Style_Blur(IntPtr hWnd)
 {
     WindowComposition.Set(hWnd, AccentState.ACCENT_ENABLE_BLURBEHIND, AccentFlags.DrawAllBorders);
 }