zoukankan      html  css  js  c++  java
  • 汉化版AspNetForum里的FreeTexBox插入表情写得很好

    插入表情共用这个文件,用Request.QueryString["rif"]来判断提取什么表情。
    文件名:EmoticonsGallery.aspx,记录一下,明天再看看


    using System;
    using System.IO;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Xml;
    using AspNetForums.Components;
    using Image = System.Drawing.Image;

    namespace AspNetForums
    {
        
    /// <summary>
        
    /// EmoticonGallery 的摘要说明。
        
    /// </summary>

        public class EmoticonsGallery : Page
        
    {
            
    protected System.Web.UI.WebControls.Image Image1;
            
    protected Table EmoticonsTable;

            
    private void Page_Load(object sender, EventArgs e)
            
    {
                StreamReader sr 
    = new StreamReader(MapPath("~/Script/Emoticon.js"));
                
    this.RegisterClientScriptBlock("EmoticonScript", sr.ReadToEnd());
                sr.Close();

                
    int ColumnCount = 10;
                
    int index = 0;
    //            if (Request.QueryString["rif"] == null)
    //                return;

                
    //string imagepath = Request.QueryString["rif"];

                
    string imagepath ="Emoticons/JuPai";// Request.QueryString["rif"];

                
    string path = MapPath(imagepath);
                TableRow row 
    = new TableRow();

                
    if (File.Exists(path + "\\emoticons.xml"))
                
    {
                    XmlDocument myxml 
    = new XmlDocument();
                    myxml.Load(path 
    + "\\emoticons.xml");
                    XmlNodeList nodes 
    = myxml.SelectNodes("/emoticons/emoticon");
                    
    foreach (XmlNode node in nodes)
                    
    {
                        
    try
                        
    {
                            TableCell cell 
    = new TableCell();
                            cell.BorderWidth 
    = 1;

                            Image myimg 
    = Image.FromFile(Server.MapPath("~/" + imagepath + "/"+ node.Attributes["FileName"].Value);
                            
    string width = myimg.Width.ToString();
                            
    string height = myimg.Height.ToString();
                            
    string apppath = Globals.GetSiteUrls().Home; //Dottext.Framework.Util.Globals.GetAppUrl(Request);
                            string fileName = node.Attributes["FileName"].Value;
                            
    string toolTip = node.Attributes["ToolTip"].Value;
                            
    string fullWebFileName = apppath + imagepath + "/" + fileName;
                            
    string celltext = "<img border=0 src='" + fullWebFileName + "' onclick=\"returnImage('" + fullWebFileName + "','" + width + "','" + height + "','" + toolTip + "')\">";
                            cell.Text 
    = celltext;
                            row.Cells.Add(cell);
                            index
    ++;
                            
    if (index%ColumnCount == 0)
                            
    {
                                EmoticonsTable.Rows.Add(row);
                                row 
    = new TableRow();
                            }

                        }

                        
    catch
                        
    {
                        }



                    }

                }

                
    else
                
    {
                    DirectoryInfo dir 
    = new DirectoryInfo(path);
                    
    foreach (FileInfo file in dir.GetFiles())
                    
    {
                        
    try
                        
    {
                            TableCell cell 
    = new TableCell();
                            cell.BorderWidth 
    = 1;

                            
    //System.Web.UI.WebControls.Image image=new System.Web.UI.WebControls.Image();
                            
    //image.ImageUrl=imagepath+"/"+file.Name;
                            Image myimg = Image.FromFile(file.FullName);
                            
    string width = myimg.Width.ToString();
                            
    string height = myimg.Height.ToString();
                            
    string apppath = Globals.GetSiteUrls().Home; //Dottext.Framework.Util.Globals.GetAppUrl(Request);
                            string celltext = "<div onclick=\"returnImage('" + apppath + imagepath + "/" + file.Name + "','" + width + "','" + height + "','" + file.Name + "')\">";
                            celltext 
    += "<img src='" + imagepath + "/" + file.Name + "' alt='" + file.Name + "'>";
                            celltext 
    += "</div>";
                            cell.Text 
    = celltext;
                            
    //image.Attributes.Add("ondblclick","returnImage('"+image.ImageUrl+"','"+width+"','"+height+"')");
                            
    //cell.Controls.Add(image);
                            row.Cells.Add(cell);
                            index
    ++;
                            
    if (index%ColumnCount == 0)
                            
    {
                                EmoticonsTable.Rows.Add(row);
                                row 
    = new TableRow();
                            }

                        }

                        
    catch
                        
    {
                        }

                    }

                }



                
    //Response.Write(MapPath(folder));
                Response.Expires = -1;
            }


            
    Web 窗体设计器生成的代码
        }

    }
  • 相关阅读:
    Win7发布,微软首页Silverlight引领绿色浪潮
    [Toolkit]最新Silverlight Toolkit中的Drag&Drop支持
    [Toolkit]Silverlight Toolkit 2009年10月 Release
    推荐一个激动人心的Silverlight网站应用
    Silverlight4Beta之RichTextArea
    [WPF]WPF4.0中的字体呈现改进
    用eclipse开发silverlight的好选择:eclipse4sl v1.0 release
    【转】Origin 8(V8.0724) 绿色破解版
    一个不错的C# Telnet类库(改进了汉字显示乱码的问题)
    【转】Windows系统环境变量列表
  • 原文地址:https://www.cnblogs.com/LCX/p/554727.html
Copyright © 2011-2022 走看看