Wednesday, January 27, 2010

zhuce.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class zhuce : System.Web.UI.Page
{

SqlConnection connecotion = new SqlConnection("Data Source=.;Initial Catalog=liaotian;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{ IRCModel._IRCModel addallUser = new IRCModel._IRCModel();
IRCBLL._IRCBLL addoneUser = new IRCBLL._IRCBLL();

int z = 0;
addallUser.ID = TextBox1.Text;
addallUser.Pwd = TextBox2.Text;
addallUser.Name = TextBox3.Text;
addallUser.Online =Convert.ToString(z);//5%1%a%s%p%x
if (addoneUser.into(addallUser))
{
Label5.Visible =false;
Response.Redirect("denglu.aspx");
}
else
{
Label5.Visible=true;

}

}
}

AJAXEnabledWebSite2.sln

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "E:\...\AJAXEnabledWebSite2\", ".", "{5A29974E-5E8F-427D-852B-21F4E65F2F86}"
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.VirtualPath = "/AJAXEnabledWebSite2"
Debug.AspNetCompiler.PhysicalPath = "E:\项目\未分类\聊天室\AJAXEnabledWebSite2\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\AJAXEnabledWebSite2\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/AJAXEnabledWebSite2"
Release.AspNetCompiler.PhysicalPath = "E:\项目\未分类\聊天室\AJAXEnabledWebSite2\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\AJAXEnabledWebSite2\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
VWDPort = "13495"
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5A29974E-5E8F-427D-852B-21F4E65F2F86}.Debug|.NET.ActiveCfg = Debug|.NET
{5A29974E-5E8F-427D-852B-21F4E65F2F86}.Debug|.NET.Build.0 = Debug|.NET
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

uploadimages.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


namespace PanRoor
{
public partial class uploadimages : XMLX
{

PanRoorImageWaterMark wm = new PanRoorImageWaterMark();
PanRoorImageWaterMark.ImageAlign align;
PanRoorImageWaterMark.TextCSS txtcss;
PanRoorImageWaterMark.ConvertEffect ceff;

string fpath, ftype, fname,dot;

protected void Page_Load(object sender, EventArgs e)
{

}
protected void But_upload_Click(object sender, EventArgs e)
{
fname = fup_img.FileName;
fpath = fup_img.PostedFile.FileName;
ftype = fup_img.PostedFile.ContentType;
string[] type = ftype.Split('/');
string[] fn = fname.Split('.');
dot = "." + fn[1].ToString();
if (type[0].ToString() != "image")
{
Response.Write("文件格式错误!");
}
else
{
string filename = DateTime.Now.ToString("yyyyMMddHHmmssffff");
string pt = Server.MapPath("UploadFiles/") + filename + dot;
fup_img.SaveAs(pt);

wm.SaveWaterMarkImagePath = Server.MapPath(XMLRead("SavePath")) + filename + "_S.jpg";
wm.SourceImagePath = pt;
wm.MiniatureImagePath = Server.MapPath(XMLRead("MinPath")) + filename + "_M.jpg";
wm.MiniatureImageWidth = Convert.ToInt32(XMLRead("MinWidth"));
if (XMLRead("PicAndText") == "pic")
wm.WaterMarkImagePath = Server.MapPath(XMLRead("PicPath"));
else
wm.WaterMarkText = XMLRead("WM_Text");
wm.WaterMarkTextFont = XMLRead("Font");
wm.WaterMarkTextSize =Convert.ToInt32(XMLRead("FontSize"));
switch (XMLRead("WM_Location"))
{
case "LeftTop":
align = PanRoorImageWaterMark.ImageAlign.LeftTop;
break;
case "LeftBottom":
align = PanRoorImageWaterMark.ImageAlign.LeftBottom;
break;
case "Center":
align = PanRoorImageWaterMark.ImageAlign.Center;
break;
case "RightTop":
align = PanRoorImageWaterMark.ImageAlign.RightTop;
break;
case "RightBottom":
align = PanRoorImageWaterMark.ImageAlign.RightBottom;
break;
case "CenterTop":
align = PanRoorImageWaterMark.ImageAlign.CenterTop;
break;
case "CenterBottom":
align = PanRoorImageWaterMark.ImageAlign.CenterBottom;
break;
case "CenterLeft":
align = PanRoorImageWaterMark.ImageAlign.CenterLeft;
break;
case "CenterRight":
align = PanRoorImageWaterMark.ImageAlign.CenterRight;
break;


}
wm.WaterMarkAlign = align;
wm.WaterMarkTextColor = XMLRead("FontColor");
wm.WaterMarkTextShadowColor = XMLRead("FontShadow");
if (XMLRead("FontForm") == "Bold")
txtcss = PanRoorImageWaterMark.TextCSS.Bold;
else if (XMLRead("FontForm") == "Underline")
txtcss = PanRoorImageWaterMark.TextCSS.Underline;
else if (XMLRead("FontForm") == "Italic")
txtcss = PanRoorImageWaterMark.TextCSS.Italic;
else if (XMLRead("FontForm") == "Strikeout")
txtcss = PanRoorImageWaterMark.TextCSS.Strikeout;

wm.WaterMarkTextCSS = txtcss;
if (XMLRead("Effect") == "Negative")
ceff = PanRoorImageWaterMark.ConvertEffect.Negative;
else if (XMLRead("Effect") == "Monochrome")
ceff = PanRoorImageWaterMark.ConvertEffect.Monochrome;
else
ceff = PanRoorImageWaterMark.ConvertEffect.None;

wm.ConverImageEffect = ceff;
wm.WaterMarkTransparence = Convert.ToInt32(XMLRead("WM_Transparence"));
wm.WaterMarkPlaceX = Convert.ToInt32(XMLRead("PlaceX"));
wm.WaterMarkPlaceY = Convert.ToInt32(XMLRead("PlaceY"));
wm.WaterMarkImageGroundColor = XMLRead("Grounding");
wm.WaterMarkAngle = Convert.ToInt32(XMLRead("WM_Angle"));
wm.ImageZipHeight = Convert.ToInt32(XMLRead("ZipHeight"));
wm.WaterMarkTextShadowDepthX = Convert.ToInt32(XMLRead("ShadowX"));
wm.WaterMarkTextShadowDepthY = Convert.ToInt32(XMLRead("ShadowY"));
wm.GetToMiniatureImage();
wm.GetToWaterMarkImage();
Label1.Text = "";
}


}
}
}

