OSDN Git Service

LayoutLinesをDocumentに移動した
[fooeditengine/FooEditEngine.git] / Metro / FooEditEngine / FooTextBox.cs
index 9733adc..f40ec3b 100644 (file)
@@ -9,6 +9,7 @@
 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.\r
  */\r
 using System;\r
+using System.Text;\r
 using System.ComponentModel;\r
 using System.Threading.Tasks;\r
 using Windows.ApplicationModel.Resources.Core;\r
@@ -59,6 +60,7 @@ namespace FooEditEngine.Metro
             this.textStore = new TextStore2();\r
             this.textStore.IsLoading += textStore_IsLoading;\r
             this.textStore.IsReadOnly += textStore_IsReadOnly;\r
+            this.textStore.GetDpi += textStore_GetDpi;\r
             this.textStore.GetStringLength += () => this.Document.Length;\r
             this.textStore.GetString += _textStore_GetString;\r
             this.textStore.GetSelectionIndex += _textStore_GetSelectionIndex;\r
@@ -70,14 +72,13 @@ namespace FooEditEngine.Metro
             this.textStore.CompositionUpdated += textStore_CompositionUpdated;\r
             this.textStore.CompositionEnded += textStore_CompositionEnded;\r
 \r
-            this.Document = new Document();\r
-            DocumentExtend.Progress += Document_Progress;\r
-\r
             this.rectangle = new Windows.UI.Xaml.Shapes.Rectangle();\r
             this.rectangle.Margin = this.Padding;\r
             this.Render = new D2DRender(this,this.rectangle,this.textStore);\r
 \r
-            this.View = new EditView(this.Document, this.Render, new Margin(D2DRender.GripperWidth / 2, D2DRender.GripperWidth, D2DRender.GripperWidth / 2, D2DRender.GripperWidth));\r
+            this.Document = new Document(this.Render);\r
+\r
+            this.View = new EditView(this.Document, this.Render, new Padding(5, Gripper.HitAreaWidth, Gripper.HitAreaWidth / 2, Gripper.HitAreaWidth));\r
             this.View.SrcChanged += View_SrcChanged;\r
             this.View.InsertMode = this.InsertMode;\r
             this.View.DrawLineNumber = this.DrawLineNumber;\r
@@ -144,7 +145,6 @@ namespace FooEditEngine.Metro
                 this.View.Dispose();\r
                 this.Render.Dispose();\r
             }\r
-            DocumentExtend.Progress -= this.Document_Progress;\r
         }\r
 \r
         /// <summary>\r
@@ -154,8 +154,6 @@ namespace FooEditEngine.Metro
         /// <param name="length">長さ</param>\r
         public void Select(int start, int length)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             this._Controller.Select(start, length);\r
         }\r
 \r
@@ -166,8 +164,6 @@ namespace FooEditEngine.Metro
         /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>\r
         public void JumpCaret(int index)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             this._Controller.JumpCaret(index);\r
         }\r
         /// <summary>\r
@@ -178,8 +174,6 @@ namespace FooEditEngine.Metro
         /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>\r
         public void JumpCaret(int row, int col)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             this._Controller.JumpCaret(row, col);\r
         }\r
 \r
