private void lvresults_DoubleClick(object sender, EventArgs e) { try { if (lvresults.SelectedItems[0].SubItems[2].Text == "False") { _ynote.OpenFile(lvresults.SelectedItems[0].SubItems[0].Text); var editor = (Editor)(_ynote.Panel.ActiveDocument); editor.Tb.Navigate(Convert.ToInt32(lvresults.SelectedItems[0].SubItems[1].Text) - 1); } else { foreach ( var document in _ynote.Panel.Documents.Cast <Editor>() .Where(document => document.Name == lvresults.SelectedItems[0].SubItems[0].Text)) { document.Show(); document.Tb.Navigate(lvresults.SelectedItems[0].SubItems[1].Text.ToInt() - 1); } } } catch { _ynote.OpenFile(lvresults.SelectedItems[0].SubItems[0].Text); ((Editor)(_ynote.Panel.ActiveDocument)).Tb.Navigate( lvresults.SelectedItems[0].SubItems[1].Text.ToInt() - 1); } }
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; } }
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; } }