From 080f1697e97e13461ec6df4d31c8924d01257a1b Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 9 Apr 2019 01:47:48 +0300 Subject: MERGE --- .../VisualLineElementTextRunProperties.cs | 241 +++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Rendering/VisualLineElementTextRunProperties.cs (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Rendering/VisualLineElementTextRunProperties.cs') diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Rendering/VisualLineElementTextRunProperties.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Rendering/VisualLineElementTextRunProperties.cs new file mode 100644 index 000000000..a39276c5b --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Rendering/VisualLineElementTextRunProperties.cs @@ -0,0 +1,241 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.TextFormatting; +using Tango.Scripting.Editors.Utils; + +namespace Tango.Scripting.Editors.Rendering +{ + /// + /// implementation that allows changing the properties. + /// A instance usually is assigned to a single + /// . + /// + public class VisualLineElementTextRunProperties : TextRunProperties, ICloneable + { + Brush backgroundBrush; + BaselineAlignment baselineAlignment; + CultureInfo cultureInfo; + double fontHintingEmSize; + double fontRenderingEmSize; + Brush foregroundBrush; + Typeface typeface; + TextDecorationCollection textDecorations; + TextEffectCollection textEffects; + TextRunTypographyProperties typographyProperties; + NumberSubstitution numberSubstitution; + + /// + /// Creates a new VisualLineElementTextRunProperties instance that copies its values + /// from the specified . + /// For the and collections, deep copies + /// are created if those collections are not frozen. + /// + public VisualLineElementTextRunProperties(TextRunProperties textRunProperties) + { + if (textRunProperties == null) + throw new ArgumentNullException("textRunProperties"); + backgroundBrush = textRunProperties.BackgroundBrush; + baselineAlignment = textRunProperties.BaselineAlignment; + cultureInfo = textRunProperties.CultureInfo; + fontHintingEmSize = textRunProperties.FontHintingEmSize; + fontRenderingEmSize = textRunProperties.FontRenderingEmSize; + foregroundBrush = textRunProperties.ForegroundBrush; + typeface = textRunProperties.Typeface; + textDecorations = textRunProperties.TextDecorations; + if (textDecorations != null && !textDecorations.IsFrozen) { + textDecorations = textDecorations.Clone(); + } + textEffects = textRunProperties.TextEffects; + if (textEffects != null && !textEffects.IsFrozen) { + textEffects = textEffects.Clone(); + } + typographyProperties = textRunProperties.TypographyProperties; + numberSubstitution = textRunProperties.NumberSubstitution; + } + + /// + /// Creates a copy of this instance. + /// + public virtual VisualLineElementTextRunProperties Clone() + { + return new VisualLineElementTextRunProperties(this); + } + + object ICloneable.Clone() + { + return Clone(); + } + + /// + public override Brush BackgroundBrush { + get { return backgroundBrush; } + } + + /// + /// Sets the . + /// + public void SetBackgroundBrush(Brush value) + { + ExtensionMethods.CheckIsFrozen(value); + backgroundBrush = value; + } + + /// + public override BaselineAlignment BaselineAlignment { + get { return baselineAlignment; } + } + + /// + /// Sets the . + /// + public void SetBaselineAlignment(BaselineAlignment value) + { + baselineAlignment = value; + } + + /// + public override CultureInfo CultureInfo { + get { return cultureInfo; } + } + + /// + /// Sets the . + /// + public void SetCultureInfo(CultureInfo value) + { + if (value == null) + throw new ArgumentNullException("value"); + cultureInfo = value; + } + + /// + public override double FontHintingEmSize { + get { return fontHintingEmSize; } + } + + /// + /// Sets the . + /// + public void SetFontHintingEmSize(double value) + { + fontHintingEmSize = value; + } + + /// + public override double FontRenderingEmSize { + get { return fontRenderingEmSize; } + } + + /// + /// Sets the . + /// + public void SetFontRenderingEmSize(double value) + { + fontRenderingEmSize = value; + } + + /// + public override Brush ForegroundBrush { + get { return foregroundBrush; } + } + + /// + /// Sets the . + /// + public void SetForegroundBrush(Brush value) + { + ExtensionMethods.CheckIsFrozen(value); + foregroundBrush = value; + } + + /// + public override Typeface Typeface { + get { return typeface; } + } + + /// + /// Sets the . + /// + public void SetTypeface(Typeface value) + { + if (value == null) + throw new ArgumentNullException("value"); + typeface = value; + } + + /// + /// Gets the text decorations. The value may be null, a frozen + /// or an unfrozen . + /// If the value is an unfrozen , you may assume that the + /// collection instance is only used for this instance and it is safe + /// to add s. + /// + public override TextDecorationCollection TextDecorations { + get { return textDecorations; } + } + + /// + /// Sets the . + /// + public void SetTextDecorations(TextDecorationCollection value) + { + ExtensionMethods.CheckIsFrozen(value); + textDecorations = value; + } + + /// + /// Gets the text effects. The value may be null, a frozen + /// or an unfrozen . + /// If the value is an unfrozen , you may assume that the + /// collection instance is only used for this instance and it is safe + /// to add s. + /// + public override TextEffectCollection TextEffects { + get { return textEffects; } + } + + /// + /// Sets the . + /// + public void SetTextEffects(TextEffectCollection value) + { + ExtensionMethods.CheckIsFrozen(value); + textEffects = value; + } + + /// + /// Gets the typography properties for the text run. + /// + public override TextRunTypographyProperties TypographyProperties { + get { return typographyProperties; } + } + + /// + /// Sets the . + /// + public void SetTypographyProperties(TextRunTypographyProperties value) + { + typographyProperties = value; + } + + /// + /// Gets the number substitution settings for the text run. + /// + public override NumberSubstitution NumberSubstitution { + get { return numberSubstitution; } + } + + /// + /// Sets the . + /// + public void SetNumberSubstitution(NumberSubstitution value) + { + numberSubstitution = value; + } + } +} -- cgit v1.3.1