コード例 #1
0
ファイル: SettingsForm.cs プロジェクト: OndZal/zapoctak
 // Lets user pick a color and adds an indexedButton to hold the color.
 private void AddButton_Click(object sender, EventArgs e)
 {
     if (colorDialog1.ShowDialog() == DialogResult.OK)
     {
         var newButton = new IndexedButton(colorButtons.Count, colorDialog1.Color);
         colorButtons.Add(newButton);
         Controls.Add(newButton);
         newButton.Click += new EventHandler(this.ColorPick_Click);
     }
 }
コード例 #2
0
ファイル: SettingsForm.cs プロジェクト: OndZal/zapoctak
 // The form initializes itself according to xisting settings.
 public SettingsForm(List <Color> colors)
 {
     InitializeComponent();
     this.colors = colors;
     for (int i = 0; i < this.colors.Count; i++)
     {
         var newButton = new IndexedButton(i, this.colors[i]);
         colorButtons.Add(newButton);
         Controls.Add(newButton);
         newButton.Click += new EventHandler(this.ColorPick_Click);
     }
 }
コード例 #3
0
ファイル: SettingsForm.cs プロジェクト: OndZal/zapoctak
 // Removes the last button and thus its' assigned color
 private void RemoveButton_Click(object sender, EventArgs e)
 {
     if (colorButtons.Count > 2)
     {
         IndexedButton toRemove = colorButtons.Last();
         Controls.Remove(toRemove);
         colorButtons.Remove(toRemove);
         toRemove.Dispose();
     }
     else
     {
         MessageBox.Show("Cannot have less than two colors");
     }
 }