예제 #1
0
        static RibbonSplitButton()
        {
            CommandProperty          = Button.CommandProperty.AddOwner <RibbonSplitButton>(button => button.Command, (button, command) => button.Command = command);
            CommandParameterProperty = Button.CommandParameterProperty.AddOwner <RibbonSplitButton>();

            Button.FocusableProperty.OverrideDefaultValue <RibbonSplitButton>(false);
        }
예제 #2
0
        /*public static readonly StyledProperty<WindowState> WindowStateProperty;
         * public WindowState WindowState
         * {
         *  get => GetValue(WindowStateProperty);
         *  set => SetValue(WindowStateProperty, value);
         * }
         *
         * public static readonly DirectProperty<RibbonWindow, bool> IsActiveProperty;
         * public bool IsActive
         * {
         *  get => GetValue(IsActiveProperty);
         *  set => SetValue(IsActiveProperty, value);
         * }*/

        static RibbonWindow()
        {
            TitleBarBackgroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarBackground));
            TitleBarForegroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarForeground));

            /*WindowStateProperty = Window.WindowStateProperty.AddOwner<RibbonWindow>();
             * IsActiveProperty = Window.IsActiveProperty.AddOwner<RibbonWindow>(x => x.IsActive, (x, o) => x.IsActive = o);*/
            //HasSystemDecorationsProperty.OverrideDefaultValue(typeof(RibbonWindow), false);
        }
예제 #3
0
        public void AddOwnered_Property_Should_Be_Same()
        {
            var p1 = new StyledProperty<string>(
                "p1",
                typeof(Class1),
                new StyledPropertyMetadata<string>());
            var p2 = p1.AddOwner<Class2>();

            Assert.Same(p1, p2);
        }
예제 #4
0
        private static void ValueChangedCallback(StyledProperty d, AvaloniaPropertyChangedEventArgs e)
        {
            ObservableObject <T>        thisInstance = ((ObservableObject <T>)d);
            PropertyChangedEventHandler eventHandler = thisInstance.PropertyChanged;

            if (eventHandler != null)
            {
                eventHandler(thisInstance, new PropertyChangedEventArgs(nameof(Value)));
            }
        }
예제 #5
0
        public void AddOwnered_Property_Should_Be_Same()
        {
            var p1 = new StyledProperty <string>(
                "p1",
                typeof(Class1),
                new StyledPropertyMetadata <string>());
            var p2 = p1.AddOwner <Class2>();

            Assert.Same(p1, p2);
        }
예제 #6
0
 static RibbonComboButton()
 {
     ContentProperty   = RibbonButton.ContentProperty.AddOwner <RibbonComboButton>();
     IconProperty      = RibbonButton.IconProperty.AddOwner <RibbonComboButton>();
     LargeIconProperty = AvaloniaProperty.Register <RibbonButton, object>(nameof(LargeIcon), null);
     SizeProperty      = RibbonButton.SizeProperty.AddOwner <RibbonComboButton>();
     CanAddToQuickAccessToolbarProperty = RibbonButton.CanAddToQuickAccessToolbarProperty.AddOwner <RibbonComboButton>();
     CommandProperty          = Button.CommandProperty.AddOwner <RibbonComboButton>(button => button.Command, (button, command) => button.Command = command);
     CommandParameterProperty = Button.CommandParameterProperty.AddOwner <RibbonComboButton>();
 }
예제 #7
0
        private bool ComputeScrollBarLengths(Size arrangeSize, double viewportSize, bool isVertical, out double decreaseButtonLength, out double thumbLength, out double increaseButtonLength)
        {
            var    min            = Minimum;
            var    range          = Math.Max(0.0, Maximum - min);
            var    offset         = Math.Min(range, Value - min);
            var    extent         = Math.Max(0.0, range) + viewportSize;
            var    trackLength    = isVertical ? arrangeSize.Height : arrangeSize.Width;
            double thumbMinLength = 10;

            StyledProperty <double> minLengthProperty = isVertical ? MinHeightProperty : MinWidthProperty;

            var thumb = Thumb;

            if (thumb != null && thumb.IsSet(minLengthProperty))
            {
                thumbMinLength = thumb.GetValue(minLengthProperty);
            }

            thumbLength = trackLength * viewportSize / extent;
            CoerceLength(ref thumbLength, trackLength);
            thumbLength = Math.Max(thumbMinLength, thumbLength);

            // If we don't have enough content to scroll, disable the track.
            var notEnoughContentToScroll = MathUtilities.LessThanOrClose(range, 0.0);
            var thumbLongerThanTrack     = thumbLength > trackLength;

            // if there's not enough content or the thumb is longer than the track,
            // hide the track and don't arrange the pieces
            if (notEnoughContentToScroll || thumbLongerThanTrack)
            {
                ShowChildren(false);
                ThumbCenterOffset    = Double.NaN;
                Density              = Double.NaN;
                decreaseButtonLength = 0.0;
                increaseButtonLength = 0.0;
                return(false); // don't arrange
            }
            else
            {
                ShowChildren(true);
            }

            // Compute lengths of increase and decrease button
            double remainingTrackLength = trackLength - thumbLength;

            decreaseButtonLength = remainingTrackLength * offset / range;
            CoerceLength(ref decreaseButtonLength, remainingTrackLength);

            increaseButtonLength = remainingTrackLength - decreaseButtonLength;
            CoerceLength(ref increaseButtonLength, remainingTrackLength);

            Density = range / remainingTrackLength;

            return(true);
        }
