예제 #1
0
파일: Viewer.cs 프로젝트: terryxym/DiscuzNT
        /// <summary>
        /// 获得预览信息
        /// </summary>
        /// <param name="fileName">文件物理路径</param>
        /// <param name="attachment">附件对象</param>
        /// <returns>预览信息的HTML</returns>
        public string GetPreview(string fileName, ShowtopicPageAttachmentInfo attachment)
        {
            if (!PreviewHelper.IsFileExist(fileName))
            {
                return("");
            }
            string        id   = Guid.NewGuid().ToString();
            EXIFextractor exif = new EXIFextractor(fileName, string.Empty, string.Empty);

            if (exif.Count < 1)
            {
                return(string.Empty);
            }
            StringBuilder builder = new StringBuilder();

            foreach (System.Web.UI.Pair s in exif)
            {
                if (s.Second.ToString().Trim() == "-" || s.Second.ToString().Trim() == string.Empty || s.Second.ToString().Trim() == "0")
                {
                    continue;
                }
                builder.Append("<li>");
                builder.Append(s.First.ToString().Trim() + " : " + s.Second.ToString().Replace("\0", string.Empty).Trim());
                builder.Append("</li>");
            }
            if (builder.Length == 0)
            {
                return(string.Empty);
            }
            builder.Append("</ul></div>");

            builder.Insert(0, string.Format("<span><a onclick=\"$('{0}').style.display=$('{0}').style.display=='none'?'':'none';\" style='cursor:pointer;' title='点击显示或隐藏'>EXIF信息</a></span><div class=\"preview{1}\"><ul id=\"{0}\" style='display: none;'>", id, "jpg"));

            return(builder.ToString());
        }
예제 #2
0
        /// <summary>
        /// 获得预览信息
        /// </summary>
        /// <param name="fileName">文件物理路径</param>
        /// <param name="attachment">附件对象</param>
        /// <returns>预览信息的HTML</returns>
        public string GetPreview(string fileName, ShowtopicPageAttachmentInfo attachment)
        {
            string Result = string.Empty;

            if (!PreviewHelper.IsFileExist(fileName))
            {
                return("");
            }
            WmaMessage mp3msg = new WmaMessage(fileName);

            Result = string.Format("<div style=\"overflow:hidden; zoom:1; border:1px solid #999; font-size:13px; width:360px;\">" +
                                   "<dl style=\"margin:8px;\"><dt style=\"clear:both; float:left; width:80px;\">标题:</dt><dd>{1}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">演唱者:</dt><dd>{2}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">专辑:</dt><dd>{4}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">流派:</dt><dd>{3}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">文件类型:</dt><dd>{9}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">比特率:</dt><dd>{6}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">声道:</dt><dd>{8}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">文件大小:</dt><dd>{7}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">发行年份:</dt><dd>{5}</dd></dl>" +
                                   "<div><object classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"360\" height=\"64\"><param name=\"autostart\" value=\"1\" />" +
                                   "<param name=\"url\" value=\"{0}\" />" +
                                   "<embed src=\"{0}\" autostart=\"0\"type=\"video/x-ms-wmv\" width=\"260\"height=\"42\"></embed></object></div></div>", @"upload/" + attachment.Filename, mp3msg.Title, mp3msg.Artist, mp3msg.Genre, mp3msg.Album, mp3msg.PublishYear, mp3msg.BPS, mp3msg.Size, mp3msg.Track, mp3msg.Type);
            return(Result);
        }
예제 #3
0
        /// <summary>
        /// 绑定指定URL图片
        /// </summary>
        /// <param name="imageUrl"></param>
        public void BindImage(ShowtopicPageAttachmentInfo attachinfo)
        {
            //ucGif.Visibility = Visibility.Visible;
            //CurImage.Visibility = Visibility.Collapsed;
            ////System.Net.WebClient wcashx = new System.Net.WebClient();
            ////Uri endpoint = new Uri("", UriKind.Relative);
            ////wcashx.OpenReadCompleted += new OpenReadCompletedEventHandler(wcashx_OpenReadCompleted);
            ////wcashx.OpenReadAsync(endpoint);
            //System.Windows.Resources.StreamResourceInfo sr = Application.GetResourceStream(new Uri("../Images/Loading.gif", UriKind.Relative));
            //ucGif.SetSoruce(sr.Stream);

            try
            {
                BitmapImage bitmapImage = new BitmapImage(new Uri(attachinfo.Filename, UriKind.RelativeOrAbsolute));
                bitmapImage.DownloadProgress += new EventHandler <DownloadProgressEventArgs>(bitmapImage_DownloadProgress);
                CurImage.Source = bitmapImage;
            }
            catch { }
        }
예제 #4
0
        /// <summary>
        /// 加载单个附件实体对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static ShowtopicPageAttachmentInfo LoadSingleAttachmentInfo(IDataReader reader)
        {
            ShowtopicPageAttachmentInfo attInfo = new ShowtopicPageAttachmentInfo();

            attInfo.Aid          = TypeConverter.ObjectToInt(reader["aid"]);
            attInfo.Tid          = TypeConverter.ObjectToInt(reader["tid"]);
            attInfo.Pid          = TypeConverter.ObjectToInt(reader["pid"]);
            attInfo.Postdatetime = reader["postdatetime"].ToString();
            attInfo.Readperm     = TypeConverter.ObjectToInt(reader["readperm"]);
            attInfo.Filename     = reader["filename"].ToString();
            attInfo.Description  = reader["description"].ToString();
            attInfo.Filetype     = reader["filetype"].ToString();
            attInfo.Filesize     = TypeConverter.ObjectToInt(reader["filesize"]);
            attInfo.Attachment   = reader["attachment"].ToString();
            attInfo.Downloads    = TypeConverter.ObjectToInt(reader["downloads"]);
            attInfo.Attachprice  = TypeConverter.ObjectToInt(reader["attachprice"]);
            attInfo.Uid          = TypeConverter.ObjectToInt(reader["uid"]);
            attInfo.Width        = TypeConverter.ObjectToInt(reader["width"]);
            attInfo.Height       = TypeConverter.ObjectToInt(reader["height"]);
            return(attInfo);
        }
예제 #5
0
        /// <summary>
        /// 绑定指定URL图片
        /// </summary>
        /// <param name="imageUrl"></param>
        public void BindImage(ShowtopicPageAttachmentInfo attachinfo)
        {
            //ucGif.Visibility = Visibility.Visible;
            //CurImage.Visibility = Visibility.Collapsed;
            ////System.Net.WebClient wcashx = new System.Net.WebClient();
            ////Uri endpoint = new Uri("", UriKind.Relative);
            ////wcashx.OpenReadCompleted += new OpenReadCompletedEventHandler(wcashx_OpenReadCompleted);
            ////wcashx.OpenReadAsync(endpoint);
            //System.Windows.Resources.StreamResourceInfo sr = Application.GetResourceStream(new Uri("../Images/Loading.gif", UriKind.Relative));
            //ucGif.SetSoruce(sr.Stream); 

            try
            {
                BitmapImage bitmapImage = new BitmapImage(new Uri(attachinfo.Filename, UriKind.RelativeOrAbsolute));
                bitmapImage.DownloadProgress += new EventHandler<DownloadProgressEventArgs>(bitmapImage_DownloadProgress);
                CurImage.Source = bitmapImage;
                LoadingBar.Visibility = System.Windows.Visibility.Visible;
                SetPositionInfo();
                bitmapImage.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(bitmapImage_ImageFailed);
        
            }
            catch { }
        }