Some questions

  1. When move a GoObject using arrow keys, if a portion of GoObject is off-screen, DocPosition is changed to locate the GoObject to center of screen.
How can I prevent that DocPosition is changing?
2. When zooming out using ctrl-key and mouse middle button on GoDrawView,
it is shrank to Left-Top of GoView. Can I change it to Left-Bottom?

Here’s the answer to #1

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();
      }
  }

}

Question #2.

Add this override to the class above.

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);
      }
  }

It’s solved. Thanks very much. Jake. :)