| 0: | // SharpMessageBox.cs | |
| 1: | // Copyright (c) 2001 Mike Krueger | |
| 2: | // | |
| 3: | // This program is free software; you can redistribute it and/or modify | |
| 4: | // it under the terms of the GNU General Public License as published by | |
| 5: | // the Free Software Foundation; either version 2 of the License, or | |
| 6: | // (at your option) any later version. | |
| 7: | // | |
| 8: | // This program is distributed in the hope that it will be useful, | |
| 9: | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 10: | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 11: | // GNU General Public License for more details. | |
| 12: | // | |
| 13: | // You should have received a copy of the GNU General Public License | |
| 14: | // along with this program; if not, write to the Free Software | |
| 15: | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 16: | ||
| 17: | using System; | |
| 18: | using System.Windows.Forms; | |
| 19: | using System.Drawing; | |
| 20: | ||
| 21: | using SharpDevelop.Tool.Data; | |
| 22: | using SharpDevelop.Actions; | |
| 23: | using SharpDevelop.Actions.Menu; | |
| 24: | ||
| 25: | namespace SharpDevelop.Gui.Components { | |
| 26: | ||
| 27: | public class SharpMessageBox : Form | |
| 28: | { | |
| 29: | Button[] buttons; | |
| 30: | int retvalue = -1; | |
| 31: | ||
| 32: | public SharpMessageBox(string header, string text, params string[] buttontexts) | |
| 33: | { | |
| 34: | Text = header; | |
| 35: | FormBorderStyle = FormBorderStyle.FixedDialog; | |
| 36: | MinimizeBox = HelpButton = MaximizeBox = false; | |
| 37: | StartPosition = FormStartPosition.CenterScreen; | |
| 38: | ||
| 39: | Icon = null; | |
| 40: | ShowInTaskbar = false; | |
| 41: | ||
| 42: | Label label1 = new Label(); | |
| 43: | ||
| 44: | label1.Location = new Point(0, 0); | |
| 45: | label1.Text = text; | |
| 46: | ||
| 47: | Width = 320; | |
| 48: | Height = 100; | |
| 49: | ||
| 50: | label1.Width = Width; | |
| 51: | label1.Height = 50; | |
| 52: | ||
| 53: | buttons = new Button[buttontexts.Length]; | |
| 54: | Bitmap b = new Bitmap(400, 60); | |
| 55: | Graphics g = Graphics.FromImage(b); | |
| 56: | ||
| 57: | for (int i = 0; i < buttontexts.Length; ++i) { | |
| 58: | buttons[i] = new Button(); | |
| 59: | buttons[i].Text = buttontexts[i]; | |
| 60: | buttons[i].Size = new Size(96, 23); | |
| 61: | ||
| 62: | int v = (Width - buttontexts.Length * (buttons[i].Width + 4)) / 2; | |
| 63: | buttons[i].Location = new Point(v + i * (buttons[i].Width + 4) + Width / buttons[i].Width, 50); | |
| 64: | buttons[i].Anchor = AnchorStyles.Right | AnchorStyles.Bottom; | |
| 65: | buttons[i].Click += new EventHandler(ButtonClick); | |
| 66: | Controls.Add(buttons[i]); | |
| 67: | } | |
| 68: | ||
| 69: | Controls.Add(label1); | |
| 70: | } | |
| 71: | ||
| 72: | void ButtonClick(object sender, EventArgs e) | |
| 73: | { | |
| 74: | for (int i = 0; i < buttons.Length; ++i) | |
| 75: | if (sender == buttons[i]) { | |
| 76: | retvalue = i; | |
| 77: | break; | |
| 78: | } | |
| 79: | DialogResult = DialogResult.OK; | |
| 80: | } | |
| 81: | ||
| 82: | public int ShowMessageBox() | |
| 83: | { | |
| 84: | ShowDialog(); | |
| 85: | return retvalue; | |
| 86: | } | |
| 87: | } | |
| 88: | } |
This page was automatically generated by SharpDevelop.