示例#1
0
 internal static void SyncColumnProperty <T>(AvaloniaObject column, AvaloniaObject content, AvaloniaProperty <T> contentProperty, AvaloniaProperty <T> columnProperty)
 {
     if (!column.IsSet(columnProperty))
     {
         content.ClearValue(contentProperty);
     }
     else
     {
         content.SetValue(contentProperty, column.GetValue(columnProperty));
     }
 }
示例#2
0
        public static object UpdateDependencyColor(this AvaloniaObject depo, AvaloniaProperty dp, Color newColor)
        {
            if (!newColor.IsDefault)
            {
                depo.SetValue(dp, newColor.ToBrush());
            }
            else
            {
                depo.ClearValue(dp);
            }

            return(depo.GetValue(dp));
        }
        /// <summary>
        /// Gets a diagnostic for a <see cref="AvaloniaProperty"/> on a <see cref="AvaloniaObject"/>.
        /// </summary>
        /// <param name="o">The object.</param>
        /// <param name="property">The property.</param>
        /// <returns>
        /// A <see cref="AvaloniaPropertyValue"/> that can be used to diagnose the state of the
        /// property on the object.
        /// </returns>
        public static AvaloniaPropertyValue GetDiagnostic(this AvaloniaObject o, AvaloniaProperty property)
        {
            var set = o.GetSetValues();

            PriorityValue value;

            if (set.TryGetValue(property, out value))
            {
                return(new AvaloniaPropertyValue(
                           property,
                           o.GetValue(property),
                           (BindingPriority)value.ValuePriority,
                           value.GetDiagnostic()));
            }
            else
            {
                return(new AvaloniaPropertyValue(
                           property,
                           o.GetValue(property),
                           BindingPriority.Unset,
                           "Unset"));
            }
        }
示例#4
0
        private Layoutable?GetDependencyElement(AvaloniaProperty property, AvaloniaObject child)
        {
            var dependency = child.GetValue(property);

            if (dependency is Layoutable layoutable)
            {
                if (Children.Contains((ILayoutable)layoutable))
                {
                    return(layoutable);
                }

                throw new ArgumentException($"RelativePanel error: Element does not exist in the current context: {property.Name}");
            }

            return(null);
        }
示例#5
0
        /// <summary>
        /// Returns an <see cref="ObservableObject{T}"/> wrapper around the RegionContext value. The RegionContext
        /// will be set on any views (dependency objects) that are inside the <see cref="IRegion.Views"/> collection by
        /// the <see cref="Behaviors.BindRegionContextToAvaloniaObjectBehavior"/> Behavior.
        /// The RegionContext will also be set to the control that hosts the Region, by the <see cref="Behaviors.SyncRegionContextWithHostBehavior"/> Behavior.
        ///
        /// If the <see cref="ObservableObject{T}"/> wrapper does not already exist, an empty one will be created. This way, an observer can
        /// notify when the value is set for the first time.
        /// </summary>
        /// <param name="view">Any view that hold the RegionContext value. </param>
        /// <returns>Wrapper around the Regioncontext value. </returns>
        public static ObservableObject <object> GetObservableContext(AvaloniaObject view)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }

            ObservableObject <object> context = view.GetValue(ObservableRegionContextProperty) as ObservableObject <object>;

            if (context == null)
            {
                context = new ObservableObject <object>();
                view.SetValue(ObservableRegionContextProperty, context);
            }

            return(context);
        }
        /// <summary>
        /// Returns an <see cref="ObservableObject{T}"/> wrapper that can hold an <see cref="IRegion"/>. Using this wrapper
        /// you can detect when an <see cref="IRegion"/> has been created by the <see cref="RegionAdapterBase{T}"/>.
        ///
        /// If the <see cref="ObservableObject{T}"/> wrapper does not yet exist, a new wrapper will be created. When the region
        /// gets created and assigned to the wrapper, you can use the <see cref="ObservableObject{T}.PropertyChanged"/> event
        /// to get notified of that change.
        /// </summary>
        /// <param name="view">The view that will host the region. </param>
        /// <returns>Wrapper that can hold an <see cref="IRegion"/> value and can notify when the <see cref="IRegion"/> value changes. </returns>
        public static ObservableObject <IRegion> GetObservableRegion(AvaloniaObject view)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }

            ObservableObject <IRegion> regionWrapper = view.GetValue(ObservableRegionProperty) as ObservableObject <IRegion>;

            if (regionWrapper == null)
            {
                regionWrapper = new ObservableObject <IRegion>();
                view.SetValue(ObservableRegionProperty, regionWrapper);
            }

            return(regionWrapper);
        }
        private IEnumerable <(AvaloniaProperty, object)> CollectChangedValue(AvaloniaObject obj, IEnumerable <AvaloniaProperty> aprops)
        {
            foreach (var aprop in aprops)
            {
                if (aprop.Name == "Parent")
                {
                    continue;
                }
                if (aprop.IsReadOnly)
                {
                    continue;
                }

                if (obj.IsSet(aprop))
                {
                    var objValue = obj.GetValue(aprop);
                    yield return(aprop, objValue);
                }
            }
        }
