public MainWindow() { InitializeComponent(); CommandBindings.Add(new CommandBinding(ApplicationCommands.New, OpenNewTab)); Maximized = false; if (Maximized) { WindowState = WindowState.Maximized; } else { WindowState = WindowState.Normal; } CheckForUpdates(); Loaded += MainWindow_Loaded; Pages = new List<TabView>(); Downloads1.Height = 0; WindowChrome wc = new WindowChrome(); WindowChrome.SetWindowChrome(this, wc); wc.CaptionHeight = 0; wc.UseAeroCaptionButtons = false; }
public ShellView() { WindowChrome chrome = new WindowChrome { ResizeBorderThickness = new Thickness(10), CaptionHeight = 1.0 }; WindowChrome.SetWindowChrome(this, chrome); }
public static void SetWindowChrome(Window w, WindowChrome wc = null) { if (wc == null) { wc = new WindowChrome(); wc.CaptionHeight = 0; wc.GlassFrameThickness = new Thickness(7); wc.CornerRadius = new CornerRadius(0); wc.UseAeroCaptionButtons = true; wc.ResizeBorderThickness = new Thickness(6); } WindowChrome.SetWindowChrome(w, wc); }
public BorderlessWindow() { windowChrome = new WindowChrome(); WindowChrome.SetWindowChrome(this, windowChrome); windowChrome.GlassFrameThickness = new Thickness(1); windowChrome.CornerRadius = new CornerRadius(0); windowChrome.CaptionHeight = 0; Loaded += Window_Loaded; // for systems below Windows 8 var osversion = Environment.OSVersion.Version; if (osversion.Major == 6 && osversion.Minor < 2) { Activated += Window_Activated; Deactivated += Window_Deactivated; } }
internal UserInputDialog() { _userInputControl = new UserInputControl(); MinWidth = _userInputControl.MinWidth; MinHeight = _userInputControl.MinHeight; Width = _userInputControl.Width; Height = _userInputControl.Height; WindowStartupLocation = WindowStartupLocation.CenterScreen; Content = _userInputControl.Content; _userInputControl.CloseButton.Click += CloseDialog; _userInputControl.BackButton.Click += CloseDialog; _userInputControl.CreateButton.Click += SetCustomParametersAndCloseDialog; WindowStyle = WindowStyle.None; WindowChrome.SetWindowChrome(this, new WindowChrome { CaptionHeight = 32, ResizeBorderThickness = SystemParameters.WindowResizeBorderThickness }); Background = ToBrush(EnvironmentColors.ToolboxBackgroundColorKey); }
private static void SetCaptionHeight(WindowX windowX, double height) { var action = new Action(() => { var chrome = WindowChrome.GetWindowChrome(windowX); if (chrome == null) { return; } chrome.CaptionHeight = height; }); if (windowX.IsLoaded) { action(); } else { windowX.Loaded += delegate { action(); }; } }
private void Cleanup() { if (!isCleanedUp) { isCleanedUp = true; // clean up events if (AssociatedObject is MetroWindow) { System.ComponentModel.DependencyPropertyDescriptor.FromProperty(MetroWindow.IgnoreTaskbarOnMaximizeProperty, typeof(MetroWindow)) .RemoveValueChanged(AssociatedObject, IgnoreTaskbarOnMaximizePropertyChangedCallback); } AssociatedObject.Loaded -= AssociatedObject_Loaded; AssociatedObject.Unloaded -= AssociatedObject_Unloaded; AssociatedObject.SourceInitialized -= AssociatedObject_SourceInitialized; AssociatedObject.StateChanged -= AssociatedObject_StateChanged; AssociatedObject.Activated -= AssociatedObject_Activated; if (hwndSource != null) { hwndSource.RemoveHook(WindowProc); } windowChrome = null; } }
private void OnSizeChanged(object sender, SizeChangedEventArgs e) { if (WindowState == WindowState.Maximized) { var hMonitor = MonitorFromWindow(Hwnd, MonitorDwFlags.MONITOR_DEFAULTTONULL); MONITORINFO mi; unsafe { mi = new MONITORINFO() { cbSize = ( uint )sizeof(MONITORINFO) }; } if (GetMonitorInfoA(hMonitor, ref mi)) { Thickness t = new Thickness(0); if (ActualWidth > mi.rcMonitor.left) { t.Left = t.Right = (ActualWidth - (mi.rcMonitor.right - mi.rcMonitor.left)) / 2; } if (ActualHeight > mi.rcMonitor.bottom) { t.Top = t.Bottom = (ActualHeight - (mi.rcMonitor.bottom - mi.rcMonitor.top)) / 2; } WindowBorder.Padding = t; } } else { WindowBorder.Padding = WindowChrome.GetWindowChrome(this).ResizeBorderThickness; } }
private void Initialize() { _chrome = new WindowChrome { //CaptionHeight = SystemParameters.WindowCaptionHeight, CaptionHeight = 30, CornerRadius = new CornerRadius(0d), GlassFrameThickness = new Thickness(0d), NonClientFrameEdges = NonClientFrameEdges.None, ResizeBorderThickness = new Thickness(3), UseAeroCaptionButtons = false }; if (_chrome.CanFreeze) { _chrome.Freeze(); } if (WindowChrome.GetWindowChrome(this) == null) { WindowChrome.SetWindowChrome(this, _chrome); } Initialized += OnInitializedInternal; Loaded += OnLoadedInternal; }
protected override IntPtr FilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg != 161) { if (msg == 165) { if (wParam.ToInt32() == 2) { if (this.OpenContextMenu()) { handled = true; } if (!this._model.Root.Manager.ShowSystemMenu) { WindowChrome.GetWindowChrome(this).ShowSystemMenu = false; } else { WindowChrome.GetWindowChrome(this).ShowSystemMenu = !handled; } } } } else if (wParam.ToInt32() == 2) { this._model.Descendents().OfType <LayoutAnchorablePane>().First <LayoutAnchorablePane>((LayoutAnchorablePane p) => { if (p.ChildrenCount <= 0) { return(false); } return(p.SelectedContent != null); }).SelectedContent.IsActive = true; handled = true; } return(base.FilterMessage(hwnd, msg, wParam, lParam, ref handled)); }
protected override void OnAttached() { this.isWindwos10OrHigher = IsWindows10OrHigher(); this.windowChrome = new WindowChrome { #if NET4_5 ResizeBorderThickness = SystemParameters.WindowResizeBorderThickness, #else ResizeBorderThickness = SystemParameters2.Current.WindowResizeBorderThickness, #endif CaptionHeight = 10, CornerRadius = new CornerRadius(0), GlassFrameThickness = new Thickness(0), IgnoreTaskbarOnMaximize = false, UseAeroCaptionButtons = false, }; var window = this.AssociatedObject as WindowWithDialogs; if (window != null) { this.windowChrome.IgnoreTaskbarOnMaximize = window.IgnoreTaskbarOnMaximize; this.windowChrome.UseNoneWindowStyle = window.UseNoneWindowStyle; System.ComponentModel.DependencyPropertyDescriptor.FromProperty(WindowWithDialogs.IgnoreTaskbarOnMaximizeProperty, typeof(WindowWithDialogs)) .AddValueChanged(this.AssociatedObject, this.IgnoreTaskbarOnMaximizePropertyChangedCallback); System.ComponentModel.DependencyPropertyDescriptor.FromProperty(WindowWithDialogs.UseNoneWindowStyleProperty, typeof(WindowWithDialogs)) .AddValueChanged(this.AssociatedObject, this.UseNoneWindowStylePropertyChangedCallback); } this.AssociatedObject.SetValue(WindowChrome.WindowChromeProperty, this.windowChrome); // no transparency, because it hase more then one unwanted issues var windowHandle = new WindowInteropHelper(this.AssociatedObject).Handle; if (!this.AssociatedObject.IsLoaded && windowHandle == IntPtr.Zero) { try { this.AssociatedObject.AllowsTransparency = false; } catch (Exception) { // For some reason, we can't determine if the window has loaded or not, so we swallow the exception. } } this.AssociatedObject.WindowStyle = WindowStyle.None; this.savedBorderThickness = this.AssociatedObject.BorderThickness; this.savedResizeBorderThickness = this.windowChrome.ResizeBorderThickness; this.borderThicknessChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Control.BorderThicknessProperty); this.borderThicknessChangeNotifier.ValueChanged += this.BorderThicknessChangeNotifierOnValueChanged; this.savedTopMost = this.AssociatedObject.Topmost; this.topMostChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.TopmostProperty); this.topMostChangeNotifier.ValueChanged += this.TopMostChangeNotifierOnValueChanged; // #1823 try to fix another nasty issue // WindowState = Maximized // ResizeMode = NoResize if (this.AssociatedObject.ResizeMode == ResizeMode.NoResize) { this.windowChrome.ResizeBorderThickness = new Thickness(0); } var topmostHack = new Action(() => { if (this.AssociatedObject.Topmost) { var raiseValueChanged = this.topMostChangeNotifier.RaiseValueChanged; this.topMostChangeNotifier.RaiseValueChanged = false; this.AssociatedObject.Topmost = false; this.AssociatedObject.Topmost = true; this.topMostChangeNotifier.RaiseValueChanged = raiseValueChanged; } }); this.AssociatedObject.LostFocus += (sender, args) => { topmostHack(); }; this.AssociatedObject.Deactivated += (sender, args) => { topmostHack(); }; this.AssociatedObject.Loaded += this.AssociatedObject_Loaded; this.AssociatedObject.Unloaded += this.AssociatedObject_Unloaded; this.AssociatedObject.Closed += this.AssociatedObjectClosed; this.AssociatedObject.SourceInitialized += this.AssociatedObject_SourceInitialized; this.AssociatedObject.StateChanged += this.OnAssociatedObjectHandleMaximize; base.OnAttached(); }
void InitializeWindowCaptionAndResizeBorder(WindowChrome wc, bool useResizeBorder) { var scale = SafeWpfPixelScaleFactor; if (useResizeBorder) { wc.CaptionHeight = CaptionHeight * scale; wc.ResizeBorderThickness = new Thickness( ResizeBorderThickness.Left * scale, ResizeBorderThickness.Top * scale, ResizeBorderThickness.Right * scale, ResizeBorderThickness.Bottom * scale); } else { if (IsFullScreen) wc.CaptionHeight = 0d; else wc.CaptionHeight = GridCaptionHeight.Value * scale; wc.ResizeBorderThickness = new Thickness(0); } }
WindowChrome CreateWindowChromeObject() { var wc = new WindowChrome { CornerRadius = CornerRadius, GlassFrameThickness = GlassFrameThickness, NonClientFrameEdges = NonClientFrameEdges.None, }; InitializeWindowCaptionAndResizeBorder(wc); return wc; }
private void UpdateResizeBorderThickness() { if (this.chromeField != null) { WindowChrome chrome = (WindowChrome)this.chromeField.GetValue(this); if (this.WindowState == WindowState.Maximized) { chrome = new WindowChrome { CaptionHeight = chrome.CaptionHeight, CornerRadius = chrome.CornerRadius, GlassFrameThickness = chrome.GlassFrameThickness, NonClientFrameEdges = chrome.NonClientFrameEdges, ResizeBorderThickness = new Thickness(0D), UseAeroCaptionButtons = chrome.UseAeroCaptionButtons }; } else { chrome = new WindowChrome { CaptionHeight = chrome.CaptionHeight, CornerRadius = chrome.CornerRadius, GlassFrameThickness = chrome.GlassFrameThickness, NonClientFrameEdges = chrome.NonClientFrameEdges, ResizeBorderThickness = new Thickness( this.Margin.Left < 3D ? 3D : this.Margin.Left, this.Margin.Top < 3D ? 3D : this.Margin.Top, this.Margin.Right < 3D ? 3D : this.Margin.Right, this.Margin.Bottom < 3D ? 3D : this.Margin.Bottom), UseAeroCaptionButtons = chrome.UseAeroCaptionButtons }; } chrome.Freeze(); WindowChrome.SetWindowChrome(this, chrome); } }
/// <summary> /// Default constructor /// </summary> public RibbonWindow() { this.windowChrome = new WindowChrome(this); this.SizeChanged += this.OnSizeChanged; }
private void EnableCustomChromeHitTest() { WindowChrome.SetIsHitTestVisibleInChrome(this, true); }
private void OnLoaded(object sender, RoutedEventArgs e) { WindowChrome.GetWindowChrome(this).CaptionHeight = 55; }
/// <summary> /// Manages layout of Window components. /// </summary> protected void ManageLayout(DpiScale dpi = default) { if (!dpi.Equals(default(DpiScale))) { WindowDpi = dpi; } else if (WindowDpi.Equals(default(DpiScale))) { WindowDpi = VisualTreeHelper.GetDpi(this); } var factorFromDefaultX = WindowDpi.DpiScaleX; var factorFromDefaultY = WindowDpi.DpiScaleY; var factorFromSystemX = WindowDpi.DpiScaleX / SystemDpi.DpiScaleX; var factorFromSystemY = WindowDpi.DpiScaleY / SystemDpi.DpiScaleY; var captionHeight = 0D; // Manage chrome border. if (this.WindowState == WindowState.Maximized) { if (ChromeOutmostBorder != null) { ChromeOutmostBorder.BorderThickness = new Thickness( SystemParameters.WindowResizeBorderThickness.Left + SystemParameters.WindowNonClientFrameThickness.Left, SystemParameters.WindowResizeBorderThickness.Left + SystemParameters.WindowNonClientFrameThickness.Left, // Use Left values. SystemParameters.WindowResizeBorderThickness.Right + SystemParameters.WindowNonClientFrameThickness.Right, SystemParameters.WindowResizeBorderThickness.Bottom + SystemParameters.WindowNonClientFrameThickness.Bottom); captionHeight += ChromeOutmostBorder.BorderThickness.Top; } if (ChromeBorder != null) { ChromeBorder.BorderThickness = new Thickness(0D); } } else { if (ChromeOutmostBorder != null) { ChromeOutmostBorder.BorderThickness = new Thickness(0D); captionHeight += ChromeBorderThickness.Top; } if (ChromeBorder != null) { ChromeBorder.BorderThickness = new Thickness( ChromeBorderThickness.Left / factorFromDefaultX, ChromeBorderThickness.Top / factorFromDefaultY, ChromeBorderThickness.Right / factorFromDefaultX, ChromeBorderThickness.Bottom / factorFromDefaultY); } } // Manage title bar and content border. if ((this.WindowState == WindowState.Maximized) && !KeepsTitleContentMargin) { if (TitleBarGrid != null) { TitleBarGrid.Height = TitleBarMaximizedHeight.ToRounded(factorFromDefaultY); TitleBarPaddingLeft = 0D; } if (WindowContentBorder != null) { WindowContentBorder.Margin = new Thickness(0D); WindowContentBorder.BorderThickness = new Thickness( 0D, ContentBorderThickness.Top / factorFromDefaultY, 0D, 0D); } } else { if (TitleBarGrid != null) { TitleBarGrid.Height = TitleBarNormalHeight.ToRounded(factorFromDefaultY); TitleBarPaddingLeft = Math.Ceiling(Math.Max(TitleBarGrid.Height - IconSize.Height, 0D) / 2).ToRounded(factorFromDefaultX); } if (WindowContentBorder != null) { WindowContentBorder.Margin = new Thickness( ContentMargin.Left.ToRounded(factorFromDefaultX), ContentMargin.Top.ToRounded(factorFromDefaultY), ContentMargin.Right.ToRounded(factorFromDefaultX), ContentMargin.Bottom.ToRounded(factorFromDefaultY)); WindowContentBorder.BorderThickness = new Thickness( ContentBorderThickness.Left / factorFromDefaultX, ContentBorderThickness.Top / factorFromDefaultY, ContentBorderThickness.Right / factorFromDefaultX, ContentBorderThickness.Bottom / factorFromDefaultY); } } // Set caption height for WindowChrome.CaptionHeight. if (TitleBarGrid != null) { captionHeight += Math.Round((TitleBarGrid.Height + ContentBorderThickness.Top) * factorFromSystemY); } var windowChrome = WindowChrome.GetWindowChrome(this); if (windowChrome != null) { windowChrome.CaptionHeight = Math.Max(captionHeight - SystemParameters.WindowResizeBorderThickness.Top, 0D); } }
private void CaptionHeightChanged(object sender, EventArgs e) { WindowChrome.GetWindowChrome(this).CaptionHeight = this.CaptionHeight; }
private void OnIsExpandedPropertyChanged() { if (IsExpanded) { Height = TargetHeight; Width = TargetWidth; switch (ExpandDirection) { case System.Windows.Controls.ExpandDirection.Up: { Left -= TargetWidth / 2 - ButtonsStackPanel.ActualWidth / 2; if (Left < 0) { Left = 0; } if (Left + TargetWidth > SystemParameters.PrimaryScreenWidth) { Left = SystemParameters.PrimaryScreenWidth - TargetWidth; } Top = SystemParameters.PrimaryScreenHeight - TargetHeight; var windowChrome = WindowChrome.GetWindowChrome(this); windowChrome.ResizeBorderThickness = new Thickness(5, 5, 5, 0); break; } case System.Windows.Controls.ExpandDirection.Down: { Left -= TargetWidth / 2 - ButtonsStackPanel.ActualWidth / 2; if (Left < 0) { Left = 0; } if (Left + TargetWidth > SystemParameters.PrimaryScreenWidth) { Left = SystemParameters.PrimaryScreenWidth - TargetWidth; } var windowChrome = WindowChrome.GetWindowChrome(this); windowChrome.ResizeBorderThickness = new Thickness(5, 0, 5, 5); break; } case System.Windows.Controls.ExpandDirection.Left: { Top -= TargetHeight / 2 - ButtonsStackPanel.ActualHeight / 2; if (Top < 0) { Top = 0; } if (Top + TargetHeight > SystemParameters.PrimaryScreenHeight) { Top = SystemParameters.PrimaryScreenHeight - TargetHeight; } Left = SystemParameters.PrimaryScreenWidth - TargetWidth; var windowChrome = WindowChrome.GetWindowChrome(this); windowChrome.ResizeBorderThickness = new Thickness(5, 5, 0, 5); break; } case System.Windows.Controls.ExpandDirection.Right: { Top -= TargetHeight / 2 - ButtonsStackPanel.ActualHeight / 2; if (Top < 0) { Top = 0; } if (Top + TargetHeight > SystemParameters.PrimaryScreenHeight) { Top = SystemParameters.PrimaryScreenHeight - TargetHeight; } var windowChrome = WindowChrome.GetWindowChrome(this); windowChrome.ResizeBorderThickness = new Thickness(0, 5, 5, 5); break; } } Background = (Brush)TryFindResource("ControlBackground"); ContentPresenterBorder.Visibility = Visibility.Visible; ContentPresenter.Visibility = Visibility.Visible; CloseButton.Visibility = Visibility.Visible; } else { Height = ButtonsStackPanel.ActualHeight; Width = ButtonsStackPanel.ActualWidth; switch (ExpandDirection) { case System.Windows.Controls.ExpandDirection.Up: { Left += TargetWidth / 2 - ButtonsStackPanel.ActualWidth / 2; if (Left < 0) { Left = 0; } if (Left + TargetWidth > SystemParameters.PrimaryScreenWidth) { Left = SystemParameters.PrimaryScreenWidth - TargetWidth; } Top = SystemParameters.PrimaryScreenHeight - ButtonsStackPanel.ActualHeight; break; } case System.Windows.Controls.ExpandDirection.Down: { Left += TargetWidth / 2 - ButtonsStackPanel.ActualWidth / 2; if (Left < 0) { Left = 0; } if (Left + TargetWidth > SystemParameters.PrimaryScreenWidth) { Left = SystemParameters.PrimaryScreenWidth - TargetWidth; } break; } case System.Windows.Controls.ExpandDirection.Left: { Top += TargetHeight / 2 - ButtonsStackPanel.ActualHeight / 2; if (Top < 0) { Top = 0; } if (Top + TargetHeight > SystemParameters.PrimaryScreenHeight) { Top = SystemParameters.PrimaryScreenHeight - TargetHeight; } Left = SystemParameters.PrimaryScreenWidth - ButtonsStackPanel.ActualWidth; break; } case System.Windows.Controls.ExpandDirection.Right: { Top += TargetHeight / 2 - ButtonsStackPanel.ActualHeight / 2; if (Top < 0) { Top = 0; } if (Top + TargetHeight > SystemParameters.PrimaryScreenHeight) { Top = SystemParameters.PrimaryScreenHeight - TargetHeight; } break; } } Background = Brushes.Transparent; ContentPresenterBorder.Visibility = Visibility.Collapsed; ContentPresenter.Visibility = Visibility.Collapsed; CloseButton.Visibility = Visibility.Collapsed; var windowChrome = WindowChrome.GetWindowChrome(this); windowChrome.ResizeBorderThickness = new Thickness(0); } }
void Initialize() { Window_Border = new Border(); this.Content = Window_Border; Window_Border.BorderThickness = new Thickness(1); Window_Border.Background = new SolidColorBrush(Color.FromRgb(56, 56, 56)); Window_Border.ClipToBounds = true; Window_Border.Child = Window_Grid; DarkenOverlay.Background = Brushes.Black; DarkenOverlay.Opacity = 0; DarkenOverlay.Visibility = System.Windows.Visibility.Collapsed; DarkenOverlay.BorderThickness = new Thickness(0); DarkenOverlay.IsHitTestVisible = false; Window_Grid.Children.Add(Window_TitleGrid); Window_Content_Grid.Children.Add(ContentPlaceHolder); Window_Grid.Children.Add(Window_Content_Grid); Window_Grid.Children.Add(DarkenOverlay); #region TITLE_BAR Window_TitleGrid.ClipToBounds = true; Window_TitleGrid.Height = TITLE_BAR_HEIGHT; Window_TitleGrid.VerticalAlignment = System.Windows.VerticalAlignment.Top; Window_TitleGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; Window_TitleGrid.Children.Add(TitleIcon); Window_TitleGrid.Children.Add(Window_TitleLabel); Window_TitleGrid.Children.Add(Window_Button_Close); Window_TitleGrid.Children.Add(Window_Button_Maximize); Window_TitleGrid.Children.Add(Window_Button_Minimize); Window_TitleLabel.VerticalAlignment = System.Windows.VerticalAlignment.Top; Window_TitleLabel.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; Window_TitleLabel.Height = TITLE_BAR_HEIGHT - 2; Window_TitleLabel.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; Window_TitleLabel.Margin = new Thickness(30, 0, 140, 0); Window_TitleLabel.Foreground = Brushes.White; Window_Button_Close.MouseEnter += Window_Button_MouseEnter; Window_Button_Close.MouseLeave += Window_Button_MouseLeave; Window_Button_Close.Click += Window_Close; Window_Button_Close.Content = 'r'; Window_Button_Close.FontFamily = new System.Windows.Media.FontFamily("Webdings"); Window_Button_Close.FontSize = 11; Window_Button_Close.Height = 19; Window_Button_Close.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Window_Button_Close.VerticalAlignment = System.Windows.VerticalAlignment.Top; Window_Button_Close.Padding = new Thickness(0, -CHROME_BUTTON_TOP_MARGIN - 1, 0, 0); Window_Button_Close.Foreground = Brushes.Black; Window_Button_Close.BorderThickness = new Thickness(1); Window_Button_Close.FontWeight = FontWeights.Bold; Window_Button_Close.Width = X_BUTTON_NORMAL_WIDTH; Window_Button_Close.Margin = new Thickness(0, CHROME_BUTTON_TOP_MARGIN, 5, 0); Window_Button_Close.Focusable = false; WindowChrome.SetIsHitTestVisibleInChrome(Window_Button_Close, true); Window_Button_Maximize.MouseEnter += Window_Button_MouseEnter; Window_Button_Maximize.MouseLeave += Window_Button_MouseLeave; Window_Button_Maximize.Click += Window_MaximizeRestore; Window_Button_Maximize.Content = '1'; Window_Button_Maximize.FontFamily = new System.Windows.Media.FontFamily("Webdings"); Window_Button_Maximize.FontSize = 11; Window_Button_Maximize.Height = 19; Window_Button_Maximize.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Window_Button_Maximize.VerticalAlignment = System.Windows.VerticalAlignment.Top; Window_Button_Maximize.Padding = new Thickness(0, -CHROME_BUTTON_TOP_MARGIN - 1, 0, 0); Window_Button_Maximize.Foreground = Brushes.Black; Window_Button_Maximize.BorderThickness = new Thickness(1); Window_Button_Maximize.FontWeight = FontWeights.Bold; Window_Button_Maximize.Width = 30; Window_Button_Maximize.Margin = new Thickness(0, CHROME_BUTTON_TOP_MARGIN, 52, 0); Window_Button_Maximize.Focusable = false; WindowChrome.SetIsHitTestVisibleInChrome(Window_Button_Maximize, true); Window_Button_Minimize.MouseEnter += Window_Button_MouseEnter; Window_Button_Minimize.MouseLeave += Window_Button_MouseLeave; Window_Button_Minimize.Click += Window_Minimize; Window_Button_Minimize.Content = '0'; Window_Button_Minimize.FontFamily = new System.Windows.Media.FontFamily("Webdings"); Window_Button_Minimize.FontSize = 11; Window_Button_Minimize.Height = 19; Window_Button_Minimize.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Window_Button_Minimize.VerticalAlignment = System.Windows.VerticalAlignment.Top; Window_Button_Minimize.Padding = new Thickness(0, -CHROME_BUTTON_TOP_MARGIN - 1, 0, 0); Window_Button_Minimize.Foreground = Brushes.Black; Window_Button_Minimize.BorderThickness = new Thickness(1); Window_Button_Minimize.FontWeight = FontWeights.Bold; Window_Button_Minimize.Width = 30; Window_Button_Minimize.Margin = new Thickness(0, CHROME_BUTTON_TOP_MARGIN, 81, 0); Window_Button_Minimize.Focusable = false; WindowChrome.SetIsHitTestVisibleInChrome(Window_Button_Minimize, true); #endregion #region COLOR_PICKER foreach (ThemeColors t in AvailableThemeColors) { MenuItem NewItem = new MenuItem(); NewItem.Header = t; NewItem.Click += (o, e) => { ThemeColor = (ThemeColors)((MenuItem)e.Source).Header; }; ColorPicker.Items.Add(NewItem); } //Window_TitleGrid.ContextMenu = ColorPicker; #endregion Window_Button_Close.Style = (Style)this.FindResource("Window_Button_Close"); Window_Button_Maximize.Style = (Style)this.FindResource("Window_Button_Maximize"); Window_Button_Minimize.Style = (Style)this.FindResource("Window_Button_Minimize"); Window_TitleGrid.Style = (Style)this.FindResource("Window_Frame_Title_Bar"); Window_Border.Style = (Style)this.FindResource("Window_Frame_Border"); TitleEnabledBackground = Window_TitleGrid.Background.CloneCurrentValue(); TitleDisabledBackground = TitleEnabledBackground.CloneCurrentValue(); TitleDisabledBackground.Opacity = 0.4; TitleEnabledBackground.Freeze(); TitleDisabledBackground.Freeze(); }
public MainWindow() { #if debug WinConsole.ShowConsole(); #endif InitializeComponent(); var wc = new WindowChrome { CaptionHeight = 30, GlassFrameThickness = new Thickness(0), CornerRadius = new CornerRadius(0), UseAeroCaptionButtons = false, ResizeBorderThickness = new Thickness(5) }; WindowChrome.SetWindowChrome(this, wc); Activated += MainWindow_Activated; Deactivated += MainWindow_Deactivated; SizeChanged += MainWindow_OnSizeChanged; Client.CloseDialogPanelEvent += Client_CloseDialogPanelEvent; Client.ShowDialogPanelEvent += Client_ShowDialogPanelEvent; Client.ShowToastEvent += Client_ShowToastEvent; //基于dip决定高分屏字体 try { using (var graphics = Graphics.FromHwnd(IntPtr.Zero)) { if (Math.Abs(graphics.DpiX - 96) > 0) { TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal); FontFamily = new FontFamily("Microsoft Yahei"); } else { TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); FontFamily = new FontFamily("SimSun"); } } } catch (Exception) { // ignored } // 默认风格 _buttonStatus.Baseurl = "Resources/Icon/ControlBox/drak/"; DataContext = _buttonStatus; // 初始化页面加载、方便调用UI线程委托 Common.MainWindow = this; Client.MainWindow = this; LoginTabItem.ClickDown(null, null); // 加载login页面 if (!CheckNetworkConnected()) { Common.ShowToast("网路未连接"); } else { //启动状态定时器 new Timer { Interval = 1000, Enabled = true }.Elapsed += MainWindow_Elapsed; } }
private static void OnIsEnablePropertyChange(DependencyObject obj, DependencyPropertyChangedEventArgs e) { if (!(e.NewValue is bool) || !(bool)e.NewValue) { return; } var window = obj as Window; if (window == null) { return; } if (window.WindowStyle == WindowStyle.None) //如果是none无需加载 { return; } var windowStyle = window.WindowStyle; Action init = () => { var content = window.Content as UIElement; var windowBorder = window.FindChildrenFromTemplate <Border>(WINDOW_BORDER); if (windowBorder == null) { return; } var titleBorder = windowBorder.FindChildren <Grid>(TITLE_GRID); TextElement.SetFontSize(titleBorder, GetTitleFontSize(window)); TextElement.SetForeground(titleBorder, GetTitleForeground(window)); titleBorder.Background = GetTitleBackground(obj as UIElement); titleBorder.Height = GetTitleHeight(obj as UIElement); var windowContentControl = windowBorder.FindChildren <ContentControl>(CONTENT_CONTROL); windowContentControl.Content = content; window.Content = windowBorder.Parent; //注册命令按钮事件 var buttons = windowBorder.FindChildren <Button>().ToList(); buttons.ForEach(x => x.Foreground = GetTitleForeground(window)); var maxBtn = buttons.First(x => x.Name == MAXIMIZE_BUTTON); var minBtn = buttons.First(x => x.Name == MINIMIZE_BUTTON); if (windowStyle == WindowStyle.ToolWindow) { maxBtn.Visibility = Visibility.Collapsed; minBtn.Visibility = GetMinimizeButtonVisibleWhenInToolWindowMode(window) ? Visibility.Visible : Visibility.Collapsed; } else { maxBtn.Click += (s, arg) => window.WindowState = window.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; } minBtn.Click += (s, arg) => window.WindowState = WindowState.Minimized; buttons.First(x => x.Name == CLOSE_BUTTON).Click += (s, arg) => window.Close(); }; if (window.IsInitialized) { init(); } else { window.Initialized += delegate { init(); } }; WindowChrome chrome = new WindowChrome { // ResizeBorderThickness = new Thickness(5), // CornerRadius = new CornerRadius(0), // UseAeroCaptionButtons = false, GlassFrameThickness = new Thickness(1), CaptionHeight = GetChromeCaptionHeight(window), // NonClientFrameEdges = NonClientFrameEdges.None, }; WindowChrome.SetWindowChrome(window, chrome); }
public MainWindow( MainWindowVM viewModel, IDialogService dialogService, IRuntimeDataService runtimeDataService) { _dialogService = dialogService; _runtimeDataService = runtimeDataService; InitializeComponent(); WindowChrome windowChrome = new WindowChrome() { CaptionHeight = 55, CornerRadius = new CornerRadius(0), GlassFrameThickness = new Thickness(0), NonClientFrameEdges = NonClientFrameEdges.None, ResizeBorderThickness = new Thickness(6), UseAeroCaptionButtons = false }; WindowChrome.SetWindowChrome(this, windowChrome); // Hold reference to FontAwesome library ImageAwesome.CreateImageSource(FontAwesomeIcon.Times, Brushes.Black); SizeChanged += (s, e) => { if (WindowState == WindowState.Normal) { WidthNormal = Width; HeightNormal = Height; } }; LocationChanged += (s, e) => { if (WindowState == WindowState.Normal) { TopNormal = Top; LeftNormal = Left; } }; Loaded += (s, e) => { HwndSource.FromHwnd(new WindowInteropHelper(this).Handle).AddHook(new HwndSourceHook(WindowProc)); DataContext = viewModel; if (viewModel != null) { viewModel.Loaded(); } LoadWindowState(); }; Closed += (s, e) => { SaveWindowState(); }; }
public MainWindow() { InitializeComponent(); WindowChrome wc = new WindowChrome(); wc.UseAeroCaptionButtons = false; wc.CaptionHeight = 26; WindowChrome.SetWindowChrome(this, wc); DispatcherTimer dt = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 0, 0, 1) }; dt.Tick += (sender, args) => TabWindowPass.Window = new TabWindow(); dt.Start(); Loaded += MainWindow_Loaded; ToolBarItem item_close = new ToolBarItem(); item_close.IconSource = new BitmapImage(new Uri("pack://application:,,,/MaterialWPFTest;component/Icons/close.png")); item_close.Margin = new Thickness(item_close.Margin.Left, item_close.Margin.Top, 0, item_close.Margin.Bottom); item_close.IconWidth = 20; item_close.IconHeight = 20; item_close.Width = 32; item_close.Height = 32; ToolBarItem item_maximize = new ToolBarItem(); item_maximize.IconSource = new BitmapImage(new Uri("pack://application:,,,/MaterialWPFTest;component/Icons/maximaze.png")); item_maximize.Margin = new Thickness(item_maximize.Margin.Left, item_maximize.Margin.Top, 64, item_maximize.Margin.Bottom); item_maximize.IconWidth = 12; item_maximize.IconHeight = 12; item_maximize.Width = 32; item_maximize.Height = 32; ToolBarItem item_minimize = new ToolBarItem(); item_minimize.IconSource = new BitmapImage(new Uri("pack://application:,,,/MaterialWPFTest;component/Icons/minimaze.png")); item_minimize.Margin = new Thickness(item_minimize.Margin.Left, item_minimize.Margin.Top, 128, item_minimize.Margin.Bottom); item_minimize.IconWidth = 12; item_minimize.IconHeight = 12; item_minimize.Width = 32; item_minimize.Height = 32; item_close.PreviewMouseUp += (o, i) => { Application.Current.Shutdown(); }; item_maximize.PreviewMouseUp += (o, i) => { if (this.WindowState == WindowState.Maximized) { this.WindowState = WindowState.Normal; } else { this.WindowState = WindowState.Maximized; } }; item_minimize.PreviewMouseUp += (o, i) => { this.WindowState = WindowState.Minimized; }; }
public WindowButton() { InitializeComponent(); WindowChrome.SetIsHitTestVisibleInChrome(this, true); IsEnabledChanged += (s, e) => RefreshContent(); }
/// <summary> /// 构造方法 /// </summary> public CSWin() { var ctemp = new ControlTemplate(typeof(Window)); { var _border = new FrameworkElementFactory(typeof(Border)); _border.SetValue(Border.BackgroundProperty, Brushes.Transparent); _border.SetValue(Border.SnapsToDevicePixelsProperty, true); _border.SetBinding(Border.BorderBrushProperty, new Binding() { Source = this, Path = new PropertyPath("CSBorderBrush"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); _border.SetBinding(Border.BorderThicknessProperty, new Binding() { Source = this, Path = new PropertyPath("CSBorderThickness"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); _border.SetBinding(Border.CornerRadiusProperty, new Binding() { Source = this, Path = new PropertyPath("CSCornerRadius"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); { var _workarea = new FrameworkElementFactory(typeof(Grid)); _workarea.SetBinding(Grid.MarginProperty, new Binding() { Source = this, Path = new PropertyPath("CSWorkareaMargin"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); _workarea.SetBinding(Grid.BackgroundProperty, new Binding() { Source = this, Path = new PropertyPath("Background"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); { var __waRd1 = new FrameworkElementFactory(typeof(RowDefinition)); var __waRd2 = new FrameworkElementFactory(typeof(RowDefinition)); __waRd1.SetBinding(RowDefinition.HeightProperty, new Binding() { Source = this, Path = new PropertyPath("TitleHeight"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); __waRd2.SetBinding(RowDefinition.HeightProperty, new Binding() { Source = this, Path = new PropertyPath("WorkareaHeight"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); _workarea.AppendChild(__waRd1); _workarea.AppendChild(__waRd2); } { var _grid = new FrameworkElementFactory(typeof(Grid)); _grid.SetValue(Grid.RowProperty, 0); _grid.AddHandler(Grid.MouseMoveEvent, new MouseEventHandler(TitleBar_MouseMove)); _grid.SetBinding(Grid.BackgroundProperty, new Binding() { Source = this, Path = new PropertyPath("TitleBackground"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); { var _title = new FrameworkElementFactory(typeof(TextBlock)); _title.SetBinding(TextBlock.FontSizeProperty, new Binding() { Source = this, Path = new PropertyPath("TitleFontSize"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); _title.SetBinding(TextBlock.HorizontalAlignmentProperty, new Binding() { Source = this, Path = new PropertyPath("TitleHorizontalAlignment"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); _title.SetBinding(TextBlock.TextProperty, new Binding() { Source = this, Path = new PropertyPath("Title"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); var _dp = new FrameworkElementFactory(typeof(DockPanel)); _dp.SetValue(DockPanel.HorizontalAlignmentProperty, HorizontalAlignment.Right); _dp.SetValue(DockPanel.DockProperty, Dock.Right); { var btn_max = new FrameworkElementFactory(typeof(CSWinbtn.MinMax)); btn_max.SetValue(CSWinbtn.MinMax.PathDataProperty, Geometry.Parse("M0 0 H15 V11 H0 V2 H1 V10 H14 V2 H0 V0")); btn_max.SetBinding(Button.VisibilityProperty, new Binding() { Source = this, Path = new PropertyPath("TitleMaxBtnVisibility"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); btn_max.SetBinding(Button.WidthProperty, new Binding() { Source = this, Path = new PropertyPath("TitleBtnWidth"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); btn_max.AddHandler(Button.ClickEvent, handler: new RoutedEventHandler(btn_max_Click)); var btn_min = new FrameworkElementFactory(typeof(CSWinbtn.MinMax)); btn_min.SetBinding(Button.VisibilityProperty, new Binding() { Source = this, Path = new PropertyPath("TitleMinBtnVisibility"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); btn_min.SetBinding(Button.WidthProperty, new Binding() { Source = this, Path = new PropertyPath("TitleBtnWidth"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); btn_min.AddHandler(Button.ClickEvent, handler: new RoutedEventHandler(btn_min_Click)); var btn_close = new FrameworkElementFactory(typeof(CSWinbtn.Close)); btn_close.SetBinding(Button.VisibilityProperty, new Binding() { Source = this, Path = new PropertyPath("TitleCloseBtnVisibility"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); btn_close.SetBinding(Button.WidthProperty, new Binding() { Source = this, Path = new PropertyPath("TitleBtnWidth"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); btn_close.AddHandler(Button.ClickEvent, handler: new RoutedEventHandler(btn_close_Click)); _dp.AppendChild(btn_min); _dp.AppendChild(btn_max); _dp.AppendChild(btn_close); } var content = new FrameworkElementFactory(typeof(ContentPresenter)); content.SetValue(Grid.RowProperty, 1); _grid.AppendChild(_title); _grid.AppendChild(_dp); _workarea.AppendChild(content); } _workarea.AppendChild(_grid); } _border.AppendChild(_workarea); } ctemp.VisualTree = _border; } WindowChrome.SetWindowChrome(this, new WindowChrome() { ResizeBorderThickness = new Thickness(5), CaptionHeight = 0 }); this.Template = ctemp; WindowStyle = WindowStyle.None; AllowsTransparency = true; Loaded += _window_Loaded; Deactivated += CSWin_Deactivated; Activated += CSWin_Activated; activatedBrush = CSBorderBrush; }
void InitializeWindowCaptionAndResizeBorder(WindowChrome wc) => InitializeWindowCaptionAndResizeBorder(wc, UseResizeBorder);
public void SetWindowChrome(WindowChrome newChrome) { VerifyAccess(); Assert.IsNotNull(_window); if (newChrome == _chromeInfo) { // Nothing's changed. return; } if (_chromeInfo != null) { _chromeInfo.PropertyChangedThatRequiresRepaint -= _OnChromePropertyChangedThatRequiresRepaint; } _chromeInfo = newChrome; if (_chromeInfo != null) { _chromeInfo.PropertyChangedThatRequiresRepaint += _OnChromePropertyChangedThatRequiresRepaint; } _ApplyNewCustomChrome(); }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); WindowChrome.SetResizeGripDirection(this.FindChild <ResizeGrip>(UITreeType.Visual, child => true), ResizeGripDirection.BottomRight); }
public static void SetWindowChrome(Window window, WindowChrome chrome) { Verify.IsNotNull(window, "window"); window.SetValue(WindowChromeProperty, chrome); }
internal void ControlWindowChrome(bool isApplyShell) { WindowChrome.SetWindowChrome(this, isApplyShell ? this._chrome : null); }
public UIOfflineIndicator() { string[] args = Environment.GetCommandLineArgs(); if (args.Length <= 1) { MessageBox.Show("Invalid Commandline Parameters - BF3 for Battlefield 3, BF4 for Battlefield 4"); Environment.Exit(1); } Config config = new Config(); switch (args[1]) { case "BF3": this.battlelog = new Battlefield3(); break; case "BF4": this.battlelog = new Battlefield4(); break; case "MOHW": this.battlelog = new MedalOfHonorWarfighter(); break; case "BFH": this.battlelog = new BattlefieldHardline(); break; default: MessageBox.Show("Invalid Commandline Parameters - bf3 for Battlefield 3, bf4 for Battlefield 4,,bfh for Hardline, mohw for Medal of Honor Warfighter"); Environment.Exit(1); break; } InitializeComponent(); this.gameLabel.Content = "You are playing " + battlelog.battlefieldName + " Campaign. Please log in to Origin when prompted."; this.gameIcon.Source = new BitmapImage(new Uri("pack://*****:*****@"pack://application:,,/images/" + battlelog.battlefieldShortname + "/icon.ico")); this.KeyDown += (s, e) => { if (e.Key == Key.Enter) { this.WindowState = WindowState.Minimized; } }; this.SourceInitialized += (s, e) => { this.HideWindowButtons(); WindowChrome.SetWindowChrome(this, new WindowChrome() { CaptionHeight = 14D, ResizeBorderThickness = new Thickness(0) }); }; var origin = new OfflineOrigin(this.battlelog.gameId); origin.OriginUnexpectedClose += (s) => this.Dispatcher.Invoke(() => this.Close()); this.battlelog.GameQuit += (s, e) => { origin.KillOrigin(); this.Dispatcher.Invoke(() => this.Close()); }; origin.StartOrigin(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { WindowChrome.SetWindowChrome(this, new WindowChrome { CaptionHeight = 0 }); }
protected override void OnAttached() { windowChrome = new WindowChrome { #if NET4_5 ResizeBorderThickness = SystemParameters.WindowResizeBorderThickness, #else ResizeBorderThickness = SystemParameters2.Current.WindowResizeBorderThickness, #endif CaptionHeight = 0, CornerRadius = new CornerRadius(0), GlassFrameThickness = new Thickness(0), UseAeroCaptionButtons = false }; var metroWindow = AssociatedObject as MetroWindow; if (metroWindow != null) { windowChrome.IgnoreTaskbarOnMaximize = metroWindow.IgnoreTaskbarOnMaximize; windowChrome.UseNoneWindowStyle = metroWindow.UseNoneWindowStyle; System.ComponentModel.DependencyPropertyDescriptor.FromProperty(MetroWindow.IgnoreTaskbarOnMaximizeProperty, typeof(MetroWindow)) .AddValueChanged(AssociatedObject, IgnoreTaskbarOnMaximizePropertyChangedCallback); System.ComponentModel.DependencyPropertyDescriptor.FromProperty(MetroWindow.UseNoneWindowStyleProperty, typeof(MetroWindow)) .AddValueChanged(AssociatedObject, UseNoneWindowStylePropertyChangedCallback); } AssociatedObject.SetValue(WindowChrome.WindowChromeProperty, windowChrome); // no transparany, because it hase more then one unwanted issues var windowHandle = new WindowInteropHelper(AssociatedObject).Handle; if (!AssociatedObject.IsLoaded && windowHandle == IntPtr.Zero) { try { AssociatedObject.AllowsTransparency = false; } catch (Exception) { //For some reason, we can't determine if the window has loaded or not, so we swallow the exception. } } AssociatedObject.WindowStyle = WindowStyle.None; savedBorderThickness = AssociatedObject.BorderThickness; borderThicknessChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.BorderThicknessProperty); borderThicknessChangeNotifier.ValueChanged += BorderThicknessChangeNotifierOnValueChanged; savedTopMost = AssociatedObject.Topmost; topMostChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.TopmostProperty); topMostChangeNotifier.ValueChanged += TopMostChangeNotifierOnValueChanged; // #1823 try to fix another nasty issue // WindowState = Maximized // ResizeMode = NoResize savedResizeMode = AssociatedObject.ResizeMode; AssociatedObject.ResizeMode = ResizeMode.CanResize; resizeModeChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.ResizeModeProperty); resizeModeChangeNotifier.ValueChanged += ResizeModeChangeNotifierOnValueChanged; AssociatedObject.Loaded += AssociatedObject_Loaded; AssociatedObject.Unloaded += AssociatedObject_Unloaded; AssociatedObject.SourceInitialized += AssociatedObject_SourceInitialized; AssociatedObject.StateChanged += OnAssociatedObjectHandleMaximize; // handle the maximized state here too (to handle the border in a correct way) this.HandleMaximize(); base.OnAttached(); }
internal static void SetIsHitTestVisibleInChrome(UIElement element, bool hitTestVisible) { WindowChrome.SetIsHitTestVisibleInChrome(element, hitTestVisible); }
private IntPtr WindowProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (this.GlowStyle == GlowStyle.Glowing) { switch (msg) { case WM_SYSCOMMAND: { switch (wParam.ToInt32() & 0xFFF0) { case SC_MINIMIZE: { ShowWindow(_hWndGlow, SW_HIDE); break; } case SC_MAXIMIZE: { _isMaximized = true; ShowWindow(_hWndGlow, SW_HIDE); break; } case SC_RESTORE: { switch (this.WindowState) { case WindowState.Minimized: { _afterRestoreFromMinimize = true; break; } case WindowState.Maximized: { _afterRestoreFromMaximize = true; break; } default: { _afterRestoreFromOther = true; break; } } break; } } break; } case WM_WINDOWPOSCHANGED: { if (!_afterRestoreFromMinimize) { updateGlow(); } break; } case WM_NCPAINT: { if (_afterRestoreFromMaximize | _afterRestoreFromOther) { _afterRestoreFromMaximize = false; _afterRestoreFromOther = false; _maximizeThread = new Thread(() => { Thread.Sleep(_afterRestoreFromMaximize ? 225 : 0); _isMaximized = false; updateGlow(true); ShowWindow(_hWndGlow, SW_SHOWNOACTIVATE); }); _maximizeThread.Priority = ThreadPriority.Highest; _maximizeThread.Start(); } break; } case WM_ACTIVATE: { if (_afterRestoreFromMinimize) { _afterRestoreFromMinimize = false; if (this.WindowState != WindowState.Maximized) { _minimizeThread = new Thread(() => { Thread.Sleep(225); updateGlow(); ShowWindow(_hWndGlow, SW_SHOWNOACTIVATE); }); _minimizeThread.Priority = ThreadPriority.Highest; _minimizeThread.Start(); } } break; } case WM_SIZING: case 127: // WM_GETICON { if (this.WindowState == WindowState.Normal && _activated) { _isMaximized = false; updateGlow(true); ShowWindow(_hWndGlow, SW_SHOWNOACTIVATE); } break; } case 533: // WM_CAPTURECHANGED { _got533 = true; Debug.WriteLine("533"); break; } case 132: // WM_NCHITTEST { if (_got533) { _got132 = true; } Debug.WriteLine("132"); break; } case 36: // WM_GETMINMAXINFO { if (_got132) { _got36 = true; } Debug.WriteLine("36"); break; } case 70: // WM_WINDOWPOSCHANGING { if (_got36) { _got70 = true; } Debug.WriteLine("70"); break; } default: { _got533 = false; _got132 = false; _got36 = false; _got70 = false; Debug.WriteLine("msg={0}, state={1}", msg, this.WindowState.ToString()); break; } } if (_got533 && _got132 && _got36 && _got70) { _isMaximized = true; ShowWindow(_hWndGlow, SW_HIDE); _glow.Top = -100 - this.Height; } } else if (this.GlowStyle == GlowStyle.Standard) { switch (msg) { case WM_SYSCOMMAND: { switch (wParam.ToInt32() & 0xFFF0) { case SC_MAXIMIZE: { WindowChrome wc = (WindowChrome)this.GetValue(Microsoft.Windows.Shell.WindowChrome.WindowChromeProperty); if (wc.GlassFrameThickness.Left == 0 && wc.GlassFrameThickness.Top == 0 && wc.GlassFrameThickness.Right == 0 && wc.GlassFrameThickness.Bottom == 1) { _glassFrameThicknessReset = true; wc.GlassFrameThickness = new Thickness(0, 0, 0, 0); } break; } } break; } case WM_GETMINMAXINFO: { if (_glassFrameThicknessReset) { WindowChrome wc = (WindowChrome)this.GetValue(Microsoft.Windows.Shell.WindowChrome.WindowChromeProperty); _glassFrameThicknessReset = false; wc.GlassFrameThickness = new Thickness(0, 0, 0, 1); } break; } } } return(hwnd); }
public override void GetWindowChrome(out WindowChrome chrome) { chrome = this.chrome; }
/// <summary> /// Occurs when the background worker has completed work. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> that contains the event data.</param> private void OnBackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { // Hide the overlay WindowChrome.SetIsOverlayVisible(this, false); }
private void updateWindowChrome() { var chrome = new WindowChrome { CaptionHeight = 40, CornerRadius = new CornerRadius(0), GlassFrameThickness = new Thickness(1), UseAeroCaptionButtons = false }; if (this.isToolWindow) { chrome.ResizeBorderThickness = new Thickness(0); } if (this.WindowState == WindowState.Maximized) { chrome.ResizeBorderThickness = new Thickness(0); } WindowChrome.SetWindowChrome(this, chrome); }
private void OnCaptionSizeChanged(object sender, SizeChangedEventArgs e) { if (e.HeightChanged && Equals(WindowChrome.GetWindowChrome(this), _chrome)) { _chrome = new WindowChrome { CaptionHeight = e.NewSize.Height, CornerRadius = _chrome.CornerRadius, GlassFrameThickness = _chrome.GlassFrameThickness, NonClientFrameEdges = _chrome.NonClientFrameEdges, ResizeBorderThickness = _chrome.ResizeBorderThickness, UseAeroCaptionButtons = _chrome.UseAeroCaptionButtons }; if (_chrome.CanFreeze) { _chrome.Freeze(); } WindowChrome.SetWindowChrome(this, _chrome); } }