记事本源代码

先上效果图。

1234

这个记事本操作简便,功能强大,在记事本的基础上添加了将内容发送短信和发送邮件的功能。这个应用也已经功过了微软的认证。115网盘里面的是最新的。

QQ:29992379

下载地址:

http://115.com/file/e7bxlvs9#
Memo.xap

实体类

   1:  public class Note
   2:      {
   3:          public string NoteGuid { get; set; }
   4:          public string NoteContent { get; set; }
   5:          public string NoteTime { get; set; }
   6:      }

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

   1:  if (!IsolatedStorageSettings.ApplicationSettings.Contains("Notes"))
   2:              {
   3:                  List<Note> notes = new List<Note>();
   4:                  IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;
   5:                  IsolatedStorageSettings.ApplicationSettings.Save();
   6:   
   7:              }

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

   1:   public partial class MainPage : PhoneApplicationPage
   2:      {
   3:          // 构造函数
   4:          public MainPage()
   5:          {
   6:              InitializeComponent();
   7:              BingData();
   8:          }
   9:          List<Note> notes = new List<Note>();
  10:          private void BingData()
  11:          {
  12:              notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;
  13:   
  14:              var descInfo = from i in notes orderby i.NoteTime descending select i;//linq对文章列表的排序
  15:   
  16:              MainListBox.ItemsSource = descInfo;
  17:          }
  18:   
  19:          private void ApplicationBarIconButton_Click(object sender, EventArgs e)
  20:          {
  21:              NavigationService.Navigate(new Uri("/Add.xaml", UriKind.RelativeOrAbsolute));
  22:          }
  23:   
  24:          protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
  25:          {
  26:              e.Cancel = true;
  27:              App.Quit();
  28:              base.OnBackKeyPress(e);
  29:          }
  30:   
  31:          private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
  32:          {
  33:              NavigationService.Navigate(new Uri("/About.xaml", UriKind.RelativeOrAbsolute));
  34:          }
  35:   
  36:          private void StackPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  37:          {
  38:              string noteguid = ((TextBlock)(((StackPanel)sender).Children.First())).Tag.ToString();
  39:              NavigationService.Navigate(new Uri("/DetailsPage.xaml?noteguid=" + noteguid, UriKind.Relative));
  40:          }
  41:      }

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

   1:  public partial class DetailsPage : PhoneApplicationPage
   2:      {
   3:          // 构造函数
   4:          public DetailsPage()
   5:          {
   6:              InitializeComponent();
   7:          }
   8:          string noteguid;
   9:          protected override void OnNavigatedTo(NavigationEventArgs e)
  10:          {
  11:              BingData();
  12:              noteguid = NavigationContext.QueryString["noteguid"].ToString();
  13:              foreach (var item in notes)
  14:              {
  15:                  if (item.NoteGuid==noteguid)
  16:                  {
  17:                      ContentText.Text = item.NoteContent;
  18:                      TimeText.Text = item.NoteTime;
  19:                      return;
  20:                  }
  21:              }
  22:          }
  23:   
  24:          List<Note> notes = new List<Note>();
  25:          private void BingData()
  26:          {
  27:              notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;
  28:          }
  29:   
  30:          private void Edit_Click(object sender, EventArgs e)
  31:          {
  32:              NavigationService.Navigate(new Uri("/Edit.xaml?noteguid=" + noteguid.ToString(), UriKind.RelativeOrAbsolute));
  33:          }
  34:   
  35:          protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
  36:          {
  37:              e.Cancel = true;
  38:              NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
  39:              base.OnBackKeyPress(e);
  40:          }
  41:   
  42:          private void Del_Click(object sender, EventArgs e)
  43:          {
  44:              for (int i = 0; i < notes.Count; i++)
  45:              {
  46:                  if (notes[i].NoteGuid==noteguid)
  47:                  {
  48:                      notes.RemoveAt(i);
  49:                  }
  50:              }
  51:              IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;
  52:              IsolatedStorageSettings.ApplicationSettings.Save();
  53:              NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
  54:          }
  55:   
  56:          private void Email_Click(object sender, EventArgs e)
  57:          {
  58:              EmailComposeTask email = new EmailComposeTask();
  59:              email.Body = ContentText.Text.ToString();
  60:              email.Show();
  61:          }
  62:   
  63:          private void Message_Click(object sender, EventArgs e)
  64:          {
  65:              SmsComposeTask sms = new SmsComposeTask();
  66:              sms.Body = ContentText.Text.ToString();
  67:              sms.Show();
  68:          }
  69:      }

 

文章的编辑页面代码

   1:  public partial class Edit : PhoneApplicationPage
   2:      {
   3:          public Edit()
   4:          {
   5:              InitializeComponent();
   6:          }
   7:   
   8:          private void ApplicationBarIconButton_Click(object sender, EventArgs e)
   9:          {
  10:              foreach (var item in notes)
  11:              {
  12:                  if (item.NoteGuid == noteguid)
  13:                  {
  14:                      item.NoteContent = ContentText.Text;
  15:                      item.NoteTime=TimeText.Text;
  16:                  }
  17:              }
  18:   
  19:              IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;
  20:              IsolatedStorageSettings.ApplicationSettings.Save();
  21:              NavigationService.Navigate(new Uri("/DetailsPage.xaml?noteguid=" + noteguid.ToString(), UriKind.RelativeOrAbsolute));
  22:          }
  23:          string noteguid;
  24:          protected override void OnNavigatedTo(NavigationEventArgs e)
  25:          {
  26:              BingData();
  27:              noteguid = NavigationContext.QueryString["noteguid"].ToString();
  28:              foreach (var item in notes)
  29:              {
  30:                  if (item.NoteGuid==noteguid)
  31:                  {
  32:                      ContentText.Text = item.NoteContent;
  33:                      TimeText.Text = item.NoteTime;
  34:                      return;
  35:                  }
  36:              }
  37:          }
  38:   
  39:          List<Note> notes = new List<Note>();
  40:          private void BingData()
  41:          {
  42:              notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;
  43:          }
  44:      }
posted @ 2012-03-23 00:37  巫鸦  阅读(5015)  评论(9编辑  收藏  举报