Browse Source

Visibility support for Matrix Control.

pull/19/head
Tomas Linhart 15 years ago
parent
commit
7c53b16934
  1. 1
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
  2. 2
      src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrix.cs
  3. 37
      src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs
  4. 1
      src/AddIns/Analysis/CodeQuality/Src/Utility/Matrix.cs
  5. 41
      src/AddIns/Analysis/CodeQuality/Src/Utility/VisibleMatrix.cs

1
src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj

@ -148,6 +148,7 @@ @@ -148,6 +148,7 @@
<Compile Include="Src\Utility\Matrix.cs" />
<Compile Include="Src\Utility\RelayCommand.cs" />
<Compile Include="Src\Utility\ViewModelBase.cs" />
<Compile Include="Src\Utility\VisibleMatrix.cs" />
<Page Include="Resources\GridSplitterTemplate.xaml" />
<Page Include="Resources\GraphTemplate.xaml">
<SubType>Designer</SubType>

2
src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrix.cs

@ -9,7 +9,7 @@ using ICSharpCode.CodeQualityAnalysis.Utility; @@ -9,7 +9,7 @@ using ICSharpCode.CodeQualityAnalysis.Utility;
namespace ICSharpCode.CodeQualityAnalysis.Controls
{
public class DependencyMatrix : Matrix<INode, Relationship>
public class DependencyMatrix : VisibleMatrix<INode, Relationship>
{
protected override Relationship GetCellValue(int rowIndex, int columnIndex)
{

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

@ -6,6 +6,7 @@ using System.Collections.Generic; @@ -6,6 +6,7 @@ using System.Collections.Generic;
using ICSharpCode.CodeQualityAnalysis.Utility;
using System.Drawing.Drawing2D;
using System.Windows;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
@ -44,8 +45,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -44,8 +45,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
{
matrix = value;
matrixHeight = Matrix.HeaderRows.Count - 1;
matrixWidth = Matrix.HeaderColumns.Count - 1;
// matrixHeight = matrix.HeaderRows.Count - 1;
// matrixWidth = matrix.HeaderColumns.Count - 1;
}
}
@ -62,8 +63,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -62,8 +63,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public MatrixControl()
{
CellHeight = CellWidth = 18;
matrixWidth = 20;
matrixHeight = 20;
matrixWidth = 0;
matrixHeight = 0;
fontSize = CellHeight / 3;
penSize = 1;
font = "Verdana";
@ -71,6 +72,20 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -71,6 +72,20 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
HoveredCell = new HoveredCell<TValue>();
}
public void SetVisibleItems(HeaderType tree, ICollection<TItem> visibleItems)
{
var items = tree == HeaderType.Columns ? matrix.HeaderColumns : matrix.HeaderRows;
foreach (var item in items)
{
var foundItem = visibleItems.Where(n => n.Equals(item.Value)).SingleOrDefault();
item.Visible = foundItem != null;
}
matrixHeight = matrix.HeaderRows.Count - 1;
matrixWidth = matrix.HeaderColumns.Count - 1;
}
protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseMove(e);
@ -181,10 +196,10 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -181,10 +196,10 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
CellHeight);
SolidColorBrush brush = null;
if ((i * CellWidth - offsetDiffX) == currentXLine ||
((i * CellWidth - offsetDiffX) == currentXLine))
brush = Colorizer.GetColorBrushMixedWith(Colors.GreenYellow, value);
else
// if ((i * CellWidth - offsetDiffX) == currentXLine ||
// ((i * CellWidth - offsetDiffX) == currentXLine))
// brush = Brushes.Pink; //Colorizer.GetColorBrushMixedWith(Colors.GreenYellow, value);
// else
brush = Colorizer.GetColorBrush(value);
drawingContext.DrawRectangle(brush, null, rect);
@ -449,4 +464,10 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -449,4 +464,10 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
HoveredCell = cell;
}
}
public enum HeaderType
{
Columns,
Rows
}
}

1
src/AddIns/Analysis/CodeQuality/Src/Utility/Matrix.cs

@ -56,6 +56,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility @@ -56,6 +56,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility
public class Cell<TItem>
{
public TItem Value { get; set; }
public bool Visible { get; set; }
public Cell(TItem value)
{

41
src/AddIns/Analysis/CodeQuality/Src/Utility/VisibleMatrix.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.CodeQualityAnalysis.Utility
{
/// <summary>
/// Description of VisibleMatrix.
/// </summary>
public abstract class VisibleMatrix<TItem, TValue> : Matrix<TItem, TValue>
{
public new List<Cell<TItem>> HeaderRows
{
get
{
return base.HeaderRows.Where(c => c.Visible).ToList();
}
set
{
base.HeaderRows = value;
}
}
public new List<Cell<TItem>> HeaderColumns
{
get
{
return base.HeaderColumns.Where(c => c.Visible).ToList();
}
set
{
base.HeaderColumns = value;
}
}
}
}
Loading…
Cancel
Save