コード例 #1
0
 public MarkdownHeaderFormatDefinition()
 {
     IsBold = true;
     TextDecorations = new TextDecorationCollection();
     TextDecorations.Add(new TextDecoration());
     DisplayName = "Markdown Headers";
 }
コード例 #2
0
ファイル: RichTextAreaHandler.cs プロジェクト: zzlvff/Eto
        bool HasDecorations(swd.TextRange range, sw.TextDecorationCollection decorations)
        {
            swd.TextRange realRange;
            var           existingDecorations = range.GetRealPropertyValue(swd.Inline.TextDecorationsProperty, out realRange) as sw.TextDecorationCollection;

            return(existingDecorations != null && decorations.All(r => existingDecorations.Contains(r)));
        }
コード例 #3
0
        void UpdateTextDecorations()
        {
            if (!Element.IsSet(Label.TextDecorationsProperty))
            {
                return;
            }

            var textDecorations = Element.TextDecorations;

            var newTextDecorations = new System.Windows.TextDecorationCollection(Control.TextDecorations);

            if ((textDecorations & TextDecorations.Underline) == 0)
            {
                newTextDecorations.TryRemove(System.Windows.TextDecorations.Underline, out newTextDecorations);
            }
            else
            {
                newTextDecorations.Add(System.Windows.TextDecorations.Underline);
            }

            if ((textDecorations & TextDecorations.Strikethrough) == 0)
            {
                newTextDecorations.TryRemove(System.Windows.TextDecorations.Strikethrough, out newTextDecorations);
            }
            else
            {
                newTextDecorations.Add(System.Windows.TextDecorations.Strikethrough);
            }

            Control.TextDecorations = newTextDecorations;
        }
コード例 #4
0
        public GenericTextRunProperties(
            Typeface typeface,
            double size,
            double hintingSize,
            TextDecorationCollection textDecorations,
            Brush forgroundBrush,
            Brush backgroundBrush,
            BaselineAlignment baselineAlignment,
            TextEffectCollection textEffects,
            CultureInfo culture)
        {
            if (typeface == null)
                throw new ArgumentNullException("typeface");

            ValidateCulture(culture);

            _typeface = typeface;
            _emSize = size;
            _emHintingSize = hintingSize;
            _textDecorations = textDecorations;
            _foregroundBrush = forgroundBrush;
            _backgroundBrush = backgroundBrush;
            _baselineAlignment = baselineAlignment;
            _textEffects = textEffects;
            _culture = culture;
        }
コード例 #5
0
        public void GameLogWrite(String text, SolidColorBrush brush, TextDecorationCollection decorations)
        {
            // FIXME: probably more invalid characters...
            text = text.Replace((Char)0x17, ' ');
            //text = System.Security.SecurityElement.Escape(text).Replace((Char)0x17, ' ');

            XmlElement run = GameLogCreateXmlElement("Run");
            run.InnerText = text;

            Procedure<String, String> addXmlAttribute = (name, value) =>
            {
                XmlAttribute attribute = gameLog.CreateAttribute(name);
                attribute.InnerXml = value;
                run.Attributes.Append(attribute);
            };

            if (brush != Brushes.Black)
            {
                addXmlAttribute("Foreground", brush.ToString());
            }

            if (decorations != null)
            {
                // TODO: fixme for multiple attributes, what's the XML for that?
                addXmlAttribute("TextDecorations", decorations[0].Location.ToString());
            }

            gameLogParagraph.AppendChild(run);
        }
コード例 #6
0
        public void TextDecoration(TextRange range, SW.TextDecorationCollection decor, bool add)
        {
            var td = range.GetPropertyValue(Inline.TextDecorationsProperty) as SW.TextDecorationCollection;

            if (td == null)
            {
                return;
            }
            td = td.CloneCurrentValue();
            foreach (var d in decor)
            {
                var r = td.FirstOrDefault(s => s.Location == d.Location);
                if (add)
                {
                    if (r == null)
                    {
                        td.Add(d.Clone());
                    }
                }
                else
                {
                    if (r != null)
                    {
                        td.Remove(r);
                    }
                }
            }
            decor = td;

            range.ApplyPropertyValue(Inline.TextDecorationsProperty, decor);
        }
コード例 #7
0
        private static double CheckTextBox(TextBox textBox)  // Функция проверит значение, если вернется не 0, то все условия выполнены
        {
            double checkedString = 0;

            try
            {
                checkedString = Convert.ToDouble(textBox.Text);
                if (textBox.TextDecorations != null) textBox.TextDecorations.Clear();
            }
            catch (FormatException)
            {
                var myUnderline = new TextDecoration();

                // Create a linear gradient pen for the text decoration.
                var myPen = new Pen();
                myPen.Brush = new LinearGradientBrush(Colors.Red, Colors.Red, new Point(0, 0.5), new Point(1, 0.5));
                myPen.Brush.Opacity = 0.5;
                myPen.Thickness = 1.5;
                myPen.DashStyle = DashStyles.DashDot;
                myUnderline.Pen = myPen;
                myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;

                // Set the underline decoration to a TextDecorationCollection and add it to the text block.
                var myDecorationCollection = new TextDecorationCollection {myUnderline};
                textBox.TextDecorations = myDecorationCollection;
            }

            return checkedString;
        }
