Skip to content

Commit 9fd9b68

Browse files
committed
[QpTestClient]Fix icon don't change gray when disconnected.
1 parent b22e984 commit 9fd9b68

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

QpTestClient/ConnectionContext.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,23 @@ namespace QpTestClient
99
public class ConnectionContext : IDisposable
1010
{
1111
public TestConnectionInfo ConnectionInfo { get; private set; }
12-
public bool Connected { get; private set; } = false;
12+
13+
private bool _Connected = false;
14+
public bool Connected
15+
{
16+
get { return _Connected; }
17+
private set
18+
{
19+
if (_Connected == value)
20+
return;
21+
_Connected = value;
22+
if (!value)
23+
Disconnected?.Invoke(this, EventArgs.Empty);
24+
}
25+
}
26+
1327
public QpClient QpClient { get; private set; }
28+
public event EventHandler Disconnected;
1429

1530
public ConnectionContext(TestConnectionInfo connectionInfo)
1631
{

QpTestClient/MainForm.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,14 @@ private async void BtnConnectConnection_Click(object sender, EventArgs e)
313313
if (connectionContext == null)
314314
return;
315315

316-
this.Enabled = false;
316+
scMain.Enabled = false;
317317
try
318318
{
319319
var preConnectionInfoContent = Quick.Xml.XmlConvert.Serialize(connectionContext.ConnectionInfo);
320320

321321
await connectionContext.Connect();
322322
connectionNode.ImageIndex = connectionNode.SelectedImageIndex = 1;
323-
connectionContext.QpClient.Disconnected += (sender, e) =>
323+
connectionContext.Disconnected += (sender, e) =>
324324
{
325325
Invoke(new Action(() =>
326326
{
@@ -339,7 +339,7 @@ private async void BtnConnectConnection_Click(object sender, EventArgs e)
339339
{
340340
MessageBox.Show($"连接失败,原因:{ExceptionUtils.GetExceptionMessage(ex)}", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
341341
}
342-
this.Enabled = true;
342+
scMain.Enabled = true;
343343
}
344344

345345
private void BtnRecvHeartbeat_Connection_Click(object sender, EventArgs e)

0 commit comments

Comments
 (0)