예제 #1
0
        /// <summary>
        /// Adds the specified control, specifying its horizontal and vertical position and a control reference.
        /// <para xml:lang="es">Agrega el control especificado, especificando su posicion horizontal y vertical y un control de referencia</para>
        /// </summary>
        /// <param name="control">Control.
        /// <para xml:lang="es">El control a agregar.</para>
        /// </param>
        /// <param name="horizontalContraint">Horizontal contraint.
        /// <para xml:lang="es">Referencia horizontal donde se colocara el control.</para>
        /// </param>
        /// <param name="verticalContraint">Vertical contraint.
        /// <para xml:lang="es">Referencia vertical donde se colocara el control.</para>
        /// </param>
        /// <param name="referenceControl">Reference control.
        /// <para xml:lang="es">Control de referencia.</para>
        /// </param>
        void IRelativePanel.Add(IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint, IControl referenceControl)
        {
            if (control == null)
            {
                throw new ArgumentNullException(nameof(control));
            }

            //if no reference control is provided, then use this panel as reference
            if (referenceControl == null)
            {
                referenceControl = this;
            }

            base.Controls.Add((NativeControl)control);

            //the anchors at the current control
            string myHorizontalAnchor = "center";
            string myVerticalAnchor   = "center";

            //the anchors at the reference control
            string atHorizontalAnchor = "center";
            string atVerticalAnchor   = "center";

            //the reference control's id
            string of = ((NativeControl)referenceControl).ClientID;

            //horizontal constraint

            switch (horizontalContraint)
            {
            case RelativePanelHorizontalContraint.CenterWith:
                myHorizontalAnchor = "center";
                atHorizontalAnchor = "center";
                break;

            case RelativePanelHorizontalContraint.LeftOf:
                myHorizontalAnchor = "right";
                atHorizontalAnchor = "left";
                break;

            case RelativePanelHorizontalContraint.LeftWith:
                myHorizontalAnchor = "left";
                atHorizontalAnchor = "left";
                break;

            case RelativePanelHorizontalContraint.RightOf:
                myHorizontalAnchor = "left";
                atHorizontalAnchor = "right";
                break;

            case RelativePanelHorizontalContraint.RightWith:
                myHorizontalAnchor = "right";
                atHorizontalAnchor = "right";
                break;
            }

            //vertical constraint

            switch (verticalContraint)
            {
            case RelativePanelVerticalContraint.AboveOf:
                myVerticalAnchor = "bottom";
                atVerticalAnchor = "top";
                break;

            case RelativePanelVerticalContraint.BelowOf:
                myVerticalAnchor = "top";
                atVerticalAnchor = "bottom";
                break;

            case RelativePanelVerticalContraint.BottomWith:
                myVerticalAnchor = "bottom";
                atVerticalAnchor = "bottom";
                break;

            case RelativePanelVerticalContraint.CenterWith:
                myVerticalAnchor = "center";
                atVerticalAnchor = "center";
                break;

            case RelativePanelVerticalContraint.TopWith:
                myVerticalAnchor = "top";
                atVerticalAnchor = "top";
                break;
            }

            string positionJS = string.Format
                                (
                @"
				$('#{0}').position
				(
					{{
						my: '{1} {2}',
						at: '{3} {4}',
						of: '#{5}'
					}}
				);"                ,
                ((NativeControl)control).ClientID, myHorizontalAnchor, myVerticalAnchor, atHorizontalAnchor, atVerticalAnchor, ((NativeControl)referenceControl).ClientID
                                );

            ClientScripts.Add(positionJS);
        }
예제 #2
0
		/// <summary>
		/// Adds the specified control to RelativePanel with vertical and horizontal alignment specified for the specified reference control.
		/// <para xml:lang="es">
		/// Agrega el control especificado al RelativePanel con la alineacion vertical y horizontal especificadas con respecto al control de referencia especificado.
		/// </para>
		/// </summary>
		/// <returns>The control Relative panel add.
		/// <para xml:lang="es">El control agregado al RelativePanel.</para>
		/// </returns>
		/// <param name="control">Control.
		/// <para xml:lang="es">El control a agregar al control.</para>
		/// </param>
		/// <param name="horizontalContraint">Horizontal contraint.
		/// <para xml:lang="es">Restriccion de la alineacion horizontal para el control.</para>
		/// </param>
		/// <param name="verticalContraint">Vertical contraint.
		/// <para xml:lang="es">Restricciona de la alineacion vertical para el control.</para>
		/// </param>
		/// <param name="referenceControl">Reference control.
		/// <para xml:lang="es">Control de referencia.</para>
		/// </param>
		void IRelativePanel.Add(IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint, IControl referenceControl)
		{
			if (control == null)
			{
				throw new ArgumentNullException(nameof(control));
			}

			if (control.Margin == null)
			{
				control.Margin = new Thickness(0);
			}

			if (((IRelativePanel) this).Margin == null)
			{
				((IRelativePanel) this).Margin = new Thickness(0);
			}

			Thickness myMargin = ((IRelativePanel) this).Margin;
			Constraint horizontalXamarinConstraint = null;
			Constraint verticalXamarinConstraint = null;

			//no reference is given, so we position the control relative to the this panel

			if (referenceControl == null)
			{
				switch (horizontalContraint)
				{
					case RelativePanelHorizontalContraint.CenterWith:
						horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.X + (parent.Width / 2) - (control.Width.Value / 2); });
						break;

					case RelativePanelHorizontalContraint.LeftOf:
						horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.X - control.Width.Value - control.Margin.Right.Value - myMargin.Left.Value; });
						break;

					case RelativePanelHorizontalContraint.LeftWith:
						horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.X + control.Margin.Left.Value; });
						break;

					case RelativePanelHorizontalContraint.RightOf:
						horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.X + parent.Width + control.Margin.Left.Value + myMargin.Right.Value; });
						break;

					case RelativePanelHorizontalContraint.RightWith:
						horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.X + parent.Width - control.Width.Value - control.Margin.Right.Value; });
						break;
				}

				switch (verticalContraint)
				{
					case RelativePanelVerticalContraint.AboveOf:
						verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.Y - control.Height.Value - control.Margin.Bottom.Value - myMargin.Top.Value; });
						break;

					case RelativePanelVerticalContraint.BelowOf:
						verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.Y + parent.Height + control.Margin.Top.Value + myMargin.Bottom.Value; });
						break;

					case RelativePanelVerticalContraint.BottomWith:
						verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.Y + parent.Height - control.Height.Value - control.Margin.Bottom.Value; });
						break;

					case RelativePanelVerticalContraint.CenterWith:
						verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.Y + (parent.Height / 2) - (control.Height.Value / 2); });
						break;

					case RelativePanelVerticalContraint.TopWith:
						verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return parent.Y + control.Margin.Top.Value; });
						break;
				}
			}
			//a reference control is given, so we position the control relative to referenceControl
			else
			{
				switch (horizontalContraint)
				{
					case RelativePanelHorizontalContraint.CenterWith:
						horizontalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.X + (reference.Width / 2) - (control.Width.Value / 2); });
						break;

					case RelativePanelHorizontalContraint.LeftOf:
						horizontalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.X - control.Width.Value - control.Margin.Right.Value - ((IControl) reference).Margin.Left.Value; });
						break;
						
					case RelativePanelHorizontalContraint.LeftWith:
						horizontalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.X + control.Margin.Left.Value; });
						break;

					case RelativePanelHorizontalContraint.RightOf:
						horizontalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.X + reference.Width + control.Margin.Left.Value + ((IControl) reference).Margin.Right.Value; });
						break;

					case RelativePanelHorizontalContraint.RightWith:
						horizontalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.X + reference.Width - control.Width.Value - control.Margin.Right.Value; });
						break;
				}

				switch (verticalContraint)
				{
					case RelativePanelVerticalContraint.AboveOf:
						verticalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.Y - control.Height.Value - control.Margin.Bottom.Value - ((IControl) reference).Margin.Top.Value; });
						break;

					case RelativePanelVerticalContraint.BelowOf:
						verticalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.Y + reference.Height + control.Margin.Top.Value + ((IControl) reference).Margin.Bottom.Value; });
						break;

					case RelativePanelVerticalContraint.BottomWith:
						verticalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.Y + reference.Height - control.Margin.Bottom.Value; });
						break;

					case RelativePanelVerticalContraint.CenterWith:
						verticalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.Y + (reference.Height / 2) - (control.Height.Value / 2); });
						break;

					case RelativePanelVerticalContraint.TopWith:
						verticalXamarinConstraint = Constraint.RelativeToView((View) referenceControl, (parent, reference) => { return reference.Y + control.Margin.Top.Value; });
						break;
				}
			}

			//finally add to children using the constraints
			base.Children.Add((View) control, horizontalXamarinConstraint, verticalXamarinConstraint, null, null);
		}
예제 #3
0
 public void Add(IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint, IControl referenceControl)
 {
 }
예제 #4
0
        void IRelativePanel.Add(IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint, IControl referenceControl)
        {
            if (control == null)
            {
                throw new ArgumentNullException(nameof(control));
            }

            //no reference is given, so we position the control relative to the this panel
            if (referenceControl == null)
            {
                switch (horizontalContraint)
                {
                case RelativePanelHorizontalContraint.CenterWith:
                    SetAlignHorizontalCenterWithPanel((UIElement)control, true);
                    break;

                case RelativePanelHorizontalContraint.LeftOf:
                    throw new NotImplementedException();

                case RelativePanelHorizontalContraint.LeftWith:
                    SetAlignHorizontalCenterWithPanel((UIElement)control, true);
                    break;

                case RelativePanelHorizontalContraint.RightOf:
                    throw new NotImplementedException();

                case RelativePanelHorizontalContraint.RightWith:
                    SetAlignRightWithPanel((UIElement)control, true);
                    break;
                }

                switch (verticalContraint)
                {
                case RelativePanelVerticalContraint.AboveOf:
                    throw new NotImplementedException();

                case RelativePanelVerticalContraint.BelowOf:
                    throw new NotImplementedException();

                case RelativePanelVerticalContraint.BottomWith:
                    SetAlignBottomWithPanel((UIElement)control, true);
                    break;

                case RelativePanelVerticalContraint.CenterWith:
                    SetAlignVerticalCenterWithPanel((UIElement)control, true);
                    break;

                case RelativePanelVerticalContraint.TopWith:
                    SetAlignTopWithPanel((UIElement)control, true);
                    break;
                }
            }
            //a reference control is given, so we position the control relative to referenceControl
            else
            {
                switch (horizontalContraint)
                {
                case RelativePanelHorizontalContraint.CenterWith:
                    SetAlignHorizontalCenterWith((UIElement)control, referenceControl);
                    break;

                case RelativePanelHorizontalContraint.LeftOf:
                    SetLeftOf((UIElement)control, referenceControl);
                    break;

                case RelativePanelHorizontalContraint.LeftWith:
                    SetAlignLeftWith((UIElement)control, referenceControl);
                    break;

                case RelativePanelHorizontalContraint.RightOf:
                    SetRightOf((UIElement)control, referenceControl);
                    break;

                case RelativePanelHorizontalContraint.RightWith:
                    SetAlignRightWith((UIElement)control, referenceControl);
                    break;
                }

                switch (verticalContraint)
                {
                case RelativePanelVerticalContraint.AboveOf:
                    SetAbove((UIElement)control, referenceControl);
                    break;

                case RelativePanelVerticalContraint.BelowOf:
                    SetBelow((UIElement)control, referenceControl);
                    break;

                case RelativePanelVerticalContraint.BottomWith:
                    SetAlignBottomWith((UIElement)control, referenceControl);
                    break;

                case RelativePanelVerticalContraint.CenterWith:
                    SetAlignVerticalCenterWith((UIElement)control, referenceControl);
                    break;

                case RelativePanelVerticalContraint.TopWith:
                    SetAlignTopWith((UIElement)control, referenceControl);
                    break;
                }
            }

            //finally add to children
            base.Children.Add((UIElement)control);
        }
예제 #5
0
 /// <summary>
 /// Adds a control to the panel and positions it using the constraints, relative to the container panel
 /// <para xml:lang="es">
 /// Agrega un control al panel y lo posiciona usando las restricciones, con relacion al panel contenedor.
 /// </para>
 /// </summary>
 /// <param name="control">
 /// Control to add and position to the panel.
 /// <para xml:lang="es">
 /// Control a agregar y posicionar al panel.
 /// </para>
 /// </param>
 /// <param name="horizontalContraint">
 /// Horizontal constraint to use
 /// <para xml:lang="es">
 /// Restriccion horizontal a usar.
 /// </para>
 /// </param>
 /// <param name="verticalContraint">
 /// Vertical constraint to use
 /// <para xml:lang="es">
 /// Restriccion vertical a usar.
 /// </para>
 /// </param>
 public static void Add(this IRelativePanel panel, IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint)
 {
     panel.Add(control, horizontalContraint, verticalContraint, null);
 }
예제 #6
0
        void IRelativePanel.Add(IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint, IControl referenceControl)
        {
            if (control == null)
            {
                throw new ArgumentNullException(nameof(control));
            }

            //if no reference control is provided, then use this panel as reference
            if (referenceControl == null)
            {
                referenceControl = this;
            }

            NativeControl nativeControl   = (NativeControl)control;
            NativeControl nativeReference = (NativeControl)referenceControl;

            System.Drawing.Point location = new System.Drawing.Point();

            switch (horizontalContraint)
            {
            case RelativePanelHorizontalContraint.CenterWith:
                location.X = nativeReference.Location.X + (nativeReference.Width / 2) - (nativeControl.Width / 2);
                break;

            case RelativePanelHorizontalContraint.LeftOf:
                location.X = nativeReference.Location.X - nativeControl.Width;
                break;

            case RelativePanelHorizontalContraint.LeftWith:
                location.X = nativeReference.Location.X;
                break;

            case RelativePanelHorizontalContraint.RightOf:
                location.X = nativeReference.Location.X + nativeReference.Width + nativeControl.Width;
                break;

            case RelativePanelHorizontalContraint.RightWith:
                location.X = nativeReference.Location.X + nativeReference.Width;
                break;
            }

            //vertical constraint

            switch (verticalContraint)
            {
            case RelativePanelVerticalContraint.AboveOf:
                location.Y = nativeReference.Location.Y - nativeControl.Height;
                break;

            case RelativePanelVerticalContraint.BelowOf:
                location.Y = nativeReference.Location.Y + nativeReference.Height;
                break;

            case RelativePanelVerticalContraint.BottomWith:
                location.Y = nativeReference.Location.Y + nativeReference.Height - nativeControl.Height;
                break;

            case RelativePanelVerticalContraint.CenterWith:
                location.Y = nativeReference.Location.Y + (nativeReference.Height / 2) - (nativeControl.Height / 2);
                break;

            case RelativePanelVerticalContraint.TopWith:
                location.Y = nativeReference.Location.Y;
                break;
            }

            ((NativeControl)control).Location = location;
            base.Controls.Add((NativeControl)control);
        }
예제 #7
0
		void IRelativePanel.Add(IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint, IControl referenceControl)
		{
			if (control == null)
			{
				throw new ArgumentNullException(nameof(control));
			}

			//if no reference control is provided, then use this panel as reference
			if (referenceControl == null)
			{
				referenceControl = this;
			}

			NativeControl nativeControl = (NativeControl) control;
			NativeControl nativeReference = (NativeControl) referenceControl;
			System.Drawing.Point location = new System.Drawing.Point();
			
			switch (horizontalContraint)
			{
				case RelativePanelHorizontalContraint.CenterWith:
					location.X = nativeReference.Location.X + (nativeReference.Width / 2) - (nativeControl.Width / 2);
					break;

				case RelativePanelHorizontalContraint.LeftOf:
					location.X = nativeReference.Location.X - nativeControl.Width;
					break;

				case RelativePanelHorizontalContraint.LeftWith:
					location.X = nativeReference.Location.X;
					break;

				case RelativePanelHorizontalContraint.RightOf:
					location.X = nativeReference.Location.X + nativeReference.Width + nativeControl.Width;
					break;

				case RelativePanelHorizontalContraint.RightWith:
					location.X = nativeReference.Location.X + nativeReference.Width;
					break;
			}

			//vertical constraint

			switch (verticalContraint)
			{
				case RelativePanelVerticalContraint.AboveOf:
					location.Y = nativeReference.Location.Y - nativeControl.Height;
					break;

				case RelativePanelVerticalContraint.BelowOf:
					location.Y = nativeReference.Location.Y + nativeReference.Height;
					break;

				case RelativePanelVerticalContraint.BottomWith:
					location.Y = nativeReference.Location.Y + nativeReference.Height - nativeControl.Height;
					break;

				case RelativePanelVerticalContraint.CenterWith:
					location.Y = nativeReference.Location.Y + (nativeReference.Height / 2) - (nativeControl.Height / 2);
					break;

				case RelativePanelVerticalContraint.TopWith:
					location.Y = nativeReference.Location.Y;
					break;
			}

			((NativeControl)control).Location = location;
			base.Controls.Add((NativeControl) control);
		}
예제 #8
0
		/// <summary>
		/// Adds a control to the panel and positions it using the constraints, relative to the container panel
		/// <para xml:lang="es">
		/// Agrega un control al panel y lo posiciona usando las restricciones, con relacion al panel contenedor.
		/// </para>
		/// </summary>
		/// <param name="control">
		/// Control to add and position to the panel.
		/// <para xml:lang="es">
		/// Control a agregar y posicionar al panel.
		/// </para>
		/// </param>
		/// <param name="horizontalContraint">
		/// Horizontal constraint to use
		/// <para xml:lang="es">
		/// Restriccion horizontal a usar.
		/// </para>
		/// </param>
		/// <param name="verticalContraint">
		/// Vertical constraint to use
		/// <para xml:lang="es">
		/// Restriccion vertical a usar.
		/// </para>
		/// </param>
		public static void Add(this IRelativePanel panel, IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint)
		{
			panel.Add(control, horizontalContraint, verticalContraint, null);
		}
예제 #9
0
        /// <summary>
        /// Adds the specified control to RelativePanel with vertical and horizontal alignment specified for the specified reference control.
        /// <para xml:lang="es">
        /// Agrega el control especificado al RelativePanel con la alineacion vertical y horizontal especificadas con respecto al control de referencia especificado.
        /// </para>
        /// </summary>
        /// <returns>The control Relative panel add.
        /// <para xml:lang="es">El control agregado al RelativePanel.</para>
        /// </returns>
        /// <param name="control">Control.
        /// <para xml:lang="es">El control a agregar al control.</para>
        /// </param>
        /// <param name="horizontalContraint">Horizontal contraint.
        /// <para xml:lang="es">Restriccion de la alineacion horizontal para el control.</para>
        /// </param>
        /// <param name="verticalContraint">Vertical contraint.
        /// <para xml:lang="es">Restricciona de la alineacion vertical para el control.</para>
        /// </param>
        /// <param name="referenceControl">Reference control.
        /// <para xml:lang="es">Control de referencia.</para>
        /// </param>
        void IRelativePanel.Add(IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint, IControl referenceControl)
        {
            if (control == null)
            {
                throw new ArgumentNullException(nameof(control));
            }

            if (control.Margin == null)
            {
                control.Margin = new Thickness(0);
            }

            if (((IRelativePanel)this).Margin == null)
            {
                ((IRelativePanel)this).Margin = new Thickness(0);
            }

            Thickness  myMargin = ((IRelativePanel)this).Margin;
            Constraint horizontalXamarinConstraint = null;
            Constraint verticalXamarinConstraint   = null;

            //no reference is given, so we position the control relative to the this panel

            if (referenceControl == null)
            {
                switch (horizontalContraint)
                {
                case RelativePanelHorizontalContraint.CenterWith:
                    horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.X + (parent.Width / 2) - (control.Width.Value / 2)); });
                    break;

                case RelativePanelHorizontalContraint.LeftOf:
                    horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.X - control.Width.Value - control.Margin.Right.Value - myMargin.Left.Value); });
                    break;

                case RelativePanelHorizontalContraint.LeftWith:
                    horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.X + control.Margin.Left.Value); });
                    break;

                case RelativePanelHorizontalContraint.RightOf:
                    horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.X + parent.Width + control.Margin.Left.Value + myMargin.Right.Value); });
                    break;

                case RelativePanelHorizontalContraint.RightWith:
                    horizontalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.X + parent.Width - control.Width.Value - control.Margin.Right.Value); });
                    break;
                }

                switch (verticalContraint)
                {
                case RelativePanelVerticalContraint.AboveOf:
                    verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.Y - control.Height.Value - control.Margin.Bottom.Value - myMargin.Top.Value); });
                    break;

                case RelativePanelVerticalContraint.BelowOf:
                    verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.Y + parent.Height + control.Margin.Top.Value + myMargin.Bottom.Value); });
                    break;

                case RelativePanelVerticalContraint.BottomWith:
                    verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.Y + parent.Height - control.Height.Value - control.Margin.Bottom.Value); });
                    break;

                case RelativePanelVerticalContraint.CenterWith:
                    verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.Y + (parent.Height / 2) - (control.Height.Value / 2)); });
                    break;

                case RelativePanelVerticalContraint.TopWith:
                    verticalXamarinConstraint = Constraint.RelativeToParent((parent) => { return(parent.Y + control.Margin.Top.Value); });
                    break;
                }
            }
            //a reference control is given, so we position the control relative to referenceControl
            else
            {
                switch (horizontalContraint)
                {
                case RelativePanelHorizontalContraint.CenterWith:
                    horizontalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.X + (reference.Width / 2) - (control.Width.Value / 2)); });
                    break;

                case RelativePanelHorizontalContraint.LeftOf:
                    horizontalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.X - control.Width.Value - control.Margin.Right.Value - ((IControl)reference).Margin.Left.Value); });
                    break;

                case RelativePanelHorizontalContraint.LeftWith:
                    horizontalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.X + control.Margin.Left.Value); });
                    break;

                case RelativePanelHorizontalContraint.RightOf:
                    horizontalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.X + reference.Width + control.Margin.Left.Value + ((IControl)reference).Margin.Right.Value); });
                    break;

                case RelativePanelHorizontalContraint.RightWith:
                    horizontalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.X + reference.Width - control.Width.Value - control.Margin.Right.Value); });
                    break;
                }

                switch (verticalContraint)
                {
                case RelativePanelVerticalContraint.AboveOf:
                    verticalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.Y - control.Height.Value - control.Margin.Bottom.Value - ((IControl)reference).Margin.Top.Value); });
                    break;

                case RelativePanelVerticalContraint.BelowOf:
                    verticalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.Y + reference.Height + control.Margin.Top.Value + ((IControl)reference).Margin.Bottom.Value); });
                    break;

                case RelativePanelVerticalContraint.BottomWith:
                    verticalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.Y + reference.Height - control.Margin.Bottom.Value); });
                    break;

                case RelativePanelVerticalContraint.CenterWith:
                    verticalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.Y + (reference.Height / 2) - (control.Height.Value / 2)); });
                    break;

                case RelativePanelVerticalContraint.TopWith:
                    verticalXamarinConstraint = Constraint.RelativeToView((View)referenceControl, (parent, reference) => { return(reference.Y + control.Margin.Top.Value); });
                    break;
                }
            }

            //finally add to children using the constraints
            base.Children.Add((View)control, horizontalXamarinConstraint, verticalXamarinConstraint, null, null);
        }
예제 #10
0
		void IRelativePanel.Add(IControl control, RelativePanelHorizontalContraint horizontalContraint, RelativePanelVerticalContraint verticalContraint, IControl referenceControl)
		{
			if (control == null)
			{
				throw new ArgumentNullException(nameof(control));
			}

			//no reference is given, so we position the control relative to the this panel
			if (referenceControl == null)
			{
				switch (horizontalContraint)
				{
					case RelativePanelHorizontalContraint.CenterWith:
						NativeRelativePanel.SetAlignHorizontalCenterWithPanel((UIElement) control, true);
						break;

					case RelativePanelHorizontalContraint.LeftOf:
						throw new NotImplementedException();

					case RelativePanelHorizontalContraint.LeftWith:
						NativeRelativePanel.SetAlignHorizontalCenterWithPanel((UIElement) control, true);
						break;

					case RelativePanelHorizontalContraint.RightOf:
						throw new NotImplementedException();

					case RelativePanelHorizontalContraint.RightWith:
						NativeRelativePanel.SetAlignRightWithPanel((UIElement) control, true);
						break;
				}

				switch (verticalContraint)
				{
					case RelativePanelVerticalContraint.AboveOf:
						throw new NotImplementedException();

					case RelativePanelVerticalContraint.BelowOf:
						throw new NotImplementedException();

					case RelativePanelVerticalContraint.BottomWith:
						NativeRelativePanel.SetAlignBottomWithPanel((UIElement) control, true);
						break;

					case RelativePanelVerticalContraint.CenterWith:
						NativeRelativePanel.SetAlignVerticalCenterWithPanel((UIElement) control, true);
						break;

					case RelativePanelVerticalContraint.TopWith:
						NativeRelativePanel.SetAlignTopWithPanel((UIElement) control, true);
						break;
				}
			}
			//a reference control is given, so we position the control relative to referenceControl
			else
			{
				switch (horizontalContraint)
				{
					case RelativePanelHorizontalContraint.CenterWith:
						NativeRelativePanel.SetAlignHorizontalCenterWith((UIElement) control, referenceControl);
						break;

					case RelativePanelHorizontalContraint.LeftOf:
						NativeRelativePanel.SetLeftOf((UIElement) control, referenceControl);
						break;

					case RelativePanelHorizontalContraint.LeftWith:
						NativeRelativePanel.SetAlignLeftWith((UIElement) control, referenceControl);
						break;

					case RelativePanelHorizontalContraint.RightOf:
						NativeRelativePanel.SetRightOf((UIElement) control, referenceControl);
						break;

					case RelativePanelHorizontalContraint.RightWith:
						NativeRelativePanel.SetAlignRightWith((UIElement) control, referenceControl);
						break;
				}

				switch (verticalContraint)
				{
					case RelativePanelVerticalContraint.AboveOf:
						NativeRelativePanel.SetAbove((UIElement) control, referenceControl);
						break;

					case RelativePanelVerticalContraint.BelowOf:
						NativeRelativePanel.SetBelow((UIElement) control, referenceControl);
						break;

					case RelativePanelVerticalContraint.BottomWith:
						NativeRelativePanel.SetAlignBottomWith((UIElement) control, referenceControl);
						break;

					case RelativePanelVerticalContraint.CenterWith:
						NativeRelativePanel.SetAlignVerticalCenterWith((UIElement) control, referenceControl);
						break;

					case RelativePanelVerticalContraint.TopWith:
						NativeRelativePanel.SetAlignTopWith((UIElement) control, referenceControl);
						break;
				}
			}

			//finally add to children
			base.Children.Add((UIElement) control);
		}