-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGeneratedResults.cs
77 lines (70 loc) · 2.34 KB
/
GeneratedResults.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
using System;
using System.Windows.Forms;
using System.IO;
namespace Xrm.Tools
{
public partial class GeneratedResults : UserControl
{
public EventArgs e = null;
public event OnCompleteHandler OnComplete;
public delegate void OnCompleteHandler(EventArgs e);
public GeneratedResults()
{
InitializeComponent();
}
public void ShowResults(string templateResults, string loggingResults)
{
textBoxResults.Text = templateResults;
textBoxLoggingResults.Text = loggingResults;
}
private void buttonOk_Click(object sender, EventArgs e)
{
CloseMe();
}
private void buttonSave_Click(object sender, EventArgs e)
{
using (var saveDlg = new SaveFileDialog()
{
InitialDirectory = Path.GetPathRoot(Environment.SystemDirectory),
Filter = Constants.GetFileOpenFilter(),
FilterIndex = 1,
RestoreDirectory = true
})
{
if (saveDlg.ShowDialog() == DialogResult.OK)
{
var fileName = saveDlg.FileName;
var doSave = true;
if (File.Exists(fileName)) {
if (MessageBox.Show(string.Format("The file '{0}' already exists. Would you like to overwrire it?", fileName),
"Overwrite?",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Warning) != DialogResult.Yes) {
doSave = false;
}
}
if (doSave) {
File.WriteAllText(fileName, textBoxResults.Text);
}
}
}
}
private void buttonCopy_Click(object sender, EventArgs e)
{
Clipboard.Clear();
textBoxResults.SelectAll();
Clipboard.SetText(this.textBoxResults.Text);
}
private void GeneratedResults_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape) {
CloseMe();
}
}
private void CloseMe()
{
Hide();
OnComplete?.Invoke(null);
}
}
}