先上效果图
这个记事本操作简便,功能强大,在记事本的基础上添加了将内容发送短信和发送邮件的功能。这个应用也已经功过了微软的认证。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