-
Notifications
You must be signed in to change notification settings - Fork 3
/
Settings.cs
80 lines (71 loc) · 2.37 KB
/
Settings.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
#region License
/*
ClipboardDiff Visual Studio Extension
Copyright (C) 2011-2014 Einar Egilsson
http://einaregilsson.com/clipboarddiff-visual-studio-extension/
This program is licensed under the MIT license, see the file LICENSE
for details.
*/
#endregion
using System;
using System.IO;
using System.Windows.Forms;
namespace EinarEgilsson.ClipboardDiff
{
public partial class Settings : Form
{
public Settings()
{
InitializeComponent();
}
public Settings(string program, string arguments) : this()
{
txtProgram.Text = program;
txtArguments.Text = arguments;
}
public string Program
{
get { return txtProgram.Text; }
}
public string Arguments
{
get { return txtArguments.Text; }
}
private void OnFindProgramClick(object sender, EventArgs e)
{
using (var filePicker = new OpenFileDialog())
{
filePicker.Title = "Choose diff program to use...";
filePicker.CheckFileExists = true;
filePicker.Filter = "Executable files|*.exe";
filePicker.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
if (filePicker.ShowDialog(this) == DialogResult.OK)
{
txtProgram.Text = filePicker.FileName;
}
}
}
private void OnCancelClick(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void OnOKClick(object sender, EventArgs e)
{
if (!File.Exists(txtProgram.Text))
{
MessageBox.Show("The program you have picked doesn't exist!", "File doesn't exist", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
if (!txtArguments.Text.Contains("$FILE1$") || !txtArguments.Text.Contains("$FILE2$"))
{
MessageBox.Show("The arguments must contain both $FILE1$ and $FILE2$ for the diff to work!", "Arguments are invalid", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
DialogResult = DialogResult.OK;
Close();
}
}
}