-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGeneratedResultsForm.cs
78 lines (70 loc) · 2.3 KB
/
GeneratedResultsForm.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
using System;
using System.IO;
using System.Windows.Forms;
namespace Xrm.Tools
{
public partial class GeneratedResultsForm : Form
{
public EventArgs e = null;
public GeneratedResultsForm()
{
InitializeComponent();
}
public void ShowResults(string templateResults, string loggingResults)
{
textBoxResults.Text = templateResults;
textBoxLoggingResults.Text = loggingResults;
}
private void buttonCopy_Click(object sender, EventArgs e)
{
Clipboard.Clear();
textBoxResults.SelectAll();
Clipboard.SetText(this.textBoxResults.Text);
}
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 GeneratedResultsForm_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Close();
}
}
private void GeneratedResultsForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Close();
}
}
}
}