Browse Source

Add HoveredCellChanged event.

pull/19/head
Tomas Linhart 15 years ago
parent
commit
204c4526eb
  1. 1
      src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyGraphLayout.cs
  2. 36
      src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs
  3. 7
      src/AddIns/Analysis/CodeQuality/Src/Controls/TreeMatrixControl.xaml
  4. 2
      src/AddIns/Analysis/CodeQuality/Src/MetricsReader.cs

1
src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyGraphLayout.cs

@ -366,7 +366,6 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
New = @new; New = @new;
Old = old; Old = old;
} }
} }
} }
} }

36
src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs

@ -16,6 +16,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public class MatrixControl<TItem, TValue> : FrameworkElement, IScrollInfo public class MatrixControl<TItem, TValue> : FrameworkElement, IScrollInfo
where TValue : IValue where TValue : IValue
{ {
public event EventHandler<HoveredCellEventArgs<TValue>> HoveredCellChanged;
private Dictionary<string, ImageSource> imgs = new Dictionary<string, ImageSource>(); private Dictionary<string, ImageSource> imgs = new Dictionary<string, ImageSource>();
private Coords currentCell = new Coords(-1, -1); private Coords currentCell = new Coords(-1, -1);
private string font; private string font;
@ -50,6 +52,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public HoveredCell<TValue> HoveredCell { get; set; } public HoveredCell<TValue> HoveredCell { get; set; }
public bool RenderZeroes { get; set; }
public MatrixControl() public MatrixControl()
{ {
CellHeight = CellWidth = 36; CellHeight = CellWidth = 36;
@ -72,7 +76,17 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
else else
currentCell = new Coords(-1, -1); currentCell = new Coords(-1, -1);
InvalidateVisual(); if (currentCell.X != HoveredCell.RowIndex ||
currentCell.Y != HoveredCell.ColumnIndex)
{
InvalidateVisual();
HoveredCell.RowIndex = currentCell.X;
HoveredCell.ColumnIndex = currentCell.Y;
HoveredCell.Value = matrix[HoveredCell.RowIndex, HoveredCell.ColumnIndex];
if (HoveredCellChanged != null)
HoveredCellChanged(this, new HoveredCellEventArgs<TValue>(HoveredCell));
}
} }
protected override void OnRender(DrawingContext drawingContext) protected override void OnRender(DrawingContext drawingContext)
@ -156,11 +170,11 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
// text // text
for (int i = 0; i < cellsHorizontally; i++) { for (int i = 0; i < cellsHorizontally; i++) {
for (int j = 0; j < cellsVertically; j++) { for (int j = 0; j < cellsVertically; j++) {
HoveredCell.RowIndex = i + scaledOffsetX; int rowIndex = i + scaledOffsetX;
HoveredCell.ColumnIndex = j + scaledOffsetY; int columnIndex = j + scaledOffsetY;
HoveredCell.Value = matrix[HoveredCell.RowIndex, HoveredCell.ColumnIndex]; var value = matrix[rowIndex, columnIndex];
drawingContext.DrawImage( drawingContext.DrawImage(
CreateText(HoveredCell.Value.Text), CreateText(value.Text),
new Rect(i * CellWidth - offsetDiffX, j * CellHeight - offsetDiffY, CellWidth, CellHeight)); new Rect(i * CellWidth - offsetDiffX, j * CellHeight - offsetDiffY, CellWidth, CellHeight));
} }
} }
@ -168,7 +182,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public ImageSource CreateText(string text) public ImageSource CreateText(string text)
{ {
if (text == "0") // rendering zeroes would be distracting if (!RenderZeroes && text == "0") // rendering zeroes would be distracting
text = string.Empty; text = string.Empty;
if (imgs.ContainsKey(text)) if (imgs.ContainsKey(text))
@ -392,4 +406,14 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public int ColumnIndex { get; set; } public int ColumnIndex { get; set; }
public TValue Value { get; set; } public TValue Value { get; set; }
} }
public class HoveredCellEventArgs<TValue> : EventArgs
{
public HoveredCell<TValue> HoveredCell { get; set; }
public HoveredCellEventArgs(HoveredCell<TValue> cell)
{
HoveredCell = cell;
}
}
} }

7
src/AddIns/Analysis/CodeQuality/Src/Controls/TreeMatrixControl.xaml

@ -6,11 +6,8 @@
xmlns:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls" xmlns:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls"
xmlns:tree="http://icsharpcode.net/sharpdevelop/treeview"> xmlns:tree="http://icsharpcode.net/sharpdevelop/treeview">
<UserControl.Resources> <UserControl.Resources>
<Style <Style TargetType="{x:Type tree:SharpTreeNodeView}">
TargetType="{x:Type tree:SharpTreeNodeView}" <Setter Property="Height" Value="{Binding ElementName=matrixControl, Path=CellHeight}" />
>
<Setter Property="Height" Value="36" />
</Style> </Style>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>

2
src/AddIns/Analysis/CodeQuality/Src/MetricsReader.cs

@ -603,7 +603,7 @@ namespace ICSharpCode.CodeQualityAnalysis
if (!String.IsNullOrEmpty(type.Namespace)) if (!String.IsNullOrEmpty(type.Namespace))
return type.Namespace; return type.Namespace;
return "-"; return "(no namespace)";
} }
} }
} }

Loading…
Cancel
Save