This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAboutForm.cs
executable file
·74 lines (69 loc) · 2.61 KB
/
AboutForm.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
namespace tray_windows
{
public partial class AboutForm : Form
{
private VersionResult version;
public AboutForm()
{
InitializeComponent();
}
private void AboutForm_Load(object sender, EventArgs e)
{
Bitmap bm = new Bitmap(Resource.ocp_logo);
Icon = Icon.FromHandle(bm.GetHicon());
Text = @"About";
FormClosing += AboutForm_FormClosing;
TrayVersion.Text = Application.ProductVersion;
//this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Shown += GetVersion;
}
private void GetVersion(object sender, EventArgs e)
{
var d = new Daemon.DaemonCommander();
try
{
var r = d.GetVersion();
version = JsonConvert.DeserializeObject<VersionResult>(r);
if (version.Success) {
CrcVersionLabel.Text = String.Format("{0}+{1}", version.CrcVersion, version.CommitSha);
OcpVersion.Text = version.OpenshiftVersion;
}
else
{
DisplayMessageBox.Warn("Unable to fetch version information from daemon");
}
}
catch (System.Net.Sockets.SocketException ex)
{
this.Hide();
DisplayMessageBox.Warn(ex.Message);
}
}
private void AboutForm_FormClosing(object sender, FormClosingEventArgs e)
{
this.Hide();
e.Cancel = true; // this cancels the close event.
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
var crcVersionWithGitSha = version.CrcVersion.Split('+');
var v = crcVersionWithGitSha[0].Substring(0, crcVersionWithGitSha[0].Length - 2);
var docsUrl = string.Format("https://access.redhat.com/documentation/en-us/red_hat_codeready_containers/{0}/", v);
System.Diagnostics.Process.Start(docsUrl);
}
private void linkLabel2_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/code-ready/tray-windows");
}
}
}