internal void UpdatePseudoClasses() { CurrentSortingState = null; if (OwningGrid != null && OwningGrid.DataConnection != null && OwningGrid.DataConnection.AllowSort) { var sort = OwningColumn.GetSortDescription(); if (sort != null) { CurrentSortingState = sort.Direction; } } PseudoClasses.Set(":sortascending", CurrentSortingState == ListSortDirection.Ascending); PseudoClasses.Set(":sortdescending", CurrentSortingState == ListSortDirection.Descending); }
public void Attach(Window hostWindow) { if (_disposables == null) { _hostWindow = hostWindow; _disposables = new CompositeDisposable { _hostWindow.GetObservable(Window.WindowStateProperty) .Subscribe(x => { PseudoClasses.Set(":minimized", x == WindowState.Minimized); PseudoClasses.Set(":normal", x == WindowState.Normal); PseudoClasses.Set(":maximized", x == WindowState.Maximized); PseudoClasses.Set(":fullscreen", x == WindowState.FullScreen); }) }; } }
protected override void OnKeyUp(KeyEventArgs e) { if (e.Key == Key.Enter | e.Key == Key.Space) { SetValue(IsPressedProperty, false); PseudoClasses.Set(":pressed", false); PseudoClasses.Set(":pointerover", false); if (ClickMode == ClickMode.Release) { OnClick(); e.Handled = true; } else { e.Handled = true; } } base.OnKeyUp(e); }
/// <summary> /// Called when the <see cref="INotifyCollectionChanged.CollectionChanged"/> event is /// raised on <see cref="Items"/>. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event args.</param> protected virtual void ItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: AddControlItemsToLogicalChildren(e.NewItems); break; case NotifyCollectionChangedAction.Remove: RemoveControlItemsFromLogicalChildren(e.OldItems); break; } UpdateItemCount(); var collection = sender as ICollection; PseudoClasses.Set(":empty", collection == null || collection.Count == 0); PseudoClasses.Set(":singleitem", collection != null && collection.Count == 1); }
public CurrencyEntryBox() { _customCultureInfo = new CultureInfo("") { NumberFormat = { CurrencyGroupSeparator = _groupSeparator.ToString(), NumberGroupSeparator = _groupSeparator.ToString(), CurrencyDecimalSeparator = _decimalSeparator.ToString(), NumberDecimalSeparator = _decimalSeparator.ToString() } }; this.GetObservable(TextProperty).Subscribe(InputText); this.GetObservable(ConversionRateProperty).Subscribe(_ => UpdateDisplay(false)); this.GetObservable(ConversionCurrencyCodeProperty).Subscribe(_ => UpdateDisplay(true)); this.GetObservable(AmountBtcProperty).Subscribe(_ => UpdateDisplay(true)); this.GetObservable(IsReadOnlyProperty).Subscribe(_ => UpdateDisplay(true)); Watermark = "0 BTC"; Text = string.Empty; _regexBtcFormat = new Regex( $"^(?<Whole>[0-9{_groupSeparator}]*)(\\{_decimalSeparator}?(?<Frac>[0-9{_groupSeparator}]*))$", RegexOptions.Compiled); _regexDecimalCharsOnly = new Regex( $"^[0-9{_groupSeparator}{_decimalSeparator}]*$", RegexOptions.Compiled); _regexConsecutiveSpaces = new Regex( $"{_groupSeparator}{{2,}}", RegexOptions.Compiled); _regexGroupAndDecimal = new Regex( $"[{_groupSeparator}{_decimalSeparator}]+", RegexOptions.Compiled); PseudoClasses.Set(":noexchangerate", true); }
public CurrencyEntryBox() { _customCultureInfo = new CultureInfo("") { NumberFormat = { CurrencyGroupSeparator = _groupSeparator.ToString(), NumberGroupSeparator = _groupSeparator.ToString(), CurrencyDecimalSeparator = _decimalSeparator.ToString(), NumberDecimalSeparator = _decimalSeparator.ToString() } }; Text = string.Empty; _regexBtcFormat = new Regex( $"^(?<Whole>[0-9{_groupSeparator}]*)(\\{_decimalSeparator}?(?<Frac>[0-9{_groupSeparator}]*))$", RegexOptions.Compiled); _regexDecimalCharsOnly = new Regex( $"^[0-9{_groupSeparator}{_decimalSeparator}]*$", RegexOptions.Compiled); _regexConsecutiveSpaces = new Regex( $"{_groupSeparator}{{2,}}", RegexOptions.Compiled); _regexGroupAndDecimal = new Regex( $"[{_groupSeparator}{_decimalSeparator}]+", RegexOptions.Compiled); PseudoClasses.Set(":noexchangerate", true); PseudoClasses.Set(":isrightside", false); this.GetObservable(IsRightSideProperty) .Subscribe(x => PseudoClasses.Set(":isrightside", x)); ModifiedPaste = ReactiveCommand.Create(ModifiedPasteAsync, this.GetObservable(CanPasteProperty)); }
public FluentWindow() { ExtendClientAreaToDecorationsHint = true; ExtendClientAreaTitleBarHeightHint = -1; TransparencyLevelHint = WindowTransparencyLevel.AcrylicBlur; this.GetObservable(WindowStateProperty) .Subscribe(x => { PseudoClasses.Set(":maximized", x == WindowState.Maximized); PseudoClasses.Set(":fullscreen", x == WindowState.FullScreen); }); this.GetObservable(IsExtendedIntoWindowDecorationsProperty) .Subscribe(x => { if (!x) { SystemDecorations = SystemDecorations.Full; TransparencyLevelHint = WindowTransparencyLevel.Blur; } }); }
public MetroWindow() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { // do this in code or we get a delay in osx. HasSystemDecorations = false; ClientDecorations = true; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var classes = (int)GetClassLongPtr(PlatformImpl.Handle.Handle, (int)ClassLongIndex.GCL_STYLE); classes |= 0x00020000; SetClassLong(PlatformImpl.Handle.Handle, ClassLongIndex.GCL_STYLE, new IntPtr(classes)); } } else { ClientDecorations = false; } if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { HasSystemDecorations = true; } // This will need implementing properly once this is supported by avalonia itself. // var color = (ColorTheme.CurrentTheme.Background as SolidColorBrush).Color; // (PlatformImpl as Avalonia.Native.WindowImpl).SetTitleBarColor(color); this.WhenAnyValue(x => x.WindowState) .Select(x => x == WindowState.Maximized) .Subscribe(x => { PseudoClasses.Set(":maximised", x); }); this.WhenAnyValue(x => x.SideBarEnabled) .DistinctUntilChanged() .Subscribe(x => { PseudoClasses.Set(":sidebar", x); }); }
/// <summary> /// Updates the visual state of the control by applying latest PseudoClasses. /// </summary> private void UpdatePseudoClasses() { // The slider itself can be transparent for certain color values. // This causes an issue where a white selector thumb over a light window background or // a black selector thumb over a dark window background is not visible. // This means under a certain alpha threshold, neither a white or black selector thumb // should be shown and instead the default slider thumb color should be used instead. if (Color.A < 128 && (IsAlphaMaxForced == false || ColorComponent == ColorComponent.Alpha)) { PseudoClasses.Set(pcDarkSelector, false); PseudoClasses.Set(pcLightSelector, false); } else { Color perceivedColor; if (ColorModel == ColorModel.Hsva) { perceivedColor = GetEquivalentBackgroundColor(HsvColor).ToRgb(); } else { perceivedColor = GetEquivalentBackgroundColor(Color); } if (ColorHelper.GetRelativeLuminance(perceivedColor) <= 0.5) { PseudoClasses.Set(pcDarkSelector, false); PseudoClasses.Set(pcLightSelector, true); } else { PseudoClasses.Set(pcDarkSelector, true); PseudoClasses.Set(pcLightSelector, false); } } }
/// <summary> /// sets the pseudo classes /// </summary> /// <param name="context"></param> public override void Render(DrawingContext context) { if (IsLarge) { PseudoClasses.Set(PseudoClass_Large, IsLarge); } else { PseudoClasses.Set(PseudoClass_Small, IsLarge == false); } if (IsActive) { PseudoClasses.Set(PseudoClass_Active, IsActive); } else { PseudoClasses.Set(PseudoClass_Inactive, IsActive == false); } base.Render(context); }
internal void UpdatePseudoClasses() { if (_rootElement != null && Owner != null && Owner.IsVisible) { if (OwningRow != null) { PseudoClasses.Set(":invalid", !OwningRow.IsValid); PseudoClasses.Set(":selected", OwningRow.IsSelected); PseudoClasses.Set(":editing", OwningRow.IsEditing); if (OwningGrid != null) { PseudoClasses.Set(":current", OwningRow.Slot == OwningGrid.CurrentSlot); } } else if (OwningRowGroupHeader != null && OwningGrid != null) { PseudoClasses.Set(":current", OwningRowGroupHeader.RowGroupInfo.Slot == OwningGrid.CurrentSlot); } } }
public void Attach() { if (_disposables == null) { var layer = ChromeOverlayLayer.GetOverlayLayer(_hostWindow); layer?.Children.Add(this); if (_hostWindow != null) { _disposables = new CompositeDisposable { _hostWindow.GetObservable(Window.WindowDecorationMarginProperty) .Subscribe(x => UpdateSize()), _hostWindow.GetObservable(Window.ExtendClientAreaTitleBarHeightHintProperty) .Subscribe(x => UpdateSize()), _hostWindow.GetObservable(Window.OffScreenMarginProperty) .Subscribe(x => UpdateSize()), _hostWindow.GetObservable(Window.WindowStateProperty) .Subscribe(x => { PseudoClasses.Set(":minimized", x == WindowState.Minimized); PseudoClasses.Set(":normal", x == WindowState.Normal); PseudoClasses.Set(":maximized", x == WindowState.Maximized); PseudoClasses.Set(":fullscreen", x == WindowState.FullScreen); }) }; _captionButtons?.Attach(_hostWindow); } UpdateSize(); } }
/// <summary> /// Called when the <see cref="INotifyCollectionChanged.CollectionChanged"/> event is /// raised on <see cref="Items"/>. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event args.</param> protected virtual void ItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: AddControlItemsToLogicalChildren(e.NewItems); break; case NotifyCollectionChangedAction.Remove: RemoveControlItemsFromLogicalChildren(e.OldItems); break; } int?count = (Items as IList)?.Count; if (count != null) { ItemCount = (int)count; } var collection = sender as ICollection; PseudoClasses.Set(":empty", collection == null || collection.Count == 0); }
void UpdatePseudoClasses(bool?isVisuallyChecked) { PseudoClasses.Set(":indeterminate", !isVisuallyChecked.HasValue); }
/// <summary> /// Updates the pseudo classes. /// </summary> /// <param name="newValue">if set to <c>true</c> [new value].</param> private void UpdatePseudoClasses(bool newValue) { PseudoClasses.Set(":open", newValue); }
/// <summary> /// Sets PseudoClasses based on current state. /// </summary> private void SetPseudoClasses() { PseudoClasses.Set(":selected", IsSelected); PseudoClasses.Set(":inactive", IsInactive); PseudoClasses.Set(":btnfocused", IsCalendarButtonFocused && IsEnabled); }
/// <summary> /// Updates the visual state of the control by applying latest PseudoClasses. /// </summary> protected void UpdatePseudoClasses() { PseudoClasses.Set(pcFlyoutOpen, _isFlyoutOpen); PseudoClasses.Set(pcPressed, _isPressed); }
internal void UpdateDisabled(bool isEnabled) { PseudoClasses.Set(":calendardisabled", !isEnabled); }
private void UpdatePseudoClasses(Orientation o) { PseudoClasses.Set(":vertical", o == Orientation.Vertical); PseudoClasses.Set(":horizontal", o == Orientation.Horizontal); }
internal void SetPseudoClasses(string name, bool value) { PseudoClasses.Set(name, value); }
protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); e.NameScope.Get <Button>("PART_CloseButton").Click += (_, e1) => HostWindow?.Close(); _maximizeButton = e.NameScope.Get <Button>("PART_MaximizeButton"); _minimizeButton = e.NameScope.Get <Button>("PART_MinimizeButton"); _fullscreenButton = e.NameScope.Get <Button>("PART_FullScreenButton"); _maximizeButton.Click += (_, e1) => { if (HostWindow != null) { HostWindow.WindowState = HostWindow.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; } }; _minimizeButton.Click += (_, e1) => { if (HostWindow != null) { HostWindow.WindowState = WindowState.Minimized; } }; _fullscreenButton.Click += (_, e1) => { if (HostWindow != null) { HostWindow.WindowState = HostWindow.WindowState == WindowState.FullScreen ? WindowState.Normal : WindowState.FullScreen; } }; if (_disposables == null) { _disposables = new CompositeDisposable { HostWindow.GetObservable(PleasantWindow.WindowStateProperty).Subscribe(x => { PseudoClasses.Set(":minimized", x == WindowState.Minimized); PseudoClasses.Set(":normal", x == WindowState.Normal); PseudoClasses.Set(":maximized", x == WindowState.Maximized); PseudoClasses.Set(":fullscreen", x == WindowState.FullScreen); }), HostWindow.GetObservable(PleasantWindow.IsActiveProperty).Subscribe(x => { PseudoClasses.Set(":isactive", !x); }), HostWindow.GetObservable(PleasantWindow.WindowButtonsProperty).Subscribe(x => { if (x != WindowButtons.All) { if (x != WindowButtons.CloseAndCollapse) { _minimizeButton.IsVisible = false; } if (x != WindowButtons.CloseAndExpand) { _maximizeButton.IsVisible = false; } } }), HostWindow.GetObservable(PleasantWindow.FullScreenButtonProperty).Subscribe(x => { if ((_fullscreenButton is null) == false) { _fullscreenButton.IsVisible = x; if (HostWindow.WindowState == WindowState.FullScreen) { HostWindow.WindowState = WindowState.Normal; } } }) }; } }
private void Attach() { if (VisualRoot is PleasantWindow window) { _disposables = new CompositeDisposable { window.GetObservable(PleasantWindow.WindowStateProperty) .Subscribe(x => { PseudoClasses.Set(":minimized", x == WindowState.Minimized); PseudoClasses.Set(":normal", x == WindowState.Normal); PseudoClasses.Set(":maximized", x == WindowState.Maximized); PseudoClasses.Set(":fullscreen", x == WindowState.FullScreen); if (x == WindowState.Maximized) { _reestablishMenuItem.IsEnabled = true; _expandMenuItem.IsEnabled = false; } else { _reestablishMenuItem.IsEnabled = false; _expandMenuItem.IsEnabled = true; } if (x == WindowState.FullScreen) { _reestablishMenuItem.IsEnabled = false; _expandMenuItem.IsEnabled = false; _collapseMenuItem.IsEnabled = false; } else { _collapseMenuItem.IsEnabled = true; } }), window.GetObservable(PleasantWindow.IsActiveProperty) .Subscribe(x => { PseudoClasses.Set(":isactive", !x); }), window.GetObservable(PleasantWindow.IconProperty) .Subscribe(x => _image.Source = window.Icon.ToBitmap()), window.GetObservable(PleasantWindow.TitleProperty) .Subscribe(x => { _title.Text = x; }), window.GetObservable(PleasantWindow.LogoProperty) .Subscribe(x => { _logo.Data = x; _logo.IsVisible = (_logo.Data is null) == false; _title.IsVisible = _logo.Data is null; }), window.GetObservable(PleasantWindow.TitleBarMenuProperty) .Subscribe(x => { _titleBarMenu.Content = x; }), window.GetObservable(PleasantWindow.WindowButtonsProperty) .Subscribe(x => { switch (x) { case WindowButtons.All: _expandMenuItem.IsVisible = true; _reestablishMenuItem.IsVisible = true; _collapseMenuItem.IsVisible = true; _separator.IsVisible = true; break; case WindowButtons.CloseAndCollapse: _expandMenuItem.IsVisible = false; _reestablishMenuItem.IsVisible = false; _collapseMenuItem.IsVisible = true; _separator.IsVisible = true; break; case WindowButtons.CloseAndExpand: _expandMenuItem.IsVisible = true; _reestablishMenuItem.IsVisible = true; _collapseMenuItem.IsVisible = false; _separator.IsVisible = true; break; default: _expandMenuItem.IsVisible = false; _reestablishMenuItem.IsVisible = false; _collapseMenuItem.IsVisible = false; _separator.IsVisible = false; break; } }), window.GetObservable(PleasantWindow.ShowPinButtonProperty).Subscribe(x => { _pinButton.IsVisible = x; }), window.GetObservable(PleasantWindow.ShowCustomTitleBarProperty).Subscribe(x => { if (x) { IsVisible = true; _titlePanel.IsVisible = true; _dragWindow.IsVisible = true; _titleBarMenu.Margin = new Thickness(5, 0); _captionButtons.IsVisible = true; } else { if (window.WindowState == WindowState.FullScreen) { window.WindowState = WindowState.Normal; } _titlePanel.IsVisible = false; _dragWindow.IsVisible = false; _titleBarMenu.Margin = new Thickness(1, 0); _captionButtons.IsVisible = false; if (window.TitleBarMenu is null || window.ShowMenuBar == false) { IsVisible = false; } } }) }; } }
internal void ShowHideButtons(bool show) { PseudoClasses.Set(":acceptdismiss", show); }
private void UpdatePseudoClasses(bool isPressed) { PseudoClasses.Set(":pressed", isPressed); }
public FluentWindow(bool isSaveStatus) { #if WINDOWS PseudoClasses.Set(":windows", true); #pragma warning disable CA1416 // 验证平台兼容性 if (OperatingSystem2.IsWindows10AtLeast) { if (PlatformImpl is AvaloniaWin32WindowingPlatformImpl.Window10Impl cwi) { cwi.SetOwner(this); } } #pragma warning restore CA1416 // 验证平台兼容性 #endif TransparencyLevelHint = (WindowTransparencyLevel)UISettings.WindowBackgroundMateria.Value; if (TransparencyLevelHint == WindowTransparencyLevel.Transparent || TransparencyLevelHint == WindowTransparencyLevel.None || TransparencyLevelHint == WindowTransparencyLevel.Blur) { PseudoClasses.Set(":transparent", true); } else { PseudoClasses.Set(":transparent", false); } ExtendClientAreaToDecorationsHint = true; ExtendClientAreaTitleBarHeightHint = -1; SystemDecorations = SystemDecorations.Full; this.GetObservable(WindowStateProperty) .Subscribe(x => { PseudoClasses.Set(":maximized", x == WindowState.Maximized); PseudoClasses.Set(":fullscreen", x == WindowState.FullScreen); }); //this.GetObservable(IsExtendedIntoWindowDecorationsProperty) // .Subscribe(x => // { // SystemDecorations = SystemDecorations.Full; // //TransparencyLevelHint = WindowTransparencyLevel.AcrylicBlur; // }); if (isSaveStatus) { Opened += FluentWindow_Opened; Closing += FluentWindow_Closing; //PositionChanged += FluentWindow_PositionChanged; } #pragma warning disable CA1416 // 验证平台兼容性 if (OperatingSystem2.IsWindows) { ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.PreferSystemChrome; PseudoClasses.Add(":windows"); } else if (OperatingSystem2.IsMacOS) { ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.PreferSystemChrome; } else { ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome; } #pragma warning restore CA1416 // 验证平台兼容性 //if (!ViewModelBase.IsInDesignMode) //{ // //if (OperatingSystem2.IsWindows) // //{ // // // if (OperatingSystem2.IsWindows7) // // // { // // //#pragma warning disable CA1416 // 验证平台兼容性 // // // IPlatformService.Instance.FixAvaloniaFluentWindowStyleOnWin7(PlatformImpl.Handle.Handle); // // //#pragma warning restore CA1416 // 验证平台兼容性 // // // } // // //else if (OperatingSystem2.IsWindows10AtLeast) // // //{ // // // AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>().ForceNativeTitleBarToTheme(this); // // //} // //} //} }
private void UpdatePseudoclasses() { PseudoClasses.Set(":hastext", !string.IsNullOrWhiteSpace(Text)); }
public AlertDialogBase() { PseudoClasses.Set(":emergency", IsEmergency == true); }
private void SetEditState(bool isEditing) { PseudoClasses.Set(":editing", isEditing); }
private void UpdatePseudoClasses(Location location) { PseudoClasses.Set(":left", location == Location.Left); PseudoClasses.Set(":right", location == Location.Right); }
private void UpdatePseudoclasses() { PseudoClasses.Set(":has-previous-color", PreviousColor.HasValue); PseudoClasses.Set(":spectrum-visible", IsColorSpectrumVisible); }