簡體   English   中英

如何向Windows Phone 7應用程序添加事件提醒

[英]how to add event reminder to my windows phone 7 application

我正在Windows Phone 7中構建一個應用程序,我需要在其中添加事件提醒。 單擊按鈕時,應設置提醒。 我的cs文件是:

namespace KejriwalPhoneApp
{
public partial class EventDetails : PhoneApplicationPage
{

    public EventDetails()
    {
        InitializeComponent();

        ApplicationBar = new ApplicationBar();
        ApplicationBar.Mode = ApplicationBarMode.Default;
        ApplicationBar.Opacity = 1.0;
        ApplicationBar.IsVisible = true;


        ApplicationBarIconButton home = new ApplicationBarIconButton();
        home.IconUri = new Uri("/Image/icon_home_deselect.png", UriKind.Relative);
        home.Text = "Home";
        ApplicationBar.Buttons.Add(home);
        home.Click += new EventHandler(home_Click);


        ApplicationBarIconButton share = new ApplicationBarIconButton();
        share.IconUri = new Uri("/Image/icon_share_deselect.png", UriKind.Relative);
        share.Text = "Share";
        ApplicationBar.Buttons.Add(share);
        share.Click += new EventHandler(share_Click);

        ApplicationBarIconButton news = new ApplicationBarIconButton();
        news.IconUri = new Uri("Image/icon_news_deselect.png", UriKind.Relative);
        news.Text = "News";
        ApplicationBar.Buttons.Add(news);
        news.Click += new EventHandler(news_Click);

        ApplicationBarIconButton events = new ApplicationBarIconButton();
        events.IconUri = new Uri("/Image/icon_event_deselect.png", UriKind.Relative);
        events.Text = "Video";
        ApplicationBar.Buttons.Add(events);
        events.Click += new EventHandler(events_Click);
    }

    void events_Click(object sender, EventArgs e)
    {
        NavigationService.Navigate(new Uri("/Events.xaml", UriKind.Relative));
    }

    void news_Click(object sender, EventArgs e)
    {
        NavigationService.Navigate(new Uri("/News.xaml", UriKind.Relative));
    }

    void share_Click(object sender, EventArgs e)
    {
        NavigationService.Navigate(new Uri("/share.xaml", UriKind.Relative));

    }

    void home_Click(object sender, EventArgs e)
    {
        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
    }

    private void Image_Back(object sender, RoutedEventArgs e)
    {
        NavigationService.Navigate(new Uri("/Events.xaml", UriKind.Relative));
    }

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
        var imagePath = "";
        var eventdate = "";
        var location = "";
        var utimee = "";
        var tzone = "";
        var ename = "";
        var desc = "";

        //check if particular parameter available in uri string
        if (this.NavigationContext.QueryString.ContainsKey("image_path"))
        {
            //if it is available, get parameter value
            imagePath = NavigationContext.QueryString["image_path"];

            eventimage.Source = new BitmapImage(new Uri(@"http://political-leader.vzons.com/ArvindKejriwal/images/uploaded/" + imagePath, UriKind.Absolute));


        }

        if (this.NavigationContext.QueryString.ContainsKey("Time_Zone"))
        {
            tzone = NavigationContext.QueryString["Time_Zone"];
            timezone.Text = tzone;
        }

        if (this.NavigationContext.QueryString.ContainsKey("uTime"))
        {
            utimee = NavigationContext.QueryString["uTime"];
            utime.Text = utimee;
        }

        if (this.NavigationContext.QueryString.ContainsKey("Event_Date"))
        {
            //if it is available, get parameter value
            eventdate = NavigationContext.QueryString["Event_Date"];
            evntdate.Text = eventdate;
        }

        if (this.NavigationContext.QueryString.ContainsKey("Location"))
        {
            //if it is available, get parameter value
            location = NavigationContext.QueryString["Location"];
            loc.Text = location;
        }

        if (this.NavigationContext.QueryString.ContainsKey("Event_Name"))
        {
            //if it is available, get parameter value
            ename = NavigationContext.QueryString["Event_Name"];
            enamee.Text = ename;
        }
        if (this.NavigationContext.QueryString.ContainsKey("Event_Description"))
        {
            //if it is available, get parameter value
            desc = NavigationContext.QueryString["Event_Description"];
            edescription.Text = desc;
        }

}

    private void Image_Previous(object sender, RoutedEventArgs e)
    {
        NavigationService.Navigate(new Uri("/Events.xaml", UriKind.Relative));
    }



    private void Image_rem(object sender, RoutedEventArgs e)
    {
        RegisterReminder();
    }

    private void RegisterReminder()
    {


        var reminder = ScheduledActionService.Find(ename) as Reminder ?? new Reminder(ename);
        reminder.Title = ename;
        reminder.Content = desc;
        // parse eventDate,utimee to beginDateTime
        reminder.BeginTime = beginDateTime;
        reminder.ExpirationTime = reminder.BeginTime.AddDays(1);
        reminder.RecurrenceType = RecurrenceInterval.None;
        if (ScheduledActionService.Find(ename) == null)
            ScheduledActionService.Add(reminder);
        else
            ScheduledActionService.Replace(reminder);
        MessageBox.Show("reminder set succeed!");


    }

}

}現在,當單擊提醒按鈕時,我想要設置utimee,tzone字段,然后彈出消息“成功添加事件提醒”

我不知道如何做到這一點

您可以執行以下步驟:

1.從webservice獲取值作為全局變量:

eventDate,位置,utimee,tzone,ename,desc。

2.單擊提醒按鈕,執行click方法

private void BtnReminderClick(object sender, EventArgs e)
{
    RegisterReminder();
}

3.做提醒注冊

    private void RegisterReminder()
    {
        var reminder = ScheduledActionService.Find(ename) as Reminder ?? new Reminder(ename);
        reminder.Title = ename;
        reminder.Content = desc;
// parse eventDate,utimee to beginDateTime
        reminder.BeginTime = DateTime.Parse(eventDate).Date + DateTime.Parse(utimee).TimeOfDay;
        reminder.ExpirationTime = reminder.BeginTime.AddDays(1);
        reminder.RecurrenceType = RecurrenceInterval.None;
        if (ScheduledActionService.Find(ename) == null)
           ScheduledActionService.Add(reminder);
        else
           ScheduledActionService.Replace(reminder);
       MessageBox.Show("reminder set succeed!");
    } 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM