using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;



using System.Windows.Forms.Design;
using System.ComponentModel.Design;
using Infragistics.Win.Misc;

namespace _141493
{
    [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
    public partial class MyExpandable : UserControl
    {
        bool expanded = true;

        [DefaultValue(true)]
        public bool Expanded
        {
            get { return expanded; }
            set { expanded = value;
            SetExpanded(expanded);
               
            }
        }

      
        public UltraPanel ContentArea
        {
            get { return this.ultraPanel1; }
        }

        int height; 
        public MyExpandable()
        {
            InitializeComponent();
            height = this.Height;
            this.Resize += MyExpandable_Resize;
        }

        void MyExpandable_Resize(object sender, EventArgs e)
        {
            if(expanded)
                height = this.Height + 5;
        }

        private void ultraButton1_Click(object sender, EventArgs e)
        {
            this.Expanded = !this.Expanded;

        }

        internal void SetExpanded(bool expanded)
        {
            if (expanded)
            {
                this.Height = height;
                this.ultraButton1.Text = "+";
            }
            else
            {
                this.Height = ultraTrackBar1.Height;
                this.ultraButton1.Text = "-";
            }
        }

        protected override void OnControlAdded(ControlEventArgs e)
        {
            
            if (!this.DesignMode && 
            !e.Control.Equals(this.ultraPanel1) && !e.Control.Equals(this.ultraGroupBox1))
            {
                this.ultraPanel1.ClientArea.Controls.Add(e.Control);
            }
            else
                this.Controls.Add(e.Control);

        }
       
    }

   
}
