10 changed files with 259 additions and 57 deletions
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
// 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.Linq; |
||||
using System.Collections.Generic; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.CodeQualityAnalysis.Utility; |
||||
|
||||
namespace ICSharpCode.CodeQualityAnalysis.Controls |
||||
{ |
||||
/// <summary>
|
||||
/// Description of DependencyColorizer.
|
||||
/// </summary>
|
||||
public class DependencyColorizer : IColorizer<Relationship> |
||||
{ |
||||
private Dictionary<Color, SolidColorBrush> cache; |
||||
|
||||
public DependencyColorizer() |
||||
{ |
||||
cache = new Dictionary<Color, SolidColorBrush>(); |
||||
} |
||||
|
||||
public SolidColorBrush GetColorBrush(Relationship relationship) |
||||
{ |
||||
var color = GetColor(relationship); |
||||
if (cache.ContainsKey(color)) |
||||
return cache[color]; |
||||
|
||||
var brush = new SolidColorBrush(color); |
||||
brush.Freeze(); |
||||
|
||||
cache[color] = brush; |
||||
|
||||
return brush; |
||||
} |
||||
|
||||
public Color GetColor(Relationship relationship) |
||||
{ |
||||
if (relationship.Relationships.Any(r => r == RelationshipType.UseThis)) |
||||
return Colors.Azure; |
||||
if (relationship.Relationships.Any(r => r == RelationshipType.UsedBy)) |
||||
return Colors.Beige; |
||||
if (relationship.Relationships.Any(r => r == RelationshipType.Same)) |
||||
return Colors.Gray; |
||||
|
||||
return Colors.Transparent; |
||||
} |
||||
|
||||
public SolidColorBrush GetColorBrushMixedWith(Color color, Relationship relationship) |
||||
{ |
||||
var mixedColor = GetColor(relationship); |
||||
mixedColor = mixedColor.MixedWith(color); |
||||
|
||||
if (cache.ContainsKey(mixedColor)) |
||||
return cache[mixedColor]; |
||||
|
||||
var brush = new SolidColorBrush(mixedColor); |
||||
brush.Freeze(); |
||||
|
||||
cache[mixedColor] = brush; |
||||
|
||||
return brush; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
// 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.Windows.Media; |
||||
|
||||
namespace ICSharpCode.CodeQualityAnalysis.Utility |
||||
{ |
||||
/// <summary>
|
||||
/// Description of IColorizer.
|
||||
/// </summary>
|
||||
public interface IColorizer<TValue> |
||||
{ |
||||
SolidColorBrush GetColorBrush(TValue value); |
||||
SolidColorBrush GetColorBrushMixedWith(Color color, TValue value); |
||||
Color GetColor(TValue value); |
||||
} |
||||
} |
Loading…
Reference in new issue