blob: a30ac5a2d58532ccf06094085f77bfda1cd6b433 (
plain) (
blame)
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
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShiftOS.MFSProfiler
{
public partial class Infobox : Form
{
public Infobox()
{
InitializeComponent();
}
public Action<string> TextCallback = null;
public Action<bool> YesNoCallback = null;
public string MessageText
{
get
{
return lbmessage.Text;
}
set
{
lbmessage.Text = value;
}
}
public bool ShowText
{
get { return txtinput.Visible; }
set { txtinput.Visible = value; }
}
public bool ShowYesNo
{
get { return btnyes.Parent.Visible; }
set { btnyes.Parent.Visible = value; }
}
public static void PromptYesNo(string title, string message, Action<bool> callback)
{
var inf = new Infobox();
inf.ShowText = false;
inf.ShowYesNo = true;
inf.Text = title;
inf.MessageText = message;
inf.YesNoCallback = callback;
inf.ShowDialog();
}
public static void PromptText(string title, string message, Action<string> callback)
{
var inf = new Infobox();
inf.ShowYesNo = false;
inf.ShowText = true;
inf.Text = title;
inf.MessageText = message;
inf.TextCallback = callback;
inf.ShowDialog();
}
private void btnyes_Click(object sender, EventArgs e)
{
YesNoCallback?.Invoke(true);
this.Close();
}
private void btnno_Click(object sender, EventArgs e)
{
YesNoCallback?.Invoke(false);
this.Close();
}
private void btnok_Click(object sender, EventArgs e)
{
TextCallback?.Invoke(txtinput.Text);
this.Close();
}
}
}
|