示例#1
0
        // Token: 0x06003E37 RID: 15927 RVA: 0x0011D778 File Offset: 0x0011B978
        internal static PropertyRecord[] GetPropertyRecordArray(DependencyObject d)
        {
            LocalValueEnumerator localValueEnumerator = d.GetLocalValueEnumerator();

            PropertyRecord[] array = new PropertyRecord[localValueEnumerator.Count];
            int num = 0;

            localValueEnumerator.Reset();
            while (localValueEnumerator.MoveNext())
            {
                LocalValueEntry    localValueEntry = localValueEnumerator.Current;
                DependencyProperty property        = localValueEntry.Property;
                if (!property.ReadOnly)
                {
                    array[num].Property = property;
                    array[num].Value    = d.GetValue(property);
                    num++;
                }
            }
            PropertyRecord[] array2;
            if (localValueEnumerator.Count != num)
            {
                array2 = new PropertyRecord[num];
                for (int i = 0; i < num; i++)
                {
                    array2[i] = array[i];
                }
            }
            else
            {
                array2 = array;
            }
            return(array2);
        }
        public override void Render(DrawingContext dc, Point screenPoint)
        {
            LocalValueEnumerator enumerator = GetLocalValueEnumerator();

            foreach (var marker in markers)
            {
                enumerator.Reset();
                while (enumerator.MoveNext())
                {
                    marker.SetValue(enumerator.Current.Property, enumerator.Current.Value);
                }

                marker.Render(dc, screenPoint);
            }
        }
        // Gets an array of PropertyRecords from a DependencyObject's LocalValueEnumerator.
        // The array is safe to cache, LocalValueEnumerators are not.
        internal static PropertyRecord[] GetPropertyRecordArray(DependencyObject d)
        {
            LocalValueEnumerator valuesEnumerator = d.GetLocalValueEnumerator();

            PropertyRecord[] records = new PropertyRecord[valuesEnumerator.Count];
            int count = 0;

            valuesEnumerator.Reset();
            while (valuesEnumerator.MoveNext())
            {
                DependencyProperty dp = valuesEnumerator.Current.Property;
                if (!dp.ReadOnly)
                {
                    // LocalValueEntry.Value can be an Expression, which we can't duplicate when we
                    // undo, so we copy over the current value from DependencyObject.GetValue instead.
                    records[count].Property = dp;
                    records[count].Value    = d.GetValue(dp);

                    count++;
                }
            }

            PropertyRecord[] trimmedResult;
            if (valuesEnumerator.Count != count)
            {
                trimmedResult = new PropertyRecord[count];
                for (int i = 0; i < count; i++)
                {
                    trimmedResult[i] = records[i];
                }
            }
            else
            {
                trimmedResult = records;
            }

            return(trimmedResult);
        }
示例#4
0
        // Copies a LocalValueEnumerator properties into an array of DependencyProperty. 
        // This method is useful because LocalValueEnumerator does not support 
        // setting or clearing local values while enumerating.
        private DependencyProperty[] LocalValueEnumeratorToArray(LocalValueEnumerator valuesEnumerator) 
        {
            DependencyProperty[] properties;
            int count;
 
            properties = new DependencyProperty[valuesEnumerator.Count];
 
            count = 0; 
            valuesEnumerator.Reset();
            while (valuesEnumerator.MoveNext()) 
            {
                properties[count++] = valuesEnumerator.Current.Property;
            }
 
            return properties;
        } 
示例#5
0
        /// <summary> 
        /// Sets local values on the text element scoping position.
        /// </summary>
        /// <param name="position">
        /// A position scoped by the element on which to set the property. 
        /// </param>
        /// <param name="values"> 
        /// Values to set. 
        /// </param>
        /// <exception cref="System.InvalidOperationException"> 
        /// Throws InvalidOperationException if position is not scoped by a
        /// text element or if a property value may not be applied on the
        /// scoping text element.
        /// </exception> 
        internal void SetValues(TextPointer position, LocalValueEnumerator values)
        { 
            TextElement textElement; 
            LocalValueEntry property;
 
//             VerifyAccess();

            if (position == null)
            { 
                throw new ArgumentNullException("position");
            } 
 
            // LocalValueEnumerator is a struct.
            // if (values == null) 
            // {
            //     throw new ArgumentNullException("values");
            // }
 
            EmptyDeadPositionList();
 
            ValidateSetValue(position); 

            BeginChange(); 
            try
            {
                textElement = position.Parent as TextElement;
                Invariant.Assert(textElement != null); 

                values.Reset(); 
                while (values.MoveNext()) 
                {
                    property = values.Current; 

                    //

 

 
 

 

                    if (property.Property.Name == "CachedSource")
                    {
                        continue; 
                    }
 
                    // If the property is readonly on the text element, then we shouldn't 
                    // try to copy the property value.
                    if (property.Property.ReadOnly) 
                    {
                        continue;
                    }
 
                    // Don't copy over Run.Text. This will get automatically invalidated by TextContainer
                    // when the Run's text content is set. Setting this property now will cause TextContainer 
                    // changes that get us into trouble in the middle of undo. 
                    if (property.Property == Run.TextProperty)
                    { 
                        continue;
                    }

                    BindingExpressionBase expr = property.Value as BindingExpressionBase; 
                    if (expr != null)
                    { 
                        // We can't duplicate a binding so copy over the current value instead. 
                        textElement.SetValue(property.Property, expr.Value);
                    } 
                    else
                    {
                        textElement.SetValue(property.Property, property.Value);
                    } 
                }
            } 
            finally 
            {
                EndChange(); 
            }
        }