本文整理汇总了C#中TreePosition类的典型用法代码示例。如果您正苦于以下问题:C# TreePosition类的具体用法?C# TreePosition怎么用?C# TreePosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreePosition类属于命名空间,在下文中一共展示了TreePosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetParent
public TreePosition GetParent (TreePosition pos)
{
var node = (TreeStoreNode) pos;
if (node.Parent == null)
return null;
return node.Parent;
}
示例2: GetIterPos
IterPos GetIterPos (TreePosition pos)
{
IterPos tpos = (IterPos) pos;
if (tpos != null && tpos.Version != version) {
tpos.LastChildIndex = -1;
tpos.ChildrenCount = -1;
}
return tpos;
}
示例3: GetChild
public TreePosition GetChild (TreePosition pos, int index)
{
var node = (TreeStoreNode) pos;
var list = GetListForNode (node);
if (list.Count == 0 || index >= list.Count)
return null;
return list [index];
}
示例4: AddChild
public TreePosition AddChild(TreePosition pos)
{
IterPos tpos = (IterPos)pos;
Gtk.TreeIter it;
if (pos == null)
it = Tree.AppendNode ();
else
it = Tree.AppendNode (tpos.Iter);
return new IterPos (it);
}
示例5: AddChild
public TreePosition AddChild(TreePosition pos)
{
version++;
IterPos tpos = GetIterPos (pos);
Gtk.TreeIter it;
if (pos == null)
it = Tree.AppendNode ();
else
it = Tree.AppendNode (tpos.Iter);
return new IterPos (version, it);
}
示例6: IterFromNode
Gtk.TreeIter IterFromNode (TreePosition node)
{
GCHandle gch;
if (!handleHash.TryGetValue (node, out gch)) {
gch = GCHandle.Alloc (node);
handleHash [node] = gch;
nodeHash [gch] = node;
}
Gtk.TreeIter result = Gtk.TreeIter.Zero;
result.UserData = (IntPtr)gch;
return result;
}
示例7: AddChild
public TreePosition AddChild(TreePosition pos)
{
version++;
IterPos tpos = GetIterPos (pos);
Gtk.TreeIter it;
if (pos == null)
it = Tree.AppendNode ();
else
it = Tree.AppendNode (tpos.Iter);
var node = new IterPos (version, it);
if (NodeInserted != null)
NodeInserted (this, new TreeNodeEventArgs (node));
return node;
}
示例8: SaveChildren
void SaveChildren (List<NodeInfo> info, TreePosition it)
{
int num = tree.DataSource.GetChildrenCount (it);
for (int n=0; n<num; n++) {
var child = tree.DataSource.GetChild (it, n);
object id = tree.DataSource.GetValue (child, idColumn);
NodeInfo ni = new NodeInfo ();
ni.Id = id;
ni.Expanded = tree.IsRowExpanded (child);
ni.Selected = tree.IsRowSelected (child);
info.Add (ni);
if (tree.DataSource.GetChildrenCount (child) > 0) {
ni.ChildInfo = new List<NodeInfo> ();
SaveChildren (ni.ChildInfo, child);
}
}
}
示例9: Load
void Load (List<NodeInfo> info, TreePosition it)
{
bool oneSelected = false;
var infoCopy = new List<NodeInfo> (info);
Dictionary<NodeInfo,TreePosition> nodes = new Dictionary<NodeInfo, TreePosition> ();
int num = tree.DataSource.GetChildrenCount (it);
for (int n=0; n<num; n++) {
var child = tree.DataSource.GetChild (it, n);
object id = tree.DataSource.GetValue (child, idColumn);
NodeInfo ni = ExtractNodeInfo (info, id);
if (ni != null) {
nodes [ni] = child;
if (ni.Expanded)
tree.ExpandRow (child, false);
else
tree.CollapseRow (child);
if (ni.Selected) {
oneSelected = true;
tree.SelectRow (child);
}
else
tree.UnselectRow (child);
if (ni.ChildInfo != null)
Load (ni.ChildInfo, child);
}
}
// If this tree level had a selected node and this node has been deleted, then
// try to select and adjacent node
if (!oneSelected) {
// 'info' contains the nodes that have not been inserted
if (info.Any (n => n.Selected)) {
NodeInfo an = FindAdjacentNode (infoCopy, nodes, info[0]);
if (an != null) {
it = nodes [an];
tree.SelectRow (it);
}
}
}
}
示例10: GetChildrenCount
public int GetChildrenCount(TreePosition pos)
{
if (pos == null)
return Tree.IterNChildren ();
IterPos tpos = GetIterPos (pos);
if (tpos.ChildrenCount != -1)
return tpos.ChildrenCount;
return tpos.ChildrenCount = Tree.IterNChildren (tpos.Iter);
}
示例11: SetValue
public void SetValue(TreePosition pos, int column, object value)
{
IterPos tpos = GetIterPos (pos);
SetValue (tpos.Iter, column, value);
if (NodeChanged != null)
NodeChanged (this, new TreeNodeEventArgs (pos));
}
示例12: CollapseRow
public void CollapseRow(TreePosition pos)
{
Widget.CollapseRow (Widget.Model.GetPath (((IterPos)pos).Iter));
}
示例13: ScrollToRow
public void ScrollToRow(TreePosition pos)
{
Widget.ScrollToCell (Widget.Model.GetPath (((IterPos)pos).Iter), Widget.Columns[0], false, 0, 0);
}
示例14: IsRowExpanded
public bool IsRowExpanded(TreePosition pos)
{
return Widget.GetRowExpanded (Widget.Model.GetPath (((IterPos)pos).Iter));
}
示例15: ExpandToRow
public void ExpandToRow(TreePosition pos)
{
Widget.ExpandToPath (Widget.Model.GetPath (((IterPos)pos).Iter));
}