コード例 #8
0
        void SetDecorations(swd.TextRange range, sw.TextDecorationCollection decorations, bool value)
        {
            var existingDecorations = range.GetPropertyValue(swd.Inline.TextDecorationsProperty) as sw.TextDecorationCollection;

            if (existingDecorations != null)
            {
                existingDecorations = new sw.TextDecorationCollection(existingDecorations);
            }
            if (value)
            {
                existingDecorations = existingDecorations ?? new sw.TextDecorationCollection();
                existingDecorations.Add(decorations);
            }
            else if (existingDecorations != null)
            {
                foreach (var decoration in decorations)
                {
                    if (existingDecorations.Contains(decoration))
                    {
                        existingDecorations.Remove(decoration);
                    }
                }
                if (existingDecorations.Count == 0)
                {
                    existingDecorations = null;
                }
            }
            range.ApplyPropertyValue(swd.Inline.TextDecorationsProperty, existingDecorations);
        }
コード例 #9
0
 public override void AddAttribute(object backend, TextAttribute attribute)
 {
     var t = (TextLayoutBackend)backend;
     if (attribute is FontStyleTextAttribute) {
         var xa = (FontStyleTextAttribute)attribute;
         t.FormattedText.SetFontStyle (xa.Style.ToWpfFontStyle (), xa.StartIndex, xa.Count);
     }
     else if (attribute is FontWeightTextAttribute) {
         var xa = (FontWeightTextAttribute)attribute;
         t.FormattedText.SetFontWeight (xa.Weight.ToWpfFontWeight (), xa.StartIndex, xa.Count);
     }
     else if (attribute is ColorTextAttribute) {
         var xa = (ColorTextAttribute)attribute;
         t.FormattedText.SetForegroundBrush (new SolidColorBrush (xa.Color.ToWpfColor ()), xa.StartIndex, xa.Count);
     }
     else if (attribute is StrikethroughTextAttribute) {
         var xa = (StrikethroughTextAttribute)attribute;
         var dec = new TextDecoration (TextDecorationLocation.Strikethrough, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
         TextDecorationCollection col = new TextDecorationCollection ();
         col.Add (dec);
         t.FormattedText.SetTextDecorations (col, xa.StartIndex, xa.Count);
     }
     else if (attribute is UnderlineTextAttribute) {
         var xa = (UnderlineTextAttribute)attribute;
         var dec = new TextDecoration (TextDecorationLocation.Underline, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
         TextDecorationCollection col = new TextDecorationCollection ();
         col.Add (dec);
         t.FormattedText.SetTextDecorations (col, xa.StartIndex, xa.Count);
     }
 }
コード例 #10
0
ファイル: Font.cs プロジェクト: sitdap/dynamic-image
 private TextDecorationCollection GetTextDecorations()
 {
     TextDecorationCollection textDecorations = new TextDecorationCollection();
     if (Strikeout)
         textDecorations.Add(TextDecorations.Strikethrough);
     if (Underline)
         textDecorations.Add(TextDecorations.Underline);
     return textDecorations;
 }
コード例 #11
0
 public FontRendering()
 {
     _fontSize = 12.0f;
     _alignment = TextAlignment.Left;
     _textDecorations = new TextDecorationCollection();
     _textColor = Brushes.Black;
     _typeface = new Typeface(new FontFamily("Arial"),
        FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
 }
コード例 #12
0
ファイル: FontProperties.cs プロジェクト: fednep/UV-Outliner
 public FontProperties(TextRange range)
 {
     __FontWeight = range.GetPropertyValue(RichTextBox.FontWeightProperty);
     __FontSize = range.GetPropertyValue(RichTextBox.FontSizeProperty);
     __FontStyle = range.GetPropertyValue(RichTextBox.FontStyleProperty);
     __TextDecorations = range.GetPropertyValue(TextBlock.TextDecorationsProperty) as TextDecorationCollection;
     __FontFamily = range.GetPropertyValue(RichTextBox.FontFamilyProperty) as FontFamily;
     __ForegroundColor = range.GetPropertyValue(RichTextBox.ForegroundProperty) as Brush;
 }
コード例 #13
0
ファイル: FontProperties.cs プロジェクト: fednep/UV-Outliner
 public FontProperties(FlowDocument document)
 {
     __FontWeight = document.FontWeight;
     __FontSize = document.FontSize;
     __FontStyle = document.FontStyle;
     __TextDecorations = null;
     __FontFamily = document.FontFamily;
     __ForegroundColor = document.Foreground;
 }
コード例 #14
0
ファイル: RichTextAreaHandler.cs プロジェクト: zzlvff/Eto
        void SetDecorations(swd.TextRange range, sw.TextDecorationCollection decorations, bool value)
        {
            using (Control.DeclareChangeBlock())
            {
                // set the property to each element in the range so it keeps all other decorations
                foreach (var element in range.GetInlineElements())
                {
                    var existingDecorations = element.GetValue(swd.Inline.TextDecorationsProperty) as sw.TextDecorationCollection;

                    // need to keep the range before changing otherwise the range changes
                    var elementRange = new swd.TextRange(element.ElementStart, element.ElementEnd);

                    sw.TextDecorationCollection newDecorations = null;

                    // remove decorations from the element
                    element.SetValue(swd.Inline.TextDecorationsProperty, null);

                    if (existingDecorations != null && existingDecorations.Count > 0)
                    {
                        // merge desired decorations with existing decorations.
                        if (value)
                        {
                            newDecorations = new sw.TextDecorationCollection(existingDecorations.Union(decorations));
                        }
                        else
                        {
                            newDecorations = new sw.TextDecorationCollection(existingDecorations.Except(decorations));
                        }

                        // split up existing decorations to the parts of the element that don't fall within the range
                        existingDecorations = new sw.TextDecorationCollection(existingDecorations);                         // copy so we don't update existing elements
                        if (elementRange.Start.CompareTo(range.Start) < 0)
                        {
                            new swd.TextRange(elementRange.Start, range.Start).ApplyPropertyValue(swd.Inline.TextDecorationsProperty, existingDecorations);
                        }
                        if (elementRange.End.CompareTo(range.End) > 0)
                        {
                            new swd.TextRange(range.End, elementRange.End).ApplyPropertyValue(swd.Inline.TextDecorationsProperty, existingDecorations);
                        }
                    }
                    else
                    {
                        // no existing decorations, just set the new value
                        newDecorations = value ? decorations : null;
                    }

                    if (newDecorations != null && newDecorations.Count > 0)
                    {
                        // apply new decorations to the desired range, which may be a combination of existing decorations
                        swd.TextPointer start = elementRange.Start.CompareTo(range.Start) < 0 ? range.Start : elementRange.Start;
                        swd.TextPointer end   = elementRange.End.CompareTo(range.End) > 0 ? range.End : elementRange.End;
                        new swd.TextRange(start, end).ApplyPropertyValue(swd.Inline.TextDecorationsProperty, newDecorations);
                    }
                }
            }
        }
コード例 #15
0
		public HexTextRunProperties(TextRunProperties other) {
			this._BackgroundBrush = other.BackgroundBrush;
			this._CultureInfo = other.CultureInfo;
			this._FontHintingEmSize = other.FontHintingEmSize;
			this._FontRenderingEmSize = other.FontRenderingEmSize;
			this._ForegroundBrush = other.ForegroundBrush;
			this._TextDecorations = other.TextDecorations;
			this._TextEffects = other.TextEffects;
			this._Typeface = other.Typeface;
		}
コード例 #16
0
 private TextBlock CreateUnderlinedTextBlock(string text)
 {
     var myUnderline = new TextDecoration
                           {
                               Pen = new Pen(Brushes.Blue, 1),
                               PenThicknessUnit = TextDecorationUnit.FontRecommended
                           };
     var myCollection = new TextDecorationCollection {myUnderline};
     var blockHead = new TextBlock {TextDecorations = myCollection, Text = text};
     return blockHead;
 }
コード例 #17
0
ファイル: FontRendering.cs プロジェクト: erdao/Temp
 public FontRendering()
 {
     _fontSize = 64f;
     _alignment = TextAlignment.Left;
     _textDecorations = new TextDecorationCollection();
     _typeface = new Typeface(new FontFamily("Arial"),
        FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
     _foregroundBrush = Brushes.Black;
     _backgroundBrush = Brushes.Transparent;
     _textEffects = new TextEffectCollection();
 }
コード例 #18
0
ファイル: ChatFormatter.cs プロジェクト: derrickcreamer/Floe
			public CustomTextRunProperties(Typeface typeface, double fontSize, Brush foreground, Brush background, bool underline)
			{
				_typeface = typeface;
				_fontSize = fontSize;
				_foreground = foreground;
				_background = background;
				if (underline)
				{
					_decorations = new TextDecorationCollection(1);
					_decorations.Add(System.Windows.TextDecorations.Underline);
				}
			}
コード例 #19
0
 public GenericTextRunProperties(FontRendering newRender)
 {
     _typeface = newRender.Typeface;
     _emSize = newRender.FontSize;
     _emHintingSize = newRender.FontSize;
     _textDecorations = newRender.TextDecorations;
     _foregroundBrush = newRender.ForegroundBrush;
     _backgroundBrush = newRender.BackgroundBrush;
     _baselineAlignment = BaselineAlignment.Baseline;
     _textEffects = newRender.TextEffects;
     _culture = CultureInfo.CurrentUICulture;
 }
コード例 #20
0
 void SetDecorations(FontDecoration decoration)
 {
     WpfTextDecorations = new sw.TextDecorationCollection();
     if (decoration.HasFlag(FontDecoration.Underline))
     {
         WpfTextDecorations.Add(sw.TextDecorations.Underline);
     }
     if (decoration.HasFlag(FontDecoration.Strikethrough))
     {
         WpfTextDecorations.Add(sw.TextDecorations.Strikethrough);
     }
     this.decoration = decoration;
 }
コード例 #21
0
 public FontRendering(
     double emSize,
     TextAlignment alignment,
     TextDecorationCollection decorations,
     Brush textColor,
     Typeface face)
 {
     _fontSize = emSize;
     _alignment = alignment;
     _textDecorations = decorations;
     _textColor = textColor;
     _typeface = face;
 }
コード例 #22
0
 bool HasDecorations(swd.TextRange range, sw.TextDecorationCollection decorations, bool useRealPropertyValue = true)
 {
     swd.TextRange realRange;
     sw.TextDecorationCollection existingDecorations;
     if (useRealPropertyValue)
     {
         existingDecorations = range.GetRealPropertyValue(swd.Inline.TextDecorationsProperty, out realRange) as sw.TextDecorationCollection;
     }
     else
     {
         existingDecorations = range.GetPropertyValue(swd.Inline.TextDecorationsProperty) as sw.TextDecorationCollection;
     }
     return(existingDecorations != null && decorations.All(r => existingDecorations.Contains(r)));
 }
コード例 #23
0
        /// <summary>
        /// Implementation of Freezable.GetCurrentValueAsFrozenCore()
        /// </summary>
        protected override void GetCurrentValueAsFrozenCore(Freezable source)
        {
            TextDecorationCollection sourceTextDecorationCollection = (TextDecorationCollection)source;

            base.GetCurrentValueAsFrozenCore(source);

            int count = sourceTextDecorationCollection._collection.Count;

            _collection = new FrugalStructList <TextDecoration>(count);

            for (int i = 0; i < count; i++)
            {
                TextDecoration newValue = (TextDecoration)sourceTextDecorationCollection._collection[i].GetCurrentValueAsFrozen();
                OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                _collection.Add(newValue);
            }
        }
コード例 #24
0
ファイル: Conversions.cs プロジェクト: CheckTech/Eto
        public static FontDecoration Convert(sw.TextDecorationCollection decorations)
        {
            var decoration = FontDecoration.None;

            if (decorations != null)
            {
                if (sw.TextDecorations.Underline.All(decorations.Contains))
                {
                    decoration |= FontDecoration.Underline;
                }
                if (sw.TextDecorations.Strikethrough.All(decorations.Contains))
                {
                    decoration |= FontDecoration.Strikethrough;
                }
            }
            return(decoration);
        }
コード例 #25
0
ファイル: FontRendering.cs プロジェクト: erdao/Temp
 public FontRendering(
     double emSize,
     TextAlignment alignment,
     TextDecorationCollection decorations,
     Typeface face,
     Brush foreBrush,
     Brush backBrush,
     TextEffectCollection textEffectCollection)
 {
     _fontSize = emSize;
     _alignment = alignment;
     _textDecorations = decorations;
     _typeface = face;
     _foregroundBrush = foreBrush;
     _backgroundBrush = backBrush;
     _textEffects = textEffectCollection;
 }
コード例 #26
0
        public TextBlock GetTextBlock(MatchString matchedText, TextDecorationCollection matchDecoration, Brush matchColor)
        {
            TextBlock textBlock = new TextBlock();
            textBlock.HorizontalAlignment = HorizontalAlignment.Left;

            foreach (MatchSubstring matchSubstring in matchedText)
            {
                Run substringControl = new Run(matchSubstring.Value);
                if (matchSubstring.IsMatched)
                {
                    substringControl.TextDecorations = matchDecoration;
                    substringControl.Foreground = matchColor;
                }

                textBlock.Inlines.Add(substringControl);
            }

            return textBlock;
        }
コード例 #27
0
		/// <summary>
		/// Creates a new VisualLineElementTextRunProperties instance that copies its values
		/// from the specified <paramref name="textRunProperties"/>.
		/// For the <see cref="TextDecorations"/> and <see cref="TextEffects"/> collections, deep copies
		/// are created if those collections are not frozen.
		/// </summary>
		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();
			}
		}
コード例 #28
0
        [FriendAccessAllowed]   // used by Framework
        internal bool ValueEquals(TextDecorationCollection textDecorations)
        {
            if (textDecorations == null) 
                return false;   // o is either null or not TextDecorations object

            if (this == textDecorations) 
                return true;    // Reference equality.

            if ( this.Count != textDecorations.Count)
                return false;   // Two counts are different.

            // To be considered equal, TextDecorations should be same in the exact order.
            // Order matters because they imply the Z-order of the text decorations on screen.
            // Same set of text decorations drawn with different orders may have different result.
            for (int i = 0; i < this.Count; i++)
            {
                if (!this[i].ValueEquals(textDecorations[i]))
                    return false;
            }            
            return true;                     
        }
        public PascalSyntaxHighlighterFormat()
        {
            var firstCharacterUnderline = new TextDecoration();

            var underlinePen = new Pen
                            {
                                Brush =
                                    new LinearGradientBrush(
                                    Colors.Black, Colors.White, new Point(0.75, 0.5), new Point(1, 0.5)) { Opacity = 0.5 },
                                Thickness = 1.75,
                                DashStyle = DashStyles.Solid
                            };

            firstCharacterUnderline.Pen = underlinePen;
            firstCharacterUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;

            var textDecorations = new TextDecorationCollection { firstCharacterUnderline };
            this.TextDecorations = textDecorations;

            this.DisplayName = "Pascal Syntax Highlighter";
            this.IsBold = true;
        }
コード例 #30
0
 /// <summary>
 /// Constructing TextRunProperties
 /// </summary>
 /// <param name="typeface">typeface</param> 
 /// <param name="size">text size</param>
 /// <param name="hintingSize">text size for Truetype hinting program</param> 
 /// <param name="culture">text culture info</param> 
 /// <param name="textDecorations">TextDecorations </param>
 /// <param name="foregroundBrush">text foreground brush</param> 
 /// <param name="backgroundBrush">highlight background brush</param>
 /// <param name="baselineAlignment">text vertical alignment to its container</param>
 /// <param name="substitution">number substitution behavior to apply to the text; can be null,
 /// in which case the default number substitution method for the text culture is used</param> 
 public GenericTextRunProperties(
     Typeface                 typeface, 
     double                   size, 
     double                   hintingSize,
     TextDecorationCollection textDecorations, 
     Brush                    foregroundBrush,
     Brush                    backgroundBrush,
     BaselineAlignment        baselineAlignment,
     CultureInfo              culture, 
     NumberSubstitution       substitution
 ) 
 { 
      _typeface = typeface;
     _emSize = size; 
     _emHintingSize = hintingSize;
     _textDecorations = textDecorations;
     _foregroundBrush = foregroundBrush;
     _backgroundBrush = backgroundBrush; 
     _baselineAlignment = baselineAlignment;
     _culture = culture; 
     _numberSubstitution = substitution; 
 }
コード例 #31
0
ファイル: RichTextAreaHandler.cs プロジェクト: zzlvff/Eto
        void SetSelectionDecorationAttribute(sw.TextDecorationCollection setDecorations, bool value)
        {
            selectionAttributes = selectionAttributes ?? new Dictionary <sw.DependencyProperty, object>();
            object decorationsObj;

            sw.TextDecorationCollection decorations;
            if (!selectionAttributes.TryGetValue(swd.Inline.TextDecorationsProperty, out decorationsObj))
            {
                decorations = Control.Selection.GetPropertyValue(swd.Inline.TextDecorationsProperty) as sw.TextDecorationCollection;
                if (decorations == null)
                {
                    decorations = new sw.TextDecorationCollection();
                }
                else
                {
                    decorations = new sw.TextDecorationCollection(decorations);
                }
                selectionAttributes[swd.Inline.TextDecorationsProperty] = decorations;
            }
            else
            {
                decorations = (sw.TextDecorationCollection)decorationsObj;
            }

            foreach (var decoration in setDecorations)
            {
                if (value)
                {
                    decorations.Add(decoration);
                }
                else
                {
                    decorations.Remove(decoration);
                }
            }

            Control.Selection.ApplyPropertyValue(swd.Inline.TextDecorationsProperty, decorations);
        }
コード例 #32
0
        private TextDecorationCollection BuildDecoration()
        {
            var result = new TextDecorationCollection();
            if (HasFlag(0x01))
            {
                result.Add(new TextDecoration(TextDecorationLocation.Underline, null, 0.0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended));
            }
            else if (HasFlag(0x08))
            {
                result.Add(new TextDecoration(TextDecorationLocation.Strikethrough, null, 0.0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended));
            }
            else if (HasFlag(0x100))
            {
                result.Add(new TextDecoration() { Location = TextDecorationLocation.Underline, PenOffset = 1 });
                result.Add(new TextDecoration() { Location = TextDecorationLocation.Underline, PenOffset = -1 });
            }
            else if (HasFlag(0x200))
            {
                result.Add(new TextDecoration() { Location = TextDecorationLocation.Strikethrough, PenOffset = 0.5 });
                result.Add(new TextDecoration() { Location = TextDecorationLocation.Strikethrough, PenOffset = 0}   );
            }

            return result;
        }
コード例 #33
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; 
        }
コード例 #34
0
 protected virtual void SetDecorations(sw.TextDecorationCollection decorations)
 {
 }
コード例 #35
0
ファイル: TextAreaHandler.cs プロジェクト: yaram/Eto
 protected override void SetDecorations(sw.TextDecorationCollection decorations)
 {
     Control.TextDecorations = decorations;
 }
コード例 #36
0
ファイル: About.cs プロジェクト: emrul/CmisSync
        /// <summary>
        /// Constructor.
        /// </summary>
        public Link (string title, string address)
        {
            FontSize   = 11;
            Cursor     = Cursors.Hand;
            Foreground = new SolidColorBrush (Color.FromRgb (135, 178, 227));

            TextDecoration underline = new TextDecoration () {
                Pen              = new Pen (new SolidColorBrush (Color.FromRgb (135, 178, 227)), 1),
                PenThicknessUnit = TextDecorationUnit.FontRecommended
            };

            TextDecorationCollection collection = new TextDecorationCollection ();
            collection.Add (underline);

            TextBlock text_block = new TextBlock () {
                Text            = title,
                TextDecorations = collection
            };

            Content = text_block;

            MouseUp += delegate {
                Process.Start (new ProcessStartInfo (address));
            };
        }
コード例 #37
0
ファイル: RtfParser.cs プロジェクト: Titaye/SLExtensions
 private void ResetFont()
 {
     this.FontSize = 12;
     this.FontStyle = FontStyles.Normal;
     this.FontWeight = FontWeights.Normal;
     this.TextDecorations = null;
 }
コード例 #38
0
        private static string TextDecorationsFixup(TextDecorationCollection textDecorations)
        { 
            string stringValue = null;
            // Work around for incorrect serialization for TextDecorations property
            //
 
            // Special case for TextDecorations serialization
            if (TextDecorations.Underline.ValueEquals(textDecorations)) 
            { 
                stringValue = "Underline";
            } 
            else if (TextDecorations.Strikethrough.ValueEquals(textDecorations))
            {
                stringValue = "Strikethrough";
            } 
            else if (TextDecorations.OverLine.ValueEquals(textDecorations))
            { 
                stringValue = "OverLine"; 
            }
            else if (TextDecorations.Baseline.ValueEquals(textDecorations)) 
            {
                stringValue = "Baseline";
            }
            else if (textDecorations.Count == 0) 
            {
                stringValue = string.Empty; 
            
} 

            return stringValue; 
コード例 #39
0
ファイル: SystemFonts.cs プロジェクト: dox0/DotNet471RS3
        private static void CopyTextDecorationCollection(TextDecorationCollection from, TextDecorationCollection to)
        {
            int count = from.Count;

            for (int i = 0; i < count; ++i)
            {
                to.Add(from[i]);
            }
        }
コード例 #40
0
ファイル: WpfRenderer.cs プロジェクト: Core2D/Core2D
        /// <inheritdoc/>
        public override void Draw(object dc, XText text, double dx, double dy, ImmutableArray<XProperty> db, XRecord r)
        {
            var _dc = dc as DrawingContext;

            var style = text.Style;
            if (style == null)
                return;

            var tbind = text.BindText(db, r);
            if (string.IsNullOrEmpty(tbind))
                return;

            double thickness = style.Thickness / _state.ZoomX;
            double half = thickness / 2.0;

            Tuple<Brush, Pen> styleCached = _styleCache.Get(style);
            Brush fill;
            Pen stroke;
            if (styleCached != null)
            {
                fill = styleCached.Item1;
                stroke = styleCached.Item2;
            }
            else
            {
                fill = CreateBrush(style.Fill);
                stroke = CreatePen(style, thickness);
                _styleCache.Set(style, Tuple.Create(fill, stroke));
            }

            var rect = CreateRect(text.TopLeft, text.BottomRight, dx, dy);

            Tuple<string, FormattedText, ShapeStyle> tcache = _textCache.Get(text);
            FormattedText ft;
            string ct;
            if (tcache != null && string.Compare(tcache.Item1, tbind) == 0 && tcache.Item3 == style)
            {
                ct = tcache.Item1;
                ft = tcache.Item2;
                _dc.DrawText(ft, GetTextOrigin(style, ref rect, ft));
            }
            else
            {
                var ci = CultureInfo.InvariantCulture;

                var fontStyle = System.Windows.FontStyles.Normal;
                var fontWeight = FontWeights.Regular;

                if (style.TextStyle.FontStyle != null)
                {
                    if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Italic))
                    {
                        fontStyle = System.Windows.FontStyles.Italic;
                    }

                    if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Bold))
                    {
                        fontWeight = FontWeights.Bold;
                    }
                }

                var tf = new Typeface(new FontFamily(style.TextStyle.FontName), fontStyle, fontWeight, FontStretches.Normal);

                ft = new FormattedText(
                    tbind,
                    ci,
                    ci.TextInfo.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight,
                    tf,
                    style.TextStyle.FontSize > 0.0 ? style.TextStyle.FontSize : double.Epsilon,
                    stroke.Brush, null, TextFormattingMode.Ideal);

                if (style.TextStyle.FontStyle != null)
                {
                    if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Underline)
                    || style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Strikeout))
                    {
                        var decorations = new TextDecorationCollection();

                        if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Underline))
                        {
                            decorations = new TextDecorationCollection(
                                decorations.Union(TextDecorations.Underline));
                        }

                        if (style.TextStyle.FontStyle.Flags.HasFlag(Core2D.Style.FontStyleFlags.Strikeout))
                        {
                            decorations = new TextDecorationCollection(
                                decorations.Union(TextDecorations.Strikethrough));
                        }

                        ft.SetTextDecorations(decorations);
                    }
                }

                _textCache.Set(text, Tuple.Create(tbind, ft, style));

                _dc.DrawText(ft, GetTextOrigin(style, ref rect, ft));
            }
        }