예제 #8
0
 static Ribbon()
 {
     OrientationProperty = StackLayout.OrientationProperty.AddOwner <Ribbon>();
     OrientationProperty.OverrideDefaultValue <Ribbon>(Orientation.Horizontal);
     HeaderBackgroundProperty = AvaloniaProperty.Register <Ribbon, IBrush>(nameof(HeaderBackground));
     HeaderForegroundProperty = AvaloniaProperty.Register <Ribbon, IBrush>(nameof(HeaderForeground));
     IsCollapsedProperty      = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsCollapsed));
     IsMenuOpenProperty       = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsMenuOpen));
     MenuItemsProperty        = MenuBase.ItemsProperty.AddOwner <Ribbon>(x => x.MenuItems, (x, v) => x.MenuItems = v);
     MenuPlacesItemsProperty  = ItemsControl.ItemsProperty.AddOwner <Ribbon>(x => x.MenuPlacesItems, (x, v) => x.MenuPlacesItems = v);
 }
예제 #9
0
        public void AddOwnered_Property_Should_Equal_Original()
        {
            var p1 = new StyledProperty <string>(
                "p1",
                typeof(Class1),
                new StyledPropertyMetadata <string>());
            var p2 = p1.AddOwner <Class2>();

            Assert.Equal(p1, p2);
            Assert.Equal(p1.GetHashCode(), p2.GetHashCode());
            Assert.True(p1 == p2);
        }
예제 #10
0
        public void AddOwnered_Property_Should_Equal_Original()
        {
            var p1 = new StyledProperty<string>(
                "p1", 
                typeof(Class1), 
                new StyledPropertyMetadata<string>());
            var p2 = p1.AddOwner<Class2>();

            Assert.Equal(p1, p2);
            Assert.Equal(p1.GetHashCode(), p2.GetHashCode());
            Assert.True(p1 == p2);
        }
예제 #11
0
        static Ribbon()
        {
            OrientationProperty = StackLayout.OrientationProperty.AddOwner <Ribbon>();
            OrientationProperty.OverrideDefaultValue <Ribbon>(Orientation.Horizontal);
            HeaderBackgroundProperty     = AvaloniaProperty.Register <Ribbon, IBrush>(nameof(HeaderBackground));
            HeaderForegroundProperty     = AvaloniaProperty.Register <Ribbon, IBrush>(nameof(HeaderForeground));
            IsCollapsedProperty          = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsCollapsed));
            IsCollapsedPopupOpenProperty = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsCollapsedPopupOpen));
            IsMenuOpenProperty           = AvaloniaProperty.Register <Ribbon, bool>(nameof(IsMenuOpen));

            SelectedIndexProperty.Changed.AddClassHandler <Ribbon>((x, e) =>
            {
                if (((int)e.NewValue >= 0) && (x.SelectedItem != null) && (x.SelectedItem is RibbonTab tab))
                {
                    x.SelectedGroups = tab.Groups;
                }
                else
                {
                    x.SelectedGroups = new AvaloniaList <object>();
                }
            });

            IsCollapsedProperty.Changed.AddClassHandler(new Action <Ribbon, AvaloniaPropertyChangedEventArgs>((sneder, args) =>
            {
                sneder.UpdatePresenterLocation((bool)args.NewValue);
            }));

            AccessKeyHandler.AccessKeyPressedEvent.AddClassHandler <Ribbon>((sender, e) =>
            {
                if (e.Source is Control ctrl)
                {
                    (sender as Ribbon).HandleKeyTipControl(ctrl);
                }
            });

            KeyTip.ShowChildKeyTipKeysProperty.Changed.AddClassHandler <Ribbon>(new Action <Ribbon, AvaloniaPropertyChangedEventArgs>((sender, args) =>
            {
                bool isOpen = (bool)args.NewValue;
                if (isOpen)
                {
                    sender.Focus();
                }
                sender.SetChildKeyTipsVisibility(isOpen);
            }));

            HelpButtonCommandProperty = AvaloniaProperty.RegisterDirect <Ribbon, ICommand>(nameof(HelpButtonCommand), o => o.HelpButtonCommand, (o, v) => o.HelpButtonCommand = v);

            BoundsProperty.Changed.AddClassHandler <RibbonGroupsStackPanel>((sender, e) => sender.InvalidateMeasure());
        }
