forked from ToadsworthLP/desktoptale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDuplicateOptionsForm.cs
172 lines (161 loc) · 5.27 KB
/
DuplicateOptionsForm.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Desktoptale.Messages;
using Desktoptale.Messaging;
namespace Desktoptale
{
public class DuplicateOptionsForm : Form
{
private static DuplicateOptionsForm instance;
private IContainer components = null;
private NumericUpDown NumInput;
private Action<int> SuccessAction;
private Action CancelAction;
static DuplicateOptionsForm()
{
instance = new DuplicateOptionsForm();
instance.StartPosition = FormStartPosition.CenterParent;
}
public static void Show(Action<int> 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((int)instance.NumInput.Value);
}
else
{
instance.CancelAction();
}
}
private DuplicateOptionsForm()
{
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;
NumInput = new NumericUpDown();
BtnOk = new Button();
BtnCancel = new Button();
PnlMain = new Panel();
LblMainText = new Label();
PnlMain.SuspendLayout();
((ISupportInitialize)(NumInput)).BeginInit();
SuspendLayout();
//
// PnlMain
//
PnlMain.BackColor = SystemColors.Window;
PnlMain.Controls.Add(NumInput);
PnlMain.Controls.Add(LblMainText);
PnlMain.Location = new Point(0, 0);
PnlMain.Size = new Size(565, 115);
PnlMain.TabIndex = 0;
//
// NumInput
//
NumInput.Location = new Point(429, 45);
NumInput.Maximum = new decimal(new[] {
10000,
0,
0,
0});
NumInput.Minimum = new decimal(new[] {
1,
0,
0,
0});
NumInput.Name = "NumInput";
NumInput.Size = new Size(110, 26);
NumInput.TabIndex = 1;
NumInput.Value = new decimal(new[] {
1,
0,
0,
0});
//
// LblMainText
//
LblMainText.AutoSize = true;
LblMainText.Location = new Point(23, 45);
LblMainText.Size = new Size(489, 40);
LblMainText.TabIndex = 0;
LblMainText.Text = "How many copies would you like to create?";
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();
((ISupportInitialize)(NumInput)).EndInit();
ResumeLayout(false);
AcceptButton = BtnOk;
}
}
}