本文整理汇总了C#中Gtk.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.Insert方法的具体用法?C# Gtk.Insert怎么用?C# Gtk.Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk
的用法示例。
在下文中一共展示了Gtk.Insert方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartUpload
public void StartUpload(Gtk.TextBuffer updateWindow)
{
//Create a temp file
updateWindow.Insert (updateWindow.EndIter, "Saving file.\n");
PintaCore.Workspace.ActiveDocument.Save (false);
//Using Imgur API key
updateWindow.Insert (updateWindow.EndIter, "Uploading file.\n");
string result = PostToImgur (PintaCore.Workspace.ActiveDocument.PathAndFileName,
"ecf58baa7533e4c4535205bcac51a010");
string web_path = ParseResult (result);
updateWindow.Insert (updateWindow.EndIter, "The imgur address is:\n");
updateWindow.Insert (updateWindow.EndIter, web_path);
}
示例2: InsertTimeStamp
protected override void InsertTimeStamp(Gtk.TextBuffer buffer, ref Gtk.TextIter iter,
string timestamp, MessageModel msg)
{
if (String.IsNullOrWhiteSpace(msg.ID)) {
buffer.Insert(ref iter, timestamp);
} else {
var uri = new Uri(String.Format("https://twitter.com/{0}/status/{1}", msg.GetNick(), msg.ID));
var tags = new List<Gtk.TextTag>();
// link URI tag
var linkTag = new LinkTag(uri);
linkTag.TextEvent += OnLinkTagTextEvent;
_MessageTextTagTable.Add(linkTag);
tags.Add(linkTag);
// link style tag
tags.Add(LinkTag);
buffer.InsertWithTags(ref iter, timestamp, tags.ToArray());
}
buffer.Insert(ref iter, " ");
}
示例3: BuildToolbar
public override void BuildToolbar(Gtk.Toolbar toolBar)
{
ToolBarComboBox zoomCombobox = new ToolBarComboBox (100, 4, true, new string[] { "400%", "300%", "200%", "150%", "100%", "66%", "50%" });
zoomCombobox.ComboBox.Changed += delegate(object sender, EventArgs e) {
string text = zoomCombobox.ComboBox.ActiveText;
text = text.Trim ('%');
double percent;
if (!double.TryParse (text, out percent))
return;
percent = Math.Min (percent, 400);
designService.ZoomChanged (percent / 100.0);
};
toolBar.Insert(zoomCombobox,0);
}
示例4: InsertOptions
public void InsertOptions (Gtk.Menu menu, CommandEntrySet entrySet, int index)
{
CommandTargetRoute route = new CommandTargetRoute ();
foreach (CommandEntry entry in entrySet) {
Gtk.MenuItem item = entry.CreateMenuItem (this);
CustomItem ci = item.Child as CustomItem;
if (ci != null)
ci.SetMenuStyle (menu);
int n = menu.Children.Length;
menu.Insert (item, index);
if (item is ICommandUserItem)
((ICommandUserItem)item).Update (route);
else
item.Show ();
index += menu.Children.Length - n;
}
}
示例5: AddAlternativeText
static void AddAlternativeText(Gtk.TextBuffer buffer, ref Gtk.TextIter iter, ImageMessagePartModel imgPart)
{
if (!String.IsNullOrEmpty(imgPart.AlternativeText)) {
buffer.Insert(ref iter, imgPart.AlternativeText);
}
}
示例6: InsertToBuffer
private void InsertToBuffer(Gtk.TextBuffer buffer, ref Gtk.TextIter iter, TextMessagePartModel fmsgti)
{
var tags = new List<Gtk.TextTag>();
if (fmsgti.Text == null) {
// Gtk.TextBuffer.Insert*() asserts on text == NULL
return;
}
if (fmsgti.ForegroundColor != TextColor.None) {
var bg = ColorConverter.GetTextColor(BackgroundColor);
if (fmsgti.BackgroundColor != TextColor.None) {
bg = fmsgti.BackgroundColor;
}
TextColor color = TextColorTools.GetBestTextColor(
fmsgti.ForegroundColor, bg
);
string tagname = GetTextTagName(color, null);
var tag = _MessageTextTagTable.Lookup(tagname);
tags.Add(tag);
}
if (fmsgti.BackgroundColor != TextColor.None) {
// TODO: get this from ChatView
string tagname = GetTextTagName(null, fmsgti.BackgroundColor);
var tag = _MessageTextTagTable.Lookup(tagname);
tags.Add(tag);
}
if (fmsgti.Underline) {
#if LOG4NET && MSG_DEBUG
_Logger.Debug("AddMessage(): fmsgti.Underline is true");
#endif
tags.Add(UnderlineTag);
}
if (fmsgti.Bold) {
#if LOG4NET && MSG_DEBUG
_Logger.Debug("AddMessage(): fmsgti.Bold is true");
#endif
tags.Add(BoldTag);
}
if (fmsgti.Italic) {
#if LOG4NET && MSG_DEBUG
_Logger.Debug("AddMessage(): fmsgti.Italic is true");
#endif
tags.Add(ItalicTag);
}
if (tags.Count > 0) {
buffer.InsertWithTags(ref iter, fmsgti.Text, tags.ToArray());
} else {
buffer.Insert(ref iter, fmsgti.Text);
}
}
示例7: InsertTimeStamp
protected virtual void InsertTimeStamp(Gtk.TextBuffer buffer, ref Gtk.TextIter iter,
string timestamp, MessageModel msg)
{
timestamp = String.Format("{0} ", timestamp);
buffer.Insert(ref iter, timestamp);
}
示例8: Deserialize
public static void Deserialize (Gtk.TextBuffer buffer,
Gtk.TextIter start,
XmlTextReader xml)
{
int offset = start.Offset;
Stack<TagStart> stack = new Stack<TagStart> ();
TagStart tag_start;
NoteTagTable note_table = buffer.TagTable as NoteTagTable;
int curr_depth = -1;
// A stack of boolean values which mark if a
// list-item contains content other than another list
Stack<bool> list_stack = new Stack<bool> ();
while (xml.Read ()) {
switch (xml.NodeType) {
case XmlNodeType.Element:
if (xml.Name == "note-content")
break;
tag_start = new TagStart ();
tag_start.Start = offset;
if (note_table != null &&
note_table.IsDynamicTagRegistered (xml.Name)) {
tag_start.Tag =
note_table.CreateDynamicTag (xml.Name);
} else if (xml.Name == "list") {
curr_depth++;
break;
} else if (xml.Name == "list-item") {
if (curr_depth >= 0) {
if (xml.GetAttribute ("dir") == "rtl") {
tag_start.Tag =
note_table.GetDepthTag (curr_depth, Pango.Direction.Rtl);
} else {
tag_start.Tag =
note_table.GetDepthTag (curr_depth, Pango.Direction.Ltr);
}
list_stack.Push (false);
} else {
Logger.Error("</list> tag mismatch");
}
} else {
tag_start.Tag = buffer.TagTable.Lookup (xml.Name);
}
if (tag_start.Tag is NoteTag) {
((NoteTag) tag_start.Tag).Read (xml, true);
}
stack.Push (tag_start);
break;
case XmlNodeType.Text:
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
Gtk.TextIter insert_at = buffer.GetIterAtOffset (offset);
buffer.Insert (ref insert_at, xml.Value);
offset += xml.Value.Length;
// If we are inside a <list-item> mark off
// that we have encountered some content
if (list_stack.Count > 0) {
list_stack.Pop ();
list_stack.Push (true);
}
break;
case XmlNodeType.EndElement:
if (xml.Name == "note-content")
break;
if (xml.Name == "list") {
curr_depth--;
break;
}
tag_start = stack.Pop ();
if (tag_start.Tag == null)
break;
Gtk.TextIter apply_start, apply_end;
apply_start = buffer.GetIterAtOffset (tag_start.Start);
apply_end = buffer.GetIterAtOffset (offset);
if (tag_start.Tag is NoteTag) {
((NoteTag) tag_start.Tag).Read (xml, false);
}
// Insert a bullet if we have reached a closing
// <list-item> tag, but only if the <list-item>
// had content.
DepthNoteTag depth_tag = tag_start.Tag as DepthNoteTag;
if (depth_tag != null && list_stack.Pop ()) {
((NoteBuffer) buffer).InsertBullet (ref apply_start,
depth_tag.Depth,
//.........这里部分代码省略.........
示例9: PopulateNodeTypes
void PopulateNodeTypes (Gtk.Menu menu, TreeIter it)
{
ExtensionNodeTypeCollection types = GetAllowedChildTypes (it);
Extension ext = (Extension) store.GetValue (it, ColExtension);
ExtensionNodeDescription node = (ExtensionNodeDescription) store.GetValue (it, ColNode);
if (types != null && types.Count > 0) {
if (menu.Children.Length > 0)
menu.Insert (new Gtk.SeparatorMenuItem (), -1);
foreach (ExtensionNodeType nt in types) {
Gtk.ImageMenuItem mi = new Gtk.ImageMenuItem (AddinManager.CurrentLocalizer.GetString ("Add node '{0}'", nt.NodeName));
menu.Insert (mi, -1);
ExtensionNodeType ntc = nt;
mi.Activated += delegate {
CreateNode (it, ext, node, ntc);
};
}
}
}
示例10: Deserialize
public static void Deserialize (Gtk.TextBuffer buffer, Gtk.TextIter start, string content)
{
StringReader reader = new StringReader(content);
int intCharacter;
char convertedCharacter;
int offset = start.Offset;
string sbuffer = String.Empty;
Stack<TagStart> stack = new Stack<TagStart> ();
TagStart tag_start;
while (true) {
intCharacter = reader.Read ();
if (intCharacter == -1) break;
convertedCharacter = Convert.ToChar (intCharacter);
if (sbuffer != String.Empty || convertedCharacter == '<') {
sbuffer += convertedCharacter;
if (sbuffer == "<bold>") {
tag_start = new TagStart ();
tag_start.Start = offset;
tag_start.Tag = buffer.TagTable.Lookup ("bold");
stack.Push (tag_start);
sbuffer = String.Empty;
} else if (sbuffer == "<italic>") {
tag_start = new TagStart ();
tag_start.Start = offset;
tag_start.Tag = buffer.TagTable.Lookup ("italic");
stack.Push (tag_start);
sbuffer = String.Empty;
} else if (sbuffer == "</bold>" || sbuffer == "</italic>") {
if (stack.Count > 0) {
tag_start = stack.Pop ();
Gtk.TextIter apply_start, apply_end;
apply_start = buffer.GetIterAtOffset (tag_start.Start);
apply_end = buffer.GetIterAtOffset (offset);
buffer.ApplyTag (tag_start.Tag, apply_start, apply_end);
sbuffer = String.Empty;
}
} else if (sbuffer.Length > 9) {
Gtk.TextIter insert_at = buffer.GetIterAtOffset(offset);
buffer.Insert (ref insert_at, sbuffer);
offset += sbuffer.Length;
sbuffer = String.Empty;
}
} else {
Gtk.TextIter insert_at = buffer.GetIterAtOffset(offset);
buffer.Insert (ref insert_at, convertedCharacter.ToString ());
offset += 1;
}
}
}
示例11: BuildToolbar
public override void BuildToolbar(Gtk.Toolbar toolBar)
{
bool setMode = false;
ToolBarComboBox zoomCombobox = new ToolBarComboBox (100, 4, true, zoomItems);
designService.OnZoomChanged += (a, b) => {
setMode = true;
((Gtk.Entry)zoomCombobox.ComboBox.Child).Text = (designService.Zoom * 100).ToString() + "%";
setMode = false;
};
zoomCombobox.ComboBox.Changed += delegate(object sender, EventArgs e) {
if (!setMode)
{
string text = zoomCombobox.ComboBox.ActiveText;
text = text.Trim('%');
double percent;
if (!double.TryParse(text, out percent))
return;
percent = Math.Min(percent, 400);
designService.ZoomChanged(percent / 100.0);
}
};
toolBar.Insert(zoomCombobox,0);
}
示例12: Redo
public void Redo (Gtk.TextBuffer buffer)
{
Gtk.TextIter iter = buffer.GetIterAtOffset (offset);
buffer.Insert (ref iter, "\n");
((NoteBuffer) buffer).InsertBullet (ref iter, depth, direction);
buffer.MoveMark (buffer.InsertMark, iter);
buffer.MoveMark (buffer.SelectionBound, iter);
}
示例13: BuildToolbar
public virtual void BuildToolbar(Gtk.Toolbar toolBar)
{
if(IsToolbarTool){
ToolBarButton toolButton = new ToolBarButton (ToolbarImageName,Name,Name);
toolButton.Clicked += delegate(object sender, EventArgs e) {
designService.SelectedControl = null;
designService.SelectedTool = this;
this.CreateMode = true;
};
toolBar.Insert (toolButton, 1);
}
}