Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextFormattingRunProperties"/> class.
 /// </summary>
 public TextFormattingRunProperties(Typeface typeface, Double size, Color foreground)
 {
     _typeface        = typeface;
     _size            = _hintingSize = size;
     _foreground      = foreground;
     _foregroundBrush = new SolidColorBrush(foreground);
     _backgroundBrush = Brushes.Transparent;
     _textDecorations = new TextDecorationCollection();
     _textEffects     = new TextEffectCollection();
     _cultureInfo     = CultureInfo.CurrentCulture;
     if (_foregroundBrush.CanFreeze)
     {
         _foregroundBrush.Freeze();
     }
     if (_backgroundBrush.CanFreeze)
     {
         _backgroundBrush.Freeze();
     }
     if (_textEffects.CanFreeze)
     {
         _textEffects.Freeze();
     }
     if (_textDecorations.CanFreeze)
     {
         _textDecorations.Freeze();
     }
 }
Exemplo n.º 2
0
        private void OnTextDecorationCheckBoxChanged(object sender, RoutedEventArgs eventArgs)
        {
            // Only handle if changed was caused by user.
            if (_isInternalUpdate)
            {
                return;
            }

            var textDecorations = new TextDecorationCollection();

            if (_underlineCheckBox.IsChecked.GetValueOrDefault())
            {
                textDecorations.Add(TextDecorations.Underline);
            }

            if (_baselineCheckBox.IsChecked.GetValueOrDefault())
            {
                textDecorations.Add(TextDecorations.Baseline);
            }

            if (_strikethroughCheckBox.IsChecked.GetValueOrDefault())
            {
                textDecorations.Add(TextDecorations.Strikethrough);
            }

            if (_overlineCheckBox.IsChecked.GetValueOrDefault())
            {
                textDecorations.Add(TextDecorations.OverLine);
            }

            textDecorations.Freeze();
            SelectedTextDecorations = textDecorations;
        }
        static TextDecorations()
        {
            // Init Underline            
            TextDecoration td = new TextDecoration();
            td.Location       = TextDecorationLocation.Underline;
            underline         = new TextDecorationCollection();
            underline.Add(td);
            underline.Freeze();

            // Init strikethrough
            td = new TextDecoration();
            td.Location       = TextDecorationLocation.Strikethrough;
            strikethrough     = new TextDecorationCollection();
            strikethrough.Add(td);
            strikethrough.Freeze();
            
            // Init overline
            td = new TextDecoration();
            td.Location       = TextDecorationLocation.OverLine;
            overLine          = new TextDecorationCollection();
            overLine.Add(td);
            overLine.Freeze();

            // Init baseline
            td = new TextDecoration();
            td.Location       = TextDecorationLocation.Baseline;
            baseline          = new TextDecorationCollection();
            baseline.Add(td);
            baseline.Freeze();            
        }
Exemplo n.º 4
0
        static TextDecorations()
        {
            // Init Underline
            TextDecoration td = new TextDecoration();

            td.Location = TextDecorationLocation.Underline;
            underline   = new TextDecorationCollection();
            underline.Add(td);
            underline.Freeze();

            // Init strikethrough
            td            = new TextDecoration();
            td.Location   = TextDecorationLocation.Strikethrough;
            strikethrough = new TextDecorationCollection();
            strikethrough.Add(td);
            strikethrough.Freeze();

            // Init overline
            td          = new TextDecoration();
            td.Location = TextDecorationLocation.OverLine;
            overLine    = new TextDecorationCollection();
            overLine.Add(td);
            overLine.Freeze();

            // Init baseline
            td          = new TextDecoration();
            td.Location = TextDecorationLocation.Baseline;
            baseline    = new TextDecorationCollection();
            baseline.Add(td);
            baseline.Freeze();
        }
Exemplo n.º 5
0
        private static TextDecorationCollection GetDefaultInvalidDecorations()
        {
            DrawingGroup drawingGroup = new DrawingGroup();

            using (DrawingContext drawingContext = drawingGroup.Open())
            {
                Pen pen = new Pen(Brushes.Red, 0.33);

                drawingContext.DrawLine(pen, new Point(0.0, 0.0), new Point(0.5, 1.0));
                drawingContext.DrawLine(pen, new Point(0.5, 1.0), new Point(1.0, 0.0));
            }

            DrawingBrush brush = new DrawingBrush(drawingGroup);

            brush.TileMode      = TileMode.Tile;
            brush.Viewport      = new Rect(0, 0, 3, 3);
            brush.ViewportUnits = BrushMappingMode.Absolute;

            TextDecoration textDecoration = new TextDecoration(TextDecorationLocation.Underline, new Pen(brush, 3), 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.Pixel);

            TextDecorationCollection decorationCollection = new TextDecorationCollection();

            decorationCollection.Add(textDecoration);
            decorationCollection.Freeze();

            return(decorationCollection);
        }
 static BooleanToTextDecorationCollectionConverter()
 {
     Strikethrough = new TextDecorationCollection
     {
         TextDecorations.Strikethrough,
     };
     Strikethrough.Freeze();
 }
