本文整理汇总了C#中Gtk.ListStore.Foreach方法的典型用法代码示例。如果您正苦于以下问题:C# ListStore.Foreach方法的具体用法?C# ListStore.Foreach怎么用?C# ListStore.Foreach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.ListStore
的用法示例。
在下文中一共展示了ListStore.Foreach方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListStoreToOSD
OSDArray ListStoreToOSD(ListStore list)
{
OSDArray ret = new OSDArray();
list.Foreach((model, path, iter) =>
{
var item = model.GetValue(iter, 0) as FilterItem;
if (null != item)
{
ret.Add(item.ToOSD());
}
return false;
});
return ret;
}
示例2: GenerateNotebookPages
//.........这里部分代码省略.........
bool showAll = false;
tvList.ButtonReleaseEvent += delegate(object o, ButtonReleaseEventArgs args){
if (args.Event.Button == 3) {
TreeSelection ts = tvList.Selection;
Gtk.TreePath[] selRow = ts.GetSelectedRows();
if(selRow.Length<1){
TreeIter tiFirst= new TreeIter();
ls.GetIterFirst(out tiFirst);
tvList.Selection.SelectIter(tiFirst);
selRow = ts.GetSelectedRows();
}
if(selRow.Length<1) return;
Gtk.TreePath tp = selRow[0];
TreeIter ti = new TreeIter();
ls.GetIter(out ti,tp);
CombinePublish combinePublish= (CombinePublish)ls.GetValue(ti,2);
if(combinePublish!=null){
Menu popupMenu = new Menu();
if(!showAll){
MenuItem miShowDenied = new MenuItem( MainClass.Languages.Translate("show_denied" ));
miShowDenied.Activated+= delegate(object sender, EventArgs e) {
// odoberem zakazane, ktore sa zobrazuju kedze su zaceknute na publish
List<TreeIter> lst= new List<TreeIter>();
ls.Foreach((model, path, iterr) => {
bool cp =(bool) ls.GetValue(iterr,4);
bool selected =(bool) ls.GetValue(iterr,0);
if(!cp && selected){
lst.Add(iterr);
}
return false;
});
foreach(TreeIter ti2 in lst){
TreeIter ti3 =ti2;
ls.Remove(ref ti3);
}
// pridam zakazane
if( (lcpDennied==null) || (lcpDennied.Count<1))
return;
foreach (CombinePublish cp in lcpDennied){
ls.AppendValues(cp.IsSelected,cp.ProjectName,cp,cp.ProjectName,false);
}
showAll = true;
};
popupMenu.Append(miShowDenied);
} else {
MenuItem miHideDenied = new MenuItem( MainClass.Languages.Translate("hide_denied" ));
miHideDenied.Activated+= delegate(object sender, EventArgs e) {
List<TreeIter> lst= new List<TreeIter>();
ls.Foreach((model, path, iterr) => {
bool cp =(bool) ls.GetValue(iterr,4);
示例3: SetAllToggles
void SetAllToggles(bool on, ListStore store)
{
if (null == store) return;
store.Foreach((model, path, iter) =>
{
var item = model.GetValue(iter, 0) as FilterItem;
if (null != item)
{
item.Enabled = on;
model.SetValue(iter, 0, item);
}
return false;
});
}
示例4: updateTime
private void updateTime(ref ListStore ls)
{
ls.Foreach(new TreeModelForeachFunc(delegate(TreeModel model, TreePath path, TreeIter iter) {
long ticks = DateTime.Now.Ticks - (long)model.GetValue(iter,5);
TimeSpan t = TimeSpan.FromTicks( ticks );
string pt = "";
if(t.Hours < 1){
pt = string.Format("{0:#0}分前", t.Minutes);
}else{
pt = string.Format("{0:#0}時間{1:#0}分前",
t.Hours,
t.Minutes);
}
model.SetValue(iter, 3, pt);
return false;
}));
}
示例5: OnButtonPressed
void OnButtonPressed(object sender, Gtk.ButtonPressEventArgs args)
{
switch (args.Event.Button) {
case 3: // third mouse button (right-click)
clickedTask = null;
Gtk.TreeView tv = sender as Gtk.TreeView;
if (tv == null)
return;
Gtk.TreeModel model = tv.Model;
Gtk.TreeIter iter;
Gtk.TreePath path;
Gtk.TreeViewColumn column = null;
if (!tv.GetPathAtPos ((int) args.Event.X,
(int) args.Event.Y, out path, out column))
return;
if (!model.GetIter (out iter, path))
return;
clickedTask = model.GetValue (iter, 0) as ITask;
if (clickedTask == null)
return;
Menu popupMenu = new Menu ();
ImageMenuItem item;
item = new ImageMenuItem (Catalog.GetString ("_Notes..."));
item.Image = new Gtk.Image (noteIcon);
item.Activated += OnShowTaskNotes;
popupMenu.Add (item);
popupMenu.Add (new SeparatorMenuItem ());
item = new ImageMenuItem (Catalog.GetString ("_Delete task"));
item.Image = new Gtk.Image(Gtk.Stock.Delete, IconSize.Menu);
item.Activated += OnDeleteTask;
popupMenu.Add (item);
item = new ImageMenuItem(Catalog.GetString ("_Edit task"));
item.Image = new Gtk.Image(Gtk.Stock.Edit, IconSize.Menu);
item.Activated += OnEditTask;
popupMenu.Add (item);
/*
* Depending on the currently selected task's taskList, we create a context popup
* here in order to enable changing taskLists. The list of available taskLists
* is pre-filtered as to not contain the current taskList and the AllTaskList.
*/
var filteredTaskLists = new ListStore (typeof (ITaskList));
foreach (var cat in application.BackendManager.TaskLists) {
if (cat != null && !(cat.ListType == TaskListType.Smart)
&& !cat.Contains (clickedTask))
filteredTaskLists.AppendValues (cat);
}
// The taskLists submenu is only created in case we actually provide at least one taskList.
if (filteredTaskLists.GetIterFirst(out iter))
{
Menu taskListMenu = new Menu();
TaskListMenuItem taskListItem;
filteredTaskLists.Foreach(delegate(TreeModel t, TreePath p, TreeIter i) {
taskListItem = new TaskListMenuItem((ITaskList)t.GetValue(i, 0));
taskListItem.Activated += OnChangeTaskList;
taskListMenu.Add(taskListItem);
return false;
});
// TODO Needs translation.
item = new ImageMenuItem(Catalog.GetString("_Change list"));
item.Image = new Gtk.Image(Gtk.Stock.Convert, IconSize.Menu);
item.Submenu = taskListMenu;
popupMenu.Add(item);
}
popupMenu.ShowAll();
popupMenu.Popup ();
// Logger.Debug ("Right clicked on task: " + task.Name);
break;
}
}