diff options
| author | Michael VanOverbeek <[email protected]> | 2016-07-25 12:57:52 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-07-25 12:57:52 -0400 |
| commit | 46c1c31302f111a1f3ec23a70e6f3986a9aa2a27 (patch) | |
| tree | f00af7ea3f6ad2641fb26fa1d310fd8b7179b39c /source/ShiftUI/Form/MessageBox.cs | |
| parent | af48e774189596b8d7a058c564a7d6d75205ca03 (diff) | |
| parent | 6fa16209519896de09949a27425dff00ebf2970a (diff) | |
| download | shiftos-c--46c1c31302f111a1f3ec23a70e6f3986a9aa2a27.tar.gz shiftos-c--46c1c31302f111a1f3ec23a70e6f3986a9aa2a27.tar.bz2 shiftos-c--46c1c31302f111a1f3ec23a70e6f3986a9aa2a27.zip | |
Merge pull request #17 from MichaelTheShifter/shiftui_integration
Shiftui integration
Diffstat (limited to 'source/ShiftUI/Form/MessageBox.cs')
| -rw-r--r-- | source/ShiftUI/Form/MessageBox.cs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/source/ShiftUI/Form/MessageBox.cs b/source/ShiftUI/Form/MessageBox.cs new file mode 100644 index 0000000..aab960a --- /dev/null +++ b/source/ShiftUI/Form/MessageBox.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftUI +{ + public class MessageBox : Form + { + + public static void Show(string message, string title) + { + var m = new MessageBox(title, message); + + m.TopMost = true; + m.ShowDialog(); + } + + public MessageBox(string title, string message) + { + var pnlbottom = new FlowLayoutPanel(); + pnlbottom.Height = 30; + pnlbottom.BackColor = Application.CurrentSkin.MessageBox_BottomPanel; + var pnltop = new Panel(); + pnlbottom.Dock = DockStyle.Bottom; + pnltop.Dock = DockStyle.Fill; + this.Widgets.Add(pnlbottom); + pnlbottom.Show(); + this.Widgets.Add(pnltop); + pnltop.Show(); + var btnok = new Button(); + btnok.Text = "OK"; + btnok.AutoSize = true; + btnok.AutoSizeMode = AutoSizeMode.GrowAndShrink; + pnlbottom.Widgets.Add(btnok); + btnok.Show(); + btnok.Click += (s, a) => + { + this.Close(); + }; + var lblmessage = new Label(); + lblmessage.Padding = new Padding(25); + lblmessage.Text = message; + lblmessage.Dock = DockStyle.Fill; + pnltop.Widgets.Add(lblmessage); + lblmessage.Show(); + //autosize the form + int newheight = 10; + for(int i = 0; i < lblmessage.Text.Length; i++) + { + if ((i % 2) == 0) + newheight += 10; + } + this.MaximumSize = new System.Drawing.Size(500, 200); + this.Height = newheight + pnlbottom.Height; + this.Load += (o, a) => + { + this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; + this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; + + }; + this.Text = title; + } + } +} |
