日本好好热aⅴ|国产99视频精品免费观看|日本成人aV在线|久热香蕉国产在线

  • <cite id="ikgdy"><table id="ikgdy"></table></cite>
    1. 西西軟件園多重安全檢測下載網站、值得信賴的軟件下載站!
      軟件
      軟件
      文章
      搜索

      首頁編程開發(fā)其它知識 → Windows Mobile 5.0 SDk Demo 分析

      Windows Mobile 5.0 SDk Demo 分析

      相關軟件相關文章發(fā)表評論 來源:本站整理時間:2010/7/20 13:40:25字體大小:A-A+

      作者:佚名點擊:128次評論:0次標簽: Mobile

      • 類型:PPC|WM平臺大。322KB語言:中文 評分:6.6
      • 標簽:
      立即下載

      SDK 文件路徑
      C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CS\SmsIm

      C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Samples\Cs\Smsim

      功能: 接受和發(fā)送短信,并在同一頁面上模擬顯示通信內容
      發(fā)送:從聯(lián)系人名單中選擇contact然后發(fā)信息給他
      接收:開機后隨時監(jiān)聽是否收到信息,收到后進行顯示

      實現(xiàn):
      本程序包含一個private類:Conversation 用來模擬顯示一次短信接發(fā)的信息包括:聯(lián)系人、電話號碼、短息

      內容?梢酝ㄟ^Contact、PhoneNumber、Transcript屬性分別進行訪問。

      發(fā)送:
      1.添加聯(lián)系人
      點擊 Add name,調用CreateNewConversation方法
      打開選擇聯(lián)系人窗口:
      ChooseContactDialog dlg = new ChooseContactDialog();
      dlg.RequiredProperties = new ContactProperty[] {ContactProperty.AllTextMessaging };
      選定聯(lián)系人后添加到聯(lián)系人列表中并創(chuàng)建一個Conversation實例。
      2.填寫message
      首先調用SwitchToConversation方法,將剛才創(chuàng)建的conversation實例作為信息發(fā)送的目的地址。
      并將焦點跳到填寫信息處。
      3.發(fā)送message
      點擊send,調用SmsMessage的Send方法進行發(fā)送
      // Send the SMS message
      SmsMessage msg = new SmsMessage(NormalizePhoneNumber(conv.PhoneNumber), txtMsgToSend.Text);
      msg.Send();
      其中NormalizePhoneNumber方法用來將聯(lián)系人的號碼中非數字的信息剔除

      然后模擬顯示信息并清空填寫信息文本框

      接收:
      1.FormLoad時候初始化一個MessageInterceptor
      類成員變量:private MessageInterceptor interceptor;
      //初始化并注冊一個信息收到的處理方法 OnSmsReceived
      interceptor = new MessageInterceptor();
      interceptor.InterceptionAction = InterceptionAction.NotifyAndDelete;
      interceptor.MessageReceived += new MessageInterceptorEventHandler(OnSmsReceived);

      2.當收到短信時,MessageInterceptor對象的事件處理方法:OnSmsReceived
      private void OnSmsReceived(object sender, MessageInterceptorEventArgs e)
      收到的短息信息全在(msg=)e.Message 中
      檢查發(fā)送信息的地址(msg.)
      如果是聯(lián)系人列表中的成員:
      foreach (Conversation conv in conversations.Items)
      {
      if (PhoneNumbersMatch(conv.PhoneNumber, msg.From.Address))
      。。。
      }
      如果是新的聯(lián)系人,查找到并添加到列表中
      foreach (Contact c in session.Contacts.Items)
      {
      if (c.MobileTelephoneNumber.Length != 0
      && PhoneNumbersMatch(c.MobileTelephoneNumber, msg.From.Address))
      。。。
      }
      如果是尚未添加的聯(lián)系人,將此聯(lián)系人進行添加
      if (contact == null)
      {
      // There is no contact for this phone number
      // so create one
      contact = new Contact();
      contact.MobileTelephoneNumber = msg.From.Address; //聯(lián)系人地址
      // TODO: prompt for name from user?
      session.Contacts.Items.Add(contact); //添加到聯(lián)系人名單中
      }
      將當前聯(lián)系人作為當前對話參數,回到模擬頁面進行信息顯示
      3.Form1.close時候釋放OnSmsReceived對象
      interceptor.Dispose();

      ps:
      1. RequiredProperties : Gets or sets the ContactProperty array values that specify which properties a

      Contact must have in order to be shown in the Contact Chooser dialog box.
      獲取或設置聯(lián)系人屬性值數組,規(guī)定這些屬性值是必須出現(xiàn)在聯(lián)系人信息中的。
      dlg.RequiredProperties = new ContactProperty[]{ ContactProperty.AllTextMessaging};

      2.SmsMessage

      Represents a Short Message Service (SMS) message. 短息服務類。

      主要成員有:Body:文本內容, From:發(fā)送者,ItemID, LastModified最后修改日期,Read讀取狀態(tài),Received接受與否,To 接受者集合,RequestDeliveryReport: 是否送達報告要求。

      主要方法有: Send、Tostring、Equals、GetType、GetHashCode、ReferenceEqual.

      3.可以選擇在聯(lián)系人列表中默認添加了所有聯(lián)系人信息
      #if PrePopulateConversationsComboBox
      using (OutlookSession session = new OutlookSession())
      {
      foreach (Contact c in session.Contacts.Items)
      {
      if (c.MobileTelephoneNumber != "")
      {
      conversations.Items.Add(new Conversation(c));
      }
      }
      }
      #endif

        相關評論

        閱讀本文后您有什么感想? 已有人給出評價!

        • 8 喜歡喜歡
        • 3 頂
        • 1 難過難過
        • 5 囧
        • 3 圍觀圍觀
        • 2 無聊無聊

        熱門評論

        最新評論

        發(fā)表評論 查看所有評論(0)

        昵稱:
        表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
        字數: 0/500 (您的評論需要經過審核才能顯示)