private double DetermineX()
{
switch (_child.HorizontalAlignment)
{
case HorizontalAlignment.Left:
{
if (_horizontalAdornerPlacement == AdornerPlacement.Outside)
{
return -_child.DesiredSize.Width + _offsetX;
}
return _offsetX;
}
case HorizontalAlignment.Right:
{
if (_horizontalAdornerPlacement == AdornerPlacement.Outside)
{
double adornedWidth = AdornedElement.ActualWidth;
return adornedWidth + _offsetX;
}
else
{
double adornerWidth = _child.DesiredSize.Width;
double adornedWidth = AdornedElement.ActualWidth;
double x = adornedWidth - adornerWidth;
return x + _offsetX;
}
}
case HorizontalAlignment.Center:
{
double adornerWidth = _child.DesiredSize.Width;
double adornedWidth = AdornedElement.ActualWidth;
double x = (adornedWidth / 2) - (adornerWidth / 2);
return x + _offsetX;
}
case HorizontalAlignment.Stretch:
{
return 0.0;
}
}
return 0.0;
}