private void CreatePlaceholderPanel(PlaceholderSection section, IEnumerable <Placeholder> placeholders) { var sectionItems = placeholders?.Where(x => x.Section == section).ToArray(); if (sectionItems?.Any() ?? false) { var row = new GridRow(section); switch (section) { case PlaceholderSection.Model: row.Cells[0].CellStyles.Default.Image = Resources.threat_model_small; break; case PlaceholderSection.Counter: row.Cells[0].CellStyles.Default.Image = Properties.Resources.odometer_small; break; case PlaceholderSection.Chart: row.Cells[0].CellStyles.Default.Image = Properties.Resources.presentation_pie_chart_small; break; case PlaceholderSection.List: row.Cells[0].CellStyles.Default.Image = Properties.Resources.list_style_numbered_small; break; case PlaceholderSection.Table: row.Cells[0].CellStyles.Default.Image = Properties.Resources.table_small; break; default: throw new ArgumentOutOfRangeException(nameof(section), section, null); } _docStructure.PrimaryGrid.Rows.Add(row); var panel = CreateSimplePanel(section, sectionItems); if (section == PlaceholderSection.List) { UpgradeToListPanel(panel); } else if (section == PlaceholderSection.Table) { UpgradeToTablePanel(panel); } row.Rows.Add(panel); } }
private GridPanel CreateSimplePanel(PlaceholderSection section, [NotNull] IEnumerable <IPlaceholder> placeholders) { GridPanel result = null; result = new GridPanel { Name = section.ToString(), AllowRowDelete = false, AllowRowInsert = false, AllowRowResize = true, ShowRowDirtyMarker = false, ShowTreeButtons = true, ShowTreeLines = true, InitialSelection = RelativeSelection.None }; result.Columns.Add(new GridColumn("Name") { HeaderText = "Placeholder Name", Width = 400, DataType = typeof(string), AllowEdit = false }); foreach (var ph in placeholders) { var row = new GridRow(ph.Label) { Tag = ph }; var image = ph.Image; if (image != null) { row.Cells[0].CellStyles.Default.Image = image; } result.Rows.Add(row); } return(result); }