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 窗体设计器生成的代码
        }

    }
  • 相关阅读:
    easyui combobox 获取焦点
    easyui combobox keyhandler使用
    easyui combobox 取值
    Tomcat启动超时问题Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds
    spring定时器中如何获取servletcontext
    不用asp.net MVC,用WebForm照样能够实现MVC
    打印从1到最大的n位数
    [NOIP复习]第三章:动态规划
    Java并发与同步
    Bootstrap的js插件之按钮(button)
  • 原文地址:https://www.cnblogs.com/LCX/p/554727.html
Copyright © 2011-2022 走看看