Esempio n. 1
0
 public DropDownItem()
 {
     this.GetObservable(DropDownItem.IsFocusedProperty).Subscribe(focused =>
     {
         PseudoClasses.Set(":selected", focused);
     });
 }
Esempio n. 2
0
 protected virtual void OnDragLeave(object sender, RoutedEventArgs e)
 {
     if (Parent is AuraTabView atw && atw.ImmediateDrag)
     {
         PseudoClasses.Remove(":dragging");
     }
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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)}");
            }
        }
Esempio n. 5
0
        private void UpdatePseudoClasses()
        {
            PseudoClasses.Remove(PseudoClass_Active);
            PseudoClasses.Remove(PseudoClass_Inactive);

            PseudoClasses.Add(IsActive ? PseudoClass_Active : PseudoClass_Inactive);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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))
                };
            }
        }
Esempio n. 8
0
        /// <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);
        }
Esempio n. 9
0
 private void HeaderChanged(AvaloniaPropertyChangedEventArgs e)
 {
     if (e.NewValue is string newValue && newValue == "-")
     {
         PseudoClasses.Add(":separator");
         Focusable = false;
     }
Esempio n. 10
0
        /// <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);
        }
Esempio n. 11
0
        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;
            }
        }
Esempio n. 13
0
 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);
 }
Esempio n. 14
0
        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
        }
Esempio n. 15
0
        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();
        }
Esempio n. 16
0
        protected override void OnSelectionChanged(object sender, AvaloniaPropertyChangedEventArgs e)
        {
            base.OnSelectionChanged(sender, e);

            PseudoClasses.Remove(":normal");
            PseudoClasses.Add(":normal");
        }
Esempio n. 17
0
 protected virtual void OnDragStarted(object sender, DragEventArgs e)
 {
     if (Parent is AuraTabView atw && !atw.ImmediateDrag)
     {
         PseudoClasses.Add(":dragging");
     }
 }
Esempio n. 18
0
        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];
            }
        }
Esempio n. 19
0
        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;
        }
Esempio n. 21
0
        public SplitView()
        {
            PseudoClasses.Add(":overlay");
            PseudoClasses.Add(":left");

            TemplateSettings = new SplitViewTemplateSettings();
        }
Esempio n. 22
0
        //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);
        }
Esempio n. 23
0
        private void UpdateVisualState()
        {
            //states :headertextcollapsed, :headertextvisible
            bool collapsed = _isClosedCompact && IsTopLevelItem;

            PseudoClasses.Set(":headertextcollapsed", collapsed);
            PseudoClasses.Set(":headertextvisible", !collapsed);
        }
Esempio n. 24
0
 public NavigationView()
 {
     PseudoClasses.Add(":normal");
     this.GetObservable(BoundsProperty).Subscribe(async(bounds) =>
     {
         OnBoundsChanged(bounds);
     });
 }
Esempio n. 25
0
        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);
        }
Esempio n. 26
0
 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);
 }
Esempio n. 27
0
        internal void UpdatePseudoClasses()
        {
            PseudoClasses.Set(":current", IsCurrent);

            if (RowGroupInfo?.CollectionViewGroup != null)
            {
                PseudoClasses.Set(":expanded", RowGroupInfo.IsVisible && RowGroupInfo.CollectionViewGroup.ItemCount > 0);
            }
        }
Esempio n. 28
0
 //TODO Implement
 internal void UpdatePseudoClasses()
 {
     PseudoClasses.Set(":selected", IsSelected);
     PseudoClasses.Set(":editing", IsEditing);
     if (RootElement != null && OwningGrid != null && IsVisible)
     {
         ApplyHeaderStatus();
     }
 }
Esempio n. 29
0
        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);
            }
        }
Esempio n. 30
0
        public void Pause()
        {
            if (soundStream != null)
            {
                soundStream.Play();
            }

            PseudoClasses.Remove(":playing");
            PseudoClasses.Add(":paused");
        }