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(); }
public static void SetWindowChrome(Window window, WindowChrome chrome) { Verify.IsNotNull(window, "window"); window.SetValue(WindowChromeProperty, chrome); }
private void UpdateWindowChrome() { var windowChrome = WindowChrome.GetWindowChrome(this); if (windowChrome == null) { windowChrome = new WindowChrome(); WindowChrome.SetWindowChrome(this, windowChrome); } var metrics = this.windowSizing.GetBorderWidthAndCaptionHeight(); var borderWidth = metrics.Item1; if (this.UseDefaultBorderSize) { var captionHeight = metrics.Item2; this.BorderWidth = borderWidth; this.TitleBarHeight = Math.Ceiling(this.WindowState == WindowState.Maximized ? captionHeight : borderWidth + captionHeight); this.GlassBorderThickness = new Thickness(borderWidth, Math.Ceiling(borderWidth + captionHeight + this.ExtendedGlassBorderHeight), borderWidth, borderWidth); this.WindowMargin = this.WindowState == WindowState.Maximized ? new Thickness(borderWidth, Math.Ceiling(borderWidth), borderWidth, borderWidth) : new Thickness(borderWidth, 0, borderWidth, borderWidth); windowChrome.GlassFrameThickness = this.GlassBorderThickness; windowChrome.ResizeBorderThickness = new Thickness(borderWidth); } else { this.WindowMargin = this.WindowState == WindowState.Maximized ? new Thickness(borderWidth, Math.Ceiling(borderWidth), borderWidth, borderWidth) : new Thickness(0); windowChrome.CaptionHeight = RibbonProperties.GetTitleBarHeight(this); windowChrome.CornerRadius = this.CornerRadius; windowChrome.GlassFrameThickness = this.GlassBorderThickness; windowChrome.ResizeBorderThickness = this.ResizeBorderThickness; } #if NET45 windowChrome.UseAeroCaptionButtons = this.CanUseDwm; #endif }
private void UpdateWindowChrome() { var windowChrome = WindowChrome.GetWindowChrome(this); if (windowChrome == null) { windowChrome = new WindowChrome(); WindowChrome.SetWindowChrome(this, windowChrome); } windowChrome.CaptionHeight = RibbonProperties.GetTitleBarHeight(this); windowChrome.CornerRadius = this.CornerRadius; windowChrome.GlassFrameThickness = this.GlassBorderThickness; windowChrome.ResizeBorderThickness = this.ResizeBorderThickness; #if NET45 windowChrome.UseAeroCaptionButtons = this.CanUseDwm; #endif }
public Window() { _chrome = new WindowChrome { CaptionHeight = SystemParameters2.Current.WindowCaptionHeight, CornerRadius = new CornerRadius(0d), GlassFrameThickness = new Thickness(0d), NonClientFrameEdges = NonClientFrameEdges.None, ResizeBorderThickness = Parameters.Window.GetResizeBorderThickness(this), UseAeroCaptionButtons = false }; _chrome.Freeze(); if (WindowChrome.GetWindowChrome(this) == null) { WindowChrome.SetWindowChrome(this, _chrome); } var resizeBorderThicknessPropertyDescriptor = DependencyPropertyDescriptor.FromProperty(Parameters.Window.ResizeBorderThicknessProperty, typeof(Window)); resizeBorderThicknessPropertyDescriptor.AddValueChanged(this, delegate { if (Equals(WindowChrome.GetWindowChrome(this), _chrome)) { _chrome = new WindowChrome { CaptionHeight = _chrome.CaptionHeight, CornerRadius = _chrome.CornerRadius, GlassFrameThickness = _chrome.GlassFrameThickness, NonClientFrameEdges = _chrome.NonClientFrameEdges, ResizeBorderThickness = Parameters.Window.GetResizeBorderThickness(this), UseAeroCaptionButtons = _chrome.UseAeroCaptionButtons }; _chrome.Freeze(); WindowChrome.SetWindowChrome(this, _chrome); } }); CommandBindings.Add(new CommandBinding(WindowCommands.Minimize, (sender, e) => WindowState = WindowState.Minimized)); CommandBindings.Add(new CommandBinding(WindowCommands.Maximize, (sender, e) => WindowState = WindowState.Maximized)); CommandBindings.Add(new CommandBinding(WindowCommands.Restore, (sender, e) => WindowState = WindowState.Normal)); CommandBindings.Add(new CommandBinding(WindowCommands.Close, (sender, e) => Close())); }
protected virtual void OnHasDropShadowChanged(bool oldHasDropShadow, bool newHasDropShadow) { if (Equals(WindowChrome.GetWindowChrome(this), _chrome)) { _chrome = new WindowChrome { CaptionHeight = _chrome.CaptionHeight, CornerRadius = _chrome.CornerRadius, GlassFrameThickness = !newHasDropShadow ? new Thickness(0d) : new Thickness(0d, 0d, 0d, 1d), NonClientFrameEdges = _chrome.NonClientFrameEdges, ResizeBorderThickness = _chrome.ResizeBorderThickness, UseAeroCaptionButtons = _chrome.UseAeroCaptionButtons }; _chrome.Freeze(); WindowChrome.SetWindowChrome(this, _chrome); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template != null) { // NOTE: Lack of contracts: FindName is pure method Contract.Assume(Template != null); _caption = Template.FindName(CaptionName, this) as FrameworkElement; if (_caption == null) { Trace.TraceError(CaptionName + " not found."); } else { _caption.SizeChanged += (sender, e) => { if (Equals(WindowChrome.GetWindowChrome(this), _chrome) && e.HeightChanged) { _chrome = new WindowChrome { CaptionHeight = e.NewSize.Height, CornerRadius = _chrome.CornerRadius, GlassFrameThickness = _chrome.GlassFrameThickness, NonClientFrameEdges = _chrome.NonClientFrameEdges, ResizeBorderThickness = _chrome.ResizeBorderThickness, UseAeroCaptionButtons = _chrome.UseAeroCaptionButtons }; _chrome.Freeze(); WindowChrome.SetWindowChrome(this, _chrome); } }; } } }
public override void Apply() { // Expected: Managed Debugging Assistant LoadFromContext // See Also: http://stackoverflow.com/questions/31362077/loadfromcontext-occured WindowChrome = new WindowChrome() { CaptionHeight = 35, GlassFrameThickness = new Thickness(0), ResizeBorderThickness = new Thickness(7), CornerRadius = new CornerRadius(10) }; WindowChrome.SetWindowChrome(Decorated, WindowChrome); MainGrid = new Grid(); MainGrid.RowDefinitions.Add(TitleRow = new RowDefinition { Height = new GridLength(35) }); MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); MainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(100, GridUnitType.Star) }); MainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0, GridUnitType.Auto) }); MainBorder.Child = MainGrid; MainBorder.Padding = new Thickness(8); MainGrid.Children.Add(ContentArea); Grid.SetRow(ContentArea, 1); Grid.SetColumnSpan(ContentArea, 2); AddTitleBar(); AddWindowControls(); Decorated.PropertyChanged += DecoratedOnPropertyChanged; }
public override void Apply() { WindowChrome = new WindowChrome() { CaptionHeight = 35, GlassFrameThickness = new Thickness(0), ResizeBorderThickness = new Thickness(7), CornerRadius = new CornerRadius(10) }; WindowChrome.SetWindowChrome(Decorated, WindowChrome); MainGrid = new Grid(); MainGrid.RowDefinitions.Add(TitleRow = new RowDefinition { Height = new GridLength(35) }); MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); MainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(100, GridUnitType.Star) }); MainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0, GridUnitType.Auto) }); MainBorder.Child = MainGrid; MainBorder.Padding = new Thickness(8); MainGrid.Children.Add(ContentArea); Grid.SetRow(ContentArea, 1); Grid.SetColumnSpan(ContentArea, 2); AddTitleBar(); AddWindowControls(); Decorated.PropertyChanged += DecoratedOnPropertyChanged; }
public ExpressionWindow() : base() { TitleIcon.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; TitleIcon.VerticalAlignment = System.Windows.VerticalAlignment.Center; TitleIcon.Width = 16; TitleIcon.Height = 16; TitleIcon.Margin = new Thickness(8, 0, 0, 0); this.Icon = Imaging.CreateBitmapSourceFromHIcon( System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location).Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions() ); TitleIcon.Source = this.Icon; TitleIcon.SetBinding(Image.SourceProperty, new Binding() { Path = new PropertyPath("Icon"), RelativeSource = new RelativeSource() { AncestorType = typeof(ExpressionWindow), Mode = RelativeSourceMode.FindAncestor }, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); this.MinWidth = 50; this.MinHeight = TITLE_BAR_HEIGHT; IsColorPickerEnabled = true; IsModal = false; Window_TitleLabel.SetBinding(Label.ContentProperty, new Binding() { Path = new PropertyPath("Title"), RelativeSource = new RelativeSource() { AncestorType = typeof(ExpressionWindow), Mode = RelativeSourceMode.FindAncestor }, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); if (FrameLoaded) themeColor = ((ExpressionWindow)Application.Current.MainWindow).ThemeColor; else { ThemeColor = DEFAULT_COLOR; FrameLoaded = true; } Chrome = new WindowChrome(); Chrome.CaptionHeight = TITLE_BAR_HEIGHT; Chrome.CornerRadius = new CornerRadius(0); Chrome.ResizeBorderThickness = new Thickness(RESIZE_HANDLE_SIZE); Chrome.GlassFrameThickness = new Thickness(0); WindowChrome.SetWindowChrome(this, Chrome); Initialize(); Application.Current.Deactivated += Current_Deactivated; Application.Current.Activated += Current_Activated; }
static WindowChrome() { WindowChrome.WindowChromeProperty = DependencyProperty.RegisterAttached("WindowChrome", typeof(WindowChrome), typeof(WindowChrome), new PropertyMetadata(null, new PropertyChangedCallback(WindowChrome._OnChromeChanged))); WindowChrome.IsHitTestVisibleInChromeProperty = DependencyProperty.RegisterAttached("IsHitTestVisibleInChrome", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits)); WindowChrome.CaptionHeightProperty = DependencyProperty.Register("CaptionHeight", typeof(double), typeof(WindowChrome), new PropertyMetadata((object)0, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), (object value) => (double)value >= 0); Type type = typeof(Thickness); Type type1 = typeof(WindowChrome); Thickness thickness = new Thickness(); WindowChrome.ResizeBorderThicknessProperty = DependencyProperty.Register("ResizeBorderThickness", type, type1, new PropertyMetadata((object)thickness), (object value) => Utility.IsThicknessNonNegative((Thickness)value)); Type type2 = typeof(Thickness); Type type3 = typeof(WindowChrome); thickness = new Thickness(); WindowChrome.GlassFrameThicknessProperty = DependencyProperty.Register("GlassFrameThickness", type2, type3, new PropertyMetadata((object)thickness, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint(), (DependencyObject d, object o) => WindowChrome._CoerceGlassFrameThickness((Thickness)o))); Type type4 = typeof(System.Windows.CornerRadius); Type type5 = typeof(WindowChrome); System.Windows.CornerRadius cornerRadiu = new System.Windows.CornerRadius(); WindowChrome.CornerRadiusProperty = DependencyProperty.Register("CornerRadius", type4, type5, new PropertyMetadata((object)cornerRadiu, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), (object value) => Utility.IsCornerRadiusValid((System.Windows.CornerRadius)value)); List <WindowChrome._SystemParameterBoundProperty> _SystemParameterBoundProperties = new List <WindowChrome._SystemParameterBoundProperty>(); WindowChrome._SystemParameterBoundProperty __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.CornerRadiusProperty, SystemParameterPropertyName = "WindowCornerRadius" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.CaptionHeightProperty, SystemParameterPropertyName = "WindowCaptionHeight" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.ResizeBorderThicknessProperty, SystemParameterPropertyName = "WindowResizeBorderThickness" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.GlassFrameThicknessProperty, SystemParameterPropertyName = "WindowNonClientFrameThickness" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); WindowChrome._BoundProperties = _SystemParameterBoundProperties; }
static WindowChrome() { Class6.yDnXvgqzyB5jw(); WindowChrome.WindowChromeProperty = DependencyProperty.RegisterAttached("WindowChrome", typeof(WindowChrome), typeof(WindowChrome), new PropertyMetadata(null, new PropertyChangedCallback(WindowChrome._OnChromeChanged))); WindowChrome.IsHitTestVisibleInChromeProperty = DependencyProperty.RegisterAttached("IsHitTestVisibleInChrome", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits)); WindowChrome.ResizeGripDirectionProperty = DependencyProperty.RegisterAttached("ResizeGripDirection", typeof(ResizeGripDirection), typeof(WindowChrome), new FrameworkPropertyMetadata((object)ResizeGripDirection.None, FrameworkPropertyMetadataOptions.Inherits)); WindowChrome.CaptionHeightProperty = DependencyProperty.Register("CaptionHeight", typeof(double), typeof(WindowChrome), new PropertyMetadata((object)0, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), (object value) => (double)value >= 0); Type type = typeof(Thickness); Type type1 = typeof(WindowChrome); Thickness thickness = new Thickness(); WindowChrome.ResizeBorderThicknessProperty = DependencyProperty.Register("ResizeBorderThickness", type, type1, new PropertyMetadata((object)thickness), (object value) => ((Thickness)value).IsNonNegative()); Type type2 = typeof(Thickness); Type type3 = typeof(WindowChrome); thickness = new Thickness(); WindowChrome.GlassFrameThicknessProperty = DependencyProperty.Register("GlassFrameThickness", type2, type3, new PropertyMetadata((object)thickness, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint(), (DependencyObject d, object o) => WindowChrome._CoerceGlassFrameThickness((Thickness)o))); WindowChrome.UseAeroCaptionButtonsProperty = DependencyProperty.Register("UseAeroCaptionButtons", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(true)); WindowChrome.IgnoreTaskbarOnMaximizeProperty = DependencyProperty.Register("IgnoreTaskbarOnMaximize", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(false, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint())); WindowChrome.UseNoneWindowStyleProperty = DependencyProperty.Register("UseNoneWindowStyle", typeof(bool), typeof(WindowChrome), new FrameworkPropertyMetadata(false, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint())); Type type4 = typeof(System.Windows.CornerRadius); Type type5 = typeof(WindowChrome); System.Windows.CornerRadius cornerRadiu = new System.Windows.CornerRadius(); WindowChrome.CornerRadiusProperty = DependencyProperty.Register("CornerRadius", type4, type5, new PropertyMetadata((object)cornerRadiu, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), (object value) => ((System.Windows.CornerRadius)value).IsValid()); WindowChrome.SacrificialEdgeProperty = DependencyProperty.Register("SacrificialEdge", typeof(Microsoft.Windows.Shell.SacrificialEdge), typeof(WindowChrome), new PropertyMetadata((object)Microsoft.Windows.Shell.SacrificialEdge.None, (DependencyObject d, DependencyPropertyChangedEventArgs e) => ((WindowChrome)d)._OnPropertyChangedThatRequiresRepaint()), new ValidateValueCallback(WindowChrome._IsValidSacrificialEdge)); WindowChrome.SacrificialEdge_All = Microsoft.Windows.Shell.SacrificialEdge.Left | Microsoft.Windows.Shell.SacrificialEdge.Top | Microsoft.Windows.Shell.SacrificialEdge.Right | Microsoft.Windows.Shell.SacrificialEdge.Bottom | Microsoft.Windows.Shell.SacrificialEdge.Office; List <WindowChrome._SystemParameterBoundProperty> _SystemParameterBoundProperties = new List <WindowChrome._SystemParameterBoundProperty>(); WindowChrome._SystemParameterBoundProperty __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.CornerRadiusProperty, SystemParameterPropertyName = "WindowCornerRadius" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.CaptionHeightProperty, SystemParameterPropertyName = "WindowCaptionHeight" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.ResizeBorderThicknessProperty, SystemParameterPropertyName = "WindowResizeBorderThickness" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); __SystemParameterBoundProperty = new WindowChrome._SystemParameterBoundProperty() { DependencyProperty = WindowChrome.GlassFrameThicknessProperty, SystemParameterPropertyName = "WindowNonClientFrameThickness" }; _SystemParameterBoundProperties.Add(__SystemParameterBoundProperty); WindowChrome._BoundProperties = _SystemParameterBoundProperties; }