@@ -188,8 +182,6 @@ namespace FooEditEngine.Metro
         /// </summary>\r
         public void Copy()\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             string text = this._Controller.SelectedText;\r
             if (text != null && text != string.Empty)\r
             {\r
@@ -206,8 +198,6 @@ namespace FooEditEngine.Metro
         /// </summary>\r
         public void Cut()\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             string text = this._Controller.SelectedText;\r
             if (text != null && text != string.Empty)\r
             {\r
@@ -226,9 +216,6 @@ namespace FooEditEngine.Metro
         /// </summary>\r
         public async Task PasteAsync()\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
-\r
             var dataPackageView = Clipboard.GetContent();\r
             if (dataPackageView.Contains(StandardDataFormats.Text))\r
             {\r
@@ -241,8 +228,6 @@ namespace FooEditEngine.Metro
         /// </summary>\r
         public void SelectAll()\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             this._Controller.Select(0, this.Document.Length);\r
         }\r
 \r
@@ -251,8 +236,6 @@ namespace FooEditEngine.Metro
         /// </summary>\r
         public void DeSelectAll()\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             this._Controller.DeSelectAll();\r
         }\r
 \r
@@ -264,8 +247,6 @@ namespace FooEditEngine.Metro
         /// <remarks>テキストポイントがクライアント領域の原点より外にある場合、返される値は原点に丸められます</remarks>\r
         public Windows.Foundation.Point GetPostionFromTextPoint(TextPoint tp)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             if (this.Document.FireUpdateEvent == false)\r
                 throw new InvalidOperationException("");\r
             return this.View.GetPostionFromTextPoint(tp);\r
@@ -278,8 +259,6 @@ namespace FooEditEngine.Metro
         /// <returns>テキストポイント</returns>\r
         public TextPoint GetTextPointFromPostion(Windows.Foundation.Point p)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             if (this.Document.FireUpdateEvent == false)\r
                 throw new InvalidOperationException("");\r
             return this.View.GetTextPointFromPostion(p);\r
@@ -292,8 +271,6 @@ namespace FooEditEngine.Metro
         /// <returns>行の高さ</returns>\r
         public double GetLineHeight(int row)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             if (this.Document.FireUpdateEvent == false)\r
                 throw new InvalidOperationException("");\r
             return this.View.LayoutLines.GetLayout(row).Height; ;\r
@@ -306,8 +283,6 @@ namespace FooEditEngine.Metro
         /// <returns>座標を返す</returns>\r
         public Windows.Foundation.Point GetPostionFromIndex(int index)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             if (this.Document.FireUpdateEvent == false)\r
                 throw new InvalidOperationException("");\r
             TextPoint tp = this.View.GetLayoutLineFromIndex(index);\r
@@ -321,8 +296,6 @@ namespace FooEditEngine.Metro
         /// <returns>インデックスを返す</returns>\r
         public int GetIndexFromPostion(Windows.Foundation.Point p)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                throw new InvalidOperationException();\r
             if (this.Document.FireUpdateEvent == false)\r
                 throw new InvalidOperationException("");\r
             TextPoint tp = this.View.GetTextPointFromPostion(p);\r
@@ -345,6 +318,37 @@ namespace FooEditEngine.Metro
             this.View.PerfomLayouts();\r
         }\r
 \r
+        /// <summary>\r
+        /// ファイルからドキュメントを構築する\r
+        /// </summary>\r
+        /// <param name="sr">StremReader</param>\r
+        /// <returns>Taskオブジェクト</returns>\r
+        public async Task LoadFileAsync(System.IO.StreamReader sr, System.Threading.CancellationTokenSource token)\r
+        {\r
+            this.IsEnabled = false;\r
+            this.View.LayoutLines.IsFrozneDirtyFlag = true;\r
+            WinFileReader fs = new WinFileReader(sr);\r
+            await this.Document.LoadAsync(fs, token);\r
+            this.View.LayoutLines.IsFrozneDirtyFlag = false;\r
+            TextStoreHelper.NotifyTextChanged(this.textStore, 0, 0, this.Document.Length);\r
+            if (this.verticalScrollBar != null)\r
+                this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;\r
+            this.View.CalculateLineCountOnScreen();\r
+            this.IsEnabled = true;\r
+        }\r
+\r
+        /// <summary>\r
+        /// ドキュメントの内容をファイルに保存する\r
+        /// </summary>\r
+        /// <param name="sw">StreamWriter</param>\r
+        /// <param name="enc">エンコード</param>\r
+        /// <returns>Taskオブジェクト</returns>\r
+        public async Task SaveFile(System.IO.StreamWriter sw, System.Threading.CancellationTokenSource token)\r
+        {\r
+            WinFileWriter fs = new WinFileWriter(sw);\r
+            await this.Document.SaveAsync(fs, token);\r
+        }\r
+\r
         #region command\r
         void CopyCommand()\r
         {\r
@@ -424,8 +428,6 @@ namespace FooEditEngine.Metro
         /// <inheritdoc/>\r
         protected override async void OnKeyDown(KeyRoutedEventArgs e)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                return;\r
             bool isControlPressed = this.IsModiferKeyPressed(VirtualKey.Control);\r
             bool isShiftPressed = this.IsModiferKeyPressed(VirtualKey.Shift);\r
             bool isMovedCaret = false;\r
@@ -469,7 +471,7 @@ namespace FooEditEngine.Metro
                     if (isControlPressed)\r
                         this._Controller.JumpToHead(isShiftPressed);\r
                     else\r
-                        this._Controller.JumpCaret(this.View.CaretPostion.row, 0);\r
+                        this.Controller.JumpToLineHead(this.View.CaretPostion.row,isShiftPressed);\r
                     this.Refresh();\r
                     isMovedCaret = true;\r
                     break;\r
@@ -477,7 +479,7 @@ namespace FooEditEngine.Metro
                     if (isControlPressed)\r
                         this._Controller.JumpToEnd(isShiftPressed);\r
                     else\r
-                        this._Controller.JumpCaret(this.View.CaretPostion.row, this.View.LayoutLines[this.View.CaretPostion.row].Length - 1);\r
+                        this.Controller.JumpToLineEnd(this.View.CaretPostion.row,isShiftPressed);\r
                     this.Refresh();\r
                     isMovedCaret = true;\r
                     break;\r
@@ -593,7 +595,7 @@ namespace FooEditEngine.Metro
             this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));\r
             e.Handled = true;\r
 \r
