Browse Source

Merge branch 'master' of github.com:icsharpcode/SharpDevelop

pull/19/head
PeterForstmeier 14 years ago
parent
commit
23ca112111
  1. 89
      src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs
  2. 16
      src/AddIns/Analysis/CodeQuality/Src/Utility/Helper.cs
  3. 8
      src/AddIns/Analysis/CodeQuality/Src/Utility/Matrix.cs

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

@ -38,20 +38,12 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -38,20 +38,12 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
private int fontSize = 0;
private int penSize = 0;
private TMatrix matrix;
public TMatrix Matrix
{
get { return matrix; }
set
{
matrix = value;
// matrixHeight = matrix.HeaderRows.Count - 1;
// matrixWidth = matrix.HeaderColumns.Count - 1;
}
}
protected int PageSizeWidth { get; set; }
protected int PageSizeHeight { get; set; }
public TMatrix Matrix { get; set; }
public int CellHeight { get; set; }
@ -77,10 +69,10 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -77,10 +69,10 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public void SetVisibleItems(HeaderType type, ICollection<TItem> visibleItems)
{
matrix.SetVisibleItems(type, visibleItems);
Matrix.SetVisibleItems(type, visibleItems);
matrixHeight = matrix.HeaderRows.Count;
matrixWidth = matrix.HeaderColumns.Count;
matrixHeight = Matrix.HeaderRows.Count;
matrixWidth = Matrix.HeaderColumns.Count;
bool changedCoords = false;
if (currentCell.X > matrixHeight) {
@ -103,7 +95,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -103,7 +95,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public void HighlightLine(HeaderType type, INode node)
{
var items = type == HeaderType.Columns ? matrix.HeaderColumns : matrix.HeaderRows;
var items = type == HeaderType.Columns ? Matrix.HeaderColumns : Matrix.HeaderRows;
for (int i = 0; i < items.Count; i++) {
if (items[i].Value.Equals(node)) {
if (currentCell.X == i && type == HeaderType.Rows)
@ -156,7 +148,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -156,7 +148,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
{
HoveredCell.RowIndex = currentCell.Y;
HoveredCell.ColumnIndex = currentCell.X;
HoveredCell.Value = matrix[HoveredCell.RowIndex, HoveredCell.ColumnIndex];
HoveredCell.Value = Matrix[HoveredCell.RowIndex, HoveredCell.ColumnIndex];
if (HoveredCellChanged != null)
HoveredCellChanged(this, new HoveredCellEventArgs<TValue>(HoveredCell));
}
@ -175,7 +167,10 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -175,7 +167,10 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
var cellsHorizontally = maxWidth >= matrixWidth ? matrixWidth : maxWidth + 1;
var cellsVertically = maxHeight >= matrixHeight ? matrixHeight : maxHeight + 1;
// number of cell which will be drawn
PageSizeWidth = cellsHorizontally;
PageSizeHeight = cellsVertically;
// number of cell which arent visible
var scaledOffsetX = (int)offset.X / CellWidth;
var scaledOffsetY = (int)offset.Y / CellHeight;
@ -230,9 +225,14 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -230,9 +225,14 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
// text
for (int i = 0; i < cellsHorizontally; i++) {
for (int j = 0; j < cellsVertically; j++) { // dont draw text in unavailables places
int rowIndex = j;
int columnIndex = i;
var value = matrix[rowIndex, columnIndex];
int rowIndex = j + scaledOffsetY;
int columnIndex = i + scaledOffsetX;
// adjust scales
rowIndex = rowIndex >= Matrix.HeaderRows.Count ? rowIndex - 1 : rowIndex;
columnIndex = columnIndex >= Matrix.HeaderColumns.Count ? columnIndex - 1 : columnIndex;
var value = Matrix[rowIndex, columnIndex];
if (Colorizer != null) {
var rect = new Rect(
@ -242,11 +242,18 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -242,11 +242,18 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
CellHeight);
SolidColorBrush brush = null;
// if ((i * CellWidth - offsetDiffX) == currentXLine ||
// ((i * CellWidth - offsetDiffX) == currentXLine))
// brush = Brushes.Pink; //Colorizer.GetColorBrushMixedWith(Colors.GreenYellow, value);
// else
brush = Colorizer.GetColorBrush(value);
if ((i * CellWidth - offsetDiffX) == currentXLine ||
((j * CellHeight - offsetDiffY) == currentYLine)) {
var color = Colors.GreenYellow;
if (currentCell.X == i && currentCell.Y == j) {
color = color.MixedWith(Colors.Red);
}
brush = Colorizer.GetColorBrushMixedWith(color, value);
}
else
brush = Colorizer.GetColorBrush(value);
drawingContext.DrawRectangle(brush, null, rect);
}
@ -374,75 +381,75 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -374,75 +381,75 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
public void LineUp()
{
SetVerticalOffset(VerticalOffset - 1);
SetVerticalOffset(VerticalOffset - CellHeight);
}
public void LineDown()
{
SetVerticalOffset(VerticalOffset + 1);
SetVerticalOffset(VerticalOffset + CellHeight);
}
public void LineLeft()
{
SetHorizontalOffset(HorizontalOffset - 1);
SetHorizontalOffset(HorizontalOffset - CellWidth);
}
public void LineRight()
{
SetHorizontalOffset(HorizontalOffset + 1);
SetHorizontalOffset(HorizontalOffset + CellWidth);
}
public void PageUp()
{
SetVerticalOffset(VerticalOffset - CellHeight);
SetVerticalOffset(VerticalOffset - CellHeight * PageSizeHeight);
}
public void PageDown()
{
SetVerticalOffset(VerticalOffset + CellHeight);
SetVerticalOffset(VerticalOffset + CellHeight * PageSizeHeight);
}
public void PageLeft()
{
SetHorizontalOffset(HorizontalOffset - CellWidth);
SetHorizontalOffset(HorizontalOffset - CellWidth * PageSizeWidth);
}
public void PageRight()
{
SetHorizontalOffset(HorizontalOffset + CellWidth);
SetHorizontalOffset(HorizontalOffset + CellWidth * PageSizeWidth);
}
public void MouseWheelUp()
{
SetVerticalOffset(VerticalOffset - 4);
SetVerticalOffset(VerticalOffset - CellHeight);
}
public void MouseWheelDown()
{
SetVerticalOffset(VerticalOffset + 4);
SetVerticalOffset(VerticalOffset + CellHeight);
}
public void MouseWheelLeft()
{
SetVerticalOffset(HorizontalOffset - 4);
SetVerticalOffset(HorizontalOffset - CellWidth);
}
public void MouseWheelRight()
{
SetVerticalOffset(HorizontalOffset + 4);
SetVerticalOffset(HorizontalOffset + CellWidth);
}
public void SetHorizontalOffset(double offset)
{
if (offset == this.offset.X) return;
this.offset.X = offset;
this.offset.X = Math.Round(offset / CellWidth) * CellWidth;
InvalidateVisual();
}
public void SetVerticalOffset(double offset)
{
if (offset == this.offset.Y) return;
this.offset.Y = offset;
this.offset.Y = Math.Round(offset / CellHeight) * CellHeight;
InvalidateVisual();
}

16
src/AddIns/Analysis/CodeQuality/Src/Utility/Helper.cs

@ -57,16 +57,14 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility @@ -57,16 +57,14 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility
public static Color MixedWith(this Color c1, Color c2)
{
int r = Math.Min((c1.R + c2.R), 255);
int g = Math.Min((c1.G + c2.G), 255);
int b = Math.Min((c1.B + c2.B), 255);
var percent = .5f;
var amountFrom = 1.0f - percent;
return new Color
{
R = Convert.ToByte(r),
G = Convert.ToByte(g),
B = Convert.ToByte(b)
};
return Color.FromArgb(
(byte)(c1.A * amountFrom + c2.A * percent),
(byte)(c1.R * amountFrom + c2.R * percent),
(byte)(c1.G * amountFrom + c2.G * percent),
(byte)(c1.B * amountFrom + c2.B * percent));
}
public static T FindVisualChild<T>( DependencyObject obj )

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

@ -64,12 +64,12 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility @@ -64,12 +64,12 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility
columnIndex > HeaderColumns.Count || columnIndex < 0)
return default(TValue);
var cacheResult = GetFromCache(rowIndex, columnIndex);
if (cacheResult != null)
return cacheResult;
// var cacheResult = GetFromCache(rowIndex, columnIndex);
// if (cacheResult != null)
// return cacheResult;
var result = GetCellValue(rowIndex, columnIndex);
SaveToCache(rowIndex, columnIndex, result);
// SaveToCache(rowIndex, columnIndex, result);
return result;
}
}

Loading…
Cancel
Save