コード例 #41
0
 void SetFrozenDecorations() => WpfTextDecorationsFrozen = (sw.TextDecorationCollection)WpfTextDecorations?.GetAsFrozen();
コード例 #42
0
		public OutlinedTextBlock()
		{
			TextDecorations = new TextDecorationCollection();
		}
コード例 #43
0
ファイル: LabelHandler.cs プロジェクト: nzysoft/Eto
 protected override void SetDecorations(sw.TextDecorationCollection decorations)
 {
     accessText.TextDecorations = decorations;
 }
コード例 #44
0
ファイル: RtfParser.cs プロジェクト: Titaye/SLExtensions
        /// <summary>
        /// Gets the next token.
        /// </summary>
        /// <returns></returns>
        public RtfToken NextToken()
        {
            RtfToken token;
            do {
                token = (RtfToken)Read();

                if (token.Type == RtfTokenType.ControlSymbol) {
                    if (token.Value == "*") {
                        SkipGroup();
                    }
                }
                else if (token.Type == RtfTokenType.ControlWord) {
                    if (token.Value == "colortbl") {
                        ParseColorTable();
                    }
                    else if (token.Value == "fonttbl") {
                        ParseFontTable();
                    }
                    else if (destinations.ContainsKey(token.Value)) {
                        SkipGroup();
                    }
                    else if (token.Value == "cf") {
                        int index = token.Parameter ?? 0;
                        if (index < this.colorTable.Count) {
                            this.Foreground = this.colorTable[token.Parameter.Value];
                        }
                    }
                    else if (token.Value == "f") {
                        int index = token.Parameter ?? 0;
                        string fontFamily;
                        if (this.fontTable.TryGetValue(index, out fontFamily)){
                            this.FontFamily = fontFamily;
                        }
                    }
                    else if (token.Value == "fs") {
                        if (token.Parameter.HasValue) {
                            this.FontSize = token.Parameter.Value / 1.5;
                        }
                    }
                    else if (token.Value == "b") {
                        this.FontWeight = token.Parameter == 0 ? FontWeights.Normal : FontWeights.Bold;
                    }
                    else if (token.Value == "i") {
                        this.FontStyle = token.Parameter == 0 ? FontStyles.Normal : FontStyles.Italic;
                    }
                    else if (token.Value == "ul") {
                        this.TextDecorations = token.Parameter == 0 ? null : System.Windows.TextDecorations.Underline;
                    }
                    else if (token.Value == "plain") {
                        ResetFont();
                    }
                    else if (token.Value == "par") {
                        break;
                    }
                }
                else if (token.Type == RtfTokenType.Text) {
                    break;
                }
            }
            while (!token.IsEof);

            return token;
        }
