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
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 moviehttp://tinypic.com/r/2b9oom/5can you tell me how to fix it?
thanks,