Пример #1
0
 private void menuRename_Click(object sender, EventArgs e)
 {
     Monitor.Enter(_System.LockObject);
     try
     {
         if (GetSelectedFile() == null)
         {
             return;
         }
         string newNoteName = FileNameForm.GetValue("Enter new name for selected note:", (NoteFolder)tabMain.SelectedTab.Tag);
         if (newNoteName == null)
         {
             return;
         }
         string newFullPath = _System.CurrentFolder.GetFullPath(newNoteName + ".txt");
         File.Move(GetSelectedFile().GetFullPath(), newFullPath);
         _System.RefreshCurrentFolder();
     }
     catch (Exception ex)
     {
         ShowException(ex);
     }
     finally
     {
         Monitor.Exit(_System.LockObject);
     }
 }
Пример #2
0
 public static string GetValue(string instructions, NoteFolder noteFolder)
 {
     using (FileNameForm frm = new FileNameForm())
     {
         frm._NoteFolder          = noteFolder;
         frm.lblInstructions.Text = instructions;
         DialogResult result = frm.ShowDialog();
         if (result == DialogResult.OK)
         {
             return(frm.txtFileName.Text);
         }
         return(null);
     }
 }
Пример #3
0
        private void menuNew_Click(object sender, EventArgs e)
        {
            string newNoteName = FileNameForm.GetValue("Enter name of new note:", (NoteFolder)tabMain.SelectedTab.Tag);

            if (newNoteName == null)
            {
                return;
            }
            Monitor.Enter(_System.LockObject);
            try
            {
                string fullFilePath = _System.CurrentFolder.GetFullPath(newNoteName + ".txt");
                string initialContents;
                try
                {
                    initialContents = File.ReadAllText(_System.CurrentFolder.GetConfigFilePath("InitialContents.txt"));
                }
                catch
                {
                    initialContents =
                        "Created By: " + Environment.NewLine +
                        "Assigned To: " + Environment.NewLine +
                        "Priority: " + Environment.NewLine +
                        "Due Date: " + Environment.NewLine +
                        "--------------------------------" + Environment.NewLine;
                }
                File.WriteAllText(fullFilePath, initialContents);
                _System.RefreshCurrentFolder();
                EditFile(fullFilePath);
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
            finally
            {
                Monitor.Exit(_System.LockObject);
            }
        }