public static float CalculateHeight(this GridVerticalAlignment alignment, float boundaryFrameHeight, float subViewHeight,
                                            bool autoHeight, SubViewThickness subViewMargin)
        {
            switch (alignment)
            {
                case GridVerticalAlignment.Top:
                case GridVerticalAlignment.Bottom:
                case GridVerticalAlignment.Center:
                    return autoHeight ? 0 : subViewHeight; 
                case GridVerticalAlignment.Stretch:
                    return autoHeight ? (boundaryFrameHeight - subViewMargin.Bottom - subViewMargin.Top) : subViewHeight;
            }

            throw new ArgumentException("This alignment can't be processed");
        }
        public static float CalculateWidth(this GridHorizontalAlignment alignment, float boundaryFrameWidth, float subViewWidth,
                                           bool autoWidth, SubViewThickness subViewMargin)
        {
            switch (alignment)
            {
                case GridHorizontalAlignment.Left:
                case GridHorizontalAlignment.Right:
                case GridHorizontalAlignment.Center:
                    return autoWidth ? 0 : subViewWidth;
                case GridHorizontalAlignment.Stretch:
                    return autoWidth ? (boundaryFrameWidth - subViewMargin.Left - subViewMargin.Right) : subViewWidth;
            }

            throw new ArgumentException("The alignment can't be processed");
        }
        public static float CalculateYPosition(this GridVerticalAlignment alignment, float boundaryFrameHeight, 
                                               float subViewHeight, SubViewThickness subViewMargin)
        {
            switch (alignment)
            {
                case GridVerticalAlignment.Top:
                    return subViewMargin.Top;
                case GridVerticalAlignment.Bottom:
                    return boundaryFrameHeight - subViewHeight - subViewMargin.Bottom;
                case GridVerticalAlignment.Center:
                    return (boundaryFrameHeight - subViewHeight) / 2;
                case GridVerticalAlignment.Stretch:
                    return subViewMargin.Top;
            }

            throw new ArgumentException("This alignment can't be processed");
        }
        public static float CalculateXPosition(this GridHorizontalAlignment alignment, float boundaryFrameWidth, 
                                               float subViewWidth, SubViewThickness subViewMargin)
        {
            switch (alignment)
            {
                case GridHorizontalAlignment.Left:
                    return subViewMargin.Left;
                case GridHorizontalAlignment.Right:
                    return boundaryFrameWidth - subViewWidth - subViewMargin.Right;
                case GridHorizontalAlignment.Center:
                    return (boundaryFrameWidth - subViewWidth) / 2;
                case GridHorizontalAlignment.Stretch:
                    return subViewMargin.Left;
            }

            throw new ArgumentException("The alignment can't be processed");
        }
 public GridSubViewMeasure()
 {
     this.Width = 0F;
     this.Height = 0F;
     this.ActualWidth = 0F;
     this.ActualHeight = 0F;
     this.AutoWidth = true;
     this.AutoHeight = true;
     this.Row = 0;
     this.Column = 0;
     this.ColumnSpan = 1;
     this.RowSpan = 1;
     this.HorizontalAlignment = GridHorizontalAlignment.Stretch;
     this.VerticalAlignment = GridVerticalAlignment.Stretch;
     this.Margin = new SubViewThickness(0);
 }
Exemple #6
0
        public void AddChild(UIView subView, int row = 0, int column = 0, int rowSpan = 1, int columnSpan = 1, 
                               bool autoHeight = true, bool autoWidth = true, GridHorizontalAlignment horizontalAlingment = GridHorizontalAlignment.Stretch, 
                               GridVerticalAlignment verticalAlingment = GridVerticalAlignment.Stretch, 
                               SubViewThickness margin = default(SubViewThickness))
        {
            GridSubViewMeasure subViewMeasure = new GridSubViewMeasure()
            {Row = row, Column = column, RowSpan = rowSpan, ColumnSpan = columnSpan,
                AutoWidth = autoWidth, AutoHeight = autoHeight, 
                HorizontalAlignment = horizontalAlingment, VerticalAlignment = verticalAlingment,
                Margin = margin, Width = subView.Frame.Width, Height = subView.Frame.Height
            };

            __measures.Add(subView, subViewMeasure);
            RectangleF subViewFrame = this.CalculateMeasure(subViewMeasure);
            subView.Frame = subViewFrame;
            this.Add(subView);
        }
Exemple #7
0
 public void AddChild(UIView subView, int row, int column, SubViewThickness margin)
 {
     this.AddChild(subView, row, column, 1, 1, true, true, GridHorizontalAlignment.Stretch, GridVerticalAlignment.Stretch, margin);
 }
        public void SetMargin(UIView subView, SubViewThickness margin)
        {
            if (!__measures.ContainsKey(subView))
                throw new ArgumentException("The SubView is not in the Grid");

            __measures[subView].Margin = margin;
            this.UpdateInnerChild(subView);
        }