private void CreateLayoutItems(LayoutControl layout) { layout.BeginUpdate(); try { layout.Clear(); IList <DocumentItemBase> documentItems = GetSortedDocumentItems(); if (documentItems.Count != 0) { int itemsPerRow = DefaultItemsPerRow; ItemsPerRowAttribute attr = MemberInfo.FindAttribute <ItemsPerRowAttribute>(); if (attr != null) { itemsPerRow = attr.Value; } for (int rowNumber = 0; rowNumber < Math.Ceiling((decimal)documentItems.Count / (decimal)itemsPerRow); rowNumber++) { LayoutControlGroup row = layout.AddGroup(); row.Name = GetId("Row", rowNumber); row.DefaultLayoutType = DevExpress.XtraLayout.Utils.LayoutType.Horizontal; row.GroupBordersVisible = false; for (int cellNumber = 0; cellNumber < itemsPerRow; cellNumber++) { if (rowNumber * itemsPerRow + cellNumber < documentItems.Count) { DocumentItemBase item = documentItems[rowNumber * itemsPerRow + cellNumber]; LayoutControlItem cell = new LayoutControlItem(layout, CreateDocumentItemEditor(item)); cell.Name = GetId("Cell", item); cell.Text = item.Caption; if (application.Model.Options.LayoutManagerOptions.EnableCaptionColon) { cell.Text += ":"; } row.Add(cell); } else { row.Add(new EmptySpaceItem()); } } } } } finally { layout.EndUpdate(); layout.BestFit(); } }
private Control CreateDocumentItemEditor(DocumentItemBase item) { IModelMemberViewItem modelViewItem = (IModelMemberViewItem)application.FindModelClass(item.GetType()).DefaultDetailView.Items["Value"]; if (modelViewItem != null) { WinPropertyEditor propertyEditor = (WinPropertyEditor)application.EditorFactory.CreatePropertyEditorByType(modelViewItem.PropertyEditorType, modelViewItem, item.GetType(), application, objectSpace); propertyEditor.CurrentObject = item; propertyEditor.CreateControl(); propertyEditor.Control.Name = GetId("Editor", item); if (propertyEditor.Control is CheckEdit) { ((CheckEdit)propertyEditor.Control).Text = String.Empty; } propertyEditor.ControlValueChanged += new EventHandler(propertyEditor_ControlValueChanged); return(propertyEditor.Control); } return(null); }
private string GetId(string elementName, DocumentItemBase item) { return(elementName + item.GetHashCode().ToString()); }