|
|
|
|
using Mesnac.Compressor.Unity.Properties;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Compressor.Unity
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmConnnectFlag : Form
|
|
|
|
|
{
|
|
|
|
|
delegate void InvokCallBack();
|
|
|
|
|
|
|
|
|
|
public bool socketReconnect = false;
|
|
|
|
|
|
|
|
|
|
public bool GunReconnect = false;
|
|
|
|
|
|
|
|
|
|
public FrmConnnectFlag()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void init()
|
|
|
|
|
{
|
|
|
|
|
RefreshLight();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新界面
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void RefreshLight()
|
|
|
|
|
{
|
|
|
|
|
lock(string.Empty)
|
|
|
|
|
{
|
|
|
|
|
//服务器
|
|
|
|
|
if (Common.Instance.ServerConnect)
|
|
|
|
|
{
|
|
|
|
|
pb_Server.Image = Resources.绿色;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pb_Server.Image = Resources.Red140;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Common.Instance.LocalConnect)
|
|
|
|
|
{
|
|
|
|
|
pb_local.Image = Resources.绿色;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pb_local.Image = Resources.Red140;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Common.Instance.ReadLocalDB)
|
|
|
|
|
{
|
|
|
|
|
pb_change.Image = Resources.手动1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pb_change.Image = Resources.手动2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 单击重新连接
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void pb_socket_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
|
|
|
|
InvokCallBack call = new InvokCallBack(Refresh);
|
|
|
|
|
this.Invoke(call);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FrmConnnectFlag_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pb_change_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Common.Instance.ReadLocalDB)
|
|
|
|
|
{
|
|
|
|
|
Common.Instance.ReadLocalDB = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Common.Instance.ReadLocalDB = true;
|
|
|
|
|
}
|
|
|
|
|
RefreshLight();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn_SocketReconnect_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!socketReconnect)
|
|
|
|
|
{
|
|
|
|
|
socketReconnect = true;
|
|
|
|
|
Thread SocketThread = null;
|
|
|
|
|
SocketThread = new Thread(ReconnectThread);
|
|
|
|
|
SocketThread.Start(1);
|
|
|
|
|
timer2.Stop();
|
|
|
|
|
timer2.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn_GunReconnect_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(!GunReconnect)
|
|
|
|
|
{
|
|
|
|
|
GunReconnect = true;
|
|
|
|
|
Thread SocketThread = null;
|
|
|
|
|
SocketThread = new Thread(ReconnectThread);
|
|
|
|
|
SocketThread.Start(2);
|
|
|
|
|
timer2.Stop();
|
|
|
|
|
timer2.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void timer2_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GunReconnect = false;
|
|
|
|
|
socketReconnect = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReconnectThread(object i)
|
|
|
|
|
{
|
|
|
|
|
int value = Convert.ToInt32(i);
|
|
|
|
|
if (value == 1)
|
|
|
|
|
{
|
|
|
|
|
Common.Instance.SocketReconnect(null, null);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Common.Instance.SerialReconnect(null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|