Config_XML.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
//该源码下载自www.51aspx.com(51aspx.com)

namespace PanRoor
{
public partial class XML : XMLX
{
XMLX bind = new XMLX();
protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
colorloading();
string[] FormValue = new string[] { "Bold","Underline", "Italic", "Strikeout" };
string[] FormName = new string[] { "加粗文本","下划线文本", "倾斜文本", "中划线文本" };
for (int i = 0; i < FormValue.Length; i++)
{
ddl_Form.Items.Add(new ListItem(FormName[i].ToString(), FormValue[i].ToString()));

}
bind.getcolor(ref ddl_font);
rb_NoAndOff.SelectedValue = bind.XMLRead("NoAndOff");
rb_PicAndText.SelectedValue = bind.XMLRead("PicAndText");
tb_picpath.Text = bind.XMLRead("PicPath");
tb_WM_Text.Text = bind.XMLRead("WM_Text");
ddl_Location.SelectedValue = bind.XMLRead("WM_Location");
tb_Transparence.Text = bind.XMLRead("WM_Transparence");
tb_Angle.Text = bind.XMLRead("WM_Angle");
ddl_font.SelectedValue = bind.XMLRead("Font");
tb_FontSize.Text = bind.XMLRead("FontSize");
tb_FontColor.Text = bind.XMLRead("FontColor");
tb_FontShadow.Text = bind.XMLRead("FontShadow");
ddl_Form.SelectedValue = bind.XMLRead("FontForm");
tb_groundcolor.Text = XMLRead("Grounding");
tb_PlaceX.Text = XMLRead("PlaceX");
tb_PlaceY.Text = XMLRead("PlaceY");
tb_ShadowX.Text = XMLRead("ShadowX");
tb_ShadowY.Text = XMLRead("ShadowY");
tb_ZipWidth.Text = XMLRead("ZipWidth");
tb_ZipHeight.Text = XMLRead("ZipHeight");
tb_MinWidth.Text = XMLRead("MinWidth");
tb_MinHeight.Text = XMLRead("MinHeight");
tb_MinPath.Text = XMLRead("MinPath");
tb_SavePath.Text = XMLRead("SavePath");
DropDownList1.SelectedValue = XMLRead("Effect");

}
}

protected void But_Save_Click1(object sender, EventArgs e)
{
try
{
if (Convert.ToInt32(tb_Transparence.Text) > 100)
Alert("透明度不支持大于100,请重设!");
else
bind.CreateXML(rb_NoAndOff.SelectedValue, rb_PicAndText.SelectedValue, tb_picpath.Text, tb_WM_Text.Text, ddl_Location.SelectedValue, tb_Transparence.Text, tb_Angle.Text, ddl_font.SelectedValue, tb_FontSize.Text, tb_FontColor.Text, tb_FontShadow.Text, ddl_Form.SelectedValue, tb_groundcolor.Text, tb_ShadowX.Text, tb_ShadowY.Text, tb_PlaceX.Text, tb_PlaceY.Text, tb_MinWidth.Text, tb_MinHeight.Text, tb_ZipWidth.Text, tb_ZipHeight.Text, tb_MinPath.Text, tb_SavePath.Text,DropDownList1.SelectedValue);

colorloading();
Alert("保存成功!");
}
catch
{
Alert("保存失败!");
}


}
private void colorloading()
{
tb_groundcolor.BackColor = System.Drawing.ColorTranslator.FromHtml(XMLRead("Grounding"));
tb_groundcolor.ForeColor = System.Drawing.ColorTranslator.FromHtml(XMLRead("Grounding"));
tb_FontColor.BackColor = System.Drawing.ColorTranslator.FromHtml(XMLRead("FontColor"));
tb_FontColor.ForeColor = System.Drawing.ColorTranslator.FromHtml(XMLRead("FontColor"));
tb_FontShadow.BackColor = System.Drawing.ColorTranslator.FromHtml(XMLRead("FontShadow"));
tb_FontShadow.ForeColor = System.Drawing.ColorTranslator.FromHtml(XMLRead("FontShadow"));
}


}
}

