Пример #1
0
        void port_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            //Regex r = new Regex(@"DATE\s*=\s*[0-9]*");
            //Regex r = new Regex(@"TIME\s*=\s*[0-9]*");

            string phoneNumber = this.port.ReadExisting();
            Regex  r           = new Regex(@"NMBR\s*=\s*[0-9]*");
            Match  m           = r.Match(phoneNumber);

            string result = string.Empty;

            if (m != null && m.Success)
            {
                result = m.Value;
                result = result.Substring(result.IndexOf("=") + 1).Trim();
            }
            if (string.IsNullOrEmpty(result))
            {
                return;
            }
            if (Ring != null)
            {
                RingEventArgs eventArgs = new RingEventArgs();
                eventArgs.PhoneNumber = result;
                foreach (EventHandler <RingEventArgs> handler in Ring.GetInvocationList())
                {
                    handler.Invoke(this, eventArgs);
                    if (eventArgs.Handled)
                    {
                        break;
                    }
                }
            }
        }
Пример #2
0
 void modem_Ring(object sender, RingEventArgs e)
 {
     this.phoneNumber = e.PhoneNumber;
     this.ShowPhoneNumber();
 }