public void ProcessCommand(string val, IYnote ynote)
{
var edit = ynote.Panel.ActiveDocument as Editor;
switch (val)
{
case "New":
ynote.CreateNewDoc();
break;
case "Open":
using (var dlg = new OpenFileDialog())
{
dlg.Filter = "All Files (*.*)|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
ynote.OpenFile(dlg.FileName);
}
break;
case "Save":
ynote.SaveEditor(ynote.Panel.ActiveDocument as Editor);
break;
case "SaveAll":
foreach (Editor item in ynote.Panel.Documents.OfType<Editor>())
ynote.SaveEditor(item);
break;
case "Properties":
if (edit.IsSaved)
NativeMethods.ShowFileProperties(edit.Name);
break;
case "Revert":
if (edit == null || !edit.IsSaved) return;
edit.Tb.OpenFile(edit.Name);
edit.Text = Path.GetFileName(edit.Name);
break;
case "Close":
edit.Close();
break;
case "CloseAll":
foreach (Editor doc in ynote.Panel.Documents.OfType<Editor>())
doc.Close();
break;
case "Delete":
var filename = edit.Name;
if (!edit.IsSaved) return;
var result = MessageBox.Show("Are you sure you want to Delete " + edit.Text + " ?", "Confirm",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
File.Delete(filename);
edit.Close();
}
break;
}
}