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

    }
  • 相关阅读:
    老罗Android开发视频教程录制计划
    经典游戏源码汇总
    横向TimePicker带三角指示器
    可延长、缩短、拖动图形的画图软件
    手把手教你写android项目@第一期项目——身份证查询创新
    android图表引擎AchartEngine制作柱图
    SharePoint2010如何配置唯一文档ID服务快速生效
    SharePoint客户端对象模型 - .NET托管
    JQuery里如何选择超链接
    如何在SharePointDesigner订制页面里判断用户权限
  • 原文地址:https://www.cnblogs.com/LCX/p/554727.html
Copyright © 2020-2023  润新知