Hey, that sounds like a nice feature.
[Serializable]
public class FocussingTool : GoToolManager {
public FocussingTool(GoView view) : base(view) {}
public override void DoMouseWheel() {
GoInputEventArgs evt = this.LastInput;
if (evt.Control && evt.Delta != 0) {
PointF oldpos = this.View.DocPosition;
this.View.DocScale *= (1 + ((float)evt.Delta)/2400);
PointF focus = this.View.ConvertViewToDoc(evt.ViewPoint);
this.View.DocPosition = new PointF(oldpos.X + evt.DocPoint.X - focus.X, oldpos.Y + evt.DocPoint.Y - focus.Y);
} else {
base.DoMouseWheel();
}
}
}
and then initialize your view as follows:
myView.DefaultTool = new FocussingTool(myView);
myView.ReplaceMouseTool(typeof(GoToolManager), myView.DefaultTool);
Question for other people: should this be the default control-mouse-wheel behavior?
It would be handy if both modes were available. Perhaps it could be switchable via a view property?
This seems more intuitive than the way it works right now.
Good Morning Walter:
Could I bug you again regarding your mouse wheel zooming code snippet? I converted your code to VB.NET and came up with the following code. As I reported, it does work great for the zooming feature. Unfortunately, our testers immediately pointed out (to my utter chagrin), that GoNodes within the GoView will now only respond to a single mouse click. As I’m still a little fuzzy about what’s going on here, could you offer any further suggestions? Here’s my implementation:
<Serializable()> Public Class clsVTGoTool
Inherits Northwoods.Go.GoTool
Private m_GoView As Northwoods.Go.GoView
Public Sub New(ByRef gView As Northwoods.Go.GoView)
MyBase.New(gView)
m_GoView = gView
End Sub
Public Overrides Sub DoMouseWheel()
Dim evt As Northwoods.Go.GoInputEventArgs = Me.m_GoView.LastInput
If (evt.Control = True) And (evt.Delta <> 0) Then
Dim oldpos As PointF = Me.m_GoView.DocPosition
Me.m_GoView.DocScale *= (1 + (CDbl(evt.Delta) / 2400))
Dim focus As PointF = Me.m_GoView.ConvertViewToDoc(evt.ViewPoint)
Me.m_GoView.DocPosition = New PointF(oldpos.X + evt.DocPoint.X - focus.X, oldpos.Y + evt.DocPoint.Y - focus.Y)
Else
MyBase.DoMouseWheel()
End If
End Sub
End Class
Then, when I dynamically allocate my GoView:
gView.DefaultTool = New clsVTGoTool(gView)
gView.ReplaceMouseTool(GetType(GoToolManager), gView.DefaultTool)
Do you see any glaring errors in this?
Thanks very much for any pointers,
Doug P.
Except for the unnecessary m_GoView field (you can use the GoTool.View property), it looks fine to me.
The tool you defined has no effect on clicking or other mouse actions, so I don’t believe it caused your nodes not to respond to double-clicks. I can’t reproduce any problem with double-clicks in my applications.
Hi, just implemented this behavior and my opinion is that this should be the default behavior.
Actually, it has been the default behavior since v2.2.2, since soon after this discussion took place.