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
88
89
|
class FirefoxUtilities
{
private string firefoxPath;
/// <summary>
/// Initializes a new instance of the <see cref="FirefoxUtilities"/> class.
/// </summary>
public FirefoxUtilities()
{
firefoxPath =
string.Format(@"{0}\Mozilla Firefox\firefox.exe",
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
}
/// <summary>
/// Open Firefox if Firefox is available
/// </summary>
/// <param name="arguments">the url</param>
private void Open(string arguments)
{
if (!IsFirefoxAvailable())
throw new Exception("Firefox is not installed.");
else
Process.Start(firefoxPath, arguments);
}
/// <summary>
/// Determines whether [is firefox available].
/// </summary>
/// <returns>
/// <c>true</c> if [is firefox available]; otherwise, <c>false</c>.
/// </returns>
public bool IsFirefoxAvailable()
{
FileInfo fiFirefox = new FileInfo(firefoxPath);
return fiFirefox.Exists;
}
/// <summary>
/// Opens the firefox.
/// </summary>
public void OpenFirefox()
{
Open(string.Empty);
}
/// <summary>
/// Opens the firefox with a specific url.
/// </summary>
/// <param name="url">the url</param>
public void OpenFirefox(string url)
{
Open(url);
}
/// <summary>
/// Opens the firefox in save mode.
/// </summary>
public void OpenFirefoxInSaveMode()
{
Open("-safe-mode");
}
/// <summary>
/// Opens the firefox in a new window.
/// </summary>
/// <param name="url">the url</param>
public void OpenFirefoxInNewWindow(string url)
{
Open(string.Format("-new-window {0}", url));
}
/// <summary>
/// Opens the firefox in a new tab.
/// </summary>
/// <param name="url">the url</param>
public void OpenFirefoxInNewTab(string url)
{
Open(string.Format("-new-tab {0}", url));
}
/// <summary>
/// Opens the mozilla website.
/// </summary>
public void OpenMozillaWebsite()
{
Process.Start("http://www.mozilla-europe.org");
}
}
|