OSDN Git Service

一部プラットフォームでレタリングの間隔を一定にしてみた
authorkonekoneko <test2214@hotmail.co.jp>
Sun, 13 Nov 2016 18:36:41 +0000 (00:06 +0530)
committerkonekoneko <test2214@hotmail.co.jp>
Sun, 13 Nov 2016 18:36:41 +0000 (00:06 +0530)
UWP/FooEditEngine.UWP/FooTextBox.cs
WPF/FooEditEngine/FooTextBox.cs

index d6ab0ec..be4b14d 100644 (file)
@@ -104,7 +104,7 @@ namespace FooEditEngine.UWP
             this.gestureRecongnizer.ManipulationUpdated += gestureRecongnizer_ManipulationUpdated;
             this.gestureRecongnizer.ManipulationCompleted += gestureRecongnizer_ManipulationCompleted;
 
-            this.timer.Interval = new TimeSpan(0, 0, 0, 0, 500);
+            this.timer.Interval = new TimeSpan(0, 0, 0, 0, 16);
             this.timer.Tick += this.timer_Tick;
             this.timer.Start();
 
@@ -303,7 +303,7 @@ namespace FooEditEngine.UWP
         /// </summary>
         public void Refresh()
         {
-            this.Refresh(this.View.PageBound);
+            this.Document.RequestRedraw();
         }
 
         /// <summary>
@@ -352,6 +352,7 @@ namespace FooEditEngine.UWP
                 if (this.verticalScrollBar != null)
                     this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
                 this.IsEnabled = true;
+                this.Refresh(this.View.PageBound);
             }
         }
 
@@ -442,6 +443,7 @@ namespace FooEditEngine.UWP
             this.CreateTextContext();
 
             this.View.IsFocused = true;
+            this.timer.Start();
             this.Refresh();
         }
 
@@ -460,7 +462,8 @@ namespace FooEditEngine.UWP
             this.RemoveTextContext();
 
             this.View.IsFocused = false;
-            this.Refresh();
+            this.Refresh(this.View.PageBound);
+            this.timer.Stop();
         }
 
         private void CreateTextContext()
@@ -1259,7 +1262,9 @@ namespace FooEditEngine.UWP
         void timer_Tick(object sender, object e)
         {
             if (this.View.LayoutLines.HilightAll() || this.View.LayoutLines.GenerateFolding() || this.Document.IsRequestRedraw)
+            {
                 this.Refresh(this.View.PageBound);
+            }
         }
 
         private void SetDocument(Document value)
index c03183e..0bd9fff 100644 (file)
@@ -125,7 +125,7 @@ namespace FooEditEngine.WPF
             this.InputBindings.Add(new InputBinding(FooTextBoxCommands.ToggleCodePoint, new KeyGesture(Key.X, ModifierKeys.Alt)));
 
             this.timer = new DispatcherTimer();
-            this.timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
+            this.timer.Interval = new TimeSpan(0, 0, 0, 0, 16);
             this.timer.Tick += new EventHandler(timer_Tick);
 
             this.Loaded += new RoutedEventHandler(FooTextBox_Loaded);
@@ -337,7 +337,7 @@ namespace FooEditEngine.WPF
         /// </summary>
         public void Refresh()
         {
-            this.Refresh(this.View.PageBound);
+            this.Document.RequestRedraw();
         }
 
         /// <summary>
@@ -396,6 +396,7 @@ namespace FooEditEngine.WPF
                     this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
                 this.View.CalculateLineCountOnScreen();
                 this.IsEnabled = true;
+                this.Refresh(this.View.PageBound);
             }
         }
 
@@ -647,6 +648,7 @@ namespace FooEditEngine.WPF
             base.OnGotKeyboardFocus(e);
             this.textStore.SetFocus();
             this.View.IsFocused = true;
+            this.timer.Start();
             this.Refresh();
         }
 
@@ -658,7 +660,9 @@ namespace FooEditEngine.WPF
         {
             base.OnLostKeyboardFocus(e);
             this.View.IsFocused = false;
-            this.Refresh();
+            //タイマーを止めるので強制的に再描写させる
+            this.Refresh(this.View.PageBound);
+            this.timer.Stop();
         }
         #endregion
         #region Event
@@ -1132,14 +1136,14 @@ namespace FooEditEngine.WPF
                 return;
             if (this.Resize(this.image.ActualWidth, this.image.ActualHeight))
             {
-                this.Refresh();
+                this.Refresh(this.View.PageBound);
                 return;
             }
 
             bool updateAll = this.View.LayoutLines.HilightAll() || this.View.LayoutLines.GenerateFolding() || this.Document.IsRequestRedraw;
 
             if (updateAll)
-                this.Refresh();
+                this.Refresh(this.View.PageBound);
             else
                 this.Refresh(this.View.GetCurrentCaretRect());
         }