Browse Source

move information tooltip into NodeDescription

pull/18/head
Siegfried Pammer 14 years ago
parent
commit
d96f74b6df
  1. 16
      src/AddIns/Analysis/CodeQuality/Engine/Dom/Relationship.cs
  2. 17
      src/AddIns/Analysis/CodeQuality/Gui/DependencyMatrixView.xaml
  3. 40
      src/AddIns/Analysis/CodeQuality/Gui/DependencyMatrixView.xaml.cs
  4. 14
      src/AddIns/Analysis/CodeQuality/Gui/NodeDescription.xaml
  5. 13
      src/AddIns/Analysis/CodeQuality/Gui/NodeDescriptionViewModel.cs

16
src/AddIns/Analysis/CodeQuality/Engine/Dom/Relationship.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.NRefactory.TypeSystem;
@ -36,6 +37,19 @@ namespace ICSharpCode.CodeQuality.Engine.Dom @@ -36,6 +37,19 @@ namespace ICSharpCode.CodeQuality.Engine.Dom
Relationships.Add(type);
}
public string InfoText {
get {
string text = "is not related to";
if (Relationships.Any(r => r == RelationshipType.Uses))
text = "uses";
else if (Relationships.Any(r => r == RelationshipType.UsedBy))
text = "is used by";
else if (Relationships.Any(r => r == RelationshipType.Same))
text = "is the same as";
return string.Format("{0} {1} {2}", From.Name, text, To.Name);
}
}
public override string ToString()
{
var builder = new StringBuilder();
@ -68,7 +82,7 @@ namespace ICSharpCode.CodeQuality.Engine.Dom @@ -68,7 +82,7 @@ namespace ICSharpCode.CodeQuality.Engine.Dom
/// <summary>
/// a is used by b.
/// </summary>
UsedBy,
UsedBy,
/// <summary>
/// a and b are the same INode
/// </summary>

17
src/AddIns/Analysis/CodeQuality/Gui/DependencyMatrixView.xaml

@ -17,14 +17,14 @@ @@ -17,14 +17,14 @@
<gui:NodeDescription x:Name="inform"
Grid.Row="0" Grid.Column="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"></gui:NodeDescription>
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"></gui:NodeDescription>
<!-- Top TreeView -->
<tv:SharpTreeView Name="topTree" Grid.Column="2"
<tv:SharpTreeView Name="topTree" Grid.Column="2"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
MouseMove="TopTreeMouseMove"
MouseMove="TopTreeMouseMove"
ScrollViewer.ScrollChanged="ViewScrollChanged">
<tv:SharpTreeView.LayoutTransform>
<RotateTransform Angle="-90" />
@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
Height="5" />
<!-- Left TreeView -->
<tv:SharpTreeView Name="leftTree"
Grid.Row="2"
Grid.Row="2"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
MouseMove="LeftTreeMouseMove"
@ -65,13 +65,12 @@ @@ -65,13 +65,12 @@
</Popup>
<ScrollViewer Name="scrollViewer"
HorizontalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible"
Grid.Row="2" Grid.Column="2"
Grid.Row="2" Grid.Column="2"
CanContentScroll="True"
ScrollChanged="ViewScrollChanged">
<gui:DependencyMatrixControl x:Name="matrix" HoveredCellChanged="MatrixHoveredCellChanged" MouseMove="MatrixMouseMove" MouseLeave="MatrixMouseLeave" />
<gui:DependencyMatrixControl x:Name="matrix" HoveredCellChanged="MatrixHoveredCellChanged" />
</ScrollViewer>
</Grid>
</UserControl>

40
src/AddIns/Analysis/CodeQuality/Gui/DependencyMatrixView.xaml.cs

@ -29,13 +29,12 @@ namespace ICSharpCode.CodeQuality.Gui @@ -29,13 +29,12 @@ namespace ICSharpCode.CodeQuality.Gui
{
ScrollViewer topTreeScrollViewer, leftTreeScrollViewer;
NodeDescriptionViewModel nodeDescriptionViewModel;
ToolTip infoTooltip;
public DependencyMatrixView()
{
InitializeComponent();
Visibility = Visibility.Hidden;
popUp.IsOpen = true;
popUp.IsOpen = true;
nodeDescriptionViewModel = new NodeDescriptionViewModel();
this.inform.DataContext = nodeDescriptionViewModel;
@ -43,15 +42,13 @@ namespace ICSharpCode.CodeQuality.Gui @@ -43,15 +42,13 @@ namespace ICSharpCode.CodeQuality.Gui
leftTree.Root = new ICSharpCode.TreeView.SharpTreeNode();
matrix.Colorizer = new DependencyColorizer();
matrix.ScrollOwner = scrollViewer;
infoTooltip = new ToolTip() { StaysOpen = false };
}
public void Update(IEnumerable<INode> nodes)
{
this.Visibility = Visibility.Visible;
popUp.IsOpen = false;
popUp.StaysOpen = true;
@ -66,7 +63,7 @@ namespace ICSharpCode.CodeQuality.Gui @@ -66,7 +63,7 @@ namespace ICSharpCode.CodeQuality.Gui
var matrix = new DependencyMatrix();
if (nodes != null)
AddChildrenToMatrix(matrix, nodes);
AddChildrenToMatrix(matrix, nodes);
this.matrix.Matrix = matrix;
BuildLeftINodeList(null, null);
BuildTopINodeList(null, null);
@ -79,7 +76,7 @@ namespace ICSharpCode.CodeQuality.Gui @@ -79,7 +76,7 @@ namespace ICSharpCode.CodeQuality.Gui
matrix.AddColumn(node);
matrix.AddRow(node);
if (node.Children != null)
AddChildrenToMatrix(matrix, node.Children);
AddChildrenToMatrix(matrix, node.Children);
}
}
@ -148,7 +145,6 @@ namespace ICSharpCode.CodeQuality.Gui @@ -148,7 +145,6 @@ namespace ICSharpCode.CodeQuality.Gui
matrix.HighlightLine(HeaderType.Rows, n.Node);
leftTree.SelectedItem = n;
}
infoTooltip.IsOpen = false;
}
void TopTreeMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
@ -159,7 +155,6 @@ namespace ICSharpCode.CodeQuality.Gui @@ -159,7 +155,6 @@ namespace ICSharpCode.CodeQuality.Gui
matrix.HighlightLine(HeaderType.Columns, n.Node);
topTree.SelectedItem = n;
}
infoTooltip.IsOpen = false;
}
MatrixTreeNode ConvertNode(DependencyObject node)
@ -179,32 +174,7 @@ namespace ICSharpCode.CodeQuality.Gui @@ -179,32 +174,7 @@ namespace ICSharpCode.CodeQuality.Gui
if (e.HoveredCell.ColumnIndex < topTree.Items.Count) {
topTree.SelectedItem = topTree.Items[e.HoveredCell.ColumnIndex + 1];
}
}
void MatrixMouseMove(object sender, MouseEventArgs e)
{
infoTooltip.Placement = PlacementMode.Relative;
infoTooltip.VerticalOffset = 15;
infoTooltip.PlacementTarget = this;
infoTooltip.Content = GetTooltip(matrix.HoveredCell.Value);
infoTooltip.IsOpen = true;
}
object GetTooltip(Relationship relationship)
{
string text = "is not related to";
if (relationship.Relationships.Any(r => r == RelationshipType.Uses))
text = "uses";
else if (relationship.Relationships.Any(r => r == RelationshipType.UsedBy))
text = "is used by";
else if (relationship.Relationships.Any(r => r == RelationshipType.Same))
text = "is the same as";
return string.Format("{0} {1} {2}", relationship.From.Name, text, relationship.To.Name);
}
void MatrixMouseLeave(object sender, MouseEventArgs e)
{
infoTooltip.IsOpen = false;
nodeDescriptionViewModel.Relationship = e.HoveredCell.Value;
}
#endregion
}

