FirstFloor.ModernUI.Windows.Controls.FrameworkElementAdorner.DetermineX C# (CSharp) Method

DetermineX() private method

Determine the X coordinate of the child.
private DetermineX ( ) : double
return double
        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) {
                        var adornedWidth = AdornedElement.ActualWidth;
                        return adornedWidth + _offsetX;
                    } else {
                        var adornerWidth = _child.DesiredSize.Width;
                        var adornedWidth = AdornedElement.ActualWidth;
                        var x = adornedWidth - adornerWidth;
                        return x + _offsetX;
                    }
                case HorizontalAlignment.Center: {
                    var adornerWidth = _child.DesiredSize.Width;
                    var adornedWidth = AdornedElement.ActualWidth;
                    var x = adornedWidth / 2 - adornerWidth / 2;
                    return x + _offsetX;
                }
                case HorizontalAlignment.Stretch:
                    return 0.0;
            }

            return 0.0;
        }