-            if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && this.Document.State != AsyncState.Loading)\r
+            if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)\r
             {\r
                 Point p = e.GetCurrentPoint(this).Position;\r
                 if (this.View.HitTextArea(p.X, p.Y))\r
@@ -648,7 +650,7 @@ namespace FooEditEngine.Metro
 \r
         void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)\r
         {\r
-            if (this.FocusState == FocusState.Unfocused || this.Document.State == AsyncState.Loading)\r
+            if (this.FocusState == FocusState.Unfocused || !this.IsEnabled)\r
                 return;\r
             if (args.KeyCode >= 00 && args.KeyCode <= 0x1f)\r
                 return;\r
@@ -656,6 +658,13 @@ namespace FooEditEngine.Metro
             this.Refresh();\r
         }\r
 \r
+        double textStore_GetDpi()\r
+        {\r
+            float dpi;\r
+            this.Render.GetDpi(out dpi, out dpi);\r
+            return dpi;\r
+        }\r
+\r
         bool textStore_IsReadOnly()\r
         {\r
             return false;\r
@@ -663,7 +672,7 @@ namespace FooEditEngine.Metro
 \r
         bool textStore_IsLoading()\r
         {\r
-            return this.Document.State == AsyncState.Loading;\r
+            return false;\r
         }\r
 \r
         void textStore_CompositionEnded()\r
@@ -725,8 +734,6 @@ namespace FooEditEngine.Metro
 \r
         void _textStore_SetSelectionIndex(int i_startIndex, int i_endIndex)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                return;\r
             TextStoreHelper.SetSelectionIndex(this._Controller, this.View, i_startIndex, i_endIndex);\r
             this.Refresh();\r
         }\r
@@ -749,43 +756,46 @@ namespace FooEditEngine.Metro
         }\r
 \r
         Gripper FirstGripper, SecondGripper;\r
+        bool HittedCaret;\r
+        Gripper hittedGripper;\r
         void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)\r
         {\r
-        }\r
-\r
-        void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)\r
-        {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                return;\r
-            bool HittedCaret = false;\r
+            this.HittedCaret = false;\r
+            this.hittedGripper = null;\r
 \r
-            TextPoint tp = this.View.GetTextPointFromPostion(e.Position);\r
             Point p = e.Position;\r
-\r
+            TextPoint tp = this.View.GetTextPointFromPostion(p);\r
             if (tp == this.View.CaretPostion)\r
             {\r
                 HittedCaret = true;\r
             }\r
-\r
-            Gripper hittedGripper = null;\r
+            \r
             if (this.FirstGripper.IsHit(p))\r
             {\r
-                p = this.FirstGripper.AdjustPoint(p);\r
                 hittedGripper = this.FirstGripper;\r
                 HittedCaret = true;\r
             }\r
+            \r
             else if (this.SecondGripper.IsHit(p))\r
             {\r
-                p = this.SecondGripper.AdjustPoint(p);\r
                 hittedGripper = this.SecondGripper;\r
                 HittedCaret = true;\r
             }\r
+        }\r
 \r
