Esempio n. 1
0
        /*
         *  かな漢字変換の途中で表示するテキストの書式を指定してきた。
         */
        private void EditContext_FormatUpdating(CoreTextEditContext sender, CoreTextFormatUpdatingEventArgs ev)
        {
            Debug.WriteLine("<<--- FormatUpdating: BG:{0} cancel:{1} range:({2},{3}) reason:{4} result:{5} color:{6} under-line:({7},{8})",
                            (ev.BackgroundColor == null ? "null" : ev.BackgroundColor.Value.ToString()),
                            ev.IsCanceled,
                            ev.Range.StartCaretPosition, ev.Range.EndCaretPosition,
                            ev.Reason,
                            ev.Result,
                            (ev.TextColor == null ? "null" : ev.TextColor.Value.ToString()),
                            (ev.UnderlineColor == null ? "null" : ev.UnderlineColor.Value.ToString()),
                            (ev.UnderlineType == null ? "null" : ev.UnderlineType.Value.ToString())
                            );

            if (ev.UnderlineType != null)
            {
                // 下線がnullでない場合

                // 選択範囲の文字の下線を指定します。
                for (int i = ev.Range.StartCaretPosition; i < ev.Range.EndCaretPosition; i++)
                {
                    // TCharはstructなので Chars[i]=ev.UnderlineType.Value; と書くとエラーになります。
                    TChar ch = Chars[i];
                    ch.Underline = ev.UnderlineType.Value;
                    Chars[i]     = ch;
                }
            }

            // 再描画します。
            Win2DCanvas.Invalidate();
        }
Esempio n. 2
0
        /*
         *  かな漢字変換の途中で表示するテキストの書式を指定してきた。
         */
        private void EditContext_FormatUpdating(CoreTextEditContext sender, CoreTextFormatUpdatingEventArgs ev)
        {
            Debug.WriteLine("<<--- FormatUpdating: BG:{0} cancel:{1} range:({2},{3}) reason:{4} result:{5} color:{6} under-line:({7},{8})",
                            (ev.BackgroundColor == null ? "null" : ev.BackgroundColor.Value.ToString()),
                            ev.IsCanceled,
                            ev.Range.StartCaretPosition, ev.Range.EndCaretPosition,
                            ev.Reason,
                            ev.Result,
                            (ev.TextColor == null ? "null" : ev.TextColor.Value.ToString()),
                            (ev.UnderlineColor == null ? "null" : ev.UnderlineColor.Value.ToString()),
                            (ev.UnderlineType == null ? "null" : ev.UnderlineType.Value.ToString())
                            );

            // カーソルがあると文字の操作に邪魔なので、いったん取り除きます。
            RemoveCursor();

            // 選択範囲の文字の書式を設定します。
            for (int i = ev.Range.StartCaretPosition; i < ev.Range.EndCaretPosition; i++)
            {
                // 文字を含むRunを得ます。
                Run r = (Run)EditText.Inlines[i];

                // 下線の種類によってRunの色を変えます。 ( Runには下線のプロパティがないので。 )
                switch (ev.UnderlineType)
                {
                case UnderlineType.Wave:
                    r.Foreground = BlueBrush;
                    break;

                case UnderlineType.Thick:
                    r.Foreground = GreenBrush;
                    break;

                case UnderlineType.Thin:
                    r.Foreground = RedBrush;
                    break;

                case UnderlineType.None:
                case UnderlineType.Undefined:
                default:
                    r.Foreground = BlackBrush;
                    break;
                }
            }

            // カーソルを挿入します。
            InsertCursor();
        }
Esempio n. 3
0
        void EditContext_FormatUpdating(CoreTextEditContext sender, CoreTextFormatUpdatingEventArgs args)
        {
            // The following code specifies how you would apply any formatting to the specified range of text
            // For this sample, we do not make any changes to the format.

            // Apply text color if specified.
            // A null value indicates that the default should be used.
            if (args.TextColor != null)
            {
                //InternalSetTextColor(args.Range, args.TextColor.Value);
            }
            else
            {
                //InternalSetDefaultTextColor(args.Range);
            }

            // Apply background color if specified.
            // A null value indicates that the default should be used.
            if (args.BackgroundColor != null)
            {
                //InternalSetBackgroundColor(args.Range, args.BackgroundColor.Value);
            }
            else
            {
                //InternalSetDefaultBackgroundColor(args.Range);
            }

            // Apply underline if specified.
            // A null value indicates that the default should be used.
            if (args.UnderlineType != null)
            {
                //TextDecoration underline = new TextDecoration(args.Range,args.UnderlineType.Value,args.UnderlineColor.Value);

                //InternalAddTextDecoration(underline);
            }
            else
            {
                //InternalRemoveTextDecoration(args.Range);
            }
        }
        void EditContext_FormatUpdating(CoreTextEditContext sender, CoreTextFormatUpdatingEventArgs args)
        {
            // The following code specifies how you would apply any formatting to the specified range of text
            // For this sample, we do not make any changes to the format.

            // Apply text color if specified.
            // A null value indicates that the default should be used.
            if (args.TextColor != null)
            {
                //InternalSetTextColor(args.Range, args.TextColor.Value);
            }
            else
            {
                //InternalSetDefaultTextColor(args.Range);
            }

            // Apply background color if specified.
            // A null value indicates that the default should be used.
            if (args.BackgroundColor != null)
            {
                //InternalSetBackgroundColor(args.Range, args.BackgroundColor.Value);
            }
            else
            {
                //InternalSetDefaultBackgroundColor(args.Range);
            }

            // Apply underline if specified.
            // A null value indicates that the default should be used.
            if (args.UnderlineType != null)
            {
                //TextDecoration underline = new TextDecoration(args.Range,args.UnderlineType.Value,args.UnderlineColor.Value);

                //InternalAddTextDecoration(underline);
            }
            else
            {
                //InternalRemoveTextDecoration(args.Range);
            }
        }