private void spawnLabels() { charPanel.BackColor = Properties.Settings.Default.DisplayBackground; charPanel.AutoSize = true; charPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; int width = 50; Color ForeColor = Properties.Settings.Default.DisplayForegroundInactive; for (int i = 0; i < Defines.CHAR_HEIGHT; ++i) { for (int j = 0; j < Defines.CHAR_WIDTH; ++j) { int spacing = (int)Math.Max(width * 0.1, 1); Label tile = new Label(); tile.Name = String.Format("TILE_{0}_{1}", i, j); tile.Height = width; tile.Width = width; tile.Location = new System.Drawing.Point(0 + (width + spacing) * j, 0 + (width + spacing) * i); tile.FlatStyle = FlatStyle.Flat; tile.BackColor = LCDCharacter.TileColor(tempChar[i, j]); charPanel.Controls.Add(tile); tile.Click += tile_pressed; tile.Paint += tile_Paint; } } }
private void LCDlabel_Paint(object sender, PaintEventArgs e) { Label label = (Label)sender; Graphics graphics = e.Graphics;//label.CreateGraphics(); //LCDCharacter character = (LCDCharacter)label.Tag; LCDCharacter.GenerateImage(graphics, (Character)label.Tag, TILE_WIDTH); }
private void tile_Paint(object sender, PaintEventArgs e) { String[] name = ((Label)sender).Name.Split('_'); int row = Convert.ToInt16(name[1]); int col = Convert.ToInt16(name[2]); ((Label)sender).BackColor = LCDCharacter.TileColor(tempChar[row, col]); }