<%@ Page Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="BrowseArchive.aspx.cs" 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(Container.DataItem as ZipItem) %>">
                            <asp:Image ID="imgFileOrFolder" runat="server" 
                                ImageUrl="<%# Util.GetIcon(Container.DataItem as 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((long)Eval("Length"))%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Compressed<br/>size" HeaderStyle-CssClass="thNumber" ItemStyle-CssClass="tdNumber" ItemStyle-Width="75">
                    <ItemTemplate>
                        <%# Util.GetSize((long)Eval("CompressedLength")) %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Compress.<br/>ratio" HeaderStyle-CssClass="thNumber" ItemStyle-CssClass="tdNumber" ItemStyle-Width="50">
                    <ItemTemplate>
                        <%# Util.GetRatio(Container.DataItem as 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>
