internal static void StaticEnableBlur(System.Windows.Window win, uint accentColor = 0x00FFFFFF) { var windowHelper = new WindowInteropHelper(win); AcrylicHelper.EnableBlur(windowHelper.Handle, accentColor); win.CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (_, __) => { SystemCommands.CloseWindow(win); })); win.CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, (_, __) => { SystemCommands.MinimizeWindow(win); })); win.CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, (_, __) => { SystemCommands.MaximizeWindow(win); })); win.CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, (_, __) => { SystemCommands.RestoreWindow(win); })); void ContentRendered(object?sender, EventArgs e) { if (win.SizeToContent != SizeToContent.Manual) { win.InvalidateMeasure(); } win.ContentRendered -= ContentRendered; } win.ContentRendered += ContentRendered; }
internal static void EnableBlur(Window win) { var windowHelper = new WindowInteropHelper(win); // ウィンドウに半透明のアクリル効果を適用する AcrylicHelper.EnableBlur(windowHelper.Handle); // タイトルバーの各種ボタンで利用するコマンドの設定 win.CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (_, __) => { SystemCommands.CloseWindow(win); })); win.CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, (_, __) => { SystemCommands.MinimizeWindow(win); })); win.CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, (_, __) => { SystemCommands.MaximizeWindow(win); })); win.CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, (_, __) => { SystemCommands.RestoreWindow(win); })); // WPFのSizeToContentのバグ対策 // (WindowChrome使用時に、SizeToContentのウィンドウサイズ計算が正しく行われない) void onContentRendered(object sender, EventArgs e) { if (win.SizeToContent != SizeToContent.Manual) { win.InvalidateMeasure(); } win.ContentRendered -= onContentRendered; } win.ContentRendered += onContentRendered; }
protected override void OnOpened(RoutedEventArgs e) { base.OnOpened(e); var hwnd = (HwndSource)HwndSource.FromVisual(this); AcrylicHelper.EnableBlur(hwnd.Handle, AccentFlagsType.Popup); }
protected override void OnActivated(EventArgs e) { base.OnActivated(e); //Background = (SolidColorBrush)App.Current.Resources["BlurWindowBackgroundBrush"]; var ptr = new WindowInteropHelper(this).Handle; AcrylicHelper.EnableBlur(ptr); }
protected override void OnOpened(EventArgs e) { base.OnOpened(e); var hwnd = (HwndSource)HwndSource.FromVisual(this.Child); AcrylicHelper.EnableBlur(hwnd.Handle); }
protected override void OnOpened(EventArgs e) { base.OnOpened(e); var accent = (Color)GetValue(AcrylicElement.AccentColorProperty); var accentColor = (uint)(accent.A << 24 | accent.R << 18 | accent.G << 12 | accent.B); var hwnd = ((HwndSource)PresentationSource.FromVisual(Child)) !; AcrylicHelper.EnableBlur(hwnd.Handle, accentColor, AccentFlagsType.Popup); }
internal static void EnableBlur(Window win) { var windowHelper = new WindowInteropHelper(win); // ウィンドウに半透明のアクリル効果を適用する AcrylicHelper.EnableBlur(windowHelper.Handle); // タイトルバーの各種ボタンで利用するコマンドの設定 win.CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (_, __) => { SystemCommands.CloseWindow(win); })); win.CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, (_, __) => { SystemCommands.MinimizeWindow(win); })); win.CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, (_, __) => { SystemCommands.MaximizeWindow(win); })); win.CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, (_, __) => { SystemCommands.RestoreWindow(win); })); }
internal static void EnableBlur(Window win) { var windowHelper = new WindowInteropHelper(win); AcrylicHelper.EnableBlur(windowHelper.Handle); // WPF WindowChrome bug with SizeToContent workaround void OnContentRendered(object sender, EventArgs e) { if (win.SizeToContent != SizeToContent.Manual) { win.InvalidateMeasure(); } win.ContentRendered -= OnContentRendered; } win.ContentRendered += OnContentRendered; }
private void BlurSubMenu() { var firstSubItem = ItemContainerGenerator.ContainerFromIndex(0); if (firstSubItem == null) { return; } var container = VisualTreeHelper.GetParent(firstSubItem) as Visual; if (container == null) { return; } DependencyObject parent = container; int borderIndex = 0; while (parent != null) { if (parent is Border b) { // only put color on the first border (transparent colors will add up otherwise) if (borderIndex == 0) { b.Background = new SolidColorBrush(Color.FromArgb(80, 0, 0, 0)); } else { b.Background = Brushes.Transparent; } borderIndex++; } parent = VisualTreeHelper.GetParent(parent); } AcrylicHelper.EnableBlur(container); }
public void SetWindowBlur(IntPtr hWnd) { AcrylicHelper.EnableBlur(hWnd); }
protected override void OnOpened(RoutedEventArgs e) { base.OnOpened(e); AcrylicHelper.EnableBlur(this); }