Exemplo n.º 1
0
        private void serialPortList_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            messageList.Items.Clear();

            try {
                ProgressShow("Opening Phone...");
                using (PhoneClient phoneClient = new PhoneClient(serialPortList.Text)) {
                    ProgressShow("Listing messages...");
                    try {
                        List <SmsDeliverMessage> messages = phoneClient.List(ListType.All);
                        foreach (SmsDeliverMessage message in messages)
                        {
                            ListViewItem item = new ListViewItem();
                            item.Text = message.DateReceived.ToString();
                            item.SubItems.Add(message.SenderAddress.PhoneNumber);
                            item.SubItems.Add(message.Text);
                            item.Tag = message;

                            messageList.Items.Add(item);
                        }
                    } catch (Exception ex) {
                        ProgressShow("Failed to list messages: " + ex.ToString());
                    }
                }
            } catch (Exception ex) {
                ProgressShow("Failed to open phone: " + ex.Message);
            }
        }