private void OpenItem(int index) { NotesPane note; ContentDocument page; IScriptEditorControl script; bool loaded; String filename; filename = title[index]; if (document[index] == null) { note = new NotesPane(editor, this); page = new ContentDocument(note, filename, this, ID_ICON_LEAF); // Uncomment this for additional menu next to File // TODO: Event bindings //page.MainMenu = GetExtraMenu(); //MethodInfo x = ((GUIController)editor.GUIController).GetType().GetMethod("RegisterMenuCommand", BindingFlags.NonPublic); //MessageBox.Show("x: {" + x + "}"); //((GUIController)editor.GUIController).GetType().GetMethod("RegisterMenuCommand", BindingFlags.NonPublic).Invoke((GUIController)editor.GUIController, new object[] { extraMenu.Commands[0].ID, this }); editor.GUIController.AddOrShowPane(page); pane[index] = note; document[index] = page; loaded = false; } else { page = document[index]; if (page.Visible) { loaded = true; } else { loaded = false; } editor.GUIController.AddOrShowPane(page); note = pane[index]; } if (!loaded) { script = note.GetEditor(); note.DockingContainer.Text = filename; if (File.Exists(filename)) { try { saved[index] = File.ReadAllText(filename); script.Text = saved[index]; script.Control.Focus(); } catch (Exception) { editor.GUIController.RemovePaneIfExists(page); editor.GUIController.ShowMessage("An error occurred while reading \"" + filename + "\".", MessageBoxIconType.Error); } } } }
private int GetPaneIndex(NotesPane target) { int index; index = title.Count; while (index-- > 0) { if (pane[index] == target) { break; } } return(index); }
public void OnTextChanged(NotesPane source) { int index; index = GetPaneIndex(source); if (index > -1) { if (source.GetEditor().Text != saved[index]) { source.DockingContainer.Text = title[index] + "*"; } else { source.DockingContainer.Text = title[index]; } } AbleExtraMenu(source); }
public void OnPanelClosing(NotesPane source, bool canCancel, ref bool cancelClose) { DialogResult result; int size; size = GetPaneIndex(source); if (size > -1 && canCancel && saved[size] != pane[size].GetEditor().Text) { result = MessageBox.Show("Do you want to save changes to \"" + title[size] + "\"?", "Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { SaveItem(size); } else if (result == DialogResult.Cancel) { cancelClose = true; } } }
private void AbleExtraMenu(NotesPane source) { ScintillaWrapper wrapper; bool canCutAndCopy; IList <MenuCommand> list; int index; index = GetPaneIndex(source); if (index > -1 && false) { wrapper = (ScintillaWrapper)source.GetEditor().Control; canCutAndCopy = wrapper.CanCutAndCopy(); list = document[index].MainMenu.Commands; list[0].Enabled = wrapper.CanUndo(); //list[1].Enabled = wrapper.CanRedo(); //list[3].Enabled = canCutAndCopy; //list[4].Enabled = canCutAndCopy; //list[5].Enabled = wrapper.CanPaste(); ((GUIController)editor.GUIController).MenuManager.RefreshCurrentPane(); } }
public void OnWindowActivated(NotesPane source) { AbleExtraMenu(source); }