Esempio n. 1
0
 /// <summary>
 /// Called when a property changes that should invalidate the visual.
 /// </summary>
 /// <param name="e">The event args.</param>
 private static void AffectsRenderInvalidate(AvaloniaPropertyChangedEventArgs e)
 {
     (e.Sender as Visual)?.InvalidateVisual();
 }
Esempio n. 2
0
        /// <summary>
        /// Called when a visual's <see cref="RenderTransform"/> changes.
        /// </summary>
        /// <param name="e">The event args.</param>
        private static void RenderTransformChanged(AvaloniaPropertyChangedEventArgs e)
        {
            var sender = e.Sender as Visual;

            if (sender?.VisualRoot != null)
            {
                var oldValue = e.OldValue as Transform;
                var newValue = e.NewValue as Transform;

                if (oldValue != null)
                {
                    oldValue.Changed -= sender.RenderTransformChanged;
                }

                if (newValue != null)
                {
                    newValue.Changed += sender.RenderTransformChanged;
                }

                sender.InvalidateVisual();
            }
        }
 /// <summary>
 /// Notifies the <see cref="Changed"/> observable.
 /// </summary>
 /// <param name="e">The observable arguments.</param>
 internal void NotifyChanged(AvaloniaPropertyChangedEventArgs e)
 {
     _changed.OnNext(e);
 }
 /// <summary>
 /// Notifies the <see cref="Initialized"/> observable.
 /// </summary>
 /// <param name="e">The observable arguments.</param>
 internal void NotifyInitialized(AvaloniaPropertyChangedEventArgs e)
 {
     _initialized.OnNext(e);
 }
Esempio n. 5
0
 /// <summary>
 /// Called when a avalonia property changes on the object.
 /// </summary>
 /// <param name="e">The event arguments.</param>
 protected virtual void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e)
 {
 }
Esempio n. 6
0
 /// <summary>
 /// Called when a property changes that should invalidate the visual.
 /// </summary>
 /// <param name="e">The event args.</param>
 private static void AffectsRenderInvalidate(AvaloniaPropertyChangedEventArgs e)
 {
     (e.Sender as Visual)?.InvalidateVisual();
 }
Esempio n. 7
0
        internal void NotifyInitialized(AvaloniaObject o)
        {
            Contract.Requires <ArgumentNullException>(o != null);

            var type = o.GetType();

            void Notify(AvaloniaProperty property, object value)
            {
                var e = new AvaloniaPropertyChangedEventArgs(
                    o,
                    property,
                    AvaloniaProperty.UnsetValue,
                    value,
                    BindingPriority.Unset);

                property.NotifyInitialized(e);
            }

            if (!_initializedCache.TryGetValue(type, out var initializationData))
            {
                var visited = new HashSet <AvaloniaProperty>();

                initializationData = new List <PropertyInitializationData>();

                foreach (AvaloniaProperty property in GetRegistered(type))
                {
                    if (property.IsDirect)
                    {
                        initializationData.Add(new PropertyInitializationData(property, (IDirectPropertyAccessor)property));
                    }
                    else
                    {
                        initializationData.Add(new PropertyInitializationData(property, (IStyledPropertyAccessor)property, type));
                    }

                    visited.Add(property);
                }

                foreach (AvaloniaProperty property in GetRegisteredAttached(type))
                {
                    if (!visited.Contains(property))
                    {
                        initializationData.Add(new PropertyInitializationData(property, (IStyledPropertyAccessor)property, type));

                        visited.Add(property);
                    }
                }

                _initializedCache.Add(type, initializationData);
            }

            foreach (PropertyInitializationData data in initializationData)
            {
                if (!data.Property.HasNotifyInitializedObservers)
                {
                    continue;
                }

                object value = data.IsDirect ? data.DirectAccessor.GetValue(o) : data.Value;

                Notify(data.Property, value);
            }
        }