2013-01-18 15:55:50 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Data;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
2014-01-08 14:16:39 +00:00
|
|
|
using AsterNET.Manager;
|
|
|
|
using AsterNET.Manager.Event;
|
2013-01-18 15:55:50 +00:00
|
|
|
using System.Diagnostics;
|
|
|
|
|
2014-01-08 14:16:39 +00:00
|
|
|
namespace AsterNET.WinForm
|
2013-01-18 15:55:50 +00:00
|
|
|
{
|
|
|
|
public partial class FormMain : Form
|
|
|
|
{
|
|
|
|
public FormMain()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
private ManagerConnection manager = null;
|
|
|
|
private void btnConnect_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
string address = this.tbAddress.Text;
|
|
|
|
int port = int.Parse(this.tbPort.Text);
|
|
|
|
string user = this.tbUser.Text;
|
|
|
|
string password = this.tbPassword.Text;
|
|
|
|
|
|
|
|
btnConnect.Enabled = false;
|
|
|
|
manager = new ManagerConnection(address, port, user, password);
|
2017-04-06 06:25:48 +00:00
|
|
|
manager.UnhandledEvent += new EventHandler<ManagerEvent>(manager_Events);
|
2013-01-18 15:55:50 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// Uncomment next 2 line comments to Disable timeout (debug mode)
|
|
|
|
// manager.DefaultResponseTimeout = 0;
|
|
|
|
// manager.DefaultEventTimeout = 0;
|
|
|
|
manager.Login();
|
|
|
|
}
|
|
|
|
catch(Exception ex)
|
|
|
|
{
|
|
|
|
MessageBox.Show("Error connect\n" + ex.Message);
|
|
|
|
manager.Logoff();
|
|
|
|
this.Close();
|
|
|
|
}
|
|
|
|
btnDisconnect.Enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void manager_Events(object sender, ManagerEvent e)
|
|
|
|
{
|
|
|
|
Debug.WriteLine("Event : " + e.GetType().Name);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void btnDisconnect_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
btnConnect.Enabled = true;
|
|
|
|
if (this.manager != null)
|
|
|
|
{
|
|
|
|
manager.Logoff();
|
|
|
|
this.manager = null;
|
|
|
|
}
|
|
|
|
btnDisconnect.Enabled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|