zoukankan      html  css  js  c++  java
  • 与Pocket Outlook相关的一些代码片段(C#)

    NameSpaces
    using Microsoft.WindowsMobile.Forms;
    using Microsoft.WindowsMobile.Telephony;
    using Microsoft.WindowsMobile.PocketOutlook;
    using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
    using Microsoft.WindowsMobile.Status;

    Data Binding
                // I assign the listBox1 to null first to Reset it. This is needed as currently there is no support for BeginUpdate and EndUpdate in the Compact Framework.
                this.listBox1.DataSource = null
                
    this.listBox1.DataSource = this.outlookSession.Contacts.Items;
                
    this.listBox1.DisplayMember = "FileAs";
                
    this.listBox1.ValueMember = "ItemId";

    Contact
            OutlookSession s = new OutlookSession();
            Contact c = new Contact();
            c.FullName = "Warren Tang";
            s.Contacts.Items.Add(c);    //Saved
            c.JobTitle = "Dev";
            c.Update(); //Saved

    SMS
            SmsMessage msg = new SmsMessage();
            msg.To.Add(new Recipient("234324"));
            msg.Body = "Hello, Warren.";
            msg.Send();

    Email

    EmailMessage class: http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.pocketoutlook.emailmessage.aspx


    Phone

                Phone p = new Phone();
                p.Talk("23412341");

    Dialog
            SelectPictureDialog dlg1 = new SelectPictureDialog();
            CameraCaptureDialog dlg2 
    = new CameraCaptureDialog();
            ChooseContactDialog dlg3 
    = new ChooseContactDialog();
            
    if (dlg.ShowDialog() == DialogResult.OK)
            {
                Contact cc 
    = new Contact();
                cc.ItemId 
    = dlg3.SelectedContact.ItemId;
            }


     private void mnuChooseContact_Click(object sender, EventArgs e)
            {
                ChooseContactDialog chooseContactDialog 
    = new ChooseContactDialog();
                SelectPictureDialog selectPictureDialog 
    = new SelectPictureDialog();
                Contact contact 
    = new Contact();

                
    this.mnuChooseContact.Enabled = false;

                
    // Open a PocketOutlook session
                using (OutlookSession session = new OutlookSession())
                {
                    
    // Create a single contact
                    if (session.Contacts.Items.Count <= 0)
                    {
                        contact.FirstName 
    = "Contact";
                        contact.LastName 
    = "With Picture";
                        session.Contacts.Items.Add(contact);
                    }
                    
    else
                    {
                        contact 
    = session.Contacts.Items[0];
                    }

                    
    // Open a ChooseContactDialog and a SelectPictureDialog. If a contact was selected and a picture was chosen,
                    
    // assign the picture to the contact.
                    if ((DialogResult.OK == chooseContactDialog.ShowDialog()) && (DialogResult.OK == selectPictureDialog.ShowDialog()))
                    {
                        contact.SetPicture(selectPictureDialog.FileName);
                        contact.Update();
                        contact.ShowDialog();
                    }
                }

                
    this.mnuChooseContact.Enabled = true;
            }

    Appointment
            Appointment ap = new Appointment();
            ap.Subject 
    = "Not a meeting";
            ap.AllDayEvent 
    = true;
            ap.Start 
    = new DateTime(2005101);
            s.Appointments.Items.Add(ap);
            ap.ShowDialog();    
    //Items can be displayed and edited.

    Add properties to PimItem
           Contact myCustomer = new Contact();
            
    if (!myCustomer.Properties.Contains("Employee ID"))
            {
                myCustomer.Properties.Add(
    "Employee ID"typeof(string));
            }
            myCustomer.Properties[
    "Employee ID"= "X333";

            MessagingApplication ma 
    = new MessagingApplication();

    SMS interception
            MessageInterceptor interceptor = new MessageInterceptor();
            interceptor.InterceptionAction 
    = InterceptionAction.NotifyAndDelete;
           
            interceport.MessageCondition.Property = MessageProperty.Body;
            interceptor.MessageCondition.CompareType =  MessagePropertyCompareType.Equal;
            interceptor.MessageCondition.CompareValue = "asdf";
       
            interceptor.MessageReceived 
    += new MessageInterceptorEventHandler(interceptor_MessageReceived);

    State and Notification Broker
            int degree = SystemState.DisplayRotation;   //Get a state
            string value = ConvertToString(SystemState.GetValue(SystemProperty.DisplayRotation)); //Get value of state

            SystemState s;      
    //Notification
            s.ComparisonType = StatusComparisonType.Equal;
            s.ComparisonValue = 1;
            s = new SystemState(SystemProperty.ActiveApplication);
            s.Changed 
    += new ChangeEventHandler(ChangeOccurred);

    App Launching with S&N Broker (SMS Interceptor is the same)
            SystemState state;

            
    private void Form4_Load(object sender, EventArgs e)
            {
                
    if (!SystemState.IsApplicationLauncherEnabled("MyApp.CradleChanged"))
                {
                    state 
    = new SystemState(SystemProperty.CradlePresent);
                    state.EnableApplicationLauncher(
    "MyApp.CradleChanged");
                }
                
    else
                {
                    state 
    = new SystemState("MyApp.CradleChanged");
                }

                state.Changed 
    += new ChangeEventHandler(stateChanged);
             }
  • 相关阅读:
    介绍一款jquery ui组件gijgo(含tree树状结构、grid表格),特点:简易、文档全清晰易懂、示例代码
    【未完待续】API接口
    表单中Readonly和Disabled的区别:readonly在get和post可传值到后端,disabled不可
    Newtonsoft.Json 转换DateTime类型为字符串时,串内部会有一个T。解决方案
    一种历史详细记录表,完整实现:CommonOperateLog 详细记录某用户、某时间、对某表、某主键、某字段的修改(新旧值
    js return falsee.preventDefault() 以及session
    bootstrape学习
    Redis的PHP操作手册
    PHP表单常用正则表达式(URL、HTTP、手机、邮箱等)
    大型网站架构演化
  • 原文地址:https://www.cnblogs.com/wmz/p/1317072.html
Copyright © 2011-2022 走看看