private void ChangeControlSize(TemplateCtl ucTemplate, Size newSize)
        {
            int heightChange = newSize.Height - ucTemplate.Height;
            ucTemplate.Size = new Size(ucTemplate.Size.Width, newSize.Height);
            int changedCtlIdx = this.templateControls.IndexOf(ucTemplate);

            // Relocate controls after changed control.
            int nextCtlIdx = changedCtlIdx + 1;
            for (int i = nextCtlIdx; i < this.templateControls.Count; i++)
            {
                //ucTemplate.Top += heightChange;
                this.templateControls[i].Top += heightChange;
            }
        }
 private void AttachTemplateControl(TemplateCtl newTemplateCtl)
 {
     newTemplateCtl.PrefferedSizeChanged += new EventHandler<EventArgs<Size>>(TemplateCtl_PrefferedSizeChanged);
     this.templateControls.Add(newTemplateCtl);
     this.Controls.Add(newTemplateCtl);
 }
 private void DettachTemplateControl(TemplateCtl ucBottom)
 {
     ucBottom.PrefferedSizeChanged -= this.TemplateCtl_PrefferedSizeChanged;
     this.templateControls.Remove(ucBottom);
     this.Controls.Remove(ucBottom);
 }
        private TemplateCtl CreateTemplateControl()
        {
            TemplateCtl newTemplateCtl = new TemplateCtl();
            int nextIdx = this.templateControls.Count;
            newTemplateCtl.Name = "uiTemplate" + nextIdx.ToString();

            newTemplateCtl.DefaultTemplateFileName = this.DefaultTemplateFileName;
            newTemplateCtl.VariableBus = this.VariableBus;
            newTemplateCtl.FileFilter = this.FileFilter;
            newTemplateCtl.Location = new Point(0, GetLastTemplateBottom() + TemplateGap);
            newTemplateCtl.Width = this.Width;
            newTemplateCtl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            newTemplateCtl.BorderStyle = BorderStyle.None;
            newTemplateCtl.AutoScroll = true;

            return newTemplateCtl;
        }