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
|
using com.clusterrr.FelLib;
using com.clusterrr.hakchi_gui.Properties;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Management;
using System.Windows.Forms;
namespace com.clusterrr.hakchi_gui
{
public partial class WaitingClovershellForm : Form
{
public WaitingClovershellForm()
{
InitializeComponent();
buttonDriver.Left = label6.Left + label6.Width;
timer.Enabled = true;
}
public static bool WaitForDevice(IWin32Window owner)
{
if (DeviceExists()) return true;
var form = new WaitingClovershellForm();
form.ShowDialog(owner);
return form.DialogResult == DialogResult.OK;
}
static bool DeviceExists()
{
return MainForm.Clovershell.IsOnline;
}
private void timer_Tick(object sender, EventArgs e)
{
if (DeviceExists())
{
DialogResult = DialogResult.OK;
timer.Enabled = false;
}
}
private void WaitingForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!DeviceExists())
{
if (MessageBox.Show(this, Resources.DoYouWantCancel, Resources.AreYouSure, MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
== System.Windows.Forms.DialogResult.No)
e.Cancel = true;
else
{
DialogResult = DialogResult.Abort;
}
}
}
private void buttonDriver_Click(object sender, EventArgs e)
{
try
{
var process = new Process();
var fileName = Path.Combine(Path.Combine(Program.BaseDirectoryInternal, "driver"), "nesmini_driver.exe");
process.StartInfo.FileName = fileName;
process.Start();
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void WaitingForm_FormClosed(object sender, FormClosedEventArgs e)
{
timer.Enabled = false;
}
}
}
|