OSDN Git Service

スワイプ方向の判定方法を賢くした
authorgdkhd812 <test@nnn.co.jp>
Thu, 22 Oct 2015 16:30:44 +0000 (22:00 +0530)
committergdkhd812 <test@nnn.co.jp>
Thu, 22 Oct 2015 16:30:44 +0000 (22:00 +0530)
Metro/FooEditEngine/FooTextBox.cs

index 7001625..6468898 100644 (file)
@@ -852,6 +852,7 @@ namespace FooEditEngine.Metro
                 
                 return;
             }
+
             if (e.Delta.Scale < 1)
             {
                 double newSize = this.Render.FontSize - 1;
@@ -873,17 +874,18 @@ namespace FooEditEngine.Metro
                 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
                 return;
             }
-
+            
             Point translation = e.Delta.Translation;
 
-            System.Diagnostics.Debug.WriteLine("tran y:{0}", translation.Y);
-            int scrollCount = 0;
-            if (e.PointerDeviceType == PointerDeviceType.Mouse)  //ホイールを使っているので、スクロール行数を計算する
-                scrollCount = (int)Math.Abs(translation.Y / sender.MouseWheelParameters.CharTranslation.Y);
-            else
-                scrollCount = (int)Math.Abs(Math.Ceiling(translation.Y));
-            if (scrollCount > 0)
+            //Xの絶対値が大きければ横方向のスクロールで、そうでなければ縦方向らしい
+            if (Math.Abs(e.Cumulative.Translation.X) < Math.Abs(e.Cumulative.Translation.Y))
             {
+                int scrollCount = 0;
+                if (e.PointerDeviceType == PointerDeviceType.Mouse)  //ホイールを使っているので、スクロール行数を計算する
+                    scrollCount = (int)Math.Abs(translation.Y / sender.MouseWheelParameters.CharTranslation.Y);
+                else
+                    scrollCount = (int)Math.Abs(Math.Ceiling(translation.Y));
+
                 if (translation.Y > 0)
                     this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
                 else
@@ -894,7 +896,7 @@ namespace FooEditEngine.Metro
                 return;
             }
 
-            int deltax = (int)Math.Abs(translation.X);
+            int deltax = (int)Math.Abs(Math.Ceiling(translation.X));
             if (deltax != 0)
             {
                 if (translation.X < 0)