+        void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)\r
+        {\r
             if (HittedCaret)\r
             {\r
-                if (hittedGripper != null && this.View.HitTextArea(p.X, p.Y))\r
+                Point p;\r
+                if (this.hittedGripper == null)\r
+                     p = e.Position;\r
+                else\r
+                    p = this.hittedGripper.AdjustPoint(e.Position);\r
+\r
+                if (hittedGripper != null)\r
                 {\r
-                    tp = this.View.GetTextPointFromPostion(p);\r
+                    TextPoint tp = this.View.GetTextPointFromPostion(p);\r
                     if (this._Controller.IsReverseSelect())\r
                     {\r
                         if (Object.ReferenceEquals(hittedGripper,this.SecondGripper))\r
@@ -800,11 +810,16 @@ namespace FooEditEngine.Metro
                         else\r
                             this._Controller.MoveCaretAndSelect(tp);\r
                     }\r
-                    if (this.peer != null)\r
-                        this.peer.OnNotifyCaretChanged();\r
-                    this.Refresh();\r
-                    return;\r
                 }\r
+                else\r
+                {\r
+                    TextPoint tp = this.View.GetTextPointFromPostion(p);\r
+                    this._Controller.MoveCaretAndSelect(tp);\r
+                }\r
+                if (this.peer != null)\r
+                    this.peer.OnNotifyCaretChanged();\r
+                this.Refresh();\r
+                return;\r
             }\r
             if (e.Delta.Scale < 1)\r
             {\r
@@ -865,6 +880,7 @@ namespace FooEditEngine.Metro
         async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)\r
         {\r
             ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.Metro/Resources");\r
+            ResourceContext context = ResourceContext.GetForCurrentView();\r
             if (this.View.HitTextArea(e.Position.X, e.Position.Y))\r
             {\r
                 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);\r
@@ -873,28 +889,28 @@ namespace FooEditEngine.Metro
                 if (!args.Handled)\r
                 {\r
                     PopupMenu ContextMenu = new PopupMenu();\r
-                    ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName").ValueAsString, (command) =>\r
+                    ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName", context).ValueAsString, (command) =>\r
                     {\r
                         this.CopyCommand();\r
                     }));\r
-                    ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName").ValueAsString, (command) =>\r
+                    ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName", context).ValueAsString, (command) =>\r
                     {\r
                         this.CutCommand();\r
                     }));\r
-                    ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName").ValueAsString, async (command) =>\r
+                    ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName", context).ValueAsString, async (command) =>\r
                     {\r
                         await this.PasteCommand();\r
                     }));\r
                     if (this._Controller.RectSelection)\r
                     {\r
-                        ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName").ValueAsString, (command) =>\r
+                        ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName", context).ValueAsString, (command) =>\r
                         {\r
                             this._Controller.RectSelection = false;\r
                         }));\r
                     }\r
                     else\r
                     {\r
-                        ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName").ValueAsString, (command) =>\r
+                        ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName", context).ValueAsString, (command) =>\r
                         {\r
                             this._Controller.RectSelection = true;\r
                         }));\r
@@ -914,9 +930,6 @@ namespace FooEditEngine.Metro
 \r
         void JumpCaret(Point p)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                return;\r
-            \r
             TextPoint tp = this.View.GetTextPointFromPostion(p);\r
             if (tp == TextPoint.Null)\r
                 return;\r
@@ -938,14 +951,12 @@ namespace FooEditEngine.Metro
             }\r
             if (this.peer != null)\r
                 this.peer.OnNotifyCaretChanged();\r
-            this.Focus(FocusState.Pointer);\r
+            this.View.IsFocused = true;\r
             this.Refresh();\r
         }\r
 \r
         void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                return;\r
             Point p = e.Position;\r
             if (this.View.HitTextArea(p.X, p.Y))\r
             {\r
@@ -967,8 +978,8 @@ namespace FooEditEngine.Metro
             if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0/* || !this.Render.IsCanDraw()*/)\r
                 return;\r
 \r
-            this.Render.BeginDraw();\r
-            if (this.Document.State != AsyncState.Loading)\r
+            this.Render.BegineDraw();\r
+            if (this.IsEnabled)\r
                 this.View.Draw(updateRect);\r
             else\r
                 this.Render.FillBackground(updateRect);\r
