示例#1
0
 /// <summary>
 /// Create a data source adaptor that knows how to build a tree structure
 /// </summary>
 /// <param name="tlv"></param>
 public TreeDataSourceAdapter(DataTreeListView tlv)
     : base(tlv)
 {
     this.treeListView = tlv;
     this.treeListView.CanExpandGetter = delegate(object model) { return(this.CalculateHasChildren(model)); };
     this.treeListView.ChildrenGetter  = delegate(object model) { return(this.CalculateChildren(model)); };
 }
示例#2
0
 /// <summary>
 /// Create a data source adaptor that knows how to build a tree structure
 /// </summary>
 /// <param name="tlv"></param>
 public TreeDataSourceAdapter(DataTreeListView tlv)
     : base(tlv) {
     this.treeListView = tlv;
     this.treeListView.CanExpandGetter = delegate(object model) { return this.CalculateHasChildren(model); };
     this.treeListView.ChildrenGetter = delegate(object model) { return this.CalculateChildren(model); };
 }
示例#3
0
文件: main.cs 项目: MiLO83/higanui
        private void populateDetails( FileInfo[] fs, DataTreeListView l )
        {
            List<Roms> roms = new List<Roms>();
            int index=1;

            foreach ( FileInfo file in fs )
            { //Console.WriteLine( file.FullName );
                if (file.Extension.Length < 1) break;
                string ext = file.Extension.Substring( 1, file.Extension.Length - 1 );
                switch (file.Extension.ToLower() )
                {
                    case ".sfc":
                    case ".smc":
                    case ".nes":
                    case ".gb":
                    case ".gba":
                    case ".gbc":
                        if ( l.Tag.ToString().IndexOf( "{"+ext.ToUpper()+"}" ) != -1 )//tag will hold the data that accepted. Can be multip extentions
                            roms.Add( new Roms { Tree = false, Id = index, ParentId = 0, Title = file.Name.Substring( 0, file.Name.LastIndexOf( "." ) ),FullPath = file.FullName, Image = "...", Company = "Nintendo", Language = "USA", Notes = "......." } );
                    break;

                    case ".zip":
                    case ".rar":
                    case ".7z":
                    SevenZipExtractor arc = new SevenZipExtractor( file.FullName );
                    if ( arc.ArchiveFileNames.Count > 1 && ( skipGBABloatToolStripMenuItem.CheckState == CheckState.Checked && file.Name.IndexOf( "Domain (" ) == -1 && file.Name.IndexOf( "Emulation (" ) == -1 ) )//add from archives
                        {//multiple files
                            //root
                            roms.Add( new Roms {Tree = true, Id = index, ParentId = 0,  Title = file.Name.Substring( 0, file.Name.LastIndexOf( "." )), FullPath = file.FullName, Image = "...", Company = "Nintendo", Language = "USA", Notes = "......." } );
                            //children
                            List <string> files = new List<string>();
                            for ( int i=0; i < arc.ArchiveFileNames.Count; i++)
                                if ( l.Tag.ToString().IndexOf( "{" + arc.ArchiveFileNames[ i ].Substring( arc.ArchiveFileNames[ i ].LastIndexOf( "." ) + 1 ).ToUpper() + "}" ) != -1 )//tag will hold the data that accepted. Can be multip extentions
                                    roms.Add( new Roms { Tree = false, Id = index, ParentId = index, Title = arc.ArchiveFileNames[i].Substring( 0, arc.ArchiveFileNames[i].LastIndexOf( "." )), FullPath = file.FullName, Image = "...", Company = "Nintendo", Language = "USA", Notes = "......." } );

                        }
                        else
                        {//single fle
                            if ( l.Tag.ToString().IndexOf( "{" + arc.ArchiveFileNames[ 0 ].Substring( arc.ArchiveFileNames[ 0 ].LastIndexOf( "." ) + 1 ).ToUpper() + "}" ) != -1 )//tag will hold the data that accepted. Can be multip extentions
                                roms.Add( new Roms {Tree = false, Id = index, ParentId = 0,  Title =arc.ArchiveFileNames[0].Substring( 0, arc.ArchiveFileNames[0].LastIndexOf( "." )),  FullPath = file.FullName, Image = "...", Company = "Nintendo", Language = "USA", Notes = "......." } );

                        }
                    break;
                }

                index++;
            }
            l.CanExpandGetter = delegate(object x) {var r = ( Roms ) x; return r.Tree;};
            l.ParentKeyAspectName = "ParentId";
            l.KeyAspectName = "Id";
            l.RootKeyValue = 0;
            l.ShowKeyColumns = false;
            l.DataSource = roms;
            //defult to autosize. user can override this.
            l.AutoResizeColumn( 0, ColumnHeaderAutoResizeStyle.HeaderSize );
            l.AutoResizeColumn( 1, ColumnHeaderAutoResizeStyle.HeaderSize );
            l.AutoResizeColumn( 2, ColumnHeaderAutoResizeStyle.HeaderSize );
            l.AutoResizeColumn( 3, ColumnHeaderAutoResizeStyle.HeaderSize );
            l.AutoResizeColumn( 4, ColumnHeaderAutoResizeStyle.HeaderSize );

            l.Columns[ 6 ].Dispose();//no longer need this
        }