public DropDownItem() { this.GetObservable(DropDownItem.IsFocusedProperty).Subscribe(focused => { PseudoClasses.Set(":selected", focused); }); }
protected virtual void OnDragLeave(object sender, RoutedEventArgs e) { if (Parent is AuraTabView atw && atw.ImmediateDrag) { PseudoClasses.Remove(":dragging"); } }
internal void SelectSingleItemCore(object item) { if (SelectedItem != item) { PseudoClasses.Remove(":normal"); PseudoClasses.Add(":normal"); } if (SelectedItem is not null) { (SelectedItem as ISelectable).IsSelected = false; } (item as ISelectable).IsSelected = true; SelectedItems.Clear(); SelectedItems.Add(item); var item_parents = (item as ILogical).GetLogicalAncestors().OfType <NavigationViewItem>(); if (this.IsOpen) { foreach (NavigationViewItem n in item_parents) { n.IsExpanded = true; } } // Debug.WriteLine($"{item_parents.Count()}"); SelectedItem = item; }
protected virtual void OnDrop(object sender, DragEventArgs e) { PseudoClasses.Remove(":dragging"); if (true) //TODO: check if theirs parent are the same { ItemsControlOperations.MoveItemOnDrop <AuraTabView, AuraTabItem>( sender, e, (view, src, item) => { int h = (view.Items as IList).IndexOf(item); item.PseudoClasses.Remove(":dragging"); view.lastselectindex = view.SelectedIndex; view.SelectedIndex = h; view.SelectedItem = (view.Items as IList)[view.SelectedIndex]; var it = view.Items as IList <AuraTabItem>; }); Debug.WriteLine("Drag completed"); Debug.WriteLine($"Selected Index: {this.GetParentTOfLogical<AuraTabView>().SelectedIndex}"); Debug.WriteLine($"Tab Index: {(this.GetParentTOfLogical<AuraTabView>().Items as IList).IndexOf(this)}"); } }
private void UpdatePseudoClasses() { PseudoClasses.Remove(PseudoClass_Active); PseudoClasses.Remove(PseudoClass_Inactive); PseudoClasses.Add(IsActive ? PseudoClass_Active : PseudoClass_Inactive); }
public MainWindow() { this.WhenActivated(disposables => { /* Handle view activation etc. */ }); 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; } }); this.WhenActivated(disposables => { }); AvaloniaXamlLoader.Load(this); }
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { base.OnAttachedToVisualTree(e); if (VisualRoot is Window window) { _disposables = new CompositeDisposable { window.GetObservable(Window.WindowDecorationMarginProperty) .Subscribe(x => UpdateSize(window)), window.GetObservable(Window.ExtendClientAreaTitleBarHeightHintProperty) .Subscribe(x => UpdateSize(window)), window.GetObservable(Window.OffScreenMarginProperty) .Subscribe(x => UpdateSize(window)), window.GetObservable(Window.ExtendClientAreaChromeHintsProperty) .Subscribe(x => UpdateSize(window)), window.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); }), window.GetObservable(Window.IsExtendedIntoWindowDecorationsProperty) .Subscribe(x => UpdateSize(window)) }; } }
/// <summary> /// adds the pseudo class by <see cref="StepBar.Dock"/> property /// </summary> /// <param name="context"></param> public override void Render(DrawingContext context) { StepBar stepBar = Parent as StepBar; Dock currentDock = stepBar.Dock; if (_lastDock == null || _lastDock.Value != currentDock) { pseudoClassesToClear.ForEach(x => Classes.Remove(x)); switch (currentDock) { case Dock.Top: PseudoClasses.Add(StepBar_Dock_Top_Class); break; case Dock.Left: PseudoClasses.Add(StepBar_Dock_Left_Class); break; case Dock.Bottom: PseudoClasses.Add(StepBar_Dock_Bottom_Class); break; case Dock.Right: PseudoClasses.Add(StepBar_Dock_Right_Class); break; } _lastDock = currentDock; } base.Render(context); }
private void HeaderChanged(AvaloniaPropertyChangedEventArgs e) { if (e.NewValue is string newValue && newValue == "-") { PseudoClasses.Add(":separator"); Focusable = false; }
/// <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); PseudoClasses.Set(":singleitem", collection != null && collection.Count == 1); }
public FluentWindow() { ExtendClientAreaToDecorationsHint = true; ExtendClientAreaTitleBarHeightHint = -1; TransparencyLevelHint = WindowTransparencyLevel.AcrylicBlur; Opacity = 0.5; 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; } }); }
private void ComboBox_PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e) { ComboBox comboBox = sender as ComboBox; if (e.Property.Name == nameof(ComboBox.IsVisible)) { PseudoClasses.Set(":comboBoxIsVisible", comboBox.IsVisible); } if (e.Property.Name == nameof(ComboBox.IsDropDownOpen)) { if (_oldValue == comboBox.IsDropDownOpen) { return; } if (comboBox.IsDropDownOpen == false) { comboBox_DropDownClosed(comboBox, EventArgs.Empty); } else { } _oldValue = comboBox.IsDropDownOpen; } }
private void UpdatePseudoClasses(NotificationPosition position) { PseudoClasses.Set(":topleft", position == NotificationPosition.TopLeft); PseudoClasses.Set(":topright", position == NotificationPosition.TopRight); PseudoClasses.Set(":bottomleft", position == NotificationPosition.BottomLeft); PseudoClasses.Set(":bottomright", position == NotificationPosition.BottomRight); }
internal void SelectSingleItem(object item) { if (SelectedItem != item) { PseudoClasses.Remove(":normal"); PseudoClasses.Add(":normal"); } (SelectedItem as ISelectable).IsSelected = false; SelectedItems.Clear(); SelectedItems.Add(item); (item as ISelectable).IsSelected = true; var item_parents = (item as ILogical).GetLogicalAncestors().OfType <NavigationViewItem>(); foreach (NavigationViewItem n in item_parents) { n.IsExpanded = true; } Debug.WriteLine($"{item_parents.Count()}"); SelectedItem = item; //Sets the items of AutoCompleteBox }
private void UpdateActiveState() { PseudoClasses.Remove(PseudoClass_Inactive); PseudoClasses.Remove(PseudoClass_Active); Action action; PseudoClasses.Set(PseudoClass_Active, IsActive); PseudoClasses.Set(PseudoClass_Inactive, IsActive == false); //if (IsActive) //{ /*action = () =>*/ // this.PseudoClasses.Add(PseudoClass_Active); //} //else ///*action = () =>*/ //{ // this.PseudoClasses.Add(PseudoClass_Inactive); //} //if (_deferredActions != null) // _deferredActions.Add(action); //else // action(); }
protected override void OnSelectionChanged(object sender, AvaloniaPropertyChangedEventArgs e) { base.OnSelectionChanged(sender, e); PseudoClasses.Remove(":normal"); PseudoClasses.Add(":normal"); }
protected virtual void OnDragStarted(object sender, DragEventArgs e) { if (Parent is AuraTabView atw && !atw.ImmediateDrag) { PseudoClasses.Add(":dragging"); } }
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { base.OnAttachedToVisualTree(e); _grid = this.GetVisualParent <Grid>(); _orientation = DetectOrientation(); int defenitionIndex; //row or col if (_orientation == Orientation.Vertical) { Cursor = new Cursor(StandardCursorType.SizeWestEast); _definitions = _grid.ColumnDefinitions.Cast <DefinitionBase>().ToList(); defenitionIndex = GetValue(Grid.ColumnProperty); PseudoClasses.Add(":vertical"); } else { Cursor = new Cursor(StandardCursorType.SizeNorthSouth); defenitionIndex = GetValue(Grid.RowProperty); _definitions = _grid.RowDefinitions.Cast <DefinitionBase>().ToList(); PseudoClasses.Add(":horizontal"); } if (defenitionIndex > 0) { _prevDefinition = _definitions[defenitionIndex - 1]; } if (defenitionIndex < _definitions.Count - 1) { _nextDefinition = _definitions[defenitionIndex + 1]; } }
public FluentWindow() { ExtendClientAreaToDecorationsHint = true; ExtendClientAreaTitleBarHeightHint = -1; FontFamily.Parse("avares://InDepthSearch/Assets/Fonts#Roboto"); TransparencyLevelHint = WindowTransparencyLevel.AcrylicBlur; this.GetObservable(WindowStateProperty) .Subscribe(x => { PseudoClasses.Set(":maximized", x == WindowState.Maximized); PseudoClasses.Set(":fullscreen", x == WindowState.FullScreen); if (x == WindowState.Maximized) { Padding = Thickness.Parse("8"); // https://github.com/AvaloniaUI/Avalonia/issues/5581 } else { Padding = Thickness.Parse("0"); } }); this.GetObservable(IsExtendedIntoWindowDecorationsProperty) .Subscribe(x => { if (!x) { SystemDecorations = SystemDecorations.Full; TransparencyLevelHint = WindowTransparencyLevel.Blur; } }); }
private void KnobsPanel_PointerReleased(object?sender, Input.PointerReleasedEventArgs e) { if (_isDragging) { bool shouldBecomeChecked = Canvas.GetLeft(_knobsPanel !) >= (_switchKnob !.Bounds.Width / 2); _knobsPanel !.ClearValue(Canvas.LeftProperty); PseudoClasses.Set(":dragging", false); if (shouldBecomeChecked == IsChecked) { UpdateKnobPos(shouldBecomeChecked); } else { IsChecked = shouldBecomeChecked; } } else { base.Toggle(); } _isDragging = false; _knobsPanelPressed = false; }
public SplitView() { PseudoClasses.Add(":overlay"); PseudoClasses.Add(":left"); TemplateSettings = new SplitViewTemplateSettings(); }
//TODO Implement internal void ApplyState() { /* // Common States if (IsPressed && DataGridColumnHeader._dragMode != DragMode.Resize) { VisualStates.GoToState(this, useTransitions, VisualStates.StatePressed, VisualStates.StateMouseOver, VisualStates.StateNormal); } else if (IsMouseOver && DataGridColumnHeader._dragMode != DragMode.Resize) { VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal); } // Sort States CurrentSortingState = null; if (OwningGrid != null && OwningGrid.DataConnection != null && OwningGrid.DataConnection.AllowSort) { SortDescription? sort = OwningColumn.GetSortDescription(); if (sort.HasValue) { CurrentSortingState = sort.Value.Direction; if (CurrentSortingState == ListSortDirection.Ascending) { VisualStates.GoToState(this, useTransitions, VisualStates.StateSortAscending, VisualStates.StateUnsorted); } if (CurrentSortingState == ListSortDirection.Descending) { VisualStates.GoToState(this, useTransitions, VisualStates.StateSortDescending, VisualStates.StateUnsorted); } } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateUnsorted); } } */ CurrentSortingState = null; if (OwningGrid != null && OwningGrid.DataConnection != null && OwningGrid.DataConnection.AllowSort) { var sort = OwningColumn.GetSortDescription(); if(sort != null) { CurrentSortingState = sort.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending; } } PseudoClasses.Set(":sortascending", CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Ascending); PseudoClasses.Set(":sortdescending", CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Descending); }
private void UpdateVisualState() { //states :headertextcollapsed, :headertextvisible bool collapsed = _isClosedCompact && IsTopLevelItem; PseudoClasses.Set(":headertextcollapsed", collapsed); PseudoClasses.Set(":headertextvisible", !collapsed); }
public NavigationView() { PseudoClasses.Add(":normal"); this.GetObservable(BoundsProperty).Subscribe(async(bounds) => { OnBoundsChanged(bounds); }); }
public DatePicker() { PseudoClasses.Set(":hasnodate", true); var now = DateTimeOffset.Now; _minYear = new DateTimeOffset(now.Date.Year - 100, 1, 1, 0, 0, 0, now.Offset); _maxYear = new DateTimeOffset(now.Date.Year + 100, 12, 31, 0, 0, 0, now.Offset); }
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) { base.OnDetachedFromVisualTree(e); // if enter is used, sometimes this can get stuck (popup etc) // Just make sure we reset it SetValue(IsPressedProperty, false); PseudoClasses.Set(":pressed", false); PseudoClasses.Set(":pointerover", false); }
internal void UpdatePseudoClasses() { PseudoClasses.Set(":current", IsCurrent); if (RowGroupInfo?.CollectionViewGroup != null) { PseudoClasses.Set(":expanded", RowGroupInfo.IsVisible && RowGroupInfo.CollectionViewGroup.ItemCount > 0); } }
//TODO Implement internal void UpdatePseudoClasses() { PseudoClasses.Set(":selected", IsSelected); PseudoClasses.Set(":editing", IsEditing); if (RootElement != null && OwningGrid != null && IsVisible) { ApplyHeaderStatus(); } }
protected override void OnPropertyChanged <T>(AvaloniaPropertyChangedEventArgs <T> change) { base.OnPropertyChanged(change); if (change.Property == WindowStateProperty) { PseudoClasses.Set(":maximised", change.NewValue.HasValue && change.NewValue.GetValueOrDefault <WindowState>() == WindowState.Maximized); } }
public void Pause() { if (soundStream != null) { soundStream.Play(); } PseudoClasses.Remove(":playing"); PseudoClasses.Add(":paused"); }