Esempio n. 1
0
        /// <summary>
        /// Add a child to the center anchor.
        /// </summary>
        /// <param name="transform">The child to add.</param>
        /// <param name="margin">The margin of the control.</param>
        public void AddChild(Transform transform, Rectangle margin)
        {
            LayoutControl anchorControl = new LayoutControl
            {
                Control = transform,
                Margin  = margin
            };

            lock (_controls)
            {
                _controls.Add(anchorControl);
            }

            // Hook up to event.
            transform.OnResize += _updateEvent;

            ApplyLogic();
            base.AddChild(transform);
        }
Esempio n. 2
0
        /// <summary>
        /// Remove a child from the center anchor. If not found nothing will happen.
        /// </summary>
        /// <param name="transform">The child to remove.</param>
        public override void RemoveChild(Transform transform)
        {
            lock (_controls)
            {
                LayoutControl match = _controls.FirstOrDefault(x => x.Control == transform);
                if (match != null)
                {
                    _controls.Remove(match);
                }
                else
                {
                    return;
                }
            }

            // Unhook from event.
            transform.OnResize -= _updateEvent;

            ApplyLogic();
            base.RemoveChild(transform);
        }