private void menuDelete_Click(object sender, EventArgs e) { NoteFile file = GetSelectedFile(); if (file == null) { return; } DialogResult result = MessageBox.Show( "You will generally only delete a note if you created it by mistake. " + "Normally when you are done with a note you will archive it." + Environment.NewLine + Environment.NewLine + "Are you sure you want to delete the selected note?", "Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result != DialogResult.OK) { return; } Monitor.Enter(_System.LockObject); try { File.Delete(file.GetFullPath()); _System.RefreshCurrentFolder(); } catch (Exception ex) { ShowException(ex); } finally { Monitor.Exit(_System.LockObject); } }
private void lvwFileList_DoubleClick(object sender, EventArgs e) { Monitor.Enter(_System.LockObject); try { NoteFile file = GetSelectedFile(); if (file == null) { return; } EditFile(file.GetFullPath()); } catch (Exception ex) { ShowException(ex); } finally { Monitor.Exit(_System.LockObject); } }
private void menuArchive_Click(object sender, EventArgs e) { NoteFile file = GetSelectedFile(); if (file == null) { return; } DialogResult result = MessageBox.Show( "Are you sure you want to archive the selected note " + "(this will move it to the archive subfolder)?", "Confirm Archive", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result != DialogResult.OK) { return; } Monitor.Enter(_System.LockObject); try { string archiveDirPath = _System.CurrentFolder.GetArchiveDirPath(); string baseName = Path.GetFileNameWithoutExtension(file.BareFileName); string archiveFileName = baseName + "." + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + ".txt"; string archiveFilePath = Path.Combine(archiveDirPath, archiveFileName); File.Move(file.GetFullPath(), archiveFilePath); _System.RefreshCurrentFolder(); } catch (Exception ex) { ShowException(ex); } finally { Monitor.Exit(_System.LockObject); } }