}
/// <summary>
- /// 指定した座標までスクロールする
- /// </summary>
- /// <param name="x"></param>
- /// <param name="row"></param>
- /// <remarks>
- /// 範囲外の座標を指定した場合、範囲内に収まるように調整されます
- /// </remarks>
- public void Scroll(double x, double y)
- {
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
- double totalHeight = this.LayoutLines.Count * this.render.emSize.Height;
- if (y > totalHeight)
- y = totalHeight - this.render.TextArea.Height;
- base.TryScroll(x, y);
- }
-
- /// <summary>
/// 指定行までスクロールする
/// </summary>
/// <param name="row">行</param>
return false;
}
- public virtual bool TryScroll(double x, double y)
+ Point total = new Point();
+ double noti;
+ public virtual bool TryRelativeScroll(double delta_x, double delta_y, bool logical_scroll = true)
{
+ total.X += delta_x;
+ total.Y += delta_y;
+ noti += Math.Abs(delta_y); //負の値が飛んでくる可能性がある
+
+ if (noti < this.render.emSize.Height && logical_scroll)
+ return true;
+
+ noti = 0;
+
+ double totalHeight = this.LayoutLines.Count * this.render.emSize.Height;
+ if (total.Y > totalHeight)
+ total.Y = totalHeight - this.render.TextArea.Height;
+ if (total.Y < 0)
+ total.Y = 0;
+ if (total.X < 0)
+ total.X = 0;
+
int row;
- if (y > 0)
- row = (int)(y / this.render.emSize.Height + 1.0); //レタリング時にオフセットするために切り上げる
+ if (total.Y > 0)
+ row = (int)(total.Y / this.render.emSize.Height + 1.0); //レタリング時にオフセットするために切り上げる
else
row = 0; //0の時だけは切り上げると困るので何もしない
if (row < 0)
return true;
if (row > this.LayoutLines.Count - 1)
return true;
- this.Document.Src = new SrcPoint(x, row, y);
+ this.Document.Src = new SrcPoint(total.X, row, total.Y);
this.SrcChanged(this, null);
+
return false;
}
//Xの絶対値が大きければ横方向のスクロールで、そうでなければ縦方向らしい
if (Math.Abs(e.Cumulative.Translation.X) < Math.Abs(e.Cumulative.Translation.Y))
{
- System.Diagnostics.Debug.WriteLine("tran y:{0}", translation.Y);
//下に動かした場合はマイナスの値が飛んでくる、上に動かした場合はプラスの値が飛んでくる
- this.View.Scroll(this.Document.Src.X, this.Document.Src.Y - translation.Y);
- this.View.IsFocused = false;
- this.Document.SelectGrippers.BottomLeft.Enabled = false;
- this.Document.SelectGrippers.BottomRight.Enabled = false;
- this.Refresh();
+ if(!this.View.TryRelativeScroll(0, -translation.Y, false))
+ {
+ this.View.IsFocused = false;
+ this.Document.SelectGrippers.BottomLeft.Enabled = false;
+ this.Document.SelectGrippers.BottomRight.Enabled = false;
+ this.Refresh();
+ }
return;
}
if (Math.Abs(e.CumulativeManipulation.Translation.X) < Math.Abs(e.CumulativeManipulation.Translation.Y))
{
//下に動かした場合はマイナスの値が飛んでくる、上に動かした場合はプラスの値が飛んでくる
- this.View.Scroll(this.Document.Src.X, this.Document.Src.Y - translation.Y);
- this.View.IsFocused = false;
- this.Document.SelectGrippers.BottomLeft.Enabled = false;
- this.Document.SelectGrippers.BottomRight.Enabled = false;
- this.touchScrolled = true;
- this.Refresh();
+ if(!this.View.TryRelativeScroll(0, -translation.Y))
+ {
+ this.View.IsFocused = false;
+ this.Document.SelectGrippers.BottomLeft.Enabled = false;
+ this.Document.SelectGrippers.BottomRight.Enabled = false;
+ this.touchScrolled = true;
+ this.Refresh();
+ }
return;
}