예제 #12
0
        static RibbonSplitButton()
        {
            ContentProperty   = RibbonButton.ContentProperty.AddOwner <RibbonSplitButton>();
            IconProperty      = RibbonButton.IconProperty.AddOwner <RibbonSplitButton>();
            LargeIconProperty = AvaloniaProperty.Register <RibbonButton, object>(nameof(LargeIcon), null);
            //SizeProperty = RibbonButton.SizeProperty.AddOwner<RibbonComboButton>();
            //MinSizeProperty = RibbonButton.MinSizeProperty.AddOwner<RibbonComboButton>();
            //MaxSizeProperty = RibbonButton.MaxSizeProperty.AddOwner<RibbonComboButton>();
            //CanAddToQuickAccessToolbarProperty = RibbonButton.CanAddToQuickAccessToolbarProperty.AddOwner<RibbonComboButton>();
            CommandProperty          = Button.CommandProperty.AddOwner <RibbonSplitButton>(button => button.Command, (button, command) => button.Command = command);
            CommandParameterProperty = Button.CommandParameterProperty.AddOwner <RibbonSplitButton>();
            //AffectsRender<RibbonComboButton>(SizeProperty, MinSizeProperty, MaxSizeProperty);
            //AffectsMeasure<RibbonComboButton>(SizeProperty, MinSizeProperty, MaxSizeProperty);
            //AffectsArrange<RibbonComboButton>(SizeProperty, MinSizeProperty, MaxSizeProperty);
            //RibbonControLHelper<RibbonComboButton>.AddHandlers(MinSizeProperty, MaxSizeProperty);
            RibbonControlHelper <RibbonSplitButton> .SetProperties(out SizeProperty, out MinSizeProperty, out MaxSizeProperty);

            Button.FocusableProperty.OverrideDefaultValue <RibbonSplitButton>(false);
        }
예제 #13
0
        public IDisposable BindConstraints(AvaloniaObject popup, StyledProperty <double> widthProperty, StyledProperty <double> minWidthProperty,
                                           StyledProperty <double> maxWidthProperty, StyledProperty <double> heightProperty, StyledProperty <double> minHeightProperty,
                                           StyledProperty <double> maxHeightProperty, StyledProperty <bool> topmostProperty)
        {
            var bindings = new List <IDisposable>();

            void Bind(AvaloniaProperty what, AvaloniaProperty to) => bindings.Add(this.Bind(what, popup[~to]));

            Bind(WidthProperty, widthProperty);
            Bind(MinWidthProperty, minWidthProperty);
            Bind(MaxWidthProperty, maxWidthProperty);
            Bind(HeightProperty, heightProperty);
            Bind(MinHeightProperty, minHeightProperty);
            Bind(MaxHeightProperty, maxHeightProperty);
            Bind(TopmostProperty, topmostProperty);
            return(Disposable.Create(() =>
            {
                foreach (var x in bindings)
                {
                    x.Dispose();
                }
            }));
        }
예제 #14
0
 static RibbonTabGroup()
 {
     TextProperty    = AvaloniaProperty.Register <RibbonTabGroup, string>(nameof(Text));
     CommandProperty = AvaloniaProperty.RegisterDirect <RibbonTabGroup, ICommand>(nameof(Command), button => button.Command, (button, command) => button.Command = command, enableDataValidation: true);
 }
예제 #15
0
 static GroupBox()
 {
     HeaderProperty = AvaloniaProperty.Register <GroupBox, string>(nameof(Header));
 }
예제 #16
0
 static RibbonButton()
 {
     TextProperty     = AvaloniaProperty.Register <RibbonButton, string>(nameof(Text));
     IconPathProperty = AvaloniaProperty.Register <RibbonButton, IBitmap>(nameof(IconPath));
 }
예제 #17
0
 public OwnerBinding(TabItem item, StyledProperty <T> ownerProperty)
 {
     _item          = item;
     _ownerProperty = ownerProperty;
 }
예제 #18
0
 static RibbonWindow()
 {
     TitleBarBackgroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarBackground));
     TitleBarForegroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarForeground));
 }
예제 #19
0
 static RibbonWindow()
 {
     TitleBarColorProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarColor));
 }
예제 #20
0
 static StyledWindow()
 {
     HeaderContentProperty = AvaloniaProperty.Register <StyledWindow, object>(nameof(HeaderContent));
     IsModalProperty       = AvaloniaProperty.Register <StyledWindow, bool>(nameof(IsModal));
 }
예제 #21
0
 static RibbonControl()
 {
     RemainingTabControlHeaderColorProperty = AvaloniaProperty.Register <RibbonControl, IBrush>(nameof(RemainingTabControlHeaderColor));
 }
예제 #22
0
 static Class2()
 {
     StyledProperty.OverrideDefaultValue <Class2>("bar");
     DirectProperty.OverrideMetadata <Class2>(new DirectPropertyMetadata <string>("bar"));
 }
예제 #23
0
 static RibbonView()
 {
     IsRibbonExpandedProperty = AvaloniaProperty.Register <RibbonView, bool>(nameof(IsRibbonExpanded), true);
 }
예제 #24
0
 static RibbonButton()
 {
     SizeProperty = AvaloniaProperty.Register <RibbonButton, RibbonControlSize>(nameof(RibbonControlSize), RibbonControlSize.Large);
     CanAddToQuickAccessToolbarProperty = AvaloniaProperty.Register <RibbonButton, bool>(nameof(CanAddToQuickAccessToolbar), true);
 }