OSDN Git Service

WPF版でナレーターのキャレット位置が正しく表示されないバグを修正した
authortest <test@yahoo.co.jp>
Fri, 1 Jan 2021 12:13:12 +0000 (21:13 +0900)
committertest <test@yahoo.co.jp>
Fri, 1 Jan 2021 12:13:12 +0000 (21:13 +0900)
Core/Automaion/FooTextBoxAutomationPeer.cs
Core/Controller.cs
Core/LineToIndex.cs
WPF/FooEditEngine/FooTextBox.cs

index b8c92da..e16d9a5 100644 (file)
@@ -437,8 +437,8 @@ namespace FooEditEngine
             bottomRightPos = bottomRightPos.Scale(scale);
 #endif
 #if WPF
-            System.Windows.Point topLeftPos = this.textbox.GetPostionFromTextPoint(topLeft);
-            System.Windows.Point bottomRightPos = this.textbox.GetPostionFromTextPoint(bottomRight);
+            Point topLeftPos = this.textbox.GetPostionFromTextPoint(topLeft);
+            Point bottomRightPos = this.textbox.GetPostionFromTextPoint(bottomRight);
             topLeftPos = this.textbox.PointToScreen(topLeftPos);
             bottomRightPos = this.textbox.PointToScreen(bottomRightPos);
 #endif
@@ -448,7 +448,7 @@ namespace FooEditEngine
                 width = 1;
             Rectangle rect = new Rectangle(topLeftPos.X, topLeftPos.Y,
                  width,
-                 bottomRightPos.Y - topLeftPos.Y + layoutLineCollection.GetLayout(bottomRight.row).Height);
+                 bottomRightPos.Y - topLeftPos.Y + layoutLineCollection.GetLineHeight(bottomRight));
 
 #if METRO || WINDOWS_UWP
             rectangles = new double[4]{
@@ -561,6 +561,8 @@ namespace FooEditEngine
                     newCaret = ctrl.GetNextCaret(caret, count, MoveFlow.Word, out moved);
                     break;
                 case TextUnit.Line:
+                    newCaret = ctrl.GetNextCaret(caret, count, MoveFlow.Line, out moved);
+                    break;
                 case TextUnit.Paragraph:
                     newCaret = ctrl.GetNextCaret(caret, count, MoveFlow.Paragraph, out moved);
                     break;
index 86c4e90..d9655ec 100644 (file)
@@ -557,7 +557,7 @@ namespace FooEditEngine
             {
                 for (int i = Math.Abs(count); i > 0; i--)
                 {
-                    caret = this.MoveCaretVertical(caret, count > 0);
+                    caret = this.MoveCaretVertical(caret, count > 0, method == MoveFlow.Paragraph);
                     moved++;
                 }
             }
@@ -885,10 +885,11 @@ namespace FooEditEngine
         /// </summary>
         /// <param name="count">移動量</param>
         /// <param name="current">現在のキャレット位置</param>
+        /// <param name="move_pargraph">パラグラフ単位で移動するなら真</param>
         /// <returns>移動後のキャレット位置</returns>
-        public TextPoint GetTextPointAfterMoveLine(int count, TextPoint current)
+        public TextPoint GetTextPointAfterMoveLine(int count, TextPoint current, bool move_pargraph = false)
         {
-            if(this.Document.LineBreak == LineBreakMethod.None)
+            if(this.Document.LineBreak == LineBreakMethod.None || move_pargraph == true)
             {
                 int row = current.row + count;
 
@@ -1024,13 +1025,14 @@ namespace FooEditEngine
         /// キャレットを行方向に移動させる
         /// </summary>
         /// <param name="isMoveNext">プラス方向に移動するなら真</param>
+        /// <param name="move_pargraph">パラグラフ単位で移動するするなら真</param>
         /// <remarks>このメソッドを呼び出した後でScrollToCaretメソッドとSelectWithMoveCaretメソッドを呼び出す必要があります</remarks>
-        TextPoint MoveCaretVertical(TextPoint caret,bool isMoveNext)
+        TextPoint MoveCaretVertical(TextPoint caret,bool isMoveNext, bool move_pargraph = false)
         {
             if (this.Document.FireUpdateEvent == false)
                 throw new InvalidOperationException("");
 
-            return this.GetTextPointAfterMoveLine(isMoveNext ? 1 : -1, this.Document.CaretPostion);
+            return this.GetTextPointAfterMoveLine(isMoveNext ? 1 : -1, this.Document.CaretPostion, move_pargraph);
         }
 
         private void ReplaceBeforeSelectionArea(SelectCollection Selections, int removeLength, string insertStr)
index 1a44990..484d9d2 100644 (file)
@@ -663,6 +663,16 @@ namespace FooEditEngine
             return this.Lines[row].Dirty;
         }
 
+        /// <summary>
+        /// 行の高さを返す
+        /// </summary>
+        /// <param name="tp">テキストポイント</param>
+        /// <returns>テキストポイントで指定された行の高さを返します</returns>
+        public double GetLineHeight(TextPoint tp)
+        {
+            return this.render.emSize.Height;
+        }
+
         internal ITextLayout GetLayout(int row)
         {
             if (this.Lines[row].Layout != null && this.Lines[row].Layout.Invaild)
index a11ab06..57b07aa 100644 (file)
@@ -282,7 +282,7 @@ namespace FooEditEngine.WPF
         {
             if (this.Document.FireUpdateEvent == false)
                 throw new InvalidOperationException("");
-            return this.View.GetPostionFromTextPoint(tp);
+            return this.image.TranslatePoint(this.View.GetPostionFromTextPoint(tp),this);
         }
 
         /// <summary>
@@ -294,6 +294,7 @@ namespace FooEditEngine.WPF
         {
             if (this.Document.FireUpdateEvent == false)
                 throw new InvalidOperationException("");
+            System.Windows.Point relP = this.TranslatePoint(p, this.image);
             return this.View.GetTextPointFromPostion(p);
         }