示例#8
0
 /// <summary>
 /// Gets the value of the Bottom attached property for a control.
 /// </summary>
 /// <param name="element">The control.</param>
 /// <returns>The control's bottom coordinate.</returns>
 public static double GetBottom(AvaloniaObject element)
 {
     return element.GetValue(BottomProperty);
 }
示例#9
0
 /// <summary>
 /// Gets renderer attached property.
 /// </summary>
 /// <param name="obj">The avalonia object.</param>
 /// <returns>The shape renderer property.</returns>
 public static IShapeRenderer GetRenderer(AvaloniaObject obj)
 {
     return(obj.GetValue(RendererProperty));
 }
 public static string GetName(AvaloniaObject avaloniaObject) =>
 avaloniaObject.GetValue(NameProperty);
示例#11
0
 /// <summary>
 /// Gets the value of the RowSpan attached property for a control.
 /// </summary>
 /// <param name="element">The control.</param>
 /// <returns>The control's row span.</returns>
 public static int GetRowSpan(AvaloniaObject element)
 {
     return(element.GetValue(RowSpanProperty));
 }
示例#12
0
 public static string GetFoo(AvaloniaObject target) => (string)target.GetValue(FooProperty);
示例#13
0
 public static bool GetShowAlternation(AvaloniaObject obj)
 {
     return((bool)obj.GetValue(ShowAlternationProperty));
 }
示例#14
0
 /// <summary>
 /// Gets renderer options attached property.
 /// </summary>
 /// <param name="obj">The avalonia object.</param>
 /// <returns>The shape renderer property.</returns>
 public static ShapeRenderer GetRenderer(AvaloniaObject obj)
 {
     return obj.GetValue(RendererProperty);
 }
示例#15
0
 /// <summary>
 /// Gets the value of the Top attached property for a control.
 /// </summary>
 /// <param name="element">The control.</param>
 /// <returns>The control's top coordinate.</returns>
 public static double GetTop(AvaloniaObject element)
 {
     return element.GetValue(TopProperty);
 }
示例#16
0
 /// <summary>
 /// Gets the value of the RowSpan attached property for a control.
 /// </summary>
 /// <param name="element">The control.</param>
 /// <returns>The control's row span.</returns>
 public static int GetRowSpan(AvaloniaObject element)
 {
     return element.GetValue(RowSpanProperty);
 }
示例#17
0
 /// <summary>
 /// Gets the value of the Column attached property for a control.
 /// </summary>
 /// <param name="element">The control.</param>
 /// <returns>The control's column.</returns>
 public static int GetColumn(AvaloniaObject element)
 {
     return element.GetValue(ColumnProperty);
 }
