Scrolling using mouse

I want to implement scrolling functionality i.e. when “Control” key is pressed mouse cursor should change to “Hand” and should be able to scroll the view using key + mouse button combination.

How this can be achieved?

GoToolPanning implements panning. Look in the API reference for the GoToolPanning Class. (By default, it is enabled as the middle mouse button.)



There are also several discussions in this forum on customizing panning with different options. search for GoToolPanning.

That sounds like an easy customization of GoToolPanning:

[code] [Serializable]
public class ControlPanningTool : GoToolPanning {
public ControlPanningTool(GoView v) : base(v) {
this.AutoPan = false;
this.Modal = false;
}

public override bool CanStart() {
  GoInputEventArgs e = this.LastInput;
  return e.Control && e.Buttons == MouseButtons.Left;
}

public override void Start() {
  // the regular panning cursor is "move"
  this.View.CursorName = "hand";
}

public override void DoKeyDown() {
  // don't let a key press stop the pan
}

}[/code]
Install this tool with:

    myView.MouseDownTools.Add(new ControlPanningTool(myView));

This is pretty close to what I'm trying to do as well. One thing I would like to add is that when the user presses a certain key, I change the cursor to an open hand. As long as they have the key pressed, the cursor remains this way. When they move the mouse, the panning tool takes over. Here is what I have so far:

[code]

[Serializable]
public class DiagramPanningTool : GoToolPanning
{
//private static Cursor _GrabCursor = IconManager.GetCursor("Grab24");
//private static Cursor _GrabbingCursor = IconManager.GetCursor("Grabbing24");
private static Cursor _GrabCursor = null;
private static Cursor _GrabbingCursor = null;
public DiagramPanningTool(GoView v)
: base(v)
{
this.AutoPan = false;
this.Modal = false;
}
public override bool CanStart()
{
GoInputEventArgs e = this.LastInput;
return (e.Buttons == MouseButtons.Left) && e.Control;
}
public override void Start()
{
this.View.Cursor = GrabbingCursor;
}
public static Cursor GrabbingCursor
{
get
{
return _GrabbingCursor = IconManager.GetCursor("Grabbing24");
}
}
public static Cursor GrabCursor
{
get
{
return IconManager.GetCursor("Grab24");
}
}
public override void Stop()
{
this.View.Cursor = Cursors.Default;
base.Stop();
}
public override void DoKeyDown()
{
// don't let a key press stop the pan
}

}

[/code]

The problem I'm having is that the view's OnMouseMove method is causing the cursor to alternate between the pointer and my open hand. I also have to do some shenanigans such as checking to see if there is another cursor set on key press before changing it. Also, if I make my cursors static, they don't seem to work.

Do you have any advice on the best way to achieve what I'm trying to do?

Sounds like you want the tool to be modal. Look at what DrawDemo does in editShapeDrawingToolMenuItem_Click to make that tool modal.