Exemplo n.º 1
0
		static public void CheckTextBlockInherited (Inline i)
		{
			Assert.AreEqual ("Portable User Interface", i.FontFamily.Source, "FontFamily");
			Assert.AreEqual (11, i.FontSize, "FontSize");
			Assert.AreEqual (DependencyProperty.UnsetValue, i.ReadLocalValue(Inline.FontSizeProperty), "FontSize local value");

			Assert.AreEqual (FontStretches.Normal, i.FontStretch, "FontStretch");
			Assert.AreEqual (FontStyles.Normal, i.FontStyle, "FontStyle");
			Assert.AreEqual (FontWeights.Normal, i.FontWeight, "FontWeight");

			Assert.IsNotNull (i.Foreground, "Foreground");
			Assert.AreEqual (Colors.Black, (i.Foreground as SolidColorBrush).Color, "Foreground.Color");
			Assert.AreEqual ("en-us", i.Language.IetfLanguageTag, "Language");
			Assert.IsNull (i.TextDecorations, "TextDecorations");
		}
Exemplo n.º 2
0
        // Compares a set of inheritable properties taken from two objects
        private static bool InheritablePropertiesAreEqual(Inline firstInline, Inline secondInline)
        { 
            Invariant.Assert(firstInline != null, "null check: firstInline");
            Invariant.Assert(secondInline != null, "null check: secondInline"); 
 
            // Compare inheritable properties
            DependencyProperty[] inheritableProperties = TextSchema.GetInheritableProperties(typeof(Inline)); 
            for (int i = 0; i < inheritableProperties.Length; i++)
            {
                DependencyProperty property = inheritableProperties[i];
 
                if (TextSchema.IsStructuralCharacterProperty(property))
                { 
                    if (firstInline.ReadLocalValue(property) != DependencyProperty.UnsetValue || 
                        secondInline.ReadLocalValue(property) != DependencyProperty.UnsetValue)
                    { 
                        return false;
                    }
                }
                else 
                {
                    if (!TextSchema.ValuesAreEqual(firstInline.GetValue(property), secondInline.GetValue(property))) 
                    { 
                        return false;
                    } 
                }
            }

            return true; 
        }
Exemplo n.º 3
0
		private DesignItem InlineToDesignItem(Inline inline)
		{
			DesignItem d = d = designItem.Services.Component.RegisterComponentForDesigner(CloneInline(inline));
			if (inline is Run)
			{
				var run = inline as Run;

				if (run.ReadLocalValue(Run.TextProperty) != DependencyProperty.UnsetValue)
				{
					d.Properties.GetProperty(Run.TextProperty).SetValue(run.Text);
				}
			}
			else if (inline is Span)
			{ }
			else if (inline is LineBreak)
			{ }
			else
			{
				return null;
			}

			if (inline.ReadLocalValue(TextElement.BackgroundProperty) != DependencyProperty.UnsetValue)
				d.Properties.GetProperty(TextElement.BackgroundProperty).SetValue(inline.Background);
			if (inline.ReadLocalValue(TextElement.ForegroundProperty) != DependencyProperty.UnsetValue)
				d.Properties.GetProperty(TextElement.ForegroundProperty).SetValue(inline.Foreground);
			if (inline.ReadLocalValue(TextElement.FontFamilyProperty) != DependencyProperty.UnsetValue)
				d.Properties.GetProperty(TextElement.FontFamilyProperty).SetValue(inline.FontFamily);
			if (inline.ReadLocalValue(TextElement.FontSizeProperty) != DependencyProperty.UnsetValue)
				d.Properties.GetProperty(TextElement.FontSizeProperty).SetValue(inline.FontSize);
			if (inline.ReadLocalValue(TextElement.FontStretchProperty) != DependencyProperty.UnsetValue)
				d.Properties.GetProperty(TextElement.FontStretchProperty).SetValue(inline.FontStretch);
			if (inline.ReadLocalValue(TextElement.FontStyleProperty) != DependencyProperty.UnsetValue)
				d.Properties.GetProperty(TextElement.FontStyleProperty).SetValue(inline.FontStyle);
			if (inline.ReadLocalValue(TextElement.FontWeightProperty) != DependencyProperty.UnsetValue)
				d.Properties.GetProperty(TextElement.FontWeightProperty).SetValue(inline.FontWeight);
			if (inline.TextDecorations.Count > 0)
			{
				d.Properties.GetProperty("TextDecorations").SetValue(new TextDecorationCollection());
				var tdColl = d.Properties.GetProperty("TextDecorations");

				foreach (var td in inline.TextDecorations)
				{
					var newTd = designItem.Services.Component.RegisterComponentForDesigner(new TextDecoration());
					if (inline.ReadLocalValue(TextDecoration.LocationProperty) != DependencyProperty.UnsetValue)
						newTd.Properties.GetProperty(TextDecoration.LocationProperty).SetValue(td.Location);
					if (inline.ReadLocalValue(TextDecoration.PenProperty) != DependencyProperty.UnsetValue)
						newTd.Properties.GetProperty(TextDecoration.PenProperty).SetValue(td.Pen);

					tdColl.CollectionElements.Add(newTd);
				}
			}
			
			return d;
		}
Exemplo n.º 4
0
		private Inline CloneInline(Inline inline)
		{
			Inline retVal = null;
			if (inline is LineBreak)
				retVal = new LineBreak();
			else if (inline is Span)
				retVal = new Span();
			else if (inline is Run)
			{
				retVal = new Run(((Run) inline).Text);
			}

			if (inline.ReadLocalValue(Inline.BackgroundProperty) != DependencyProperty.UnsetValue)
				retVal.Background = inline.Background;
			if (inline.ReadLocalValue(Inline.ForegroundProperty) != DependencyProperty.UnsetValue)
				retVal.Foreground = inline.Foreground;
			if (inline.ReadLocalValue(Inline.FontFamilyProperty) != DependencyProperty.UnsetValue)
				retVal.FontFamily = inline.FontFamily;
			if (inline.ReadLocalValue(Inline.FontSizeProperty) != DependencyProperty.UnsetValue)
				retVal.FontSize = inline.FontSize;
			if (inline.ReadLocalValue(Inline.FontStretchProperty) != DependencyProperty.UnsetValue)
				retVal.FontStretch = inline.FontStretch;
			if (inline.ReadLocalValue(Inline.FontStyleProperty) != DependencyProperty.UnsetValue)
				retVal.FontStyle = inline.FontStyle;
			if (inline.ReadLocalValue(Inline.FontWeightProperty) != DependencyProperty.UnsetValue)
				retVal.FontWeight = inline.FontWeight;
			if (inline.ReadLocalValue(Inline.TextEffectsProperty) != DependencyProperty.UnsetValue)
				retVal.TextEffects = inline.TextEffects;
			if (inline.ReadLocalValue(Inline.TextDecorationsProperty) != DependencyProperty.UnsetValue)
				retVal.TextDecorations = inline.TextDecorations;

			return retVal;
		}