Beispiel #1
0
        // Token: 0x0600660E RID: 26126 RVA: 0x001CB324 File Offset: 0x001C9524
        internal static TextDecorationCollection GetTextDecorationsForInlineObject(DependencyObject element, TextDecorationCollection textDecorations)
        {
            DependencyObject         parent = LogicalTreeHelper.GetParent(element);
            TextDecorationCollection textDecorationCollection = null;

            if (parent != null)
            {
                textDecorationCollection = DynamicPropertyReader.GetTextDecorations(parent);
            }
            if (!((textDecorations == null) ? (textDecorationCollection == null) : textDecorations.ValueEquals(textDecorationCollection)))
            {
                if (textDecorationCollection == null)
                {
                    textDecorations = null;
                }
                else
                {
                    textDecorations = new TextDecorationCollection();
                    int count = textDecorationCollection.Count;
                    for (int i = 0; i < count; i++)
                    {
                        textDecorations.Add(textDecorationCollection[i]);
                    }
                }
            }
            return(textDecorations);
        }
Beispiel #2
0
        // ------------------------------------------------------------------
        // Retrieve text properties from specified inline object.
        //
        // WORKAROUND: see PS task #13486 & #3399.
        // For inline object go to its parent and retrieve text decoration
        // properties from there.
        // ------------------------------------------------------------------
        internal static TextDecorationCollection GetTextDecorationsForInlineObject(DependencyObject element, TextDecorationCollection textDecorations)
        {
            Debug.Assert(element != null);

            DependencyObject         parent = LogicalTreeHelper.GetParent(element);
            TextDecorationCollection parentTextDecorations = null;

            if (parent != null)
            {
                // Get parent text decorations if it is non-null
                parentTextDecorations = GetTextDecorations(parent);
            }

            // see if the two text decorations are equal.
            bool textDecorationsEqual = (textDecorations == null) ?
                                        parentTextDecorations == null
                                       : textDecorations.ValueEquals(parentTextDecorations);

            if (!textDecorationsEqual)
            {
                if (parentTextDecorations == null)
                {
                    textDecorations = null;
                }
                else
                {
                    textDecorations = new TextDecorationCollection();
                    int count = parentTextDecorations.Count;
                    for (int i = 0; i < count; ++i)
                    {
                        textDecorations.Add(parentTextDecorations[i]);
                    }
                }
            }
            return(textDecorations);
        }
Beispiel #3
0
        // Compares two values for equality
        /// <summary>
        /// Property comparison helper.
        /// Compares property values for equivalence from serialization
        /// standpoint. In editing we consider properties equal
        /// if they have the same serialized representation.
        /// Differences coming from current dynamic state changes
        /// should not affect comparison if they are not going to be
        /// visible after serialization.
        /// Instantiation dirrefences are also insignificant.
        /// </summary>
        /// <param name="value1">
        /// </param>
        /// <param name="value2">
        /// </param>
        /// <returns>
        /// True if two values have the same serialized representation
        /// </returns>
        internal static bool ValuesAreEqual(object value1, object value2)
        {
            if ((object)value1 == (object)value2) // this check includes two nulls
            {
                return(true);
            }

            // Comparing null with empty collections
            if (value1 == null)
            {
                if (value2 is TextDecorationCollection)
                {
                    TextDecorationCollection decorations2 = (TextDecorationCollection)value2;
                    return(decorations2.Count == 0);
                }
                else if (value2 is TextEffectCollection)
                {
                    TextEffectCollection effects2 = (TextEffectCollection)value2;
                    return(effects2.Count == 0);
                }
                return(false);
            }
            else if (value2 == null)
            {
                if (value1 is TextDecorationCollection)
                {
                    TextDecorationCollection decorations1 = (TextDecorationCollection)value1;
                    return(decorations1.Count == 0);
                }
                else if (value1 is TextEffectCollection)
                {
                    TextEffectCollection effects1 = (TextEffectCollection)value1;
                    return(effects1.Count == 0);
                }
                return(false);
            }

            // Must be of exactly the same types (really ?)
            // Should we ever return true for different types?
            if (value1.GetType() != value2.GetType())
            {
                return(false);
            }

            // Special cases for known types: TextDecorations, FontFamily, Brush
            if (value1 is TextDecorationCollection)
            {
                TextDecorationCollection decorations1 = (TextDecorationCollection)value1;
                TextDecorationCollection decorations2 = (TextDecorationCollection)value2;
                return(decorations1.ValueEquals(decorations2));
            }
            else if (value1 is FontFamily)
            {
                FontFamily fontFamily1 = (FontFamily)value1;
                FontFamily fontFamily2 = (FontFamily)value2;
                return(fontFamily1.Equals(fontFamily2));
            }
            else if (value1 is Brush)
            {
                return(AreBrushesEqual((Brush)value1, (Brush)value2));
            }
            else
            {
                string string1 = value1.ToString();
                string string2 = value2.ToString();
                return(string1 == string2);
            }
        }
 // Token: 0x06003BF9 RID: 15353 RVA: 0x00114A24 File Offset: 0x00112C24
 internal static bool ValuesAreEqual(object value1, object value2)
 {
     if (value1 == value2)
     {
         return(true);
     }
     if (value1 == null)
     {
         if (value2 is TextDecorationCollection)
         {
             TextDecorationCollection textDecorationCollection = (TextDecorationCollection)value2;
             return(textDecorationCollection.Count == 0);
         }
         if (value2 is TextEffectCollection)
         {
             TextEffectCollection textEffectCollection = (TextEffectCollection)value2;
             return(textEffectCollection.Count == 0);
         }
         return(false);
     }
     else if (value2 == null)
     {
         if (value1 is TextDecorationCollection)
         {
             TextDecorationCollection textDecorationCollection2 = (TextDecorationCollection)value1;
             return(textDecorationCollection2.Count == 0);
         }
         if (value1 is TextEffectCollection)
         {
             TextEffectCollection textEffectCollection2 = (TextEffectCollection)value1;
             return(textEffectCollection2.Count == 0);
         }
         return(false);
     }
     else
     {
         if (value1.GetType() != value2.GetType())
         {
             return(false);
         }
         if (value1 is TextDecorationCollection)
         {
             TextDecorationCollection textDecorationCollection3 = (TextDecorationCollection)value1;
             TextDecorationCollection textDecorations           = (TextDecorationCollection)value2;
             return(textDecorationCollection3.ValueEquals(textDecorations));
         }
         if (value1 is FontFamily)
         {
             FontFamily fontFamily = (FontFamily)value1;
             FontFamily obj        = (FontFamily)value2;
             return(fontFamily.Equals(obj));
         }
         if (value1 is Brush)
         {
             return(TextSchema.AreBrushesEqual((Brush)value1, (Brush)value2));
         }
         string a = value1.ToString();
         string b = value2.ToString();
         return(a == b);
     }
 }