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 @@ -366,7 +366,6 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
New = @new;
Old = old;
}
}
}
}

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

@ -16,6 +16,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -16,6 +16,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public class MatrixControl<TItem, TValue> : FrameworkElement, IScrollInfo
where TValue : IValue
{
public event EventHandler<HoveredCellEventArgs<TValue>> HoveredCellChanged;
private Dictionary<string, ImageSource> imgs = new Dictionary<string, ImageSource>();
private Coords currentCell = new Coords(-1, -1);
private string font;
@ -50,6 +52,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -50,6 +52,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public HoveredCell<TValue> HoveredCell { get; set; }
public bool RenderZeroes { get; set; }
public MatrixControl()
{
CellHeight = CellWidth = 36;
@ -72,7 +76,17 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -72,7 +76,17 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
else
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)
@ -156,11 +170,11 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -156,11 +170,11 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
// text
for (int i = 0; i < cellsHorizontally; i++) {
for (int j = 0; j < cellsVertically; j++) {
HoveredCell.RowIndex = i + scaledOffsetX;
HoveredCell.ColumnIndex = j + scaledOffsetY;
HoveredCell.Value = matrix[HoveredCell.RowIndex, HoveredCell.ColumnIndex];
int rowIndex = i + scaledOffsetX;
int columnIndex = j + scaledOffsetY;
var value = matrix[rowIndex, columnIndex];
drawingContext.DrawImage(
CreateText(HoveredCell.Value.Text),
CreateText(value.Text),
new Rect(i * CellWidth - offsetDiffX, j * CellHeight - offsetDiffY, CellWidth, CellHeight));
}
}
@ -168,7 +182,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -168,7 +182,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
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;
if (imgs.ContainsKey(text))
@ -392,4 +406,14 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -392,4 +406,14 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public int ColumnIndex { 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 @@ @@ -6,11 +6,8 @@
xmlns:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls"
xmlns:tree="http://icsharpcode.net/sharpdevelop/treeview">
<UserControl.Resources>
<Style
TargetType="{x:Type tree:SharpTreeNodeView}"
>
<Setter Property="Height" Value="36" />
<Style TargetType="{x:Type tree:SharpTreeNodeView}">
<Setter Property="Height" Value="{Binding ElementName=matrixControl, Path=CellHeight}" />
</Style>
</UserControl.Resources>
<Grid>

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

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

Loading…
Cancel
Save