Bad scrolling during drag

i have a problem that the auto scrolling isnt smooth and jump too fast.
i am using Northwoods.GoWPF.dll version 1.2.7.4

you can see it in the movie

http://tinypic.com/r/1jpvfm/5

i found a solution to my problem by using my own templete and diagram panel

<go:Diagram.Template>
                    <ControlTemplate x:Uid="ControlTemplate_1">
                        <Border x:Uid="Border" x:Name="Border"
			                    Background="{TemplateBinding Background}"
			                    BorderBrush="{TemplateBinding BorderBrush}"
			                    BorderThickness="{TemplateBinding BorderThickness}">
 
                        <ScrollViewer x:Uid="ScrollViewer_1" HorizontalScrollBarVisibility="Auto"
					                      VerticalScrollBarVisibility="Auto"
					                      CanContentScroll="True">
                            
 
                                <InternalClasses:FlowCanvasDiagramPanel x:Uid="Panel" x:Name="Panel"
						               Padding="{TemplateBinding Padding}"
						               HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
						               VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                       AutoScrollRegion="50"/>
                            </ScrollViewer>
                        </Border>
                    </ControlTemplate>
                </go:Diagram.Template>


/// 
/// this panel is used to override the ComputeAutoScrollPosition of the canvas diagram panel
///
public class FlowCanvasDiagramPanel : DiagramPanel
{
    <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"><summary></span>
    <span style="color:gray;">///</span><span style="color:green;"> Initializes a new instance of the </span><span style="color:gray;"><see cref=</span><span style="color:gray;">"FlowCanvasDiagramPanel"</span><span style="color:gray;">/></span><span style="color:green;"> class.</span>
    <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></summary></span>
    <span style="color:blue;">public</span> FlowCanvasDiagramPanel()
    {
        <span style="color:green;">// setting this property fix the unsmooth scrolling</span>
        ScrollVerticalLineChange = 25;
    }

    <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"><summary></span>
    <span style="color:gray;">///</span><span style="color:green;"> This method is called to determine the next position in the document for this view,</span>
    <span style="color:gray;">///</span><span style="color:green;"> given a point at which the user is dragging the mouse.</span>
    <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></summary></span>
    <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"><param name=</span><span style="color:gray;">"viewPnt"</span><span style="color:gray;">></span><span style="color:green;">The mouse point, in control coordinates.</span><span style="color:gray;"></param></span>
    <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"><returns></returns></span>
    <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"><value></span>
    <span style="color:gray;">///</span><span style="color:green;"> The return value is in model coordinates.</span>
    <span style="color:gray;">///</span><span style="color:green;">   </span><span style="color:gray;"></value></span>
    <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"><remarks></span>
    <span style="color:gray;">///</span><span style="color:green;"> i override this function to bound the boundaries of the diagram during auto scroll with the mouse. </span>
    <span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"></remarks></span>
    <span style="color:blue;">protected</span> <span style="color:blue;">override</span> <span style="color:#2b91af;">Point</span> ComputeAutoScrollPosition(<span style="color:#2b91af;">Point</span> viewPnt)
    {
        <span style="color:blue;">var</span> bounds = DiagramBounds;
        <span style="color:blue;">var</span> view = ViewportBounds;
        <span style="color:green;">//var pos = base.ComputeAutoScrollPosition(viewPnt);</span>
        <span style="color:blue;">var</span> pos = ComputeAutoScrollPositionForSmoodeScrolling(viewPnt);
        
        pos.X = <span style="color:#2b91af;">Math</span>.Max(<span style="color:#2b91af;">Math</span>.Min(pos.X, bounds.Right - view.Width), bounds.X);
        pos.Y = <span style="color:#2b91af;">Math</span>.Max(<span style="color:#2b91af;">Math</span>.Min(pos.Y, bounds.Bottom - view.Height), bounds.Y);
        <span style="color:blue;">return</span> pos;
    }