@@ -982,7 +993,7 @@ namespace FooEditEngine.Metro
         {\r
             if (width == 0 || height == 0)\r
                 throw new ArgumentOutOfRangeException();\r
-            if (this.Document.State != AsyncState.Loading && this.Render.Resize(this.rectangle, width, height))\r
+            if (this.Render.Resize(this.rectangle, width, height))\r
             {\r
                 this.View.PageBound = new Rectangle(0, 0, width, height);\r
 \r
@@ -1019,7 +1030,7 @@ namespace FooEditEngine.Metro
 \r
         void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)\r
         {\r
-            if (this.Document.State == AsyncState.Loading || this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))\r
+            if (this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))\r
             {\r
                 this.Refresh();\r
                 return;\r
@@ -1028,8 +1039,6 @@ namespace FooEditEngine.Metro
 \r
         void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                return;\r
             if (this.horizontalScrollBar == null)\r
                 return;\r
             double toX;\r
@@ -1045,8 +1054,6 @@ namespace FooEditEngine.Metro
 \r
         void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)\r
         {\r
-            if (this.Document.State == AsyncState.Loading)\r
-                return;\r
             if (this.verticalScrollBar == null)\r
                 return;\r
             int newRow = (int)this.verticalScrollBar.Value;\r
@@ -1060,30 +1067,9 @@ namespace FooEditEngine.Metro
 \r
         void Document_Update(object sender, DocumentUpdateEventArgs e)\r
         {\r
-            if (this.textStore.IsLocked() || this.Document.State == AsyncState.Loading || e.type == UpdateType.Clear)\r
-                return;\r
-            if (e.removeLength == 0)\r
-                this.textStore.NotifyTextChanged(e.startIndex, e.startIndex, e.startIndex + e.insertLength);\r
-            else\r
-                this.textStore.NotifyTextChanged(e.startIndex, e.startIndex + 1, e.startIndex + e.insertLength - e.removeLength);\r
-        }\r
-\r
-        void Document_Progress(object sender, ProgressEventArgs e)\r
-        {\r
-            if (this.Document.State == AsyncState.Loading)\r
+            if (this.textStore.IsLocked())\r
                 return;\r
-            switch (e.state)\r
-            {\r
-                case ProgressState.Start:\r
-                    this.textStore.NotifyTextChanged(0, this.Document.Length, 0);\r
-                    break;\r
-                case ProgressState.Complete:\r
-                    this.textStore.NotifyTextChanged(0, 0, this.Document.Length);\r
-                    if (this.verticalScrollBar != null)\r
-                        this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;\r
-                    this.View.CalculateLineCountOnScreen();\r
-                    break;\r
-            }\r
+            TextStoreHelper.NotifyTextChanged(this.textStore, e.startIndex, e.removeLength, e.insertLength);\r
         }\r
 \r
         void FooTextBox_Loaded(object sender, RoutedEventArgs e)\r
@@ -1125,29 +1111,31 @@ namespace FooEditEngine.Metro
             if (e.Property.Equals(FontSizeProperty))\r
                 source.Render.FontSize = source.FontSize;\r
             if (e.Property.Equals(ForegroundProperty))\r
-                source.Render.Foreground = source.Foreground;\r
+                source.Render.Foreground = D2DRenderBase.ToColor4(source.Foreground);\r
             if (e.Property.Equals(BackgroundProperty))\r
-                source.Render.Background = source.Background;\r
+                source.Render.Background = D2DRenderBase.ToColor4(source.Background);\r
             if (e.Property.Equals(ControlCharProperty))\r
-                source.Render.ControlChar = source.ControlChar;\r
+                source.Render.ControlChar = D2DRenderBase.ToColor4(source.ControlChar);\r
             if (e.Property.Equals(HilightProperty))\r
-                source.Render.Hilight = source.Hilight;\r
+                source.Render.Hilight = D2DRenderBase.ToColor4(source.Hilight);\r
             if (e.Property.Equals(Keyword1Property))\r
-                source.Render.Keyword1 = source.Keyword1;\r
+                source.Render.Keyword1 = D2DRenderBase.ToColor4(source.Keyword1);\r
             if (e.Property.Equals(Keyword2Property))\r
-                source.Render.Keyword2 = source.Keyword2;\r
+                source.Render.Keyword2 = D2DRenderBase.ToColor4(source.Keyword2);\r
             if (e.Property.Equals(CommentProperty))\r
-                source.Render.Comment = source.Comment;\r
+                source.Render.Comment = D2DRenderBase.ToColor4(source.Comment);\r
             if (e.Property.Equals(LiteralProperty))\r
-                source.Render.Literal = source.Literal;\r
+                source.Render.Literal = D2DRenderBase.ToColor4(source.Literal);\r
             if (e.Property.Equals(URLProperty))\r
-                source.Render.Url = source.URL;\r
+                source.Render.Url = D2DRenderBase.ToColor4(source.URL);\r
             if (e.Property.Equals(InsertCaretProperty))\r
-                source.Render.InsertCaret = source.InsertCaret;\r
+                source.Render.InsertCaret = D2DRenderBase.ToColor4(source.InsertCaret);\r
             if (e.Property.Equals(OverwriteCaretProperty))\r
-                source.Render.OverwriteCaret = source.OverwriteCaret;\r
+                source.Render.OverwriteCaret = D2DRenderBase.ToColor4(source.OverwriteCaret);\r
+            if (e.Property.Equals(PaddingProperty))\r
+                source.View.Padding = new Padding((int)source.Padding.Left, (int)source.Padding.Top, (int)source.Padding.Right, (int)source.Padding.Bottom);\r
             if (e.Property.Equals(LineMarkerProperty))\r
-                source.Render.LineMarker = source.LineMarker;\r
+                source.Render.LineMarker = D2DRenderBase.ToColor4(source.LineMarker);\r
             if (e.Property.Equals(MarkURLProperty))\r
                 source.View.UrlMark = source.MarkURL;\r
             if (e.Property.Equals(ShowFullSpaceProperty))\r
@@ -1162,6 +1150,8 @@ namespace FooEditEngine.Metro
                 source.View.LineBreak = source.LineBreakMethod;\r
             if (e.Property.Equals(LineBreakCharCountProperty))\r
                 source.View.LineBreakCharCount = source.LineBreakCharCount;\r
+            if (e.Property.Equals(UpdateAreaProperty))\r
+                source.Render.UpdateArea = D2DRenderBase.ToColor4(source.UpdateArea);\r
             if (e.Property.Equals(FlowDirectionProperty))\r
             {\r
                 source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;\r
@@ -1543,6 +1533,20 @@ namespace FooEditEngine.Metro
         public static readonly DependencyProperty URLProperty =\r
             DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));\r
 \r
