Exemplo n.º 1
0
 /// <summary>
 /// 新建笔记
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnNew_Click(object sender, RoutedEventArgs e)
 {
     TitleInput input = new TitleInput(this);
     bool res = input.ShowDialog().GetValueOrDefault();
     if (res == false || string.IsNullOrEmpty(titleInput))
         return;
     string filePath = notePath + titleInput + suffix;
     File.Create(filePath).Close();
     listNames.Add(titleInput);
     listNotes.Items.Refresh();
     listNotes.SelectedItem = titleInput;
     titleInput = null;
 }
Exemplo n.º 2
0
 /// <summary>
 /// 重命名
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void itemRename_Click(object sender, RoutedEventArgs e)
 {
     string oldName = listNotes.SelectedItem.ToString();
     TitleInput input = new TitleInput(this);
     bool res = input.ShowDialog().GetValueOrDefault();
     if (res == false || string.IsNullOrEmpty(titleInput))
         return;
     string oldPath = notePath + oldName + suffix;
     string newPath = notePath + titleInput + suffix;
     FileInfo file = new FileInfo(oldPath);
     file.MoveTo(newPath);
     listNames.Remove(oldName);
     listNames.Add(titleInput);
     listNotes.Items.Refresh();
     listNotes.SelectedItem = titleInput;
     titleInput = null;
 }