昨天闲来无视,学习了一下WM的基本开发。看WM有约的那套教程心里痒痒,于是下载了SDK,看看DEMO,在Sample中的示例进行加工。小有一点心得。其实总的来说难度也不是很大,以前没有做过FORM的程序,都是WEB上面的开发,上手来看不是那么特别的困难也。

  • 如果大家不明白安装了SDK之后,如何简历新的项目,如何做调整属性和模拟器的使用。可以参考我的文章下面的,讲的非常的清楚。这里我就不过多的浪费时间做些重复的事情了。
  • 还是先看看效果好了,功能是比较简单的。建立自己的OutLook联系人,对其进行信息的发送和详细信息的管理。
  • 以上是功能的初始界面。没什么多说的。联系人的管理。ADD功能可以跳转到手机的电话簿进行添加。
  • 选中了联系人之后。进行编辑。或者是新建联系人界面也是如此的。OK保存,也就是Update。
  • ADD之后的界面。
  • Code
    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.WindowsMobile.PocketOutlook;
    using Microsoft.WindowsMobile.Forms;
    using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;

    namespace SmsDefence
    {
        public partial class Form1 : Form
        {
            private Contact contactSelect;
            private OutlookSession outLookSession;
            public Form1()
            {
                this.outLookSession = new OutlookSession();
                InitializeComponent();
                this.InitializeListBox();
            }

    public Contact Select()
            {
                this.ShowDialog();
                return this.contactSelect;
            }
            private void InitializeListBox()
            {
                this.listBox1.DataSource = null;
                this.listBox1.DataSource = this.outLookSession.Contacts.Items;
                this.listBox1.DisplayMember = "FileAs";
                this.listBox1.ValueMember = "ItemId";
            }
            private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("AlexLiu Software Development", "Warning", MessageBoxButtons.OK,   MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
            }

    private void menuItem1_Click(object sender, EventArgs e)
            {
                CreateNewConversation();
            }

    private void menuItem2_Click(object sender, EventArgs e)
            {
                this.Close();
            }

    private class Conversation
            {
                private Contact contact;
                private string transcript;
                private string phoneNumber;

    public Conversation(Contact c)
                {
                    contact = c;
                    phoneNumber = c.MobileTelephoneNumber;
                }

    public Contact Contact
                {
                    get { return contact; }
                }
                public string Transcript
                {
                    get { return transcript; }
                }
                public void AddToTranscript(string sender, string msg)
                {
                    transcript = sender + ":" + msg + "\r\n" + transcript;
                }
                public string PhoneNumber
                {
                    get { return phoneNumber; }
                }
                public override string ToString()
                {
                    return contact.ToString();
                }
            }
            private void CreateNewConversation()
            {
                Conversation currentConv = null;
                ChooseContactDialog dlg = new ChooseContactDialog();
                dlg.RequiredProperties = new ContactProperty[] { ContactProperty.AllTextMessaging };
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    foreach (Conversation conv in listBox1.Items)
                    {
                        if (conv.Contact.ItemId == dlg.SelectedContact.ItemId)
                        {
                            currentConv = conv;
                            break;
                        }
                    }
                }
                if (currentConv == null)
                {
                    currentConv = new Conversation(dlg.SelectedContact);
                    listBox1.Items.Add(currentConv);
                }
                SwitchToConversation(currentConv);
            }
            private void SwitchToConversation(Conversation conversion)
            {
                listBox1.SelectedItem = conversion;
                txtMsg.Focus();
                
            }

    private void button5_Click(object sender, EventArgs e)
            {
                this.Close();
            }

    private void btnNew_Click(object sender, EventArgs e)
            {
                this.contactSelect = new Contact();
                this.outLookSession.Contacts.Items.Add(contactSelect);
                ContactEdit contactDialog = new ContactEdit();
                contactDialog.Edit(ref contactSelect);
                this.InitializeListBox();
            }

    private void btnEdit_Click(object sender, EventArgs e)
            {
                if (this.listBox1.SelectedItem != null)
                {
                    contactSelect = this.listBox1.SelectedItem as Contact;
                    ContactEdit contactDialog = new ContactEdit();
                    contactDialog.Edit(ref contactSelect);
                }
                else { MessageBox.Show("you must select one contact"); }
            }

    private void btnSend_Click(object sender, EventArgs e)
            {
                try
                {
                    contactSelect = this.listBox1.SelectedItem as Contact;
                    if (null == this.outLookSession.SmsAccount)
                    {
                        throw new ArgumentException("this account is not i");
                    }
                    SmsMessage s = new SmsMessage(contactSelect.MobileTelephoneNumber, this.txtMsg.Text);
                    s.Body = this.txtMsg.Text;
                    s.Send();
                    MessageBox.Show("Message Sent");
                }
                catch (NullReferenceException ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
    }

  • 简要说明下:首先是Send方法,如果联系人的手机号码,不为空的话就可以进行信息的发送了。如果不为空,SDK中为我们提供了一个SmsMessage也是就是短信的发送类。新建一个对象s,初始化要指定发送的信息的内容的收件人的手机号码。s的body属性也就是信息体,是要发送的内容。对象的实例s调用Send()方法即可发送了。在Mobile中常用的也是对话框的弹出了。MessageBox.Show方法有几个重载的使用,其中最简单的就是指定弹出对话框所要显示的内容了。新建和编辑函数中的内容大体上面来说也是差不多的,新建的话就是把选中的联系人加入到OutLookSession联系中去。CreateNewConversation()函数,也就是点击ADD之后触发这个函数了,把联系人中的不重复加入进来。ChooseContactDialog这个类,建立一个对象之后,通过对象调用了ShowDialog方法即可进入到手机电话簿中联系人的选取中去。
  • Code
    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.WindowsMobile.Forms;
    using Microsoft.WindowsMobile.PocketOutlook;

    namespace SmsDefence
    {
        public partial class ContactEdit : Form
        {
            private Contact contactCreate;
            public ContactEdit()
            {
                InitializeComponent();
            }

    private void menuItem2_Click(object sender, EventArgs e)
            {
                this.Close();
            }

    private void menuItem1_Click(object sender, EventArgs e)
            {
                this.Close();
            }

    public void Edit(ref Contact contact)
            {
                contactCreate = contact;
                this.ShowDialog();
            }

    private void ContactEdit_Load(object sender, EventArgs e)
            {
                this.txtFirstName.DataBindings.Add("text", this.contactCreate, "FirstName");
                this.txtLastName.DataBindings.Add("text", this.contactCreate, "LastName");
                this.txtCompany.DataBindings.Add("text", this.contactCreate, "CompanyName");
                this.txtEmail.DataBindings.Add("text", this.contactCreate, "Email1Address");
                this.txtWorkPhone.DataBindings.Add("text", this.contactCreate, "BusinessTelephoneNumber");
                this.txtMobile.DataBindings.Add("text", this.contactCreate, "MobileTelephoneNumber");
            }

    private void btnOK_Click(object sender, EventArgs e)
            {
                this.contactCreate.FileAs = this.contactCreate.LastName + "," + this.contactCreate.FirstName;
                this.contactCreate.Update();
                this.Close();
            }
        }
    }

  • 以上的代码是另一个FORM的内容。其主要功能就是对联系人进行编辑或者是新建:当点击OK的时候触发的也就是BTNOK这个onclick时间了,重要的一个方法就是Update()对所做的操作进行更新。Close()我想不必说了。FORM的关闭。Edit方法中无非就是数据的绑定。
  • 参考文章 WM有约:http://www.cnblogs.com/allenlooplee/archive/2009/01/14/1375941.html?CommentID=1440147#Post

WM中的OutLook开发和操作相关推荐

  1. Android开发 ---如何操作资源目录中的资源文件2

    Android开发 ---如何操作资源目录中的资源文件2 一.颜色资源管理 效果图: 描述: 1.改变字体的背景颜色 2.改变字体颜色 3.改变按钮颜色 4.图像颜色切换 操作描述: 点击(1)中的颜 ...

  2. 数据库应用程序开发基础篇—— .NET中SQL Server数据库的操作C#篇之一

    数据库应用程序开发基础篇-- .NET中SQL Server数据库的操作C#篇之一 写在前面:前面介绍了数据库系统的基本概念,SQl语句基本使用方法,接下来通过学习具体语言和具体数据库结合的应用开发来 ...

  3. SAP WM中阶Storage Type的Capacity Check – Check based on palletization according to SUT 1

    SAP WM中阶Storage Type的Capacity Check – Check based on palletization  according to SUT 1 SAP WM模块里,可以根 ...

  4. SAP WM中阶之存储类型设置界面里的’Return Stock To Same Storage Bin’

    SAP WM中阶之存储类型设置界面里的'Return Stock To Same Storage Bin' 在SAP WM存储类型的配置界面里,有一个选项叫做'Return Stock to Same ...

  5. SAP WM中阶存储类型里的Full stk rmvl 字段和Return Storage type字段

    SAP WM中阶存储类型里的Full stk rmvl 字段和Return Storage type字段 SAP WM存储类型的配置里,可以配置从某个存储区域里下架的时候都是全数下架,不管需要下架的数 ...

  6. SAP WM中阶之LT25确认Group中的TO单据

    SAP WM中阶之LT25确认Group中的TO单据 SAP WM模块中,2-Step拣配中,可以为多个TR或者交货单创建Group.然后使用LX39去为Group创建TO单据,LX39里可以为这些T ...

  7. SAP WM中阶为多个TR创建了Group后将TR从Group里删除?

    SAP WM中阶为多个TR创建了Group后将TR从Group里删除? SAP WM 2-Step Picking流程里,需要为多个TR或者交货单创建组,然后去对该Group执行集中拣配和后续Allo ...

  8. 在Visual Studio 2012中使用VMSDK开发领域特定语言(一)

    前言 本专题主要介绍在Visual Studio 2012中使用Visualization & Modeling SDK进行领域特定语言(DSL)的开发,包括两个部分的内容.在第一部分中,将对 ...

  9. Java 8 Stream Api 中的 map和 flatMap 操作

    点击上方蓝色"程序猿DD",选择"设为星标" 回复"资源"获取独家整理的学习资料! 来源 | 公众号「码农小胖哥」 1.前言 Java 8  ...

最新文章

  1. java炒黄金_炒黄金追单的一些问题分析
  2. InfluxData【环境搭建 03】时序数据库 InfluxDB 离线安装配置使用(下载+安装+端口绑定+管理员用户创建+开启密码认证+开机自启配置)完整流程实例分享
  3. php连接mysql数据库的连接类
  4. Hadoop配置机架感知
  5. linux创建管道的函数,Linux下的有名管道(03)---使用函数创建和删除有名管道
  6. 201711671132《java实用教程》第一章学习总结
  7. 关于网络知识(网络运作方式)的常识
  8. 无线网为何显示无法上网络连接服务器,wlan显示已连接不可上网怎么办_wlan显示已连接但无法访问互联网怎么解决...
  9. Lipschitz function 是什么?Lipschitz continuous呢?
  10. 花花世界花家姐 舒淇:花花世界花我不会倒追
  11. 入手评测 锐龙r7 5825u和i5 1240p选哪个好
  12. Paython基础讲解(1)
  13. 山东省计算机应用能力等级考试,山东省2017年9月全国计算机等级考试报名时间...
  14. 新生学大学计算机心得,大学生信息技术心得体会怎么写
  15. 利用selenium库实现QQ空间点赞
  16. not enough arguments in call to oprot.Flush
  17. 超级应用/_超级应用
  18. Settings Preference 的理解
  19. java之环境变量设置
  20. 完美世界刘航:异构计算要避免昙花一现

热门文章

  1. saltstack 安装nginx
  2. 从此不再惧怕URI编码:JavaScript及C# URI编码详解
  3. MCGS与PLC通讯不上
  4. 前台jsp页面向后台传汉字出现乱码问题解决办法
  5. 开篇 — 【面向对象设计模式学习】
  6. java实现加减乘除运算符随机生成十道题并判断对错_2020年Java面试题(3年的工作总结),最全的知识点总结...
  7. qt 快速按行读取文件_这是知识点之Linux下分割文件并保留文件头
  8. Python的日志记录-logging模块的使用
  9. centos 7.1 apache 源码编译安装
  10. python去掉字符串中空格的方法