先上
這個記事本操作簡便,功能強大,在記事本的基礎上添加了將內容傳送簡訊和發送郵件的功能。這個應用也已經功過了微軟的認證。115網盤裡面的是最新的。
QQ:29992379
:
http://115.com/file/e7bxlvs9#
Memo.xap
實體類
public class Note<br />{<br />public string NoteGuid { get; set; }<br />public string NoteContent { get; set; }<br />public string NoteTime { get; set; }<br />}
在隔離儲存區 (Isolated Storage)中產生儲存結構。
if (!IsolatedStorageSettings.ApplicationSettings.Contains("Notes"))<br />{<br />List<Note> notes = new List<Note>();<br />IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;<br />IsolatedStorageSettings.ApplicationSettings.Save();</p><p>}
綁定文章的列表,並按編號使用linq倒排序。
public partial class MainPage : PhoneApplicationPage<br /> {<br /> // 建構函式<br /> public MainPage()<br /> {<br /> InitializeComponent();<br /> BingData();<br /> }<br /> List<Note> notes = new List<Note>();<br /> private void BingData()<br /> {<br /> notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;</p><p> var descInfo = from i in notes orderby i.NoteTime descending select i;</p><p> MainListBox.ItemsSource = descInfo;<br /> }</p><p> private void ApplicationBarIconButton_Click(object sender, EventArgs e)<br /> {<br /> NavigationService.Navigate(new Uri("/Add.xaml", UriKind.RelativeOrAbsolute));<br /> }</p><p> protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)<br /> {<br /> e.Cancel = true;<br /> App.Quit();<br /> base.OnBackKeyPress(e);<br /> }</p><p> private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)<br /> {<br /> NavigationService.Navigate(new Uri("/About.xaml", UriKind.RelativeOrAbsolute));<br /> }</p><p> private void StackPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)<br /> {<br /> string noteguid = ((TextBlock)(((StackPanel)sender).Children.First())).Tag.ToString();<br /> NavigationService.Navigate(new Uri("/DetailsPage.xaml?noteguid=" + noteguid, UriKind.Relative));<br /> }<br /> }
文章顯示的頁面以及一系列功能
public partial class DetailsPage : PhoneApplicationPage<br /> {<br /> // 建構函式<br /> public DetailsPage()<br /> {<br /> InitializeComponent();<br /> }<br /> string noteguid;<br /> protected override void OnNavigatedTo(NavigationEventArgs e)<br /> {<br /> BingData();<br /> noteguid = NavigationContext.QueryString["noteguid"].ToString();<br /> foreach (var item in notes)<br /> {<br /> if (item.NoteGuid==noteguid)<br /> {<br /> ContentText.Text = item.NoteContent;<br /> TimeText.Text = item.NoteTime;<br /> return;<br /> }<br /> }<br /> }</p><p> List<Note> notes = new List<Note>();<br /> private void BingData()<br /> {<br /> notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;<br /> }</p><p> private void Edit_Click(object sender, EventArgs e)<br /> {<br /> NavigationService.Navigate(new Uri("/Edit.xaml?noteguid=" + noteguid.ToString(), UriKind.RelativeOrAbsolute));<br /> }</p><p> protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)<br /> {<br /> e.Cancel = true;<br /> NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));<br /> base.OnBackKeyPress(e);<br /> }<br />//刪除<br /> private void Del_Click(object sender, EventArgs e)<br /> {<br /> for (int i = 0; i < notes.Count; i++)<br /> {<br /> if (notes[i].NoteGuid==noteguid)<br /> {<br /> notes.RemoveAt(i);<br /> }<br /> }<br /> IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;<br /> IsolatedStorageSettings.ApplicationSettings.Save();<br /> NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));<br /> }<br />//發送郵件<br /> private void Email_Click(object sender, EventArgs e)<br /> {<br /> EmailComposeTask email = new EmailComposeTask();<br /> email.Body = ContentText.Text.ToString();<br /> email.Show();<br /> }<br />//傳送簡訊<br /> private void Message_Click(object sender, EventArgs e)<br /> {<br /> SmsComposeTask sms = new SmsComposeTask();<br /> sms.Body = ContentText.Text.ToString();<br /> sms.Show();<br /> }<br /> }文章的編輯頁面代碼
public partial class Edit : PhoneApplicationPage<br /> {<br /> public Edit()<br /> {<br /> InitializeComponent();<br /> }</p><p> private void ApplicationBarIconButton_Click(object sender, EventArgs e)<br /> {<br /> foreach (var item in notes)<br /> {<br /> if (item.NoteGuid == noteguid)<br /> {<br /> item.NoteContent = ContentText.Text;<br /> item.NoteTime=TimeText.Text;<br /> }<br /> }</p><p> IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;<br /> IsolatedStorageSettings.ApplicationSettings.Save();<br /> NavigationService.Navigate(new Uri("/DetailsPage.xaml?noteguid=" + noteguid.ToString(), UriKind.RelativeOrAbsolute));<br /> }<br /> string noteguid;<br /> protected override void OnNavigatedTo(NavigationEventArgs e)<br /> {<br /> BingData();<br /> noteguid = NavigationContext.QueryString["noteguid"].ToString();<br /> foreach (var item in notes)<br /> {<br /> if (item.NoteGuid==noteguid)<br /> {<br /> ContentText.Text = item.NoteContent;<br /> TimeText.Text = item.NoteTime;<br /> return;<br /> }<br /> }<br /> }</p><p> List<Note> notes = new List<Note>();<br /> private void BingData()<br /> {<br /> notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;<br /> }<br /> }
原文地址:http://www.cnblogs.com/wildfeng/archive/2012/03/23/2412071.html