public void ShowFile(IconFile f) { this.activeIconFile = f; table.Visible = false; table.SuspendLayout(); foreach (Control ctl in table.Controls) { if (ctl != this.tableLabel) { ctl.Dispose(); } } table.Controls.Clear(); table.ColumnCount = 1; table.RowCount = 1; table.Controls.Add(tableLabel, 0, 0); availableSizes = f.AvailableSizes.ToList(); foreach (Size size in availableSizes) { table.RowCount += 1; table.RowStyles.Add(new RowStyle(SizeType.AutoSize)); Label lbl = new Label(); lbl.Text = size.Width + "x" + size.Height; lbl.AutoSize = true; lbl.Anchor = AnchorStyles.Right; table.Controls.Add(lbl, 0, table.RowCount - 1); } availableColorDepths = f.AvailableColorDepths.ToList(); foreach (int colorDepth in availableColorDepths) { table.ColumnCount += 1; table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); Label lbl = new Label(); lbl.TextAlign = ContentAlignment.MiddleRight; lbl.Text = colorDepth + " bit"; lbl.Anchor = AnchorStyles.Bottom; lbl.AutoSize = true; table.Controls.Add(lbl, table.ColumnCount - 1, 0); } table.ColumnCount += 1; table.RowCount += 1; iconPanels = new IconPanel[table.ColumnCount - 2, table.RowCount - 2]; for (int column = 1; column < table.ColumnCount - 1; column++) { for (int row = 1; row < table.RowCount - 1; row++) { iconPanels[column - 1, row - 1] = new IconPanel(availableSizes[row - 1], availableColorDepths[column - 1]); iconPanels[column - 1, row - 1].Anchor = AnchorStyles.None; iconPanels[column - 1, row - 1].BackColor = backgroundColors[colorComboBox.SelectedIndex]; table.Controls.Add(iconPanels[column - 1, row - 1], column, row); } } foreach (IconEntry e in f.Icons) { int row = availableSizes.IndexOf(e.Size); int column = availableColorDepths.IndexOf(e.ColorDepth); iconPanels[column, row].Entry = e; } for (int column = 1; column < table.ColumnCount - 1; column++) { for (int row = 1; row < table.RowCount - 1; row++) { iconPanels[column - 1, row - 1].EntryChanged += EditorPanel_EntryChanged; } } // Work around Windows.Forms bug (scrollbars don't update correctly): table.Size = new Size(3000, 3000); table.ResumeLayout(true); table.Visible = true; }
public void ShowFile(IconFile f) { this.activeIconFile = f; table.Visible = false; table.SuspendLayout(); foreach (Control ctl in table.Controls) { if (ctl != this.tableLabel) { ctl.Dispose(); } } table.Controls.Clear(); table.ColumnCount = 1; table.RowCount = 1; table.Controls.Add(tableLabel, 0, 0); availableSizes = f.AvailableSizes.ToList(); foreach (Size size in availableSizes) { table.RowCount += 1; table.RowStyles.Add(new RowStyle(SizeType.AutoSize)); Label lbl = new Label(); lbl.Text = size.Width + "x" + size.Height; lbl.AutoSize = true; lbl.Anchor = AnchorStyles.Right; table.Controls.Add(lbl, 0, table.RowCount - 1); } availableColorDepths = f.AvailableColorDepths.ToList(); foreach (int colorDepth in availableColorDepths) { table.ColumnCount += 1; table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); Label lbl = new Label(); lbl.TextAlign = ContentAlignment.MiddleRight; lbl.Text = colorDepth + " bit"; lbl.Anchor = AnchorStyles.Bottom; lbl.AutoSize = true; table.Controls.Add(lbl, table.ColumnCount - 1, 0); } table.ColumnCount += 1; table.RowCount += 1; iconPanels = new IconPanel[table.ColumnCount - 2, table.RowCount - 2]; for (int column = 1; column < table.ColumnCount - 1; column++) { for (int row = 1; row < table.RowCount - 1; row++) { iconPanels[column-1,row-1] = new IconPanel(availableSizes[row-1], availableColorDepths[column-1]); iconPanels[column-1,row-1].Anchor = AnchorStyles.None; iconPanels[column-1,row-1].BackColor = backgroundColors[colorComboBox.SelectedIndex]; table.Controls.Add(iconPanels[column-1,row-1], column, row); } } foreach (IconEntry e in f.Icons) { int row = availableSizes.IndexOf(e.Size); int column = availableColorDepths.IndexOf(e.ColorDepth); iconPanels[column, row].Entry = e; } for (int column = 1; column < table.ColumnCount - 1; column++) { for (int row = 1; row < table.RowCount - 1; row++) { iconPanels[column-1, row-1].EntryChanged += EditorPanel_EntryChanged; } } // Work around Windows.Forms bug (scrollbars don't update correctly): table.Size = new Size(3000, 3000); table.ResumeLayout(true); table.Visible = true; }