private void clickButton(object sender, EventArgs e, ItemSettings item) { if (String.IsNullOrEmpty(item.exeFile)) { MessageBox.Show("Не указан файл для запуска для кнопки: " + item.text); return; } item.Run(); }
private void FakeData() { for (int i = 0; i < 5; i++) { ItemSettings setting = new ItemSettings(); setting.text = "Тестовая кнопка " + (i + 1); //setting.img = "/home/boris/Изображения/!test/1200_2.jpg"; setting.img = @"icon_gampad.jpg"; this.Items.Add(setting); } }
private void CreateButton(ItemSettings item, int num) { Button button = new Button(); button.Text = item.text; button.Parent = this.form; button.Location = new System.Drawing.Point(0, num * this.HeightButton); button.Width = this.form.Width; button.Height = this.HeightButton; button.Click += delegate(object sender, EventArgs e) { clickButton(sender, e, item); }; button.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); if (!String.IsNullOrEmpty(item.img)) { button.BackgroundImage = Image.FromFile(item.getWorkPathImg()); button.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; } }