Пример #1
0
            private void PicturePanel_DataBinding(object sender, EventArgs e)
            {
                Panel panel = (Panel)sender;

                File file = (File)DataBinder.GetDataItem(panel.NamingContainer);

                var  fileMimeTypeGroups = MimeType.GetGroups(file.Name, true);
                bool isImage            = (fileMimeTypeGroups & MimeTypeGroups.Image) == MimeTypeGroups.Image;

                if (isImage)
                {
                    Picture = new Image();

                    Picture.ImageUrl = m_FileList.FileManager.GetThumbnailUrl(file.FileId, 0, 0, 0, true);

                    panel.Controls.Add(Picture);
                }
                else
                {
                    IconLabel = new Label();

                    IconLabel.CssClass = GetFileTypeIconCssClass(fileMimeTypeGroups);

                    string fontSize = string.Format(CultureInfo.InvariantCulture, "{0}px", (int)IconSize.Bigger);
                    IconLabel.Font.Size            = FontUnit.Parse(fontSize, CultureInfo.InvariantCulture);
                    IconLabel.Style["line-height"] = fontSize;

                    panel.Controls.Add(IconLabel);
                }
            }
Пример #2
0
            private void PictureLink_DataBinding(object sender, EventArgs e)
            {
                HyperLink link = (HyperLink)sender;

                File file = (File)DataBinder.GetDataItem(link.NamingContainer);

                var  fileMimeTypeGroups = MimeType.GetGroups(file.Name, true);
                bool isImage            = (fileMimeTypeGroups & MimeTypeGroups.Image) == MimeTypeGroups.Image;

                link.Text        = file.Name;
                link.NavigateUrl = file.Url;

                if (file.Extension.In(MimeType.SwfExtension) || isImage)
                {
                    link.Target            = "_blank";
                    link.Attributes["rel"] = "noopener";
                }
            }
Пример #3
0
            private void PictureLink_DataBinding(object sender, EventArgs e)
            {
                HyperLink link = (HyperLink)sender;

                File file = (File)DataBinder.GetDataItem(link.NamingContainer);

                var  fileMimeTypeGroups = MimeType.GetGroups(file.Name, true);
                bool isImage            = (fileMimeTypeGroups & MimeTypeGroups.Image) == MimeTypeGroups.Image;

                link.NavigateUrl = file.Url;

                if (file.Extension.In(MimeType.SwfExtension) || isImage)
                {
                    link.Target            = "_blank";
                    link.Attributes["rel"] = "noopener";
                }

                if (isImage)
                {
                    Picture        = new Image();
                    Picture.Width  = Unit.Pixel(ThumbnailWidth);
                    Picture.Height = Unit.Pixel(ThumbnailHeight);

                    Picture.ImageUrl = m_FileList.FileManager.GetThumbnailUrl(file.FileId, ThumbnailWidth, ThumbnailHeight, 1, false);

                    link.Controls.Add(Picture);
                }
                else
                {
                    link.CssClass = GetFileTypeIconCssClass(fileMimeTypeGroups);

                    string fontSize = string.Format(CultureInfo.InvariantCulture, "{0}px", ThumbnailHeight);
                    link.Font.Size            = FontUnit.Parse(fontSize, CultureInfo.InvariantCulture);
                    link.Style["line-height"] = fontSize;
                }
            }
Пример #4
0
        private void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (e.Row.RowType != DataControlRowType.DataRow)
            {
                return;
            }

            int count = e.Row.Cells.Count;

            if (count == 0)
            {
                return;
            }

            File file = (File)e.Row.DataItem;

            var fileMimeTypeGroups = MimeType.GetGroups(file.Name, true);

            TableCell fileNameCell;
            string    dateCssClass = "flDate";

            if (this.ShowIcons)
            {
                fileNameCell = e.Row.Cells[1];

                dateCssClass += " flIcons";

                e.Row.Cells[0].CssClass = "flFirst " + GetFileTypeIconCssClass(fileMimeTypeGroups);

                string fontSize = string.Format(CultureInfo.InvariantCulture, "{0}px", (int)this.IconSize);
                e.Row.Cells[0].Font.Size            = FontUnit.Parse(fontSize, CultureInfo.InvariantCulture);
                e.Row.Cells[0].Style["line-height"] = fontSize;
            }
            else
            {
                fileNameCell = e.Row.Cells[0];
            }

            HyperLink link = fileNameCell.Controls[0] as HyperLink;

            if (link == null)
            {
                link = fileNameCell.Controls[1] as HyperLink;
            }

            if (link != null)
            {
                link.Attributes["rel"] = "noopener";

                if (this.ShowFileToolTip)
                {
                    link.CssClass = "flFileName";

                    if ((fileMimeTypeGroups & MimeTypeGroups.Image) == MimeTypeGroups.Image)
                    {
                        string thumbUrl = this.EnableThumbnails ? this.FileManager.GetThumbnailUrl(file.FileId, 600, 500, 1, true) : file.Url;
                        string content  = string.Format(CultureInfo.InvariantCulture, ToolTipBigHtml, file.Url, file.Name, thumbUrl);

                        link.Attributes["data-ot"] = content;
                    }
                }
            }

            DateTime updatedTime = TimeZoneInfo.ConvertTimeFromUtc(file.LastModified, this.TimeZone);
            DateTime updatedDate = file.LastModified.Date;

            if (m_UpdatedDate != updatedDate)
            {
                if (m_UpdatedDate != DateTime.MinValue)
                {
                    e.Row.CssClass += " flPt";
                }

                using (HtmlGenericControl panel = new HtmlGenericControl("div"))
                {
                    panel.InnerHtml           = string.Format(this.Culture, this.DateTimeFormatString, updatedTime);
                    panel.Attributes["class"] = dateCssClass;

                    fileNameCell.Controls.AddAt(0, panel);
                }
            }
            m_UpdatedDate = updatedDate;

            if (this.EnableDeleting && this.EnableDeletingConfirmation)
            {
                TableCell deleteCell = e.Row.Cells[count - 1];

                if (deleteCell.Controls.Count > 0)
                {
                    WebControl control = deleteCell.Controls[0] as WebControl;
                    if (control != null)
                    {
                        control.Attributes.Add("onclick", OnDeletingClientScript);
                        control.ToolTip = Resources.FileList_DeleteText;
                    }
                }
            }
        }