示例#1
0
        /// <summary>
        /// <see cref="PropertyMetadata.PropertyChangedCallback"/>
        /// </summary>
        private static void OnSharedSizeGroupPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DefinitionBase definition = (DefinitionBase)d;

            if (definition.InParentLogicalTree)
            {
                string sharedSizeGroupId = (string)e.NewValue;

                if (definition._sharedState != null)
                {
                    //  if definition is already registered AND shared size group id is changing,
                    //  then un-register the definition from the current shared size state object.
                    definition._sharedState.RemoveMember(definition);
                    definition._sharedState = null;
                }

                if ((definition._sharedState == null) && (sharedSizeGroupId != null))
                {
                    SharedSizeScope privateSharedSizeScope = definition.PrivateSharedSizeScope;
                    if (privateSharedSizeScope != null)
                    {
                        //  if definition is not registered and both: shared size group id AND private shared scope
                        //  are available, then register definition.
                        definition._sharedState = privateSharedSizeScope.EnsureSharedState(sharedSizeGroupId);
                        definition._sharedState.AddMember(definition);
                    }
                }
            }
        }
示例#2
0
        /// <remark>
        /// OnPrivateSharedSizeScopePropertyChanged is called when new scope enters or
        /// existing scope just left. In both cases if the DefinitionBase object is already registered
        /// in SharedSizeState, it should un-register and register itself in a new one.
        /// </remark>
        private static void OnPrivateSharedSizeScopePropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
        {
            DefinitionBase definition = (DefinitionBase)d;

            if (definition.Parent != null)
            {
                SharedSizeScope privateSharedSizeScope = (SharedSizeScope)e.NewValue;

                if (definition._sharedState != null)
                {
                    //  if definition is already registered And shared size scope is changing,
                    //  then un-register the definition from the current shared size state object.
                    definition._sharedState.RemoveMember(definition);
                    definition._sharedState = null;
                }

                if ((definition._sharedState == null) && (privateSharedSizeScope != null))
                {
                    string sharedSizeGroup = definition.SharedSizeGroup;
                    if (sharedSizeGroup != null)
                    {
                        //  if definition is not registered and both: shared size group id AND private shared scope
                        //  are available, then register definition.
                        definition._sharedState = privateSharedSizeScope.EnsureSharedState(definition.SharedSizeGroup);
                        definition._sharedState.AddMember(definition);
                    }
                }
            }
        }
示例#3
0
 /// <summary>
 /// Default ctor.
 /// </summary>
 internal SharedSizeState(SharedSizeScope sharedSizeScope, string sharedSizeGroupId)
 {
     Debug.Assert(sharedSizeScope != null && sharedSizeGroupId != null);
     _sharedSizeScope       = sharedSizeScope;
     _sharedSizeGroupId     = sharedSizeGroupId;
     _registry              = new List <DefinitionBase>();
     _layoutUpdated         = new EventHandler(OnLayoutUpdated);
     _broadcastInvalidation = true;
 }
示例#4
0
 /// <remarks>
 /// This method reflects Grid.SharedScopeProperty state by setting / clearing
 /// dynamic property PrivateSharedSizeScopeProperty. Value of PrivateSharedSizeScopeProperty
 /// is a collection of SharedSizeState objects for the scope.
 /// </remarks>
 internal static void OnIsSharedSizeScopePropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
 {
     if ((bool)e.NewValue)
     {
         SharedSizeScope sharedStatesCollection = new SharedSizeScope();
         d.SetValue(PrivateSharedSizeScopeProperty, sharedStatesCollection);
     }
     else
     {
         d.ClearValue(PrivateSharedSizeScopeProperty);
     }
 }
示例#5
0
 /// <summary>
 /// <see cref="PropertyMetadata.PropertyChangedCallback"/>
 /// </summary>
 /// <remarks>
 /// This method reflects Grid.SharedScopeProperty state by setting / clearing
 /// dynamic property PrivateSharedSizeScopeProperty. Value of PrivateSharedSizeScopeProperty
 /// is a collection of SharedSizeState objects for the scope.
 /// Also PrivateSharedSizeScopeProperty is FrameworkPropertyMetadataOptions.Inherits property. So that all children
 /// elements belonging to a certain scope can easily access SharedSizeState collection. As well
 /// as been norified about enter / exit a scope.
 /// </remarks>
 internal static void OnIsSharedSizeScopePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     //  is it possible to optimize here something like this:
     //  if ((bool)d.GetValue(Grid.IsSharedSizeScopeProperty) == (d.GetLocalValue(PrivateSharedSizeScopeProperty) != null)
     //  { /* do nothing */ }
     if ((bool)e.NewValue)
     {
         SharedSizeScope sharedStatesCollection = new SharedSizeScope();
         d.SetValue(PrivateSharedSizeScopeProperty, sharedStatesCollection);
     }
     else
     {
         d.ClearValue(PrivateSharedSizeScopeProperty);
     }
 }
示例#6
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        /// <summary>
        /// Callback to notify about entering model tree.
        /// </summary>
        internal void OnEnterParentTree()
        {
            if (_sharedState == null)
            {
                //  start with getting SharedSizeGroup value.
                //  this property is NOT inhereted which should result in better overall perf.
                string sharedSizeGroupId = SharedSizeGroup;
                if (sharedSizeGroupId != null)
                {
                    SharedSizeScope privateSharedSizeScope = PrivateSharedSizeScope;
                    if (privateSharedSizeScope != null)
                    {
                        _sharedState = privateSharedSizeScope.EnsureSharedState(sharedSizeGroupId);
                        _sharedState.AddMember(this);
                    }
                }
            }
        }
 /// <summary>
 /// Default ctor.
 /// </summary>
 internal SharedSizeState(SharedSizeScope sharedSizeScope, string sharedSizeGroupId)
 {
     Debug.Assert(sharedSizeScope != null && sharedSizeGroupId != null);
     _sharedSizeScope = sharedSizeScope;
     _sharedSizeGroupId = sharedSizeGroupId;
     _registry = new List<DefinitionBase>();
     _layoutUpdated = new EventHandler(OnLayoutUpdated);
     _broadcastInvalidation = true;
 }
        /// <summary>
        /// <see cref="PropertyMetadata.PropertyChangedCallback"/>
        /// </summary>
        /// <remarks>
        /// This method reflects Grid.SharedScopeProperty state by setting / clearing
        /// dynamic property PrivateSharedSizeScopeProperty. Value of PrivateSharedSizeScopeProperty
        /// is a collection of SharedSizeState objects for the scope.
        /// Also PrivateSharedSizeScopeProperty is FrameworkPropertyMetadataOptions.Inherits property. So that all children
        /// elements belonging to a certain scope can easily access SharedSizeState collection. As well
        /// as been norified about enter / exit a scope.
        /// </remarks>
        internal static void OnIsSharedSizeScopePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //  


            if ((bool) e.NewValue)
            {
                SharedSizeScope sharedStatesCollection = new SharedSizeScope();
                d.SetValue(PrivateSharedSizeScopeProperty, sharedStatesCollection);
            }
            else
            {
                d.ClearValue(PrivateSharedSizeScopeProperty);
            }
        }