public Control AddCell(SettingsCell cell) { cell.PerformInit(); if (cell.SizeType != SizeType.AutoSize) { cell.SetBounds(0, 0, layoutPanel.Width, layoutPanel.Height); } cell.Dock = DockStyle.Fill; if (cell.SizeType == SizeType.AutoSize) { layoutPanel.RowStyles.Add(new RowStyle() { SizeType = SizeType.AutoSize }); } else { layoutPanel.RowStyles.Add(new RowStyle() { SizeType = SizeType.Percent, Height = 100 }); } layoutPanel.RowCount = layoutPanel.RowStyles.Count; layoutPanel.Controls.Add(cell); return(cell); }
public Control AddCell(Type cellClass, bool useIfAlreadyCreated) { if (useIfAlreadyCreated) { foreach (Control c in layoutPanel.Controls) { if (cellClass.IsAssignableFrom(c.GetType())) { return(c); } } } SettingsCell cell = (SettingsCell)cellClass.GetConstructor(new Type[0]).Invoke(new object[0]); AddCell(cell); return(cell); }
//!!!!может есть опции обновления какие-то public void PerformUpdate(bool clear) { if (clear) { Clear(); } UpdateBegin?.Invoke(this); AllProviders_UpdateBegin?.Invoke(this); OnUpdate(); //!!!!внутри suspend update видать тут что-то //sort by priority { List <Tuple <Control, float> > list = new List <Tuple <Control, float> >(); foreach (Control control in layoutPanel.Controls) { float priority = 0; SettingsCell cell = control as SettingsCell; if (cell != null) { priority = cell.CellsSortingPriority; } list.Add(new Tuple <Control, float>(control, priority)); } CollectionUtility.MergeSort(list, delegate(Tuple <Control, float> c1, Tuple <Control, float> c2) { if (c1.Item2 < c2.Item2) { return(-1); } if (c1.Item2 > c2.Item2) { return(1); } return(0); }); for (int n = 0; n < list.Count; n++) { var t = list[n]; layoutPanel.Controls.SetChildIndex(t.Item1, n); } } ////change docking //if( layoutPanel.Controls.Count == 1 && layoutPanel.Controls[ 0 ] is SettingsCell_Properties ) //{ // //only Properties. no another controls // layoutPanel.Controls[0].Size = new System.Drawing.Size(30, 15); // layoutPanel.Controls[0].Dock = DockStyle.Fill; //} //else //{ // //!!!!!temp // foreach( Control c in layoutPanel.Controls ) // { // var p = c as SettingsCell_Properties; // if( p != null ) // { // //p.Size = new System.Drawing.Size( 30, 15 ); // //p.Dock = DockStyle.Fill; // break; // } // } // //!!!!! // //layoutPanel.AutoScroll = true; // //layoutPanel.HorizontalScroll.Enabled = false; //} UpdateEnd?.Invoke(this); AllProviders_UpdateEnd?.Invoke(this); }