| 1: | // TextAreaContextmenuCommands.cs | |
| 2: | // Copyright (C) 2002 Mike Krueger | |
| 3: | // | |
| 4: | // This program is free software; you can redistribute it and/or modify | |
| 5: | // it under the terms of the GNU General Public License as published by | |
| 6: | // the Free Software Foundation; either version 2 of the License, or | |
| 7: | // (at your option) any later version. | |
| 8: | // | |
| 9: | // This program is distributed in the hope that it will be useful, | |
| 10: | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11: | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12: | // GNU General Public License for more details. | |
| 13: | // | |
| 14: | // You should have received a copy of the GNU General Public License | |
| 15: | // along with this program; if not, write to the Free Software | |
| 16: | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17: | ||
| 18: | using System; | |
| 19: | using System.IO; | |
| 20: | using System.Threading; | |
| 21: | using System.Drawing; | |
| 22: | using System.Drawing.Printing; | |
| 23: | using System.Collections; | |
| 24: | using System.ComponentModel; | |
| 25: | using System.Windows.Forms; | |
| 26: | using System.Diagnostics; | |
| 27: | using System.Text; | |
| 28: | ||
| 29: | using Core.AddIns; | |
| 30: | using Core.Util; | |
| 31: | using Core.Properties; | |
| 32: | using Core.Gui; | |
| 33: | using Core.Gui.Creators; | |
| 34: | using Core.AddIns.Codons; | |
| 35: | ||
| 36: | using SharpDevelop.Gui.Dialogs; | |
| 37: | using SharpDevelop.DefaultEditor.Text; | |
| 38: | using SharpDevelop.DefaultEditor.Gui.Editor; | |
| 39: | using SharpDevelop.Gui.Components; | |
| 40: | using SharpDevelop.Gui; | |
| 41: | ||
| 42: | namespace SharpDevelop.DefaultEditor.Commands { | |
| 43: | ||
| 44: | public class ShowBufferOptions : AbstractMenuCommand | |
| 45: | { | |
| 46: | public override void Run() | |
| 47: | { | |
| 48: | IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; | |
| 49: | ||
| 50: | if (window == null || !(window.WindowContent.Control is TextAreaControl)) { | |
| 51: | return; | |
| 52: | } | |
| 53: | TextAreaControl textarea = (TextAreaControl)window.WindowContent.Control; | |
| 54: | ||
| 55: | TabbedOptions o = new TabbedOptions(textarea.Document.Properties, AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/WindowContent/DefaultTextEditor/OptionsDialog")); | |
| 56: | o.Width = 450; | |
| 57: | o.Height = 425; | |
| 58: | o.FormBorderStyle = FormBorderStyle.FixedDialog; | |
| 59: | o.ShowDialog(); | |
| 60: | o.Dispose(); | |
| 61: | textarea.OptionsChanged(); | |
| 62: | } | |
| 63: | } | |
| 64: | ||
| 65: | ||
| 66: | public class HighlightingTypeBuilder : ISubmenuBuilder | |
| 67: | { | |
| 68: | TextAreaControl control = null; | |
| 69: | ||
| 70: | public MenuItem[] BuildSubmenu(object owner) | |
| 71: | { | |
| 72: | control = (TextAreaControl)owner; | |
| 73: | IconMenuStyle iconMenuStyle = (IconMenuStyle)GlobalProperties.GetProperty("IconMenuItem.IconMenuStyle", IconMenuStyle.VSNet); | |
| 74: | ||
| 75: | ArrayList menuItems = new ArrayList(); | |
| 76: | Console.WriteLine(owner); | |
| 77: | ||
| 78: | foreach (DictionaryEntry entry in DefaultHighlightingStrategy.HighlighterDefinitions) { | |
| 79: | IHighlightingStrategy syntax = (IHighlightingStrategy)entry.Value; | |
| 80: | RichMenuItem item = new RichMenuItem(iconMenuStyle, syntax.Name, new EventHandler(ChangeSyntax)); | |
| 81: | item.Checked = control.Document.HighlightingStrategy == syntax; | |
| 82: | menuItems.Add(item); | |
| 83: | } | |
| 84: | ||
| 85: | return (MenuItem[])menuItems.ToArray(typeof(MenuItem)); | |
| 86: | } | |
| 87: | ||
| 88: | void ChangeSyntax(object sender, EventArgs e) | |
| 89: | { | |
| 90: | if (control != null) { | |
| 91: | RichMenuItem item = ((RichMenuItem)sender); | |
| 92: | foreach (MenuItem i in item.Parent.MenuItems) { | |
| 93: | i.Checked = false; | |
| 94: | } | |
| 95: | item.Checked = true; | |
| 96: | IHighlightingStrategy strat = HighlightingStrategyFactory.CreateHighlightingStrategy(item.Text); | |
| 97: | if (strat == null) { | |
| 98: | throw new Exception("Strategy can't be null"); | |
| 99: | } | |
| 100: | control.Document.HighlightingStrategy = strat; | |
| 101: | control.Refresh(); | |
| 102: | } | |
| 103: | } | |
| 104: | ||
| 105: | } | |
| 106: | } |
This page was automatically generated by SharpDevelop.