+        /// <summary>\r
+        /// 行更新フラグの色を表す\r
+        /// </summary>\r
+        public Windows.UI.Color UpdateArea\r
+        {\r
+            get { return (Windows.UI.Color)GetValue(UpdateAreaProperty); }\r
+            set { SetValue(UpdateAreaProperty, value); }\r
+        }\r
+\r
+        /// <summary>\r
+        /// UpdateAreaの依存プロパティを表す\r
+        /// </summary>\r
+        public static readonly DependencyProperty UpdateAreaProperty =\r
+            DependencyProperty.Register("UpdateArea", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.MediumSeaGreen));\r
 \r
         /// <summary>\r
         /// ラインマーカーの色を表す\r
@@ -1590,6 +1594,21 @@ namespace FooEditEngine.Metro
             DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));\r
 \r
         /// <summary>\r
+        /// 余白を表す\r
+        /// </summary>\r
+        public new Thickness Padding\r
+        {\r
+            get { return (Thickness)GetValue(PaddingProperty); }\r
+            set { SetValue(PaddingProperty, value); }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Paddingの依存プロパティを表す\r
+        /// </summary>\r
+        public new static readonly DependencyProperty PaddingProperty =\r
+            DependencyProperty.Register("Padding", typeof(Thickness), typeof(FooTextBox), new PropertyMetadata(new Thickness(),OnPropertyChanged));        \r
+\r
+        /// <summary>\r
         /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです\r
         /// </summary>\r
         public bool InsertMode\r