The information contained here are property of DIGITAX Automotive Electronics Italy, and extremely confidential. Any disclosure, copying, distribution to third
party is strictly prohibited.
42
// register to Link events
_rasLink.IpAddressC=
new
IpAddressChangedHandler
(_rasLink_IpAddressChanged);
}
private
void
Demo_Load(
object
sender,
EventArgs
e)
{
btnDial.Enabled =
false
;
btnHangUp.Enabled =
false
;
// enable managers
_modem.Enabled =
true
;
if
(_rasLink !=
null
)
{
_rasLink.Enabled =
true
;
chkRasLinkManagerEnabled.Checked =
true
;
}
else
{
chkRasLinkManagerEnabled.Enabled =
false
;
}
}
private
void
Demo_Closing(
object
sender,
CancelEventArgs
e)
{
// dispose managers
if
(_rasLink !=
null
) _rasLink.Dispose();
if
(_rasEntry !=
null
)
{
_rasEntry.HangUp();
_rasEntry.Dispose();
}
_modem.Dispose();
}
#region
Modem events handlers
/* This region contains the handlers for the events fired by the modem manager
*/
void
_modem_SimCardStatusChanged(
SimCardStatus
status)
{
if
(InvokeRequired)
{
BeginInvoke(
new
SimCardStatusChangedHandler
(_modem_SimCardStatusChanged),
new
object
[] { status });
return
;
}
switch
(status)
{
case
SimCardStatus
.Absent:
case
SimCardStatus
.Present:
txtSim.Text = status.ToString();
break
;
default
:
txtSim.Text =
""
;
break
;
}
if
(status ==
SimCardStatus
.Present)
txtSim.Text +=
" ["
+ _modem.SimID.ToString() +
"]"
;
}
void
_modem_SignalStrengthChanged(
int
strength)
{
if
(InvokeRequired)
{
BeginInvoke(
new
SignalStrengthChangedHandler
(_modem_SignalStrengthChanged),
new
object
[] { strength });
return
;
}
if
(strength == 99)
{
txtSignalStrength.Text =
"no signal"
;
}
else
{
txtSignalStrength.Text = strength.ToString() +
"/5"
;
}
}
void
_modem_NetStatusChanged(
NetworkStatus
newStatus)
{
if
(InvokeRequired)
{
BeginInvoke(
new
NetworkStatusChangedHandler
(_modem_NetStatusChanged),
new
object
[] { newStatus });
return
;
}
switch
(newStatus)
{
case
NetworkStatus
.NotRegistered:
case
NetworkStatus
.Registered:
case
NetworkStatus
.RegisteredRoaming:
case
NetworkStatus
.RegistrationDenied:
case
NetworkStatus
.Scanning:
txtNetStatus.Text = newStatus.ToString();
break
;
default
:
txtNetStatus.Text =
""
;
break
;
}