本文整理汇总了C#中Gtk.ListStore.IterNthChild方法的典型用法代码示例。如果您正苦于以下问题:C# ListStore.IterNthChild方法的具体用法?C# ListStore.IterNthChild怎么用?C# ListStore.IterNthChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.ListStore
的用法示例。
在下文中一共展示了ListStore.IterNthChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildCombo
private Widget BuildCombo(PipelineVariable variable)
{
ListStore model = new ListStore(typeof(string), typeof(string));
PipelineVariableComboBox box = new PipelineVariableComboBox(variable, model);
TreeIter active_iter = TreeIter.Zero;
box.Changed += OnComboChanged;
if(variable.PossibleValuesCount > 0) {
foreach(string key in variable.PossibleValuesKeys) {
TreeIter iter = ComboAppend(model, variable, variable.PossibleValues[key].Display, key);
if(variable.CurrentValue == key || (active_iter.Equals(TreeIter.Zero) &&
variable.DefaultValue == key)) {
active_iter = iter;
}
}
} else {
double min = variable.MinValue;
double max = variable.MaxValue;
double step = variable.StepValue;
double current = min;
for(; current <= max; current += step) {
ComboAppend(model, variable, current.ToString(), current.ToString());
}
}
if(active_iter.Equals(TreeIter.Zero)) {
for(int i = 0, n = model.IterNChildren(); i < n; i++) {
TreeIter iter;
if(model.IterNthChild(out iter, i)) {
string value = (string)model.GetValue(iter, 1);
if(value == variable.CurrentValue) {
active_iter = iter;
break;
}
}
}
}
CellRendererText text_renderer = new CellRendererText();
box.PackStart(text_renderer, true);
box.AddAttribute(text_renderer, "text", 0);
box.Model = model;
if(active_iter.Equals(TreeIter.Zero)) {
if(model.IterNthChild(out active_iter, 0)) {
box.SetActiveIter(active_iter);
}
} else {
box.SetActiveIter(active_iter);
}
return box;
}