Browse Source

Object graph visualizer - scrolling of view area.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4353 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Martin Koníček 17 years ago
parent
commit
0f5665e2c5
  1. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 87
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Controls/DragScrollViewer.cs
  3. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/GraphDrawer.cs
  4. 17
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFWindow.xaml

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -122,6 +122,7 @@ @@ -122,6 +122,7 @@
<Compile Include="Src\Service\DebuggerEventForm.Designer.cs">
<DependentUpon>DebuggerEventForm.cs</DependentUpon>
</Compile>
<Compile Include="Src\Visualizers\Controls\DragScrollViewer.cs" />
<Compile Include="Src\Visualizers\Utils\TypeResolver.cs" />
<EmbeddedResource Include="Src\Service\DebuggeeExceptionForm.resx">
<DependentUpon>DebuggeeExceptionForm.cs</DependentUpon>
@ -311,6 +312,7 @@ @@ -311,6 +312,7 @@
<Folder Include="Src\Visualizers\Graph\Graphviz" />
<Folder Include="Src\Visualizers\Graph\ObjectGraph" />
<Folder Include="Src\Visualizers\GridVisualizer\ValueProviders" />
<Folder Include="Src\Visualizers\Controls" />
<Folder Include="Src\Visualizers\Utils" />
<Folder Include="Src\Visualizers\GridVisualizer" />
<Folder Include="Src\Visualizers\PresentationBindings" />

87
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Controls/DragScrollViewer.cs

@ -0,0 +1,87 @@ @@ -0,0 +1,87 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;
namespace Debugger.AddIn.Visualizers.Controls
{
/// <summary>
/// ScrollViewer with support for drag-scrolling.
/// </summary>
public class DragScrollViewer : ScrollViewer
{
private bool isScrolling = false;
private Point startDragPos;
private Point scrollStartOffset;
public DragScrollViewer() : base()
{
this.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(DragScrollViewer_PreviewMouseDown);
this.PreviewMouseMove += new System.Windows.Input.MouseEventHandler(DragScrollViewer_PreviewMouseMove);
this.PreviewMouseUp += new System.Windows.Input.MouseButtonEventHandler(DragScrollViewer_PreviewMouseUp);
}
void DragScrollViewer_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed && this.IsMouseDirectlyOver)
{
startDragPos = e.GetPosition(this);
scrollStartOffset.X = this.HorizontalOffset;
scrollStartOffset.Y = this.VerticalOffset;
this.Cursor = this.canScroll() ? Cursors.ScrollAll : Cursors.Arrow;
this.isScrolling = true;
this.CaptureMouse();
base.OnPreviewMouseDown(e);
}
}
void DragScrollViewer_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (this.isScrolling)
{
Point currentPos = e.GetPosition(this);
Vector delta = getScrollDelta(this.startDragPos, currentPos);
this.ScrollToHorizontalOffset(this.scrollStartOffset.X + delta.X);
this.ScrollToVerticalOffset(this.scrollStartOffset.Y + delta.Y);
}
base.OnPreviewMouseMove(e);
}
void DragScrollViewer_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Released)
{
if (this.isScrolling)
{
this.Cursor = Cursors.Arrow;
this.isScrolling = false;
this.ReleaseMouseCapture();
}
base.OnPreviewMouseUp(e);
}
}
private Vector getScrollDelta(Point startPos, Point currentPos)
{
double dx = startPos.X - currentPos.X;
double dy = startPos.Y - currentPos.Y;
//return new Vector(Math.Sign(dx)*dx*dx*0.01, Math.Sign(dy)*dy*dy*0.01);
return new Vector(dx, dy);
}
private bool canScroll()
{
return (this.ExtentWidth > this.ViewportWidth) || (this.ExtentHeight > this.ViewportHeight);
}
}
}

3
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Drawing/GraphDrawer.cs

@ -38,6 +38,9 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -38,6 +38,9 @@ namespace Debugger.AddIn.Visualizers.Graph
/// <param name="diff"></param>
public void StartAnimation(PositionedGraph oldGraph, PositionedGraph newGraph, GraphDiff diff)
{
this.canvas.Width = newGraph.BoundingRect.Width;
this.canvas.Height = newGraph.BoundingRect.Height;
if (oldGraph == null)
{
Draw(newGraph);

17
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/VisualizerWPFWindow.xaml

@ -2,9 +2,14 @@ @@ -2,9 +2,14 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dv="clr-namespace:Debugger.AddIn.Visualizers.Graph"
xmlns:controls="clr-namespace:Debugger.AddIn.Visualizers.Controls"
Title="Object graph visualizer" Height="400" Width="600">
<StackPanel>
<StackPanel Orientation="Horizontal" Background="AliceBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" Background="AliceBlue" VerticalAlignment="Top">
<StackPanel.Resources>
<Style TargetType="TextBlock">
@ -32,8 +37,10 @@ @@ -32,8 +37,10 @@
</Border>
</StackPanel>
<Canvas Name="canvas" Margin="4">
</Canvas>
<controls:DragScrollViewer x:Name="scroller" Margin="0 4 0 0" Grid.Row="1" Grid.Column="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Canvas HorizontalAlignment="Left" VerticalAlignment="Top" Name="canvas" Margin="4">
</Canvas>
</controls:DragScrollViewer>
</StackPanel>
</Grid>
</Window>
Loading…
Cancel
Save