本文整理汇总了C#中Gtk.TreeStore.GetIter方法的典型用法代码示例。如果您正苦于以下问题:C# TreeStore.GetIter方法的具体用法?C# TreeStore.GetIter怎么用?C# TreeStore.GetIter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.TreeStore
的用法示例。
在下文中一共展示了TreeStore.GetIter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ElementHelpWidget
// IWorkbenchWindow workbenchWindow;
// RegexToolkitWidget regexWidget;
public ElementHelpWidget (IWorkbenchWindow workbenchWindow, RegexToolkitWidget regexWidget)
{
// this.workbenchWindow = workbenchWindow;
// this.regexWidget = regexWidget;
this.Build ();
elementsStore = new Gtk.TreeStore (typeof(string), typeof(string), typeof(string), typeof(string));
this.elementsTreeview.Model = this.elementsStore;
this.elementsTreeview.HeadersVisible = false;
this.elementsTreeview.Selection.Mode = SelectionMode.Browse;
var col = new TreeViewColumn ();
this.elementsTreeview.AppendColumn (col);
var pix = new CellRendererPixbuf ();
var cellRendText = new CellRendererText ();
col.PackStart (pix, false);
col.AddAttribute (pix, "stock_id", 0);
col.PackStart (cellRendText, false);
col.AddAttribute (cellRendText, "text", 1);
var cellRendText2 = new CellRendererText ();
col.PackStart (cellRendText2, true);
col.SetCellDataFunc (cellRendText2, ElementDescriptionFunc);
// this.elementsTreeview.Selection.Changed += delegate {
// ShowTooltipForSelectedEntry ();
// };
// this.elementsTreeview.MotionNotifyEvent += HandleMotionNotifyEvent;
this.elementsTreeview.RowActivated += delegate (object sender, RowActivatedArgs e) {
Gtk.TreeIter iter;
if (elementsStore.GetIter (out iter, e.Path)) {
string text = elementsStore.GetValue (iter, 3) as string;
if (!System.String.IsNullOrEmpty (text)) {
regexWidget.InsertText (text);
workbenchWindow.SwitchView (0);
}
}
};
this.LeaveNotifyEvent += delegate {
this.HideTooltipWindow ();
};
FillElementsBox ();
Show ();
}
示例2: FormatTreeView
void FormatTreeView(TreeStore treeStore)
{
treeView.HeadersVisible = false;
treeView.EnableTreeLines = true;
CellRendererToggle checkboxCellRenderer = new CellRendererToggle();
checkboxCellRenderer.Activatable = true;
checkboxCellRenderer.Toggled += delegate(object o, ToggledArgs args)
{
TreeIter iter;
if (treeStore.GetIter(out iter, new TreePath(args.Path)))
{
PackageReferenceNode node = (PackageReferenceNode)treeStore.GetValue(iter, 0);
node.State = !node.State;
}
};
treeView.AppendColumn("CheckBox", checkboxCellRenderer);
CellRendererText nameCellRenderer = new CellRendererText();
treeView.AppendColumn("Name", nameCellRenderer);
treeView.Columns[0].SetCellDataFunc(checkboxCellRenderer, new TreeCellDataFunc(RenderCheckBox));
treeView.Columns[1].SetCellDataFunc(nameCellRenderer, new TreeCellDataFunc(RenderName));
}
示例3: RegexToolkitWidget
public RegexToolkitWidget ()
{
this.Build ();
optionsStore = new ListStore (typeof(bool), typeof(string), typeof(Options));
resultStore = new Gtk.TreeStore (typeof(string), typeof(string), typeof(int), typeof(int));
FillOptionsBox ();
this.entryRegEx.Changed += UpdateStartButtonSensitivity;
this.inputTextview.Buffer.Changed += UpdateStartButtonSensitivity;
SetFindMode (true);
var cellRendText = new CellRendererText ();
cellRendText.Ellipsize = Pango.EllipsizeMode.End;
this.optionsTreeview.Model = this.optionsStore;
this.optionsTreeview.HeadersVisible = false;
CellRendererToggle cellRendToggle = new CellRendererToggle ();
cellRendToggle.Toggled += new ToggledHandler (OptionToggled);
cellRendToggle.Activatable = true;
this.optionsTreeview.AppendColumn ("", cellRendToggle, "active", 0);
this.optionsTreeview.AppendColumn ("", cellRendText, "text", 1);
this.resultsTreeview.Model = this.resultStore;
this.resultsTreeview.HeadersVisible = false;
var col = new TreeViewColumn ();
this.resultsTreeview.AppendColumn (col);
var pix = new CellRendererImage ();
col.PackStart (pix, false);
col.AddAttribute (pix, "stock_id", 0);
col.PackStart (cellRendText, true);
col.AddAttribute (cellRendText, "text", 1);
this.resultsTreeview.RowActivated += delegate(object sender, RowActivatedArgs e) {
Gtk.TreeIter iter;
if (resultStore.GetIter (out iter, e.Path)) {
int index = (int)resultStore.GetValue (iter, 2);
int length = (int)resultStore.GetValue (iter, 3);
if (index >= 0) {
this.inputTextview.Buffer.SelectRange (this.inputTextview.Buffer.GetIterAtOffset (index),
this.inputTextview.Buffer.GetIterAtOffset (index + length));
} else {
this.inputTextview.Buffer.SelectRange (this.inputTextview.Buffer.GetIterAtOffset (0), this.inputTextview.Buffer.GetIterAtOffset (0));
}
}
};
this.entryReplace.Sensitive = this.checkbuttonReplace.Active = false;
this.entryReplace.Changed += delegate {
UpdateRegex ();
};
this.checkbuttonReplace.Toggled += delegate {
this.entryReplace.Sensitive = this.checkbuttonReplace.Active;
UpdateRegex ();
};
this.expandMatches.Toggled += delegate {
UpdateRegex ();
};
this.vbox4.WidthRequest = 380;
this.scrolledwindow5.HeightRequest = 150;
this.scrolledwindow1.HeightRequest = 150;
Show ();
}
示例4: RegexToolkitWidget
public RegexToolkitWidget ()
{
this.Build ();
optionsStore = new ListStore (typeof(bool), typeof(string), typeof(Options));
resultStore = new Gtk.TreeStore (typeof(string), typeof(string), typeof(int), typeof(int));
FillOptionsBox ();
this.buttonStart.Sensitive = false;
this.entryRegEx.Changed += UpdateStartButtonSensitivity;
this.inputTextview.Buffer.Changed += UpdateStartButtonSensitivity;
this.buttonStart.Clicked += delegate {
if (regexThread != null && regexThread.IsAlive) {
regexThread.Abort ();
regexThread.Join ();
SetButtonStart (GettextCatalog.GetString ("Start Regular E_xpression"), "gtk-execute");
regexThread = null;
return;
}
regexThread = new Thread (delegate() {
PerformQuery (inputTextview.Buffer.Text, this.entryRegEx.Text, this.entryReplace.Text, GetOptions ());
});
regexThread.IsBackground = true;
regexThread.Name = "regex thread";
regexThread.Start ();
SetButtonStart (GettextCatalog.GetString ("Stop e_xecution"), "gtk-media-stop");
SetFindMode (!checkbuttonReplace.Active);
};
SetFindMode (true);
var cellRendText = new CellRendererText ();
cellRendText.Ellipsize = Pango.EllipsizeMode.End;
this.optionsTreeview.Model = this.optionsStore;
this.optionsTreeview.HeadersVisible = false;
CellRendererToggle cellRendToggle = new CellRendererToggle ();
cellRendToggle.Toggled += new ToggledHandler (OptionToggled);
cellRendToggle.Activatable = true;
this.optionsTreeview.AppendColumn ("", cellRendToggle, "active", 0);
this.optionsTreeview.AppendColumn ("", cellRendText, "text", 1);
this.resultsTreeview.Model = this.resultStore;
this.resultsTreeview.HeadersVisible = false;
var col = new TreeViewColumn ();
this.resultsTreeview.AppendColumn (col);
var pix = new CellRendererImage ();
col.PackStart (pix, false);
col.AddAttribute (pix, "stock_id", 0);
col.PackStart (cellRendText, true);
col.AddAttribute (cellRendText, "text", 1);
this.resultsTreeview.RowActivated += delegate(object sender, RowActivatedArgs e) {
Gtk.TreeIter iter;
if (resultStore.GetIter (out iter, e.Path)) {
int index = (int)resultStore.GetValue (iter, 2);
int length = (int)resultStore.GetValue (iter, 3);
if (index >= 0) {
this.inputTextview.Buffer.SelectRange (this.inputTextview.Buffer.GetIterAtOffset (index),
this.inputTextview.Buffer.GetIterAtOffset (index + length));
} else {
this.inputTextview.Buffer.SelectRange (this.inputTextview.Buffer.GetIterAtOffset (0), this.inputTextview.Buffer.GetIterAtOffset (0));
}
}
};
this.entryReplace.Sensitive = this.checkbuttonReplace.Active = false;
this.checkbuttonReplace.Toggled += delegate {
this.entryReplace.Sensitive = this.checkbuttonReplace.Active;
};
this.vbox4.WidthRequest = 380;
this.scrolledwindow5.HeightRequest = 150;
this.scrolledwindow1.HeightRequest = 150;
Show ();
}
示例5: RegexToolkitWindow
public RegexToolkitWindow () : base(Gtk.WindowType.Toplevel)
{
this.Build ();
this.TransientFor = IdeApp.Workbench.RootWindow;
optionsStore = new ListStore (typeof(bool), typeof(string), typeof(Options));
resultStore = new Gtk.TreeStore (typeof(string), typeof(string), typeof(int), typeof(int));
FillOptionsBox ();
this.buttonCancel.Clicked += delegate {
this.Destroy ();
};
var isWindows = System.IO.Path.DirectorySeparatorChar == '\\';
this.buttonLibrary.Visible = !isWindows;
this.buttonStart.Sensitive = false;
this.entryRegEx.Changed += UpdateStartButtonSensitivity;
this.inputTextview.Buffer.Changed += UpdateStartButtonSensitivity;
this.buttonStart.Clicked += delegate {
if (regexThread != null && regexThread.IsAlive) {
regexThread.Abort ();
regexThread.Join ();
SetButtonStart (GettextCatalog.GetString ("_Start Regular Expression"), "gtk-media-play");
regexThread = null;
return;
}
regexThread = new Thread (delegate() {
PerformQuery (inputTextview.Buffer.Text, this.entryRegEx.Text, this.entryReplace.Text, GetOptions ());
});
regexThread.IsBackground = true;
regexThread.Name = "regex thread";
regexThread.Start ();
SetButtonStart (GettextCatalog.GetString ("_Stop execution"), "gtk-media-stop");
SetFindMode (!checkbuttonReplace.Active);
};
this.buttonLibrary.Clicked += delegate {
if (regexLib == null) {
regexLib = new RegexLibraryWindow ();
regexLib.TransientFor = this;
regexLib.Destroyed += delegate {
regexLib = null;
};
regexLib.Show ();
}
};
SetFindMode (true);
var cellRendText = new CellRendererText ();
cellRendText.Ellipsize = Pango.EllipsizeMode.End;
var pix = new CellRendererPixbuf ();
this.optionsTreeview.Model = this.optionsStore;
this.optionsTreeview.HeadersVisible = false;
CellRendererToggle cellRendToggle = new CellRendererToggle ();
cellRendToggle.Toggled += new ToggledHandler (OptionToggled);
cellRendToggle.Activatable = true;
this.optionsTreeview.AppendColumn ("", cellRendToggle, "active", 0);
this.optionsTreeview.AppendColumn ("", cellRendText, "text", 1);
this.resultsTreeview.Model = this.resultStore;
this.resultsTreeview.HeadersVisible = false;
var col = new TreeViewColumn ();
this.resultsTreeview.AppendColumn (col);
col.PackStart (pix, false);
col.AddAttribute (pix, "stock_id", 0);
col.PackStart (cellRendText, true);
col.AddAttribute (cellRendText, "text", 1);
this.resultsTreeview.RowActivated += delegate(object sender, RowActivatedArgs e) {
Gtk.TreeIter iter;
if (resultStore.GetIter (out iter, e.Path)) {
int index = (int)resultStore.GetValue (iter, 2);
int length = (int)resultStore.GetValue (iter, 3);
if (index >= 0) {
this.inputTextview.Buffer.SelectRange (this.inputTextview.Buffer.GetIterAtOffset (index),
this.inputTextview.Buffer.GetIterAtOffset (index + length));
} else {
this.inputTextview.Buffer.SelectRange (this.inputTextview.Buffer.GetIterAtOffset (0), this.inputTextview.Buffer.GetIterAtOffset (0));
}
}
};
elementsStore = new Gtk.TreeStore (typeof(string), typeof(string), typeof(string), typeof(string));
this.elementsTreeview.Model = this.elementsStore;
this.elementsTreeview.HeadersVisible = false;
this.elementsTreeview.Selection.Mode = SelectionMode.Browse;
col = new TreeViewColumn ();
this.elementsTreeview.AppendColumn (col);
col.PackStart (pix, false);
col.AddAttribute (pix, "stock_id", 0);
col.PackStart (cellRendText, true);
//.........这里部分代码省略.........
示例6: AddinView
public AddinView()
{
var hbox = new HBox () { Spacing = 6 };
var filter_label = new Label (Catalog.GetString ("Show:"));
var filter_combo = new ComboBoxText ();
filter_combo.AppendText (Catalog.GetString ("All"));
filter_combo.AppendText (Catalog.GetString ("Enabled"));
filter_combo.AppendText (Catalog.GetString ("Not Enabled"));
filter_combo.Active = 0;
var search_label = new Label (Catalog.GetString ("Search:"));
var search_entry = new Banshee.Widgets.SearchEntry () {
WidthRequest = 160,
Visible = true,
Ready = true
};
hbox.PackStart (filter_label, false, false, 0);
hbox.PackStart (filter_combo, false, false, 0);
hbox.PackEnd (search_entry, false, false, 0);
hbox.PackEnd (search_label, false, false, 0);
var model = new TreeStore (typeof(bool), typeof(bool), typeof (string), typeof (Addin));
var addins = AddinManager.Registry.GetAddins ().Where (a => { return
a.Name != a.Id && a.Description != null &&
!String.IsNullOrEmpty (a.Description.Category) && !a.Description.Category.StartsWith ("required:") &&
(!a.Description.Category.Contains ("Debug") || ApplicationContext.Debugging);
});
var categorized_addins = addins.GroupBy<Addin, string> (a => a.Description.Category)
.Select (c => new {
Addins = c.OrderBy (a => Catalog.GetString (a.Name)).ToList (),
Name = c.Key,
NameLocalized = Catalog.GetString (c.Key) })
.OrderBy (c => c.NameLocalized)
.ToList ();
tree_view = new TreeView () {
FixedHeightMode = false,
HeadersVisible = false,
SearchColumn = 1,
RulesHint = true,
Model = model
};
var update_model = new System.Action (() => {
string search = search_entry.Query;
bool? enabled = filter_combo.Active > 0 ? (bool?) (filter_combo.Active == 1 ? true : false) : null;
model.Clear ();
foreach (var cat in categorized_addins) {
var cat_iter = model.AppendValues (false, false, String.Format ("<b>{0}</b>", GLib.Markup.EscapeText (cat.NameLocalized)), null);
bool any = false;
foreach (var a in cat.Addins.Matching (search)) {
if (enabled == null || (a.Enabled == enabled.Value)) {
model.AppendValues (cat_iter, true,
a.Enabled,
String.Format (
"<b>{0}</b>\n<small>{1}</small>",
GLib.Markup.EscapeText (Catalog.GetString (a.Name)),
GLib.Markup.EscapeText (Catalog.GetString (a.Description.Description))),
a
);
any = true;
}
}
if (!any) {
model.Remove (ref cat_iter);
}
}
tree_view.ExpandAll ();
});
var txt_cell = new CellRendererText () { WrapMode = Pango.WrapMode.Word };
tree_view.AppendColumn ("Name", txt_cell , "markup", Columns.Name);
var check_cell = new CellRendererToggle () { Activatable = true };
tree_view.AppendColumn ("Enable", check_cell, "visible", Columns.IsAddin, "active", Columns.IsEnabled);
check_cell.Toggled += (o, a) => {
TreeIter iter;
if (model.GetIter (out iter, new TreePath (a.Path))) {
var addin = model.GetValue (iter, 3) as Addin;
bool enabled = (bool) model.GetValue (iter, 1);
addin.Enabled = !enabled;
model.SetValue (iter, 1, addin.Enabled);
model.Foreach (delegate (ITreeModel current_model, TreePath path, TreeIter current_iter) {
var an = current_model.GetValue (current_iter, 3) as Addin;
if (an != null) {
current_model.SetValue (current_iter, 1, an.Enabled);
}
return false;
});
}
};
update_model ();
search_entry.Changed += (o, a) => update_model ();
filter_combo.Changed += (o, a) => update_model ();
//.........这里部分代码省略.........
示例7: CreateTreeView
void CreateTreeView()
{
//CreateColumns
TreeViewColumn col = new TreeViewColumn ();
CellRendererText cell = new CellRendererText ();
cell.Editable = true;
col.Title = "Nodes";
col.PackStart (cell, true);
col.AddAttribute (cell, "text", 0);
treeview1.AppendColumn (col);
TreeViewColumn col2 = new TreeViewColumn ();
CellRendererText cell2 = new CellRendererText ();
cell2.Editable = true;
col2.Title = "Url";
col2.PackStart (cell2, true);
col2.AddAttribute (cell2, "text", 1);
col2.Visible = false;
treeview1.AppendColumn (col2);
treeview1.HeadersVisible = false;
//Add Store
treestore = new TreeStore (typeof(string), typeof(string));
treeview1.Model = treestore;
cell.Edited += (o, args) => {
Gtk.TreeIter iter;
treestore.GetIter (out iter, new Gtk.TreePath (args.Path));
String newvalue = (String)treestore.GetValue (iter, 0);
Console.WriteLine (newvalue);
treestore.SetValue (iter, 0, args.NewText);
};
cell2.Edited += (o, args) => {
Gtk.TreeIter iter;
treestore.GetIter (out iter, new Gtk.TreePath (args.Path));
String newvalue = (String)treestore.GetValue (iter, 1);
Console.WriteLine (newvalue);
treestore.SetValue (iter, 1, args.NewText);
};
TargetEntry[] ten = new TargetEntry[]{ new TargetEntry ("tree", TargetFlags.App, 1) };
treeview1.EnableModelDragDest (ten, Gdk.DragAction.Move);
treeview1.EnableModelDragSource (Gdk.ModifierType.Button1Mask, ten, Gdk.DragAction.Move);
ShowAll ();
treeview1.DragDataGet += (o, args) => {
TreeModel model;
((TreeSelection)treeview1.Selection).GetSelected (out model, out SourceIter);
args.SelectionData.Set (args.SelectionData.Target, 8, Encoding.UTF8.GetBytes (model.GetValue (SourceIter, 0).ToString ()));
};
treeview1.DragDataReceived += Tree_DragDataReceived;
treeview1.ButtonPressEvent += Tree_ButtonPressEvent;
}
示例8: NoteRenameDialog
public NoteRenameDialog (IList<Note> notes, string oldTitle, Note renamedNote) :
base (Catalog.GetString ("Rename Note Links?"), renamedNote.Window, 0)
{
this.DefaultResponse = ResponseType.Cancel;
this.BorderWidth = 10;
var renameButton = (Button)
AddButton (Catalog.GetString ("_Rename Links"),
ResponseType.Yes);
var dontRenameButton = (Button)
AddButton (Catalog.GetString ("_Don't Rename Links"),
ResponseType.No);
this.notes = notes;
notesModel = new Gtk.TreeStore (typeof (bool), typeof (string), typeof (Note));
foreach (var note in notes)
notesModel.AppendValues (true, note.Title, note);
var labelText = Catalog.GetString ("Rename links in other notes from \"<span underline=\"single\">{0}</span>\" " +
"to \"<span underline=\"single\">{1}</span>\"?\n\n" +
"If you do not rename the links, " +
"they will no longer link to anything.");
var label = new Label ();
label.UseMarkup = true;
label.Markup = String.Format (labelText,
GLib.Markup.EscapeText (oldTitle),
GLib.Markup.EscapeText (renamedNote.Title));
label.LineWrap = true;
ContentArea.PackStart (label, false, true, 5);
var notesView = new TreeView (notesModel);
notesView.SetSizeRequest (-1, 200);
var toggleCell = new CellRendererToggle ();
toggleCell.Activatable = true;
var column = new TreeViewColumn (Catalog.GetString ("Rename Links"),
toggleCell, "active", 0);
column.SortColumnId = 0;
column.Resizable = true;
notesView.AppendColumn (column);
toggleCell.Toggled += (o, args) => {
TreeIter iter;
if (!notesModel.GetIterFromString (out iter, args.Path))
return;
bool val = (bool) notesModel.GetValue (iter, 0);
notesModel.SetValue (iter, 0, !val);
};
column = new TreeViewColumn (Catalog.GetString ("Note Title"),
new CellRendererText (), "text", 1);
column.SortColumnId = 1;
column.Resizable = true;
notesView.AppendColumn (column);
notesView.RowActivated += (o, args) => {
TreeIter iter;
if (!notesModel.GetIter (out iter, args.Path))
return;
Note note = (Note) notesModel.GetValue (iter, 2);
if (note != null) {
note.Window.Present ();
NoteFindBar find = note.Window.Find;
find.ShowAll ();
find.Visible = true;
find.SearchText = "\"" + oldTitle + "\"";
}
};
var notesBox = new VBox (false, 5);
var selectAllButton = new Button ();
// Translators: This button causes all notes in the list to be selected
selectAllButton.Label = Catalog.GetString ("Select All");
selectAllButton.Clicked += (o, e) => {
notesModel.Foreach ((model, path, iter) => {
notesModel.SetValue (iter, 0, true);
return false;
});
};
var selectNoneButton = new Button ();
// Translators: This button causes all notes in the list to be unselected
selectNoneButton.Label = Catalog.GetString ("Select None");
selectNoneButton.Clicked += (o, e) => {
notesModel.Foreach ((model, path, iter) => {
notesModel.SetValue (iter, 0, false);
return false;
});
};
var notesButtonBox = new HButtonBox ();
notesButtonBox.Add (selectNoneButton);
notesButtonBox.Add (selectAllButton);
notesButtonBox.Spacing = 5;
notesButtonBox.LayoutStyle = ButtonBoxStyle.End;
var notesScroll = new ScrolledWindow ();
notesScroll.Add (notesView);
notesBox.PackStart (notesScroll, true, true, 0);
notesBox.PackStart (notesButtonBox, false, true, 0);
var advancedExpander = new Expander (Catalog.GetString ("Ad_vanced"));
var expandBox = new VBox ();
expandBox.PackStart (notesBox, true, true, 0);
alwaysShowDlgRadio = new RadioButton (Catalog.GetString ("Always show this _window"));
alwaysShowDlgRadio.Clicked += (o, e) => {
//.........这里部分代码省略.........