コード例 #45
0
        /// <summary>
        /// ConvertFromString
        /// </summary>
        /// <param name="text"> The string to be converted into TextDecorationCollection object </param> 
        /// <returns> the converted value of the string flag </returns>
        /// <remarks> 
        /// The text parameter can be either string "None" or a combination of the predefined 
        /// TextDecoration names delimited by commas (,). One or more blanks spaces can precede
        /// or follow each text decoration name or comma. There can't be duplicate TextDecoration names in the 
        /// string. The operation is case-insensitive.
        /// </remarks>
        public static new TextDecorationCollection ConvertFromString(string text)
        { 
            if (text == null)
            { 
               return null; 
            }
 
            TextDecorationCollection textDecorations = new TextDecorationCollection();

            // Flags indicating which Predefined textDecoration has alrady been added.
            byte MatchedTextDecorationFlags = 0; 

            // Start from the 1st non-whitespace character 
            // Negative index means error is encountered 
            int index = AdvanceToNextNonWhiteSpace(text, 0);
            while (index >= 0 && index < text.Length) 
            {
                if (Match(None, text, index))
                {
                    // Matched "None" in the input 
                    index = AdvanceToNextNonWhiteSpace(text, index + None.Length);
                    if (textDecorations.Count > 0 || index < text.Length) 
                    { 
                        // Error: "None" can only be specified by its own
                        index = -1; 
                    }
                }
                else
                { 
                    // Match the input with one of the predefined text decoration names
                    int i; 
                    for(i = 0; 
                           i < TextDecorationNames.Length
                        && !Match(TextDecorationNames[i], text, index); 
                       i++
                    );

                    if (i < TextDecorationNames.Length) 
                    {
                        // Found a match within the predefined names 
                        if ((MatchedTextDecorationFlags & (1 << i)) > 0) 
                        {
                            // Error: The matched value is duplicated. 
                            index = -1;
                        }
                        else
                        { 
                            // Valid match. Add to the collection and remember that this text decoration
                            // has been added 
                            textDecorations.Add(PredefinedTextDecorations[i]); 
                            MatchedTextDecorationFlags |= (byte)(1 << i);
 
                            // Advance to the start of next name
                            index = AdvanceToNextNameStart(text, index + TextDecorationNames[i].Length);
                        }
                    } 
                    else
                    { 
                        // Error: no match found in the predefined names 
                        index = -1;
                    } 
                }
            }

            if (index < 0) 
            {
                throw new ArgumentException(SR.Get(SRID.InvalidTextDecorationCollectionString, text)); 
            } 

            return textDecorations; 
        }
コード例 #46
0
        bool HasDecorations(swd.TextRange range, sw.TextDecorationCollection decorations)
        {
            var existingDecorations = GetPropertyValue(range, swd.Inline.TextDecorationsProperty) as sw.TextDecorationCollection;

            return(existingDecorations != null && decorations.All(r => existingDecorations.Contains(r)));
        }
コード例 #47
0
        /// <summary>
        /// ConvertFromString
        /// </summary>
        /// <param name="text"> The string to be converted into TextDecorationCollection object </param>
        /// <returns> the converted value of the string flag </returns>
        /// <remarks>
        /// The text parameter can be either string "None" or a combination of the predefined
        /// TextDecoration names delimited by commas (,). One or more blanks spaces can precede
        /// or follow each text decoration name or comma. There can't be duplicate TextDecoration names in the
        /// string. The operation is case-insensitive.
        /// </remarks>
        public static new TextDecorationCollection ConvertFromString(string text)
        {
            if (text == null)
            {
                return(null);
            }

            TextDecorationCollection textDecorations = new TextDecorationCollection();

            // Flags indicating which Predefined textDecoration has alrady been added.
            byte MatchedTextDecorationFlags = 0;

            // Start from the 1st non-whitespace character
            // Negative index means error is encountered
            int index = AdvanceToNextNonWhiteSpace(text, 0);

            while (index >= 0 && index < text.Length)
            {
                if (Match(None, text, index))
                {
                    // Matched "None" in the input
                    index = AdvanceToNextNonWhiteSpace(text, index + None.Length);
                    if (textDecorations.Count > 0 || index < text.Length)
                    {
                        // Error: "None" can only be specified by its own
                        index = -1;
                    }
                }
                else
                {
                    // Match the input with one of the predefined text decoration names
                    int i;
                    for (i = 0;
                         i < TextDecorationNames.Length &&
                         !Match(TextDecorationNames[i], text, index);
                         i++
                         )
                    {
                        ;
                    }

                    if (i < TextDecorationNames.Length)
                    {
                        // Found a match within the predefined names
                        if ((MatchedTextDecorationFlags & (1 << i)) > 0)
                        {
                            // Error: The matched value is duplicated.
                            index = -1;
                        }
                        else
                        {
                            // Valid match. Add to the collection and remember that this text decoration
                            // has been added
                            textDecorations.Add(PredefinedTextDecorations[i]);
                            MatchedTextDecorationFlags |= (byte)(1 << i);

                            // Advance to the start of next name
                            index = AdvanceToNextNameStart(text, index + TextDecorationNames[i].Length);
                        }
                    }
                    else
                    {
                        // Error: no match found in the predefined names
                        index = -1;
                    }
                }
            }

            if (index < 0)
            {
                throw new ArgumentException(SR.Get(SRID.InvalidTextDecorationCollectionString, text));
            }

            return(textDecorations);
        }