Пример #1
0
        public CodeTemplatePanelWidget(OptionsDialog parent)
        {
            this.parent = parent;
            this.Build();
            scrolledwindow1.Child = textEditor;
            textEditor.ShowAll();

            templateStore = new TreeStore(typeof(CodeTemplate), typeof(string), typeof(string));


            TreeViewColumn column = new TreeViewColumn();

            column.Title = GettextCatalog.GetString("Key");

            pixbufCellRenderer = new CellRendererPixbuf();
            column.PackStart(pixbufCellRenderer, false);
            column.SetCellDataFunc(pixbufCellRenderer, new Gtk.TreeCellDataFunc(RenderIcon));

            templateCellRenderer = new CellRendererText();
            column.PackStart(templateCellRenderer, true);
            column.SetCellDataFunc(templateCellRenderer, new Gtk.TreeCellDataFunc(RenderTemplateName));


            treeviewCodeTemplates.AppendColumn(column);

            treeviewCodeTemplates.Model = templateStore;
            templates = new List <CodeTemplate> (CodeTemplateService.Templates);
            templates.ForEach(t => InsertTemplate(t));

            treeviewCodeTemplates.ExpandAll();
            treeviewCodeTemplates.Selection.Changed += HandleChanged;

            options = new Mono.TextEditor.TextEditorOptions();
            options.ShowLineNumberMargin    = false;
            options.ShowFoldMargin          = false;
            options.ShowIconMargin          = false;
            options.ShowInvalidLines        = false;
            options.ShowSpaces              = options.ShowTabs = options.ShowEolMarkers = false;
            options.ColorScheme             = PropertyService.Get("ColorScheme", "Default");
            textEditor.Options              = options;
            textEditor.Document.ReadOnly    = true;
            this.buttonAdd.Clicked         += ButtonAddClicked;
            this.buttonEdit.Clicked        += ButtonEditClicked;
            this.buttonRemove.Clicked      += ButtonRemoveClicked;
            checkbuttonWhiteSpaces.Toggled += CheckbuttonWhiteSpacesToggled;
            this.treeviewCodeTemplates.Selection.Changed += SelectionChanged;
            SelectionChanged(null, null);
        }
Пример #2
0
        public CodeTemplatePanelWidget(OptionsDialog parent)
        {
            this.Build();
            scrolledwindow1.Add(textEditor);
            textEditor.ShowAll();

            templateStore = new TreeStore(typeof(CodeTemplate), typeof(string), typeof(string));


            TreeViewColumn column = new TreeViewColumn();

            column.Title = GettextCatalog.GetString("Key");

            pixbufCellRenderer = new CellRendererImage();
            column.PackStart(pixbufCellRenderer, false);
            column.SetCellDataFunc(pixbufCellRenderer, new Gtk.TreeCellDataFunc(RenderIcon));

            templateCellRenderer = new CellRendererText();
            column.PackStart(templateCellRenderer, true);
            column.SetCellDataFunc(templateCellRenderer, new Gtk.TreeCellDataFunc(RenderTemplateName));


            treeviewCodeTemplates.AppendColumn(column);

            treeviewCodeTemplates.Model = templateStore;
            templates = new List <CodeTemplate> (CodeTemplateService.Templates);
            templates.ForEach(t => InsertTemplate(t));

            treeviewCodeTemplates.ExpandAll();
            treeviewCodeTemplates.Selection.Changed += HandleChanged;

            options = new MonoDevelop.Ide.Gui.CommonTextEditorOptions();
            options.ShowLineNumberMargin = false;
            options.ShowFoldMargin       = false;
            options.ShowIconMargin       = false;
            textEditor.Options           = options;
            textEditor.Document.ReadOnly = true;
            this.buttonAdd.Clicked      += ButtonAddClicked;
            this.buttonEdit.Clicked     += ButtonEditClicked;
            this.buttonRemove.Clicked   += ButtonRemoveClicked;
            this.treeviewCodeTemplates.Selection.Changed += SelectionChanged;
            SelectionChanged(null, null);
            checkbuttonWhiteSpaces.Hide();
        }
Пример #3
0
        public EditTemplateDialog(CodeTemplate template, bool isNew)
        {
            this.Build();
            this.Title                          = isNew ? GettextCatalog.GetString("New template") : GettextCatalog.GetString("Edit template");
            this.template                       = template;
            this.entryShortcut1.Text            = template.Shortcut ?? "";
            this.comboboxentryGroups.Entry.Text = template.Group ?? "";
            this.comboboxentryMime.Entry.Text   = template.MimeType ?? "";
            this.entryDescription.Text          = template.Description ?? "";
            this.textEditor.Document.MimeType   = template.MimeType;
            this.textEditor.Document.Text       = template.Code;

            checkbuttonExpansion.Active    = (template.CodeTemplateType & CodeTemplateType.Expansion) == CodeTemplateType.Expansion;
            checkbuttonSurroundWith.Active = (template.CodeTemplateType & CodeTemplateType.SurroundsWith) == CodeTemplateType.SurroundsWith;

            scrolledwindow1.Child = textEditor;
            textEditor.ShowAll();
            textEditor.Caret.PositionChanged += CaretPositionChanged;
            options = new Mono.TextEditor.TextEditorOptions();
            options.ShowLineNumberMargin = false;
            options.ShowFoldMargin       = false;
            options.ShowIconMargin       = false;
            options.ShowInvalidLines     = false;
            options.ShowSpaces           = options.ShowTabs = options.ShowEolMarkers = false;
            options.ColorScheme          = PropertyService.Get("ColorScheme", "Default");
            textEditor.Options           = options;

            HashSet <string> mimeTypes = new HashSet <string> ();
            HashSet <string> groups    = new HashSet <string> ();

            foreach (CodeTemplate ct in CodeTemplateService.Templates)
            {
                mimeTypes.Add(ct.MimeType);
                groups.Add(ct.Group);
            }
            comboboxentryMime.AppendText("");
            foreach (string mime in mimeTypes)
            {
                comboboxentryMime.AppendText(mime);
            }
            comboboxentryGroups.AppendText("");
            foreach (string group in groups)
            {
                comboboxentryGroups.AppendText(group);
            }
            textEditor.Document.TextReplaced += DocumentTextReplaced;
            this.buttonOk.Clicked            += ButtonOkClicked;

            checkbuttonWhiteSpaces.Toggled += CheckbuttonWhiteSpacesToggled;

            variablesListStore         = new ListStore(typeof(string), typeof(CodeTemplateVariable));
            comboboxVariables.Model    = variablesListStore;
            comboboxVariables.Changed += ComboboxVariablesChanged;

            variableStore                   = new TreeStore(typeof(string), typeof(CodeTemplateVariable), typeof(string), typeof(int));
            treeviewVariable.Model          = variableStore;
            treeviewVariable.HeadersVisible = false;

            treeviewVariable.AppendColumn("", new Gtk.CellRendererText(), "text", 0);
            CellRendererText nameRenderer = new CellRendererText();

            treeviewVariable.AppendColumn("", nameRenderer, delegate(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
                nameRenderer.Markup = ((string)model.GetValue(iter, 2));
            });

            grid = new MonoDevelop.Components.PropertyGrid.PropertyGrid();
            grid.PropertySort = MonoDevelop.Components.PropertyGrid.PropertySort.Alphabetical;
            grid.ShowHelp     = true;
            grid.ShowAll();
            grid.ShowToolbar = false;

            vbox4.Remove(scrolledwindow2);
            vbox4.PackEnd(grid, true, true, 0);

            UpdateVariables();
        }