install this tool by doing this at startup for your GoView (view1)
view1.DefaultTool = new ToolManagerNoScrollOnArrowKey(view1);
// allow arrow keys to move selection, but don't update DocPosition to keep object in view. (i.e. no autoscroll)
[Serializable]
public class ToolManagerNoScrollOnArrowKey : GoToolManager
{
public ToolManagerNoScrollOnArrowKey(GoView v) : base(v) { }
public override void DoKeyDown()
{
GoInputEventArgs evt = this.LastInput;
bool control = evt.Control;
bool shift = evt.Shift;
GoViewDisableKeys cant = this.View.DisableKeys;
System.Windows.Forms.Keys key = evt.Key;
if (key == System.Windows.Forms.Keys.Up || key == System.Windows.Forms.Keys.Down ||
key == System.Windows.Forms.Keys.Left || key == System.Windows.Forms.Keys.Right)
{
float dx = 0;
float dy = 0;
switch (key)
{
case System.Windows.Forms.Keys.Left: dx = -1; break;
case System.Windows.Forms.Keys.Right: dx = 1; break;
case System.Windows.Forms.Keys.Up: dy = -1; break;
case System.Windows.Forms.Keys.Down: dy = 1; break;
}
if (!this.View.Selection.IsEmpty && this.View.CanMoveObjects() && ((cant & GoViewDisableKeys.ArrowMove) == 0))
{
float f = 1;
if (control)
{
f = this.View.ArrowMoveSmall;
}
else
{
f = this.View.ArrowMoveLarge;
}
GoToolDragging dragtool = this.View.FindMouseTool(typeof(GoToolDragging), true) as GoToolDragging;
if (dragtool != null)
{
GoSelection effsel = dragtool.ComputeEffectiveSelection(this.View.Selection, true);
this.View.MoveSelection(effsel, new SizeF(dx * f, dy * f), true);
this.View.RaiseSelectionMoved();
}
}
else
{
base.DoKeyDown();
}
}
else
{
base.DoKeyDown();
}
}
Note this zooms to the TopLeft corner UNTIL the document
is larger than the view, then it zooms to the bottom left. Also note the old code actually was
zooming on a focus around the mouse position… I’ve left the old code commented out.
public override void DoMouseWheel()
{
GoInputEventArgs evt = this.LastInput;
if (evt.Delta == 0) return;
GoView view = this.View;
GoControl goctrl = view.EditControl;
if (goctrl != null) {
view.RequestFocus(); // should end the edit like a Tab would.
}
if (evt.Control)
{
PointF oldpos = view.DocPosition;
SizeF oldExt = view.DocExtentSize;
view.DocScale *= (1 + ((float)evt.Delta) / 2400);
PointF focus = view.ConvertViewToDoc(evt.ViewPoint);
//view.DocPosition = new PointF(oldpos.X + evt.DocPoint.X - focus.X, oldpos.Y + evt.DocPoint.Y - focus.Y);
view.DocPosition = new PointF(oldpos.X, oldpos.Y + oldExt.Height);
}
else
{
view.DoWheel(this.LastInput);
}
}