XML.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
//该源码下载自www.51aspx.com(51aspx.com)

namespace PanRoor
{
///
/// XML 的摘要说明
///

public class XMLX : Page
{
public XMLX()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public string CreateXML(string NoAndOff, string PicAndText, string PicPath, string WM_Text, string WM_Location, string WM_Transparence, string WM_Angle, string Font, string FontSize, string FontColor, string FontShadow, string FontForm, string mkcolor, string ShadowX, string ShadowY, string PlaceX, string PlaceY, string MinWidth, string MinHeight, string ZipWidth, string ZipHeight, string MinPath, string SavePath, string Effect)
{
//建一个新的空的XML文档
XmlTextWriter objXml = new XmlTextWriter(Server.MapPath("WM_Xml.xml"), null);
//格式化输出XML文档
objXml.Formatting = Formatting.Indented;
objXml.Indentation = 4;
//写入XML文档标记
objXml.WriteStartDocument();
//写入XML文档注释
objXml.WriteComment("Created XML" + Context.Timestamp);
//写入根元素
objXml.WriteStartElement("WKConfig");
//写入元素
objXml.WriteStartElement("Config");
//写入属性
objXml.WriteAttributeString("Technology", "ASP.NET 2.0");
//写入属性值
objXml.WriteAttributeString("Author", "张春根");
//写入子元素及文本值
objXml.WriteElementString("Title", "水印参数配置");
//写入子元素及文本值
objXml.WriteElementString("Version", "ImageWaterMark V1.0");
//写入元素
objXml.WriteStartElement("Parameter");
//写入子元素及文本值
objXml.WriteElementString("NoAndOff", NoAndOff);
objXml.WriteElementString("PicAndText", PicAndText);
objXml.WriteElementString("PicPath", PicPath);
objXml.WriteElementString("WM_Text", WM_Text);
objXml.WriteElementString("WM_Location", WM_Location);
objXml.WriteElementString("WM_Transparence", WM_Transparence);
objXml.WriteElementString("WM_Angle", WM_Angle);
objXml.WriteElementString("Font", Font);
objXml.WriteElementString("FontSize", FontSize);
objXml.WriteElementString("FontColor", FontColor);
objXml.WriteElementString("FontShadow", FontShadow);
objXml.WriteElementString("FontForm", FontForm);
objXml.WriteElementString("Grounding", mkcolor);
objXml.WriteElementString("ShadowX", ShadowX);
objXml.WriteElementString("ShadowY", ShadowY);
objXml.WriteElementString("PlaceX", PlaceX);
objXml.WriteElementString("PlaceY", PlaceY);
objXml.WriteElementString("MinWidth", MinWidth);
objXml.WriteElementString("MinHeight", MinHeight);
objXml.WriteElementString("ZipWidth", ZipWidth);
objXml.WriteElementString("ZipHeight", ZipHeight);
objXml.WriteElementString("MinPath", MinPath);
objXml.WriteElementString("SavePath", SavePath);
objXml.WriteElementString("Effect", Effect);
//关闭子元素、元素、根元素
objXml.WriteEndElement();
objXml.WriteEndElement();
objXml.WriteEndElement();
//清除缓存
objXml.Flush();
//关闭对象
objXml.Close();
return "";
}
public string XMLRead(string Value)
{

XmlDocument xd = new XmlDocument();
xd.Load(Server.MapPath("WM_Xml.xml"));

XmlNodeList xnl = xd.GetElementsByTagName(Value);
if (xnl.Count == 0)
return "";
else
{
XmlNode mNode = xnl[0];
return mNode.InnerText;
}
}
public void getcolor(ref DropDownList ddlfont)
{


ddlfont.Items.Clear();
System.Drawing.Text.InstalledFontCollection font;
font = new System.Drawing.Text.InstalledFontCollection();
foreach (System.Drawing.FontFamily family in font.Families)
{
ddlfont.Items.Add(family.Name);
}


}
public static string HexEncoding(System.Drawing.Color color)
{
string R, G, B;
string strHexEncoding;

R = color.R.ToString("X");
G = color.G.ToString("X");
B = color.B.ToString("X");

R = R.Length == 1 ? "0" + R : R;
G = G.Length == 1 ? "0" + G : G;
B = B.Length == 1 ? "0" + B : B;

strHexEncoding = "#" + R + G + B;

return strHexEncoding;


}

public void Messages(string Message, string href)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "");

}
public void Alert(string msg)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "");
}
}
}