wp7记事本源代码

先上效果图


这个记事本操作简便,功能强大,在记事本的基础上添加了将内容发送短信和发送邮件的功能。这个应用也已经功过了微软的认证。115网盘里面的是最新的。
QQ:29992379
下载地址:
http://115.com/file/e7bxlvs9# 
Memo.xap

实体类

public class Note
{
	public string NoteGuid { get; set; }
	public string NoteContent { get; set; }
	public string NoteTime { get; set; }
}

在独立存储中生成存储结构。

if (!IsolatedStorageSettings.ApplicationSettings.Contains("Notes"))
{
	List<Note> notes = new List<Note>();
	IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;
	IsolatedStorageSettings.ApplicationSettings.Save();

}

绑定文章的列表,并按编号使用linq倒排序。

public partial class MainPage : PhoneApplicationPage
    {
        // 构造函数
        public MainPage()
        {
            InitializeComponent();
            BingData();
        }
        List<Note> notes = new List<Note>();
        private void BingData()
        {
            notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;

            var descInfo = from i in notes orderby i.NoteTime descending select i;

            MainListBox.ItemsSource = descInfo;
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/Add.xaml", UriKind.RelativeOrAbsolute));
        }

        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = true;
            App.Quit();
            base.OnBackKeyPress(e);
        }

        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/About.xaml", UriKind.RelativeOrAbsolute));
        }

        private void StackPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            string noteguid = ((TextBlock)(((StackPanel)sender).Children.First())).Tag.ToString();
            NavigationService.Navigate(new Uri("/DetailsPage.xaml?noteguid=" + noteguid, UriKind.Relative));
        }
    }

文章显示的页面以及一系列功能

public partial class DetailsPage : PhoneApplicationPage
    {
        // 构造函数
        public DetailsPage()
        {
            InitializeComponent();
        }
        string noteguid;
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            BingData();
            noteguid = NavigationContext.QueryString["noteguid"].ToString();
            foreach (var item in notes)
            {
                if (item.NoteGuid==noteguid)
                {
                    ContentText.Text = item.NoteContent;
                    TimeText.Text = item.NoteTime;
                    return;
                }
            }
        }

        List<Note> notes = new List<Note>();
        private void BingData()
        {
            notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;
        }

        private void Edit_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/Edit.xaml?noteguid=" + noteguid.ToString(), UriKind.RelativeOrAbsolute));
        }

        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = true;
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
            base.OnBackKeyPress(e);
        }
	//删除
        private void Del_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < notes.Count; i++)
            {
                if (notes[i].NoteGuid==noteguid)
                {
                    notes.RemoveAt(i);
                }
            }
            IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;
            IsolatedStorageSettings.ApplicationSettings.Save();
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
        }
	//发送邮件
        private void Email_Click(object sender, EventArgs e)
        {
            EmailComposeTask email = new EmailComposeTask();
            email.Body = ContentText.Text.ToString();
            email.Show();
        }
	//发送短信
        private void Message_Click(object sender, EventArgs e)
        {
            SmsComposeTask sms = new SmsComposeTask();
            sms.Body = ContentText.Text.ToString();
            sms.Show();
        }
    }
文章的编辑页面代码
 public partial class Edit : PhoneApplicationPage
    {
        public Edit()
        {
            InitializeComponent();
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            foreach (var item in notes)
            {
                if (item.NoteGuid == noteguid)
                {
                    item.NoteContent = ContentText.Text;
                    item.NoteTime=TimeText.Text;
                }
            }

            IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;
            IsolatedStorageSettings.ApplicationSettings.Save();
            NavigationService.Navigate(new Uri("/DetailsPage.xaml?noteguid=" + noteguid.ToString(), UriKind.RelativeOrAbsolute));
        }
        string noteguid;
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            BingData();
            noteguid = NavigationContext.QueryString["noteguid"].ToString();
            foreach (var item in notes)
            {
                if (item.NoteGuid==noteguid)
                {
                    ContentText.Text = item.NoteContent;
                    TimeText.Text = item.NoteTime;
                    return;
                }
            }
        }

        List<Note> notes = new List<Note>();
        private void BingData()
        {
            notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;
        }
    }

原文地址: http://www.cnblogs.com/wildfeng/archive/2012/03/23/2412071.html

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值