-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConnectControl.cs
55 lines (47 loc) · 1.39 KB
/
ConnectControl.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using rec.robotino.api2;
namespace rec.robotino.api2.examples.camera
{
/// <summary>
/// This control provides a graphical user interface to connect to Robotino.
/// </summary>
public partial class ConnectControl : UserControl
{
protected readonly Robot robot;
public ConnectControl(Robot robot)
{
this.robot = robot;
robot.Connected += new Robot.ConnectedEventHandler(robot_Connected);
robot.Disconnected += new Robot.DisconnectedEventHandler(robot_Disconnected);
InitializeComponent();
}
void robot_Disconnected(Robot sender)
{
if (this.InvokeRequired)
Invoke(new MethodInvoker(Connected));
}
void robot_Connected(Robot sender)
{
if (this.InvokeRequired)
Invoke(new MethodInvoker(Disconnected));
}
private void Connected()
{
buttonConnect.Enabled = true;
}
private void Disconnected()
{
buttonConnect.Enabled = false;
}
private void buttonConnect_Click(object sender, EventArgs e)
{
robot.Connect(textBoxHostname.Text, false);
}
}
}