-
Notifications
You must be signed in to change notification settings - Fork 34
/
ConanOptionsPage.cs
76 lines (68 loc) · 2.36 KB
/
ConanOptionsPage.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
using conan_vs_extension;
using Microsoft.VisualStudio.Shell;
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
[Guid(GuidList.strConanOptionsPage)]
public class ConanOptionsPage : DialogPage
{
private string _conanExecutablePath;
private bool _useSystemConan;
[DisplayName("Executable Path")]
[Description("Path to the Conan executable.")]
[Editor(typeof(ExecutablePathEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string ConanExecutablePath
{
get => _conanExecutablePath;
set
{
_conanExecutablePath = value?.Trim();
GlobalSettings.ConanExecutablePath = value;
if (value != "conan")
{
_useSystemConan = false;
}
}
}
[DisplayName("Use System Conan")]
[Description("Specify whether to use the Conan executable installed in the system.")]
public bool UseSystemConan
{
get => _useSystemConan;
set
{
_useSystemConan = value;
if (_useSystemConan)
{
_conanExecutablePath = "conan";
GlobalSettings.ConanExecutablePath = "conan";
}
if (!_useSystemConan && _conanExecutablePath == "conan")
{
_conanExecutablePath = "";
GlobalSettings.ConanExecutablePath = "";
}
}
}
public class ExecutablePathEditor : System.Drawing.Design.UITypeEditor
{
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return System.Drawing.Design.UITypeEditorEditStyle.Modal;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.Filter = "Executable Files (*.exe)|*.exe|All Files (*.*)|*.*";
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
return openFileDialog.FileName;
}
}
return value;
}
}
}