Use Enum.IsDefined as suggested.
This commit is contained in:
parent
910b2b8c7f
commit
196db4c730
|
@ -56,7 +56,7 @@ namespace Filtration.Converters
|
||||||
Width = cellWidth,
|
Width = cellWidth,
|
||||||
Height = cellHeight,
|
Height = cellHeight,
|
||||||
X = column * cellWidth,
|
X = column * cellWidth,
|
||||||
Y = row * cellWidth
|
Y = row * cellHeight
|
||||||
};
|
};
|
||||||
|
|
||||||
bitmaps.Add(new CroppedBitmap(sourceImage, bitmapRect));
|
bitmaps.Add(new CroppedBitmap(sourceImage, bitmapRect));
|
||||||
|
@ -70,7 +70,8 @@ namespace Filtration.Converters
|
||||||
{
|
{
|
||||||
if (values[0] == DependencyProperty.UnsetValue ||
|
if (values[0] == DependencyProperty.UnsetValue ||
|
||||||
values[1] == DependencyProperty.UnsetValue ||
|
values[1] == DependencyProperty.UnsetValue ||
|
||||||
values[2] == DependencyProperty.UnsetValue) {
|
values[2] == DependencyProperty.UnsetValue)
|
||||||
|
{
|
||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,46 +79,23 @@ namespace Filtration.Converters
|
||||||
var iconColor = (int)(values[1]);
|
var iconColor = (int)(values[1]);
|
||||||
var iconShape = (int)(values[2]);
|
var iconShape = (int)(values[2]);
|
||||||
|
|
||||||
switch ((IconSize) iconSize) {
|
if (!Enum.IsDefined(typeof(IconSize), iconSize) ||
|
||||||
case IconSize.Largest:
|
!Enum.IsDefined(typeof(IconColor), iconColor) ||
|
||||||
case IconSize.Medium:
|
!Enum.IsDefined(typeof(IconShape), iconShape))
|
||||||
case IconSize.Small:
|
{
|
||||||
break;
|
return empty;
|
||||||
default:
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ((IconColor) iconColor) {
|
|
||||||
case IconColor.Blue:
|
|
||||||
case IconColor.Green:
|
|
||||||
case IconColor.Brown:
|
|
||||||
case IconColor.Red:
|
|
||||||
case IconColor.White:
|
|
||||||
case IconColor.Yellow:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ((IconShape) iconShape) {
|
|
||||||
case IconShape.Circle:
|
|
||||||
case IconShape.Diamond:
|
|
||||||
case IconShape.Hexagon:
|
|
||||||
case IconShape.Square:
|
|
||||||
case IconShape.Star:
|
|
||||||
case IconShape.Triangle:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var shapeOffset = iconShape * (sizeCount * colorCount);
|
var shapeOffset = iconShape * (sizeCount * colorCount);
|
||||||
var colorOffset = iconColor * sizeCount;
|
var colorOffset = iconColor * sizeCount;
|
||||||
var iconIndex = shapeOffset + colorOffset + iconSize;
|
var iconIndex = shapeOffset + colorOffset + iconSize;
|
||||||
|
|
||||||
if (iconIndex >= bitmaps.Count) {
|
if (iconIndex >= bitmaps.Count)
|
||||||
|
{
|
||||||
return empty;
|
return empty;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return bitmaps[iconIndex];
|
return bitmaps[iconIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue