예제 #1
0
        protected void OnAlignmentChanged(RelativeAlignment newAlignment)
        {
            if (_toggle == null || _root == null)
            {
                return;
            }

            // Reset grid

            _root.RowDefinitions[0].Height   = new GridLength(1, GridUnitType.Auto);
            _root.RowDefinitions[1].Height   = new GridLength(1, GridUnitType.Star);
            _root.RowDefinitions[2].Height   = new GridLength(1, GridUnitType.Auto);
            _root.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Auto);
            _root.ColumnDefinitions[2].Width = new GridLength(1, GridUnitType.Auto);
            switch (newAlignment)
            {
            case RelativeAlignment.Left:
            {
                Grid.SetRow(_toggle, 1);
                Grid.SetColumn(_toggle, 0);
                _root.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
                break;
            }

            case RelativeAlignment.Above:
            {
                Grid.SetRow(_toggle, 0);
                Grid.SetColumn(_toggle, 0);
                Grid.SetColumnSpan(_toggle, 3);
                _root.RowDefinitions[0].Height = new GridLength(1, GridUnitType.Star);
                _root.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Auto);
                break;
            }

            case RelativeAlignment.Right:
            {
                Grid.SetRow(_toggle, 1);
                Grid.SetColumn(_toggle, 2);
                _root.ColumnDefinitions[2].Width = new GridLength(1, GridUnitType.Star);
                break;
            }

            case RelativeAlignment.Below:
            {
                Grid.SetRow(_toggle, 2);
                Grid.SetColumn(_toggle, 0);
                Grid.SetColumnSpan(_toggle, 3);
                _root.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Auto);
                _root.RowDefinitions[2].Height = new GridLength(1, GridUnitType.Star);
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 /// <summary>
 /// Adds a control to the <see cref="GridContainerItemCollection"/> at the specified index.
 /// </summary>
 /// <param name="existing">The existing control at which item should be inserted.</param>
 /// <param name="item">The <see cref="Control"/> to insert into the <see cref="GridContainerItemCollection"/>.</param>
 /// <param name="relativeAlignment">The relative placement of the item control to the existing one.</param>
 /// <param name="width">The width of the item.</param>
 /// <param name="height">The height of the item.</param>
 /// <param name="hexpand">The horizontal expand of <paramref name="item"/>.</param>
 /// <param name="vexpand">The vertical expand of <paramref name="item"/>.</param>
 /// <param name="alignment">The alignment of <paramref name="item"/>.</param>
 public void AddAt(Control existing, Control item, RelativeAlignment relativeAlignment, int width, int height, int hexpand, int vexpand, Alignment alignment)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     if (Contains(item))
     {
         throw new InvalidOperationException("Cannot add a Control that is already contained in this GridContainerItemCollection.");
     }
     ToUIAligns(alignment, out Libui.uiAlign halign, out Libui.uiAlign valign);
     Libui.uiGridInsertAt(Owner, item, existing, relativeAlignment, width, height, hexpand, halign, vexpand, valign);
     base.AddAt(existing.Index, item);
 }
예제 #3
0
            /// <summary>
            /// Adds a <see cref="Control"/> to the <see cref="ControlCollection"/> at the specified index.
            /// </summary>
            /// <param name="existing">The existing control at which child should be inserted.</param>
            /// <param name="child">The <see cref="Control"/> to insert into the <see cref="ControlCollection"/>.</param>
            /// <param name="relativeAlignment">The relative placement of the child control to the existing one.</param>
            /// <param name="width">The width of the child.</param>
            /// <param name="height">The height of the child.</param>
            /// <param name="hexpand">The horizontal expand of <paramref name="child"/>.</param>
            /// <param name="vexpand">The vertical expand of <paramref name="child"/>.</param>
            /// <param name="alignment">The alignment of <paramref name="child"/>.</param>
            public void Insert(Control existing, Control child, RelativeAlignment relativeAlignment, int width, int height, int hexpand, int vexpand, Alignment alignment)
            {
                if (width < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(width));
                }
                if (height < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(height));
                }
                if (existing == null)
                {
                    throw new ArgumentNullException(nameof(existing));
                }
                if (existing.IsInvalid)
                {
                    throw new InvalidHandleException();
                }
                if (child == null)
                {
                    throw new ArgumentNullException(nameof(child));
                }
                if (child.IsInvalid)
                {
                    throw new InvalidHandleException();
                }
                if (child.TopLevel)
                {
                    throw new ArgumentException("Cannot add a top-level control to a ControlCollectionBase{TContainer, TCollection, T}.");
                }
                if (Contains(child))
                {
                    throw new InvalidOperationException("Cannot add the same control more than once.");
                }

                ToLibuiAligns(alignment, out Libui.uiAlign halign, out Libui.uiAlign valign);
                Libui.Call <Libui.uiGridInsertAt>()(Owner.Handle, child.Handle, existing.Handle, (Libui.uiAt)relativeAlignment, width, height, hexpand, halign, vexpand, valign);
                base.Insert(existing.Index, child);
            }
예제 #4
0
        protected void OnAlignmentChanged(RelativeAlignment newAlignment)
        {
            if (_root == null)
            {
                return;
            }

            // Reset grid

            _root.RowDefinitions[0].Height   = new GridLength(1, GridUnitType.Auto);
            _root.RowDefinitions[1].Height   = new GridLength(1, GridUnitType.Star);
            _root.RowDefinitions[2].Height   = new GridLength(1, GridUnitType.Auto);
            _root.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Auto);
            _root.ColumnDefinitions[2].Width = new GridLength(1, GridUnitType.Auto);
            switch (newAlignment)
            {
            case RelativeAlignment.Left:
                _root.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
                break;

            case RelativeAlignment.Above:
                _root.RowDefinitions[0].Height = new GridLength(1, GridUnitType.Star);
                _root.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Auto);
                break;

            case RelativeAlignment.Right:
                _root.ColumnDefinitions[2].Width = new GridLength(1, GridUnitType.Star);
                break;

            case RelativeAlignment.Below:
                _root.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Auto);
                _root.RowDefinitions[2].Height = new GridLength(1, GridUnitType.Star);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #5
0
 /// <summary>
 /// Adds a <see cref="Control"/> to the <see cref="ControlCollection"/> at the specified index.
 /// </summary>
 /// <param name="existing">The existing control at which child should be inserted.</param>
 /// <param name="child">The <see cref="Control"/> to insert into the <see cref="ControlCollection"/>.</param>
 /// <param name="relativeAlignment">The relative placement of the child control to the existing one.</param>
 /// <param name="size">The size of <paramref name="child"/>.</param>
 /// <param name="expand">A <see cref="Size"/> representing the h and v-expand.</param>
 /// <param name="alignment">The alignment of <paramref name="child"/> in the container.</param>
 public void Insert(Control existing, Control child, RelativeAlignment relativeAlignment, Size size, Size expand, Alignment alignment) => Insert(existing, child, relativeAlignment, size.Width, size.Height, expand.Width, expand.Height, alignment);
 /// <summary>
 /// Adds a control to the <see cref="GridContainerItemCollection"/> at the specified index.
 /// </summary>
 /// <param name="existing">The existing control at which item should be inserted.</param>
 /// <param name="item">The <see cref="Control"/> to insert into the <see cref="GridContainerItemCollection"/>.</param>
 /// <param name="relativeAlignment">The relative placement of the item control to the existing one.</param>
 /// <param name="size">The size of <paramref name="item"/>.</param>
 /// <param name="expand">A <see cref="Size"/> representing the h and v-expand.</param>
 /// <param name="alignment">The alignment of <paramref name="item"/> in the container.</param>
 public void AddAt(Control existing, Control item, RelativeAlignment relativeAlignment, Size size, Size expand, Alignment alignment) => AddAt(existing, item, relativeAlignment, size.Width, size.Height, expand.Width, expand.Height, alignment);
예제 #7
0
 public static void uiGridInsertAt(IntPtr g, IntPtr c, IntPtr existing, RelativeAlignment at, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign) => FunctionLoader.LoadLibuiFunc <uiGridInsertAt_t>("uiGridInsertAt")(g, c, existing, at, xspan, yspan, hexpand, halign, vexpand, valign);
예제 #8
0
 public virtual void Insert(Control item, Control exists, RelativeAlignment at, int xspan, int yspan, int hexpand, Alignment halign, int vexpand, Alignment valign)
 {
     uiGridInsertAt(Owner.Handle, item.Handle, exists.Handle, at, xspan, yspan, hexpand, halign, vexpand, valign);
     base.Insert(exists.Index, item);
 }