Ejemplo n.º 1
0
        private void ToggleBlur(bool? state)
        {
            var accent = new AccentPolicy();
            state = (state == null) ? DEFAULT_BLUR : Convert.ToBoolean(state);

            if ((bool)state)
            {
                accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
            }
            else
            {
                accent.AccentState = AccentState.ACCENT_DISABLED;
            }

            var accentStructSize = Marshal.SizeOf(accent);
            var accentPtr = Marshal.AllocHGlobal(accentStructSize);
            Marshal.StructureToPtr(accent, accentPtr, false);

            var data = new WindowCompositionAttributeData();
            data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY;
            data.SizeOfData = accentStructSize;
            data.Data = accentPtr;

            SetWindowCompositionAttribute(Helper.Handle, ref data);

            Marshal.FreeHGlobal(accentPtr);
        }
Ejemplo n.º 2
0
        internal void EnableBlur()
        {
            var windowHelper = new WindowInteropHelper(this);

            var accent = new AccentPolicy();
            var accentStructSize = Marshal.SizeOf(accent);
            accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;

            var accentPtr = Marshal.AllocHGlobal(accentStructSize);
            Marshal.StructureToPtr(accent, accentPtr, false);

            var data = new WindowCompositionAttributeData();
            data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY;
            data.SizeOfData = accentStructSize;
            data.Data = accentPtr;

            SetWindowCompositionAttribute(windowHelper.Handle, ref data);

            Marshal.FreeHGlobal(accentPtr);
        }
Ejemplo n.º 3
0
 internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
Ejemplo n.º 4
0
Archivo: Theme.cs Proyecto: WELL-E/Wox
        private void SetWindowAccent(Window wind, AccentState themeAccentMode)
        {
            var windowHelper = new WindowInteropHelper(wind);
            var accent = new AccentPolicy { AccentState = themeAccentMode };
            var accentStructSize = Marshal.SizeOf(accent);

            var accentPtr = Marshal.AllocHGlobal(accentStructSize);
            Marshal.StructureToPtr(accent, accentPtr, false);

            var data = new WindowCompositionAttributeData
            {
                Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
                SizeOfData = accentStructSize,
                Data = accentPtr
            };

            SetWindowCompositionAttribute(windowHelper.Handle, ref data);

            Marshal.FreeHGlobal(accentPtr);
        }
Ejemplo n.º 5
0
 private static extern int SetWindowCompositionAttribute(IntPtr hWnd, ref WindowCompositionAttributeData data);
Ejemplo n.º 6
0
 public static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
Ejemplo n.º 7
0
 private static extern bool SetWindowCompositionAttribute(
     IntPtr hwnd,
     ref WindowCompositionAttributeData data);
Ejemplo n.º 8
0
        /// <summary>
        ///     Too complicated to explain, so no comments
        /// </summary>
        /// <param name="taskbars"></param>
        /// <param name="taskbarState"></param>
        internal static void SetBarState(this List <Taskbar> taskbars, TaskbarState taskbarState)
        {
            if (taskbarState.HideTaskbarCompletely)
            {
                AutoHide.SetAutoHide(true);
                foreach (var taskbar in taskbars)
                {
                    ShowWindow(taskbar.Handle, SwHide);
                }
            }
            else
            {
                if (taskbarState.TransparentMode == TransparentModeType.Disabled)
                {
                    ButtonSize.SetIconSize(taskbarState.IconSize);
                    AutoHide.SetAutoHide(taskbarState.IsAutoHide);

                    foreach (var taskbar in taskbars)
                    {
                        ShowWindow(taskbar.Handle, SwShow);
                    }

                    if (_accentPtr == IntPtr.Zero)
                    {
                        return;
                    }

                    PostMessage(IntPtr.Zero, WmThemechanged, IntPtr.Zero, IntPtr.Zero);
                    Marshal.FreeHGlobal(_accentPtr);
                    _accentPtr = IntPtr.Zero;
                }
                else
                {
                    if (_accentPtr == IntPtr.Zero)
                    {
                        var size = Marshal.SizeOf(typeof(AccentPolicy));
                        _accentPtr = Marshal.AllocHGlobal(size);
                        _data      = new WindowCompositionAttributeData
                        {
                            Attribute  = 19,
                            SizeOfData = size,
                            Data       = _accentPtr
                        };
                    }

                    AccentPolicy accent;
                    switch (taskbarState.TransparentMode)
                    {
                    case TransparentModeType.Transparent:
                        accent = new AccentPolicy
                        {
                            AccentState = 3,
                            AccentFlags = 1
                        };
                        break;

                    case TransparentModeType.Blur:
                        accent = new AccentPolicy
                        {
                            AccentState   = 2,
                            AccentFlags   = 2,
                            GradientColor = 0
                        };
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    Marshal.StructureToPtr(accent, _accentPtr, false);

                    ButtonSize.SetIconSize(taskbarState.IconSize);
                    AutoHide.SetAutoHide(taskbarState.IsAutoHide);
                    foreach (var taskbar in taskbars)
                    {
                        SetWindowCompositionAttribute(taskbar.Handle, ref _data);

                        ShowWindow(taskbar.Handle, SwShow);
                    }
                }
            }
        }
Ejemplo n.º 9
0
 internal static extern IntPtr SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);