Exemplo n.º 7
0
        public Imla()
        {
            SpellCheker = null;
            gCollection = new TextDecorationCollection();
            TextDecoration dec = new TextDecoration();

            dec.Pen = new Pen {
                Thickness = 2, DashStyle = DashStyles.Dash, Brush = new SolidColorBrush(Colors.Red)
            };
            dec.PenThicknessUnit = TextDecorationUnit.FontRecommended;
            gCollection.Add(dec);
            gCollection.Freeze();
            FindReplace = false;
        }
Exemplo n.º 8
0
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Private Methods

        // Calculates TextDecorations for speller errors.
        private static TextDecorationCollection GetErrorTextDecorations()
        {
            //
            // Build a "squiggle" Brush.
            //
            // This works by hard-coding a 3 pixel high TextDecoration, and
            // then tiling horizontally.  (We can't scale the squiggle in
            // the vertical direction, there's no support to limit tiling
            // to just the horizontal from the MIL.)
            //

            DrawingGroup   drawingGroup   = new DrawingGroup();
            DrawingContext drawingContext = drawingGroup.Open();
            Pen            pen            = new Pen(Brushes.Red, 0.33);

            // This is our tile:
            //
            //  x   x
            //   x x
            //    x
            //
            drawingContext.DrawLine(pen, new Point(0.0, 0.0), new Point(0.5, 1.0));
            drawingContext.DrawLine(pen, new Point(0.5, 1.0), new Point(1.0, 0.0));

            drawingContext.Close();

            DrawingBrush brush = new DrawingBrush(drawingGroup);

            brush.TileMode      = TileMode.Tile;
            brush.Viewport      = new Rect(0, 0, 3, 3);
            brush.ViewportUnits = BrushMappingMode.Absolute;

            TextDecoration textDecoration = new TextDecoration(
                TextDecorationLocation.Underline,
                new Pen(brush, 3),
                0,
                TextDecorationUnit.FontRecommended,
                TextDecorationUnit.Pixel);

            TextDecorationCollection decorationCollection = new TextDecorationCollection();

            decorationCollection.Add(textDecoration);

            decorationCollection.Freeze();

            return(decorationCollection);
        }
Exemplo n.º 9
0
        private static void InitializeGlossMap()
        {
            var map = new GlossEntry[Enum.GetValues(typeof(Gloss)).Cast <int>().Aggregate((x, y) => x | y) + 1];

            // This is primarity for debugging.
            for (var i = 0; i < map.Length; i++)
            {
                map[i] = GlossEntry.ERROR;
            }

            Brush NOR = Brushes.Black;
            Brush TAG = Brushes.Purple;
            Brush SYM = Brushes.Gray;

            Brush COMBG = Brushes.Transparent;
            Brush INSBG = Brushes.LightGreen;
            Brush DELBG = Brushes.LightPink;
            Brush EMPBG = Brushes.Yellow;

            var STRIKE = new TextDecorationCollection()
            {
                TextDecorations.Strikethrough
            };

            STRIKE.Freeze();

            map[(int)(Gloss.NOR | Gloss.COM)] = new GlossEntry(NOR, COMBG, null);
            map[(int)(Gloss.NOR | Gloss.INS)] = new GlossEntry(NOR, INSBG, null);
            map[(int)(Gloss.NOR | Gloss.DEL)] = new GlossEntry(NOR, DELBG, STRIKE);
            map[(int)(Gloss.NOR | Gloss.EMP)] = new GlossEntry(NOR, EMPBG, null);
            map[(int)(Gloss.TAG | Gloss.COM)] = new GlossEntry(TAG, COMBG, null);
            map[(int)(Gloss.TAG | Gloss.INS)] = new GlossEntry(TAG, INSBG, null);
            map[(int)(Gloss.TAG | Gloss.DEL)] = new GlossEntry(TAG, DELBG, STRIKE);
            map[(int)(Gloss.TAG | Gloss.EMP)] = new GlossEntry(TAG, EMPBG, null);
            map[(int)(Gloss.SYM | Gloss.COM)] = GlossEntry.IGNORE;
            map[(int)(Gloss.SYM | Gloss.INS)] = GlossEntry.IGNORE;
            map[(int)(Gloss.SYM | Gloss.DEL)] = GlossEntry.IGNORE;
            map[(int)(Gloss.SYM | Gloss.EMP)] = GlossEntry.IGNORE;
            map[(int)(Gloss.ALT | Gloss.COM)] = new GlossEntry(SYM, COMBG, null);
            map[(int)(Gloss.ALT | Gloss.INS)] = new GlossEntry(SYM, INSBG, null);
            map[(int)(Gloss.ALT | Gloss.DEL)] = new GlossEntry(SYM, DELBG, STRIKE);
            map[(int)(Gloss.ALT | Gloss.EMP)] = new GlossEntry(SYM, EMPBG, null);

            GlossMap = map;
        }
        // Token: 0x0600357E RID: 13694 RVA: 0x000F2DEC File Offset: 0x000F0FEC
        private static TextDecorationCollection GetErrorTextDecorations()
        {
            DrawingGroup   drawingGroup   = new DrawingGroup();
            DrawingContext drawingContext = drawingGroup.Open();
            Pen            pen            = new Pen(Brushes.Red, 0.33);

            drawingContext.DrawLine(pen, new Point(0.0, 0.0), new Point(0.5, 1.0));
            drawingContext.DrawLine(pen, new Point(0.5, 1.0), new Point(1.0, 0.0));
            drawingContext.Close();
            TextDecoration value = new TextDecoration(TextDecorationLocation.Underline, new Pen(new DrawingBrush(drawingGroup)
            {
                TileMode      = TileMode.Tile,
                Viewport      = new Rect(0.0, 0.0, 3.0, 3.0),
                ViewportUnits = BrushMappingMode.Absolute
            }, 3.0), 0.0, TextDecorationUnit.FontRecommended, TextDecorationUnit.Pixel);
            TextDecorationCollection textDecorationCollection = new TextDecorationCollection();

            textDecorationCollection.Add(value);
            textDecorationCollection.Freeze();
            return(textDecorationCollection);
        }
Exemplo n.º 11
0
        private void UpdateSelectedDecorations()
        {
            TextDecorationCollection newDecorations = new TextDecorationCollection();

            if (IsUnderline)
            {
                newDecorations.Add(System.Windows.TextDecorations.Underline[0]);
            }
            if (IsStrikethrough)
            {
                newDecorations.Add(System.Windows.TextDecorations.Strikethrough[0]);
            }
            if (IsBaseline)
            {
                newDecorations.Add(System.Windows.TextDecorations.Baseline[0]);
            }
            if (IsOverLine)
            {
                newDecorations.Add(System.Windows.TextDecorations.OverLine[0]);
            }
            newDecorations.Freeze();
            SelectedDecorations = newDecorations;
        }
        private void textDecorationCheckStateChanged(object sender, RoutedEventArgs e)
        {
            TextDecorationCollection textDecorations = new TextDecorationCollection();

            if (underlineCheckBox.IsChecked.Value)
            {
                textDecorations.Add(TextDecorations.Underline[0]);
            }
            if (baselineCheckBox.IsChecked.Value)
            {
                textDecorations.Add(TextDecorations.Baseline[0]);
            }
            if (strikethroughCheckBox.IsChecked.Value)
            {
                textDecorations.Add(TextDecorations.Strikethrough[0]);
            }
            if (overlineCheckBox.IsChecked.Value)
            {
                textDecorations.Add(TextDecorations.OverLine[0]);
            }

            textDecorations.Freeze();
            SelectedTextDecorations = textDecorations;
        }
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Private Methods

        // Calculates TextDecorations for speller errors.
        private static TextDecorationCollection GetErrorTextDecorations()
        {
            //
            // Build a "squiggle" Brush.
            //
            // This works by hard-coding a 3 pixel high TextDecoration, and
            // then tiling horizontally.  (We can't scale the squiggle in
            // the vertical direction, there's no support to limit tiling
            // to just the horizontal from the MIL.)
            //

            DrawingGroup drawingGroup = new DrawingGroup();
            DrawingContext drawingContext = drawingGroup.Open();
            Pen pen = new Pen(Brushes.Red, 0.33);

            // This is our tile:
            //
            //  x   x
            //   x x
            //    x
            //
            drawingContext.DrawLine(pen, new Point(0.0, 0.0), new Point(0.5, 1.0));
            drawingContext.DrawLine(pen, new Point(0.5, 1.0), new Point(1.0, 0.0));

            drawingContext.Close();

            DrawingBrush brush = new DrawingBrush(drawingGroup);
            brush.TileMode = TileMode.Tile;
            brush.Viewport = new Rect(0, 0, 3, 3);
            brush.ViewportUnits = BrushMappingMode.Absolute;

            TextDecoration textDecoration = new TextDecoration(
                            TextDecorationLocation.Underline,
                            new Pen(brush, 3),
                            0,
                            TextDecorationUnit.FontRecommended,
                            TextDecorationUnit.Pixel);

            TextDecorationCollection decorationCollection = new TextDecorationCollection();
            decorationCollection.Add(textDecoration);

            decorationCollection.Freeze();

            return decorationCollection;
        }
Exemplo n.º 14
0
 static GlossEntry()
 {
     None = new TextDecorationCollection();
     None.Freeze();
 }
Exemplo n.º 15
0
        void textDecorationCheckStateChanged(object sender, RoutedEventArgs e)
        {
            var textDecorations = new TextDecorationCollection();

            if (underlineCheckBox.IsChecked.Value)
            {
                textDecorations.Add(TextDecorations.Underline[0]);
            }
            if (baselineCheckBox.IsChecked.Value)
            {
                textDecorations.Add(TextDecorations.Baseline[0]);
            }
            if (strikethroughCheckBox.IsChecked.Value)
            {
                textDecorations.Add(TextDecorations.Strikethrough[0]);
            }
            if (overlineCheckBox.IsChecked.Value)
            {
                textDecorations.Add(TextDecorations.OverLine[0]);
            }

            textDecorations.Freeze();
            SelectedTextDecorations = textDecorations;
        }