forked from ToadsworthLP/desktoptale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreatePartyForm.cs
157 lines (146 loc) · 4.87 KB
/
CreatePartyForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Desktoptale.Messages;
using Desktoptale.Messaging;
namespace Desktoptale
{
public class CreatePartyForm : Form
{
private static CreatePartyForm instance;
private IContainer components = null;
private TextBox TextInput;
private Action<string> SuccessAction;
private Action CancelAction;
static CreatePartyForm()
{
instance = new CreatePartyForm();
instance.StartPosition = FormStartPosition.CenterParent;
}
public static void Show(Action<string> successAction, Action cancelAction)
{
instance.SuccessAction = successAction;
instance.CancelAction = cancelAction;
try
{
MessageBus.Send(new GlobalPauseMessage() { Paused = true });
instance.TopMost = true;
instance.ShowDialog(FromHandle(WindowsUtils.MainWindowHwnd));
instance.TopMost = false;
MessageBus.Send(new GlobalPauseMessage() { Paused = false });
}
catch (InvalidOperationException e)
{
instance.Focus();
return;
}
if (instance.DialogResult == DialogResult.OK)
{
instance.SuccessAction(instance.TextInput.Text);
}
else
{
instance.CancelAction();
}
}
private CreatePartyForm()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void OnOkClicked(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void OnCancelClicked(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void InitializeComponent()
{
Panel PnlMain;
Label LblMainText;
Button BtnOk;
Button BtnCancel;
TextInput = new TextBox();
BtnOk = new Button();
BtnCancel = new Button();
PnlMain = new Panel();
LblMainText = new Label();
PnlMain.SuspendLayout();
SuspendLayout();
//
// PnlMain
//
PnlMain.BackColor = SystemColors.Window;
PnlMain.Controls.Add(TextInput);
PnlMain.Controls.Add(LblMainText);
PnlMain.Location = new Point(0, 0);
PnlMain.Size = new Size(565, 115);
PnlMain.TabIndex = 0;
//
// NumInput
//
TextInput.Location = new Point(329, 45);
TextInput.Name = "TextInput";
TextInput.Size = new Size(210, 26);
TextInput.TabIndex = 1;
TextInput.Text = "New Party";
TextInput.Multiline = false;
//
// LblMainText
//
LblMainText.AutoSize = true;
LblMainText.Location = new Point(23, 45);
LblMainText.Size = new Size(489, 40);
LblMainText.TabIndex = 0;
LblMainText.Text = "What should the party be called?";
LblMainText.TextAlign = ContentAlignment.MiddleLeft;
//
// BtnOk
//
BtnOk.Location = new Point(298, 130);
BtnOk.Name = "BtnOk";
BtnOk.Size = new Size(113, 40);
BtnOk.TabIndex = 1;
BtnOk.Text = "OK";
BtnOk.UseVisualStyleBackColor = true;
BtnOk.Click += OnOkClicked;
//
// BtnCancel
//
BtnCancel.Location = new Point(426, 130);
BtnCancel.Name = "BtnCancel";
BtnCancel.Size = new Size(113, 40);
BtnCancel.TabIndex = 2;
BtnCancel.Text = "Cancel";
BtnCancel.UseVisualStyleBackColor = true;
BtnCancel.Click += OnCancelClicked;
//
// FrmNumberSelect
//
AutoScaleDimensions = new SizeF(9F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(565, 190);
Controls.Add(BtnCancel);
Controls.Add(BtnOk);
Controls.Add(PnlMain);
FormBorderStyle = FormBorderStyle.FixedDialog;
MinimizeBox = false;
MaximizeBox = false;
Text = "Desktoptale";
PnlMain.ResumeLayout(false);
PnlMain.PerformLayout();
ResumeLayout(false);
AcceptButton = BtnOk;
}
}
}