Media component sends notification, when its state changes.
- sender (Object)
- The source of the event.
- state (MediaState)
- Status information from media state.
/// <summary>
/// Update UI when media state changes.
/// </summary>
/// <param name="sender"></param>
/// <param name="State"></param>
private void gxsms1_OnMediaStateChange(object sender, Gurux.Common.MediaState State)
{
try
{
bool IsOpen = State == Gurux.Common.MediaState.Open;
OpenBtn.Enabled = ! IsOpen;
SendBtn.Enabled = IsOpen;
CloseBtn.Enabled = IsOpen;
SendText.Enabled = IsOpen;
StatusTimer.Enabled = IsOpen;
MsgCounterTimer.Enabled = IsOpen;
ReadBtn.Enabled = IsOpen;
DeleteBtn.Enabled = IsOpen;
//read network status if media is opened.
if (IsOpen)
{
StatusTimer_Tick(StatusTimer, new System.EventArgs());
}
else
{
RSSITB.Text = "";
BERTB.Text = "";
BatteryCapacityTB.Text = "";
PowerConsumptionTB.Text = "";
NetworkStatusTB.Text = "";
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
''' <summary>
''' Update UI when media state changes.
''' </summary>
Private Sub Gxsms1_OnMediaStateChange(ByVal sender As System.Object, ByVal State As Gurux.Common.MediaState) Handles Gxsms1.OnMediaStateChange
Try
Dim IsOpen As Boolean
IsOpen = State = Gurux.Common.MediaState.Open
OpenBtn.Enabled = Not IsOpen
SendBtn.Enabled = IsOpen
CloseBtn.Enabled = IsOpen
SendText.Enabled = IsOpen
StatusTimer.Enabled = IsOpen
MsgCounterTimer.Enabled = IsOpen
ReadBtn.Enabled = IsOpen
DeleteBtn.Enabled = IsOpen
'read network status if media is opened.
If IsOpen Then
StatusTimer_Tick(StatusTimer, New System.EventArgs())
Else
RSSITB.Text = ""
BERTB.Text = ""
BatteryCapacityTB.Text = ""
PowerConsumptionTB.Text = ""
NetworkStatusTB.Text = ""
End If
Catch Ex As Exception
MessageBox.Show(Ex.Message)
End Try
End Sub
'Update UI is media state changes.
Private Sub GXSMS1_OnMediaStateChange(ByVal sender As Object, ByVal State As GuruxSMSCtl.GX_MEDIA_STATE_CHANGE)
On Error GoTo GXErr
Dim IsOpen As Boolean
IsOpen = State = GX_MEDIA_STATE_CHANGE_OPEN
OpenBtn.Enabled = Not IsOpen
SendBtn.Enabled = IsOpen
CloseBtn.Enabled = IsOpen
SendText.Enabled = IsOpen
StatusTimer.Enabled = IsOpen
MsgCounterTimer.Enabled = IsOpen
ReadBtn.Enabled = IsOpen
DeleteBtn.Enabled = IsOpen
'read network status if media is opened.
If IsOpen Then
StatusTimer_Timer
Else
RSSITB.Text = ""
BERTB.Text = ""
BatteryCapacityTB.Text = ""
PowerConsumptionTB.Text = ""
NetworkStatusTB.Text = ""
End If
Exit Sub
GXErr:
MsgBox Err.Description
End Sub
Assembly: Gurux.SMS (Module: Gurux.SMS) Version: 5.0.0.1