    <span style="color:blue;">private</span> <span style="color:#2b91af;">Point</span> ComputeAutoScrollPositionForSmoodeScrolling(<span style="color:#2b91af;">Point</span> viewPnt)
    {
        <span style="color:#2b91af;">Point</span> docpos = <span style="color:blue;">this</span>.Position;
        <span style="color:#2b91af;">Thickness</span> margin = <span style="color:blue;">this</span>.AutoScrollRegion;
        <span style="color:green;">// no autoscroll region? just return current Position</span>
        <span style="color:blue;">if</span> (margin.Top <= 0 && margin.Left <= 0 && margin.Right <= 0 && margin.Bottom <= 0) <span style="color:blue;">return</span> docpos;
        <span style="color:green;">// get the visible part of the panel</span>
        <span style="color:#2b91af;">Rect</span> dispRect = <span style="color:blue;">new</span> <span style="color:#2b91af;">Rect</span>(0, 0, <span style="color:blue;">this</span>.ViewportWidth, <span style="color:blue;">this</span>.ViewportHeight);
        <span style="color:green;">// get the current panel position, in element coordinates</span>
        <span style="color:#2b91af;">Point</span> viewpos = <span style="color:blue;">new</span> <span style="color:#2b91af;">Point</span>(0, 0);
        <span style="color:green;">// and compute the new position if viewPnt is near any of the four sides, within the margin</span>
        <span style="color:blue;">if</span> (viewPnt.X >= dispRect.X && viewPnt.X < dispRect.X + margin.Left)
        {
            <span style="color:blue;">int</span> deltaX = <span style="color:#2b91af;">Math</span>.Max((<span style="color:blue;">int</span>)<span style="color:blue;">this</span>.ScrollHorizontalLineChange, 1);
            viewpos.X -= deltaX;
            <span style="color:blue;">if</span> (viewPnt.X < dispRect.X + margin.Left / 2)
                viewpos.X -= deltaX;
            <span style="color:blue;">if</span> (viewPnt.X < dispRect.X + margin.Left / 4)
                viewpos.X -= 4 * deltaX;
        }
        <span style="color:blue;">else</span> <span style="color:blue;">if</span> (viewPnt.X <= dispRect.X + dispRect.Width && viewPnt.X > dispRect.X + dispRect.Width - margin.Right)
        {
            <span style="color:blue;">int</span> deltaX = <span style="color:#2b91af;">Math</span>.Max((<span style="color:blue;">int</span>)<span style="color:blue;">this</span>.ScrollHorizontalLineChange, 1);
            viewpos.X += deltaX;
            <span style="color:blue;">if</span> (viewPnt.X > dispRect.X + dispRect.Width - margin.Right / 2)
                viewpos.X += deltaX;
            <span style="color:blue;">if</span> (viewPnt.X > dispRect.X + dispRect.Width - margin.Right / 4)
                viewpos.X += 4 * deltaX;
        }
        <span style="color:blue;">if</span> (viewPnt.Y >= dispRect.Y && viewPnt.Y < dispRect.Y + margin.Top)
        {
            <span style="color:blue;">int</span> deltaY = 1;
            viewpos.Y -= deltaY;
            <span style="color:blue;">if</span> (viewPnt.Y < dispRect.Y + margin.Top / 2)
                viewpos.Y -= deltaY;
            <span style="color:blue;">if</span> (viewPnt.Y < dispRect.Y + margin.Top / 4)
                viewpos.Y -= 4 * deltaY;
        }
        <span style="color:blue;">else</span> <span style="color:blue;">if</span> (viewPnt.Y <= dispRect.Y + dispRect.Height && viewPnt.Y > dispRect.Y + dispRect.Height - margin.Bottom)
        {
            <span style="color:blue;">int</span> deltaY = 1;
            viewpos.Y += deltaY;
            <span style="color:blue;">if</span> (viewPnt.Y > dispRect.Y + dispRect.Height - margin.Bottom / 2)
                viewpos.Y += deltaY;
            <span style="color:blue;">if</span> (viewPnt.Y > dispRect.Y + dispRect.Height - margin.Bottom / 4)
                viewpos.Y += 4 * deltaY;
        }
        <span style="color:green;">// don't bother changing DOCPOS if VIEWPOS hasn't changed</span>
        <span style="color:green;">// Also avoids differences due to round-off errors!</span>
        <span style="color:blue;">if</span> (!IsApprox(viewpos, <span style="color:blue;">new</span> <span style="color:#2b91af;">Point</span>(0, 0)))
        {
            <span style="color:green;">// but return a Point in model coordinates</span>
            <span style="color:blue;">double</span> scale = <span style="color:blue;">this</span>.Scale;
            docpos = <span style="color:blue;">new</span> <span style="color:#2b91af;">Point</span>(docpos.X + viewpos.X / scale, docpos.Y + viewpos.Y / scale);
        }
        <span style="color:green;">//if (this.Position != docpos) Diagram.Debug(Diagram.Str(viewPnt) + Diagram.Str(dispRect) + " " +</span>
        <span style="color:green;">//  Diagram.Str(TransformModelToView(this.Position)) + " --> " + Diagram.Str(viewpos) + "  " + Diagram.Str(this.Position) + " --> " + Diagram.Str(docpos));</span>
        <span style="color:blue;">return</span> docpos;
    }

    <span style="color:blue;">private</span> <span style="color:blue;">bool</span> IsApprox(<span style="color:blue;">double</span> x, <span style="color:blue;">double</span> y)
    {
        <span style="color:blue;">double</span> d = x - y;
        <span style="color:blue;">return</span> d < 0.5 && d > -0.5;
    }

    <span style="color:blue;">private</span> <span style="color:blue;">bool</span> IsApprox(<span style="color:#2b91af;">Point</span> a, <span style="color:#2b91af;">Point</span> b)
    {
        <span style="color:blue;">return</span> IsApprox(a.X, b.X) && IsApprox(a.Y, b.Y);
    }
  }
}

but when i use my solution the drag item is somtimes barly visiable.
see movie 
http://tinypic.com/r/2b9oom/5
can you tell me how to fix it?
thanks,

I suggested in the other thread that the flickering might be caused by the copying and/or moving not being allowed at some points during the drag. When DraggingTool.MayCopy… returns false, the temporary copied part(s) are removed; when DraggingTool.MayMove… returns false, the dragged objects (whether temporary copies or the original parts) are moved back to their original positions.

So I suggest debugging your code to see if there are inconsistent values being returned during the dragging process.

I don't think it is the reason because if I don't set the diagram template it work fine no flickering.<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The diagram template only change the ScrollVerticalLineChange property and the ComputeAutoScrollPosition function so why should it be relevant to what you said?

Oh, I didn’t know that. I suppose it might still be the cause of the problem if the change in scrolling resulted in different objects being underneath the mouse point at different times.

Have you turned off scroll/zoom animation? I wonder if that might be interfering.

When I get a chance I’ll try your custom DiagramPanel in a sample app.