Example #1
0
        private void RebuildPackTree(string[] filenames)
        {
            packStore.Clear();
            folderStore.Clear();
            currentFolder = TreeIter.Zero;

            filenames
                .Where((filename) => filename != null && filename.Length > 0).ToList()
                .ForEach((filename) => {
                        DCP.Item fileItem = new DCP.Item();
                        fileItem.Name = System.IO.Path.GetFileName(filename);
                        fileItem.Directory = filename.Replace(fileItem.Name, "");

                        List<string> folders = fileItem.Directory.Split('\\')
                            .Where((folder) => folder != null && folder.Length > 0).ToList();

                        TreeIter lastFolderIter = TreeIter.Zero;
                        DCP.Item lastFolderItem = new DCP.Item();
                        lastFolderItem.IsFolder = true;
                        folders.ForEach((folder) => {
                            DCP.Item folderItem = new DCP.Item();
                            folderItem.Name = folder;
                            folderItem.Directory = lastFolderItem.FullName;
                            folderItem.IsFolder = true;

                            lastFolderIter = AppendItem(lastFolderIter, folderItem);
                            lastFolderItem = folderItem;
                        });

                        AppendItem(lastFolderIter, fileItem);
                    });

            RefreshFolderView(currentFolder);
            TreeIter selected;
            if (folderStore.GetIterFirst(out selected))
                packTreeView.SelectAndFocus(selected);
        }
Example #2
0
        private void RefreshFolderView(TreeIter parent)
        {
            folderStore.Clear();

            TreeIter child;
            if (TreeIter.Zero.Equals(parent))
                packStore.GetIterFirst(out child);
            else {
                packStore.IterChildren(out child, parent);

                DCP.Item root = new DCP.Item(true);
                folderStore.AppendValues(root.IsFolder ? folderIcon : fileIcon, root.Name, root);
            }

            if (!TreeIter.Zero.Equals(child)) {
                do {
                    DCP.Item item = packStore.GetValue(child, 0) as DCP.Item;

                    folderStore.AppendValues(item.IsFolder ? folderIcon : fileIcon, item.Name, item);
                } while(packStore.IterNext(ref child));
            }
        }
Example #3
0
 private DCP.Item NewItem(TreeIter parent, string path)
 {
     DCP.Item item = new DCP.Item(path);
     if (!TreeIter.Zero.Equals(parent)) {
         DCP.Item parentItem = packStore.GetValue(parent, 0) as DCP.Item;
         item.Directory = parentItem.FullName;
     }
     return item;
 }