14
src/AddIns/Analysis/CodeQuality/Gui/NodeDescription.xaml

@ -5,16 +5,15 @@ @@ -5,16 +5,15 @@
<Grid>
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="Type :" ></TextBlock>
<TextBlock Text="Class :" Grid.Row="1"></TextBlock>
<TextBlock Text="Children :" Grid.Row="2"></TextBlock>
@ -28,6 +27,7 @@ @@ -28,6 +27,7 @@
<!--
<TextBlock Text="{Binding Uses}" Grid.Column="1" Grid.Row="3"></TextBlock>
<TextBlock Text="{Binding UsedBy}" Grid.Column="1" Grid.Row="4"></TextBlock>-->
<TextBlock Text="{Binding Relationship.InfoText}" Grid.Row="3" Grid.ColumnSpan="2" />
</Grid>
</Grid>
</Border>

13
src/AddIns/Analysis/CodeQuality/Gui/NodeDescriptionViewModel.cs

@ -24,9 +24,8 @@ using ICSharpCode.TreeView; @@ -24,9 +24,8 @@ using ICSharpCode.TreeView;
namespace ICSharpCode.CodeQuality.Gui
{
public class NodeDescriptionViewModel:ViewModelBase
public class NodeDescriptionViewModel : ViewModelBase
{
INode node;
public INode Node
@ -40,6 +39,16 @@ namespace ICSharpCode.CodeQuality.Gui @@ -40,6 +39,16 @@ namespace ICSharpCode.CodeQuality.Gui
}
}
Relationship relationship;
public Relationship Relationship {
get { return relationship; }
set {
relationship = value;
base.RaisePropertyChanged(() => Relationship);
}
}
public int Uses {get {return Node.Uses.Count();}}
public int UsesBy {get {return Node.UsedBy.Count();}}

Loading…
Cancel
Save