本文整理汇总了C#中MonoDevelop.Ide.CodeTemplates.CodeTemplate类的典型用法代码示例。如果您正苦于以下问题:C# CodeTemplate类的具体用法?C# CodeTemplate怎么用?C# CodeTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeTemplate类属于MonoDevelop.Ide.CodeTemplates命名空间,在下文中一共展示了CodeTemplate类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CodeTemplateCompletionData
public CodeTemplateCompletionData (Document doc, CodeTemplate template)
{
this.doc = doc;
this.template = template;
this.CompletionText = "test";
this.Icon = template.Icon;
this.DisplayText = template.Shortcut;
this.Description = template.Shortcut + Environment.NewLine + GettextCatalog.GetString (template.Description);
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:9,代码来源:CodeTemplateCompletionData.cs
示例2: SaveTemplate
public static void SaveTemplate (CodeTemplate template)
{
if (!Directory.Exists (TemplatePath))
Directory.CreateDirectory (TemplatePath);
SaveTemplate (template, Path.Combine (TemplatePath, template.Shortcut + ".template.xml"));
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:6,代码来源:CodeTemplateService.cs
示例3: GetExpansionObject
public static ExpansionObject GetExpansionObject (CodeTemplate template)
{
// TODO: Add more expansion objects.
return new ExpansionObject ();
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:5,代码来源:CodeTemplateService.cs
示例4: InsertTemplate
public void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context)
{
TextEditor.InsertTemplate (template, editor, context);
}
开发者ID:stephenoakman,项目名称:monodevelop,代码行数:4,代码来源:SourceEditorView.cs
示例5: Read
public static CodeTemplate Read (XmlReader reader)
{
Debug.Assert (reader.LocalName == Node);
var result = new CodeTemplate ();
XmlReadHelper.ReadList (reader, Node, delegate () {
//Console.WriteLine (reader.LocalName);
switch (reader.LocalName) {
case HeaderNode:
XmlReadHelper.ReadList (reader, HeaderNode, delegate () {
switch (reader.LocalName) {
case GroupNode:
result.Group = reader.ReadElementContentAsString ();
return true;
case VersionNode:
result.Version = reader.ReadElementContentAsString ();
return true;
case MimeNode:
result.MimeType = reader.ReadElementContentAsString ();
return true;
case ContextNode:
result.CodeTemplateContext = (CodeTemplateContext)Enum.Parse (typeof (CodeTemplateContext), reader.ReadElementContentAsString ());
return true;
case ShortcutNode:
result.Shortcut = reader.ReadElementContentAsString ();
return true;
case DescriptionNode:
result.Description = reader.ReadElementContentAsString ();
return true;
case TemplateTypeNode:
result.CodeTemplateType = (CodeTemplateType)Enum.Parse (typeof (CodeTemplateType), reader.ReadElementContentAsString ());
return true;
}
return false;
});
return true;
case VariablesNode:
XmlReadHelper.ReadList (reader, VariablesNode, delegate () {
//Console.WriteLine ("var:" + reader.LocalName);
switch (reader.LocalName) {
case CodeTemplateVariable.Node:
var var = CodeTemplateVariable.Read (reader);
result.variableDecarations [var.Name] = var;
return true;
}
return false;
});
return true;
case CodeNode:
result.Code = reader.ReadElementContentAsString ();
return true;
}
return false;
});
//Console.WriteLine ("result:" + result);
return result;
}
开发者ID:ZZHGit,项目名称:monodevelop,代码行数:58,代码来源:CodeTemplate.cs
示例6: InsertTemplate
public void InsertTemplate (CodeTemplate template)
{
TextIter iter = buf.GetIterAtMark (buf.InsertMark);
int newCaretOffset = iter.Offset;
string word = GetWordBeforeCaret ().Trim ();
int beginLine = iter.Line;
int endLine = beginLine;
if (word.Length > 0)
newCaretOffset = DeleteWordBeforeCaret ();
string leadingWhiteSpace = GetLeadingWhiteSpace (beginLine);
int finalCaretOffset = newCaretOffset;
for (int i =0; i < template.Text.Length; ++i) {
switch (template.Text[i]) {
case '|':
finalCaretOffset = newCaretOffset;
break;
case '\r':
break;
case '\t':
buf.InsertAtCursor ("\t");
newCaretOffset++;
break;
case '\n':
buf.InsertAtCursor ("\n");
newCaretOffset++;
endLine++;
break;
default:
buf.InsertAtCursor (template.Text[i].ToString ());
newCaretOffset++;
break;
}
}
if (endLine > beginLine) {
IndentLines (beginLine+1, endLine, leadingWhiteSpace);
}
buf.PlaceCursor (buf.GetIterAtOffset (finalCaretOffset));
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:43,代码来源:SourceEditorView.cs
示例7: InsertTemplate
public void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document doc)
{
TextEditor.InsertTemplate (template, doc);
}
开发者ID:nocache,项目名称:monodevelop,代码行数:4,代码来源:SourceEditorView.cs
示例8: InsertTemplate
TreeIter InsertTemplate (CodeTemplate template)
{
TreeIter iter = GetGroup (template.Group);
return templateStore.AppendValues (iter, template, template.Shortcut, null);
}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:5,代码来源:CodeTemplatePanel.cs
示例9: ButtonAddClicked
void ButtonAddClicked (object sender, EventArgs e)
{
var newTemplate = new CodeTemplate ();
using (var editDialog = new EditTemplateDialog (newTemplate, true)) {
if (MessageService.ShowCustomDialog (editDialog, this.Toplevel as Gtk.Window) == (int)ResponseType.Ok) {
InsertTemplate (newTemplate);
templates.Add (newTemplate);
templatesToSave.Add (newTemplate);
}
}
}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:11,代码来源:CodeTemplatePanel.cs
示例10: InsertTemplate
internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext context)
{
using (var undo = editor.OpenUndoGroup ()) {
var result = template.InsertTemplateContents (editor, context);
var links = result.TextLinks.Select (l => new Mono.TextEditor.TextLink (l.Name) {
Links = l.Links.Select (s => new TextSegment (s.Offset, s.Length)).ToList (),
IsEditable = l.IsEditable,
IsIdentifier = l.IsIdentifier
}).ToList ();
var tle = new TextLinkEditMode (this, result.InsertPosition, links);
tle.TextLinkMode = TextLinkMode.General;
if (tle.ShouldStartTextLinkMode) {
tle.OldMode = CurrentMode;
tle.StartMode ();
CurrentMode = tle;
}
}
}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:19,代码来源:ExtensibleTextEditor.cs
示例11: InsertTemplate
internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document document)
{
using (var undo = Document.OpenUndoGroup ()) {
var result = template.InsertTemplateContents (document);
var links = result.TextLinks;
if (PropertyService.Get ("OnTheFlyFormatting", true)) {
var prettyPrinter = CodeFormatterService.GetFormatter (Document.MimeType);
if (prettyPrinter != null) {
int endOffset = result.InsertPosition + result.Code.Length;
// string oldText = Document.GetTextAt (result.InsertPosition, result.Code.Length);
// var policies = document.Project != null ? document.Project.Policies : null;
var oldVersion = Document.Version;
prettyPrinter.OnTheFlyFormat (document, result.InsertPosition, endOffset);
foreach (var textLink in links) {
for (int i = 0; i < textLink.Links.Count; i++) {
var segment = textLink.Links [i];
var translatedOffset = oldVersion.MoveOffsetTo (Document.Version, result.InsertPosition + segment.Offset) - result.InsertPosition;
textLink.Links [i] = new TextSegment (translatedOffset, segment.Length);
}
}
}
}
var tle = new TextLinkEditMode (this, result.InsertPosition, links);
if (tle.ShouldStartTextLinkMode) {
tle.OldMode = CurrentMode;
tle.StartMode ();
CurrentMode = tle;
}
}
}
开发者ID:txdv,项目名称:monodevelop,代码行数:32,代码来源:ExtensibleTextEditor.cs
示例12: DeleteTemplate
public static void DeleteTemplate (CodeTemplate template)
{
try {
var fileName = Path.Combine (TemplatePath, template.Shortcut + ".template.xml");
if (File.Exists (fileName))
File.Delete (fileName);
} catch (Exception e) {
LoggingService.LogError ("Error while removing template file", e);
}
}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:10,代码来源:CodeTemplateService.cs
示例13: InsertTemplate
internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document document)
{
Document.BeginAtomicUndo ();
var result = template.InsertTemplateContents (document);
var tle = new TextLinkEditMode (this, result.InsertPosition, result.TextLinks);
if (PropertyService.Get ("OnTheFlyFormatting", false)) {
var prettyPrinter = CodeFormatterService.GetFormatter (Document.MimeType);
if (prettyPrinter != null) {
int endOffset = result.InsertPosition + result.Code.Length;
string oldText = Document.GetTextAt (result.InsertPosition, result.Code.Length);
var policies = document.Project != null ? document.Project.Policies : null;
string text = prettyPrinter.FormatText (policies, Document.Text, result.InsertPosition, endOffset);
if (text != null)
Replace (result.InsertPosition, result.Code.Length, text);
else
//if formatting failed, just use the unformatted text
text = oldText;
Caret.Offset = result.InsertPosition + TranslateOffset (oldText, text, Caret.Offset - result.InsertPosition);
foreach (TextLink textLink in tle.Links) {
foreach (ISegment segment in textLink.Links) {
segment.Offset = TranslateOffset (oldText, text, segment.Offset);
}
}
}
}
if (tle.ShouldStartTextLinkMode) {
tle.OldMode = CurrentMode;
tle.StartMode ();
CurrentMode = tle;
}
Document.EndAtomicUndo ();
}
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:36,代码来源:ExtensibleTextEditor.cs
示例14: EditTemplateDialog
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.MimeType = template.MimeType;
this.textEditor.Text = template.Code ?? "";
checkbuttonExpansion.Active = (template.CodeTemplateType & CodeTemplateType.Expansion) == CodeTemplateType.Expansion;
checkbuttonSurroundWith.Active = (template.CodeTemplateType & CodeTemplateType.SurroundsWith) == CodeTemplateType.SurroundsWith;
Gtk.Widget control = textEditor;
scrolledwindow1.Child = control;
control.ShowAll ();
textEditor.CaretPositionChanged += CaretPositionChanged;
textEditor.Options = DefaultSourceEditorOptions.PlainEditor;
var mimeTypes = new HashSet<string> ();
var 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.TextChanged += DocumentTextReplaced;
this.buttonOk.Clicked += ButtonOkClicked;
checkbuttonWhiteSpaces.Hide ();
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 ();
}
开发者ID:ZZHGit,项目名称:monodevelop,代码行数:65,代码来源:EditTemplateDialog.cs
示例15: InsertTemplate
internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document document)
{
using (var undo = Document.OpenUndoGroup ()) {
var result = template.InsertTemplateContents (document);
var links = result.TextLinks;
var tle = new TextLinkEditMode (this, result.InsertPosition, links);
tle.TextLinkMode = TextLinkMode.General;
if (tle.ShouldStartTextLinkMode) {
tle.OldMode = CurrentMode;
tle.StartMode ();
CurrentMode = tle;
}
}
}
开发者ID:John-Colvin,项目名称:monodevelop,代码行数:16,代码来源:ExtensibleTextEditor.cs
示例16: InsertTemplate
internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext context)
{
using (var undo = editor.OpenUndoGroup ()) {
var result = template.InsertTemplateContents (editor, context);
var links = result.TextLinks.Select (l => new Mono.TextEditor.TextLink (l.Name) {
Links = l.Links.Select (s => new TextSegment (s.Offset, s.Length)).ToList (),
IsEditable = l.IsEditable,
IsIdentifier = l.IsIdentifier,
GetStringFunc = l.GetStringFunc != null ? (Func<Func<string, string>, Mono.TextEditor.PopupWindow.IListDataProvider<string>>)(arg => new ListDataProviderWrapper (l.GetStringFunc (arg))) : null
}).ToList ();
var tle = new TextLinkEditMode (this, result.InsertPosition, links);
tle.TextLinkMode = TextLinkMode.General;
if (tle.ShouldStartTextLinkMode) {
tle.OldMode = CurrentMode;
tle.StartMode ();
CurrentMode = tle;
GLib.Timeout.Add (10, delegate {
tle.UpdateTextLinks ();
return false;
});
}
}
}
开发者ID:kdubau,项目名称:monodevelop,代码行数:24,代码来源:ExtensibleTextEditor.cs
示例17: InsertTemplate
internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document document)
{
Document.BeginAtomicUndo ();
var result = template.InsertTemplateContents (document);
TextLinkEditMode tle = new TextLinkEditMode (this,
result.InsertPosition,
result.TextLinks);
if (PropertyService.Get ("OnTheFlyFormatting", false)) {
Formatter prettyPrinter = TextFileService.GetFormatter (Document.MimeType);
if (prettyPrinter != null && prettyPrinter.SupportsOnTheFlyFormatting) {
int endOffset = result.InsertPosition + result.Code.Length;
string text = prettyPrinter.FormatText (document.Project.Policies, Document.MimeType, Document.Text, result.InsertPosition, endOffset);
string oldText = Document.GetTextAt (result.InsertPosition, result.Code.Length);
// Console.WriteLine (result.InsertPosition);
// Console.WriteLine ("old:" + oldText);
// Console.WriteLine ("new:" + text);
Replace (result.InsertPosition, result.Code.Length, text);
Caret.Offset = result.InsertPosition + TranslateOffset (oldText, text, Caret.Offset - result.InsertPosition);
foreach (TextLink textLink in tle.Links) {
foreach (ISegment segment in textLink.Links) {
segment.Offset = TranslateOffset (oldText, text, segment.Offset);
}
}
}
}
if (tle.ShouldStartTextLinkMode) {
tle.OldMode = CurrentMode;
tle.StartMode ();
CurrentMode = tle;
}
Document.EndAtomicUndo ();
}
开发者ID:silk,项目名称:monodevelop,代码行数:34,代码来源:ExtensibleTextEditor.cs
示例18: TemplateToolboxNode
public TemplateToolboxNode (CodeTemplate template)
{
this.Template = template;
ItemFilters.Add (new ToolboxItemFilterAttribute ("text/plain", ToolboxItemFilterType.Allow));
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:5,代码来源:TemplateToolboxNode.cs
注:本文中的MonoDevelop.Ide.CodeTemplates.CodeTemplate类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论