<%@ Page Language="VB" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="BrowseArchive.aspx.vb" Inherits="Rebex.Samples.BrowseArchive" %>

<%@ Import Namespace="Rebex.IO.Compression" %>
<%@ Import Namespace="Rebex.Samples" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <%-- page header (including current archive and path) --%>
    <h2>Content of "<asp:Literal ID="ArchiveFileNameControl" runat="server" />": <asp:Literal ID="CurrentPathControl" runat="server" /></h2>
    
    <%-- commands toolbar --%>
    <div>
        <ul class="toolbar">
            <%-- close the archive (back to ZIP files list) --%>
            <li runat="server" id="CloseArchiveListItem">
                <asp:Image ID="CloseArchiveImage" runat="server" AlternateText="Close" />
                <asp:HyperLink runat="server" ID="CloseArchive" Text="Close archive" NavigateUrl="~/Default.aspx"/>
            </li>
            <%-- change directory one level up --%>
            <li runat="server" id="GoToParentDirectoryListItem" visible="false">
                <asp:Image ID="GoToParentDirectoryImage" runat="server" AlternateText="Directory up" />
                <asp:HyperLink runat="server" ID="GoToParentDirectory" Text="Directory up" />
            </li>
        </ul>
    </div>
    
    <%-- error message --%>
    
    <div class="clear error"><asp:Label ID="ErrorMessage" runat="server" Visible="false" /></div>      
    
    <%-- list of current directory in the ZIP archive --%>
    <div>
        <asp:GridView ID="ArchiveFilesGridView" runat="server" CssClass="list" BorderStyle="None" BorderWidth="0"
            BorderColor="whitesmoke" RowStyle-BorderColor="white" AlternatingRowStyle-BackColor="whitesmoke"
            AutoGenerateColumns="false">
            <HeaderStyle CssClass="listHeader" />
            <Columns>
                <asp:TemplateField HeaderText="Name" ItemStyle-CssClass="tdName" ItemStyle-Width="450">
                    <ItemTemplate>
                        <%-- item icon: directory/file/link --%>
                        <a href="<%# GetUrl(TryCast(Container.DataItem, ZipItem)) %>">
                            <asp:Image ID="imgFileOrFolder" runat="server" 
                                ImageUrl="<%# Util.GetIcon(TryCast(Container.DataItem, ZipItem)) %>" 
                                AlternateText="File type (file/folder)" /><%# Eval("Name") %></a>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Original<br/>size" HeaderStyle-CssClass="thNumber" ItemStyle-CssClass="tdNumber" ItemStyle-Width="75">
                    <ItemTemplate>
                        <%#Util.GetSize(CType(Eval("Length"), Long))%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Compressed<br/>size" HeaderStyle-CssClass="thNumber" ItemStyle-CssClass="tdNumber" ItemStyle-Width="75">
                    <ItemTemplate>
                        <%#Util.GetSize(CType(Eval("CompressedLength"), Long))%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Compress.<br/>ratio" HeaderStyle-CssClass="thNumber" ItemStyle-CssClass="tdNumber" ItemStyle-Width="50">
                    <ItemTemplate>
                        <%#Util.GetRatio(TryCast(Container.DataItem, ZipItem))%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField HeaderText="Modified" DataField="LastWriteTime" DataFormatString="{0:G}" 
                    HeaderStyle-CssClass="thDate" ItemStyle-CssClass="tdDate" ItemStyle-Width="100" ItemStyle-Wrap="false" />
            </Columns>
            <EmptyDataTemplate>
                No files
            </EmptyDataTemplate>
        </asp:GridView>
    </div>
</asp:Content>
