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); }
/*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); }
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); }
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))); } }
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); }
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>(); }
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); }
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); }
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); }
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); }
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()); }
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); }
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(); } })); }
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); }
static GroupBox() { HeaderProperty = AvaloniaProperty.Register <GroupBox, string>(nameof(Header)); }
static RibbonButton() { TextProperty = AvaloniaProperty.Register <RibbonButton, string>(nameof(Text)); IconPathProperty = AvaloniaProperty.Register <RibbonButton, IBitmap>(nameof(IconPath)); }
public OwnerBinding(TabItem item, StyledProperty <T> ownerProperty) { _item = item; _ownerProperty = ownerProperty; }
static RibbonWindow() { TitleBarBackgroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarBackground)); TitleBarForegroundProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarForeground)); }
static RibbonWindow() { TitleBarColorProperty = AvaloniaProperty.Register <RibbonWindow, IBrush>(nameof(TitleBarColor)); }
static StyledWindow() { HeaderContentProperty = AvaloniaProperty.Register <StyledWindow, object>(nameof(HeaderContent)); IsModalProperty = AvaloniaProperty.Register <StyledWindow, bool>(nameof(IsModal)); }
static RibbonControl() { RemainingTabControlHeaderColorProperty = AvaloniaProperty.Register <RibbonControl, IBrush>(nameof(RemainingTabControlHeaderColor)); }
static Class2() { StyledProperty.OverrideDefaultValue <Class2>("bar"); DirectProperty.OverrideMetadata <Class2>(new DirectPropertyMetadata <string>("bar")); }
static RibbonView() { IsRibbonExpandedProperty = AvaloniaProperty.Register <RibbonView, bool>(nameof(IsRibbonExpanded), true); }
static RibbonButton() { SizeProperty = AvaloniaProperty.Register <RibbonButton, RibbonControlSize>(nameof(RibbonControlSize), RibbonControlSize.Large); CanAddToQuickAccessToolbarProperty = AvaloniaProperty.Register <RibbonButton, bool>(nameof(CanAddToQuickAccessToolbar), true); }