AddTextRunsToCurrentLine() public method

public AddTextRunsToCurrentLine ( IEnumerable textRuns ) : void
textRuns IEnumerable
return void
Exemplo n.º 1
0
 public override void InvokeRedo(InternalTextLayerController textdom)
 {
     textdom.CurrentLineNumber = startLineNumber;
     textdom.CharIndex         = startCharIndex;
     if (singleInsertTextRun != null)
     {
         textdom.AddTextRunToCurrentLine(singleInsertTextRun);
     }
     else
     {
         textdom.AddTextRunsToCurrentLine(insertingTextRuns);
     }
 }
Exemplo n.º 2
0
 public override void InvokeUndo(InternalTextLayerController textdom)
 {
     textdom.CancelSelect();
     textdom.AddTextRunsToCurrentLine(deletedTextRuns);
 }
Exemplo n.º 3
0
 public override void InvokeRedo(InternalTextLayerController textdom)
 {
     textdom.CurrentLineNumber = startLineNumber;
     textdom.CharIndex = startCharIndex;
     if (singleInsertTextRun != null)
     {
         textdom.AddTextRunToCurrentLine(singleInsertTextRun);
     }
     else
     {
         textdom.AddTextRunsToCurrentLine(insertingTextRuns);
     }
 }
        public void OnKeyDown(UIKeyEventArgs e)
        {
            this.SetCaretState(true);
            if (!e.HasKeyData)
            {
                return;
            }

            switch (e.KeyCode)
            {
            case UIKeys.Home:
            {
                this.DoHome(e.Shift);
            } break;

            case UIKeys.End:
            {
                this.DoEnd(e.Shift);
            } break;

            case UIKeys.Back:
            {
                if (internalTextLayerController.SelectionRange != null)
                {
                    InvalidateGraphicLocalArea(this, GetSelectionUpdateArea());
                }
                else
                {
                    InvalidateGraphicOfCurrentLineArea();
                }
                if (textSurfaceEventListener == null)
                {
                    internalTextLayerController.DoBackspace();
                }
                else
                {
                    if (!TextSurfaceEventListener.NotifyPreviewBackSpace(textSurfaceEventListener) &&
                        internalTextLayerController.DoBackspace())
                    {
                        TextSurfaceEventListener.NotifyCharactersRemoved(textSurfaceEventListener,
                                                                         new TextDomEventArgs(internalTextLayerController.updateJustCurrentLine));
                    }
                }

                EnsureCaretVisible();
            } break;

            case UIKeys.Delete:
            {
                if (internalTextLayerController.SelectionRange != null)
                {
                    InvalidateGraphicLocalArea(this, GetSelectionUpdateArea());
                }
                else
                {
                    InvalidateGraphicOfCurrentLineArea();
                }
                if (textSurfaceEventListener == null)
                {
                    internalTextLayerController.DoDelete();
                }
                else
                {
                    VisualSelectionRangeSnapShot delpart = internalTextLayerController.DoDelete();
                    TextSurfaceEventListener.NotifyCharactersRemoved(textSurfaceEventListener,
                                                                     new TextDomEventArgs(internalTextLayerController.updateJustCurrentLine));
                }

                EnsureCaretVisible();
            } break;

            default:
            {
                if (textSurfaceEventListener != null)
                {
                    UIKeys keycode = e.KeyCode;
                    if (keycode >= UIKeys.F1 && keycode <= UIKeys.F12)
                    {
                        InvalidateGraphicLocalArea(this, GetSelectionUpdateArea());
                        TextSurfaceEventListener.NotifyFunctionKeyDown(textSurfaceEventListener, keycode);
                        EnsureCaretVisible();
                    }
                }
            } break;
            }

            if (e.HasKeyData && e.Ctrl)
            {
                switch (e.KeyCode)
                {
                case UIKeys.C:
                {
                    StringBuilder stBuilder = GetFreeStringBuilder();
                    internalTextLayerController.CopySelectedTextToPlainText(stBuilder);
                    if (stBuilder != null)
                    {
                        if (stBuilder.Length == 0)
                        {
                            Clipboard.Clear();
                        }
                        else
                        {
                            Clipboard.SetText(stBuilder.ToString());
                        }
                    }
                    ReleaseStringBuilder(stBuilder);
                } break;

                case UIKeys.V:
                {
                    if (Clipboard.ContainUnicodeText())
                    {
                        internalTextLayerController.AddTextRunsToCurrentLine(
                            new EditableRun[] {
                                new EditableTextRun(this.Root,
                                                    Clipboard.GetUnicodeText(), this.CurrentTextSpanStyle)
                            });
                        EnsureCaretVisible();
                    }
                } break;

                case UIKeys.X:
                {
                    if (internalTextLayerController.SelectionRange != null)
                    {
                        if (internalTextLayerController.SelectionRange != null)
                        {
                            InvalidateGraphicLocalArea(this, GetSelectionUpdateArea());
                        }
                        StringBuilder stBuilder = GetFreeStringBuilder();
                        internalTextLayerController.CopySelectedTextToPlainText(stBuilder);
                        if (stBuilder != null)
                        {
                            Clipboard.SetText(stBuilder.ToString());
                        }

                        internalTextLayerController.DoDelete();


                        EnsureCaretVisible();
                        ReleaseStringBuilder(stBuilder);
                    }
                } break;

                case UIKeys.Z:
                {
                    internalTextLayerController.UndoLastAction();
                    EnsureCaretVisible();
                } break;

                case UIKeys.Y:
                {
                    internalTextLayerController.ReverseLastUndoAction();
                    EnsureCaretVisible();
                } break;

                case UIKeys.B:
                {
                    //TextSpanStyle style = internalTextLayerController.GetFirstTextStyleInSelectedRange();
                    //TextSpanStyle textStyle = null;

                    ////test only ***
                    ////TODO: make this more configurable
                    //if (style != null)
                    //{
                    //    TextSpanStyle defaultBeh = ((TextSpanStyle)style);
                    //    if (defaultBeh.FontBold)
                    //    {
                    //        textStyle = StyleHelper.CreateNewStyle(Color.Black);
                    //    }
                    //    else
                    //    {
                    //        textStyle = StyleHelper.CreateNewStyle(Color.Blue);
                    //    }
                    //}
                    //else
                    //{
                    //    textStyle = StyleHelper.CreateNewStyle(Color.Blue);
                    //}

                    //internalTextLayerController.DoFormatSelection(textStyle);

                    //if (internalTextLayerController.updateJustCurrentLine)
                    //{

                    //    InvalidateGraphicOfCurrentLineArea();
                    //}
                    //else
                    //{
                    //    InvalidateGraphics();
                    //}
                } break;
                }
            }
            if (textSurfaceEventListener != null)
            {
                TextSurfaceEventListener.NotifyKeyDown(textSurfaceEventListener, e.KeyCode);
            }
        }
Exemplo n.º 5
0
 public override void InvokeUndo(InternalTextLayerController textdom)
 {
     textdom.CancelSelect();
     textdom.AddTextRunsToCurrentLine(deletedTextRuns);
 }