Skip to content

Commit

Permalink
force message init on decoder in case address is missed. fixed thread…
Browse files Browse the repository at this point in the history
…ing / invoke on grid update
  • Loading branch information
Dustify committed Mar 23, 2021
1 parent b45714f commit 945139e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
34 changes: 21 additions & 13 deletions Pocsag.Plugin/PocsagControl.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Pocsag.Plugin
{
using SDRSharp.Common;
using System;
using System.ComponentModel;
using System.Windows.Forms;

Expand Down Expand Up @@ -45,19 +46,26 @@ public PocsagControl(ISharpControl control)

private void MessageReceived(Pocsag.Message message)
{
//int firstDisplayed = this.dataGridView1.FirstDisplayedScrollingRowIndex;
//int displayed = this.dataGridView1.DisplayedRowCount(true);
//int lastVisible = (firstDisplayed + displayed) - 1;
//int lastIndex = this.dataGridView1.RowCount - 1;

this.bindingList.Add(message);

//if (lastVisible == lastIndex)
//{
// this.dataGridView1.FirstDisplayedScrollingRowIndex = firstDisplayed + 1;
//}

//this.dataGridView1.FirstDisplayedScrollingRowIndex = this.messages.Count - 1;
if (this.InvokeRequired)
{
this.BeginInvoke(
new Action<Pocsag.Message>(
(message) =>
{
int firstDisplayed = this.dataGridView1.FirstDisplayedScrollingRowIndex;
int displayed = this.dataGridView1.DisplayedRowCount(true);
int lastVisible = (firstDisplayed + displayed) - 1;
int lastIndex = this.dataGridView1.RowCount - 1;
this.bindingList.Add(message);
if (lastVisible == lastIndex)
{
this.dataGridView1.FirstDisplayedScrollingRowIndex = firstDisplayed + 1;
}
}),
new object[] { message });
}
}
}
}
1 change: 1 addition & 0 deletions Pocsag/Decoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public Decoder(int baud, int sampleRate, Action<Message> messageReceived)
this.FrameIndex = -1;
this.CodeWordPosition = -1;

this.QueueCurrentMessage();
}

private uint GetBufferValue()
Expand Down

0 comments on commit 945139e

Please sign in to comment.