private void LoadSnippets() { mnuInsertSnippet.MenuItems.Clear(); mnuDeleteSnippet.MenuItems.Clear(); txtCode.Snippets.List.Clear(); while (mnuSaveAs.MenuItems.Count > 2) { mnuSaveAs.MenuItems.RemoveAt(2); } Snippet[] snippets = DbManager.GetSnippets(); foreach (Snippet snippet in snippets) { ScintillaNet.Snippet sciteSnippet = new ScintillaNet.Snippet(snippet.Name.Replace(" ", "-"), snippet.Text); sciteSnippet.Languages.Add(snippet.Type == ScriptType.Batch ? "batch" : "cs"); if (txtCode.Snippets.List.Contains(sciteSnippet.Shortcut)) { continue; } txtCode.Snippets.List.Add(sciteSnippet); MenuItem newItem = new MenuItem(snippet.Name); newItem.Tag = snippet; newItem.Click += new EventHandler(OnInsertSnippetClick); mnuInsertSnippet.MenuItems.Add(newItem); newItem = new MenuItem(snippet.Name); newItem.Tag = snippet; newItem.Click += new EventHandler(OnDeleteSnippetClick); mnuDeleteSnippet.MenuItems.Add(newItem); newItem = new MenuItem(snippet.Name); newItem.Tag = snippet; newItem.Click += new EventHandler(OnSaveSnippetAs); mnuSaveAs.MenuItems.Add(newItem); } mnuDeleteSnippet.Enabled = (snippets.Length > 0); mnuInsertSnippet.Enabled = (snippets.Length > 0); sepSaveAs.Visible = (snippets.Length > 0); }