Exemplo n.º 1
0
        // FIXME: We might want to change some names in this folder...
        // Component, ComponentFolder and ComponentView should maybe reflect
        // that they are actually not the actual "components" but only a
        // GUI model of them. But because we don't have the real implementation
        // of the components we really don't know how we want to structure it
        // so these classes might as well become the "real" ones in the end. Who knows...

        public HierarchyView(HierarchyComponent hierarchy)
        {
            TreeView = new TreeView();
            TreeView.HeadersVisible = false;
            Column       = new TreeViewColumn();
            Column.Title = "Hierarchy";

            var text = new CellRendererText();
            var pix  = new CellRendererPixbuf();

            try
            {
                pix.Icon = IconTheme.Default.LoadIcon("x-office-document", 16, 0);
            }
            catch (GLib.GException gex)
            {
                Console.WriteLine(gex);
            }

            Column.PackStart(pix, false);
            Column.PackStart(text, false);
            Column.SetCellDataFunc(text, GetTextCellData);
            Column.SetCellDataFunc(pix, GetIconCellData);
            Column.Expand = true;
            TreeView.AppendColumn(Column);

            TreeView.Model = BuildStore(hierarchy);
        }
Exemplo n.º 2
0
        private TreeStore BuildStore(HierarchyComponent item)
        {
            TreeStore store = new TreeStore(typeof(IHierarchyViewItem));
            var       iter  = store.AppendValues(item);

            if (item.Children.Count > 0)
            {
                AddChildren(store, iter, item.Children);
            }
            return(store);