示例#18
0
 public static SolidColorBrush GetSwitchTrackOffBackground(AvaloniaObject element)
 {
     return((SolidColorBrush)element.GetValue(SwitchTrackOffBackgroundProperty));
 }
示例#19
0
 public static bool GetIsFileDragDropEnabled(AvaloniaObject obj)
 {
     return((bool)obj.GetValue(IsFileDragDropEnabledProperty));
 }
 public static string GetLabel(AvaloniaObject element) => (string)element.GetValue(LabelProperty);
示例#21
0
 /// <summary>
 /// Gets the value of the Right attached property for a control.
 /// </summary>
 /// <param name="element">The control.</param>
 /// <returns>The control's right coordinate.</returns>
 public static double GetRight(AvaloniaObject element)
 {
     return element.GetValue(RightProperty);
 }
示例#22
0
 /// <summary>
 /// Gets the value of the BitmapInterpolationMode attached property for a control.
 /// </summary>
 /// <param name="element">The control.</param>
 /// <returns>The control's left coordinate.</returns>
 public static BitmapInterpolationMode GetBitmapInterpolationMode(AvaloniaObject element)
 {
     return(element.GetValue(BitmapInterpolationModeProperty));
 }
示例#23
0
 public static ICommand GetCommand(AvaloniaObject element)
 {
     return(element.GetValue(CommandProperty));
 }
示例#24
0
 public static KeyGesture GetHotKey(AvaloniaObject target) => target.GetValue(HotKeyProperty);
示例#25
0
 public static object GetAlignRightWith(AvaloniaObject obj)
 {
     return((object)obj.GetValue(AlignRightWithProperty));
 }
示例#26
0
 public static bool GetFileDragDropTarget(AvaloniaObject obj)
 {
     return((bool)obj.GetValue(FileDragDropTargetProperty));
 }
示例#27
0
 public static bool GetAlignVerticalCenterWithPanel(AvaloniaObject obj)
 {
     return((bool)obj.GetValue(AlignVerticalCenterWithPanelProperty));
 }
示例#28
0
 public static ISelection GetSelection(AvaloniaObject obj)
 {
     return(obj.GetValue(SelectionProperty));
 }
示例#29
0
 public static object GetAlignVerticalCenterWith(AvaloniaObject obj)
 {
     return((object)obj.GetValue(AlignVerticalCenterWithProperty));
 }
示例#30
0
 /// <summary>
 /// Gets the value of the Column attached property for a control.
 /// </summary>
 /// <param name="element">The control.</param>
 /// <returns>The control's column.</returns>
 public static int GetColumn(AvaloniaObject element)
 {
     return(element.GetValue(ColumnProperty));
 }
示例#31
0
 public static object GetBelow(AvaloniaObject obj)
 {
     return((object)obj.GetValue(BelowProperty));
 }
示例#32
0
 public static NativeMenu GetMenu(AvaloniaObject o) => o.GetValue(MenuProperty);
示例#33
0
 public static object GetAbove(AvaloniaObject obj)
 {
     return((object)obj.GetValue(AboveProperty));
 }
示例#34
0
 public static KeyGesture GetHotKey(AvaloniaObject target) => target.GetValue(HotKeyProperty);
示例#35
0
 public static object GetRightOf(AvaloniaObject obj)
 {
     return((object)obj.GetValue(RightOfProperty));
 }
示例#36
0
 /// <summary>
 /// Gets data flow attached property.
 /// </summary>
 /// <param name="obj">The avalonia object.</param>
 /// <returns>The data flow property.</returns>
 public static IDataFlow GetDataFlow(AvaloniaObject obj)
 {
     return(obj.GetValue(DataFlowProperty));
 }
示例#37
0
 public static bool GetAlignBottomWithPanel(AvaloniaObject obj)
 {
     return((bool)obj.GetValue(AlignBottomWithPanelProperty));
 }