代码改变世界

将网页保存成图片

2011-12-01 16:30 by Carl Xing, 548 阅读, 0 推荐, 收藏, 编辑
摘要:新建一个win Form应用程序using System;using System.Drawing;using System.Windows.Forms;namespace Snowdream.Sample.WebpageSnapshot{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } /// <summary> /// 按钮按下事件处理函数 /// </summary... 阅读全文

数据库读取图片展示

2011-09-28 09:19 by Carl Xing, 428 阅读, 0 推荐, 收藏, 编辑
摘要:将bitmap保存到页面的输出流中。在其它页面的img的src就可以使用这个流。img.aspx:protected void Page_Load(object sender, EventArgs e) { Bitmap img = null; string connStr = ConfigurationManager.ConnectionStrings["dbConn"].ToString(); using (SqlConnection conn = new SqlConnection(connStr)) ... 阅读全文

div遮盖层

2011-09-20 18:27 by Carl Xing, 1016 阅读, 0 推荐, 收藏, 编辑
摘要:<html><head> <title></title> <script type="text/javascript"> function show() { document.getElementById("mask").style.display = ""; document.getElementById("content1").style.display = ""; document.getElementById("mas 阅读全文

DIV随鼠标滚动

2011-09-20 18:25 by Carl Xing, 964 阅读, 0 推荐, 收藏, 编辑
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>JavaScript得到鼠标坐标</title> <script language="javascript& 阅读全文

Custom ServerControl

2011-08-26 16:11 by Carl Xing, 246 阅读, 0 推荐, 收藏, 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace ServerControl.Controls{ publicclass MostSimpleControl:Control { // Control类的呈现架构就是这样在三个方法之间递归的调用,以便把控件的逻辑呈现为html代码。 protectedoverridevoi... 阅读全文

继承小实验

2011-08-26 09:59 by Carl Xing, 176 阅读, 0 推荐, 收藏, 编辑
摘要:public abstract class PClass { public PClass() { Console.WriteLine("Parent"); } public virtual void Fun() { Console.WriteLine("P.Fun()"); } } public class CClass:PClass { public CClass() { Consol... 阅读全文

Attribute

2011-08-26 09:45 by Carl Xing, 374 阅读, 0 推荐, 收藏, 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ReflectionClass{ public enum Fruit { Apple, Banana, Pear, Watermelon } public class FruitTypeAttribute:System.Attribute { public FruitTypeAttribute(Fruit frui... 阅读全文

Event委托

2011-08-09 11:56 by Carl Xing, 293 阅读, 0 推荐, 收藏, 编辑
摘要:public class ArgButton:Button { public delegate void OnArgClick(btnEventArgs e); public event OnArgClick ArgClick; private string Args { get; set; } public ArgButton() { } public ArgButton(string args) { ... 阅读全文

CollectionBase的使用

2011-08-05 18:57 by Carl Xing, 341 阅读, 0 推荐, 收藏, 编辑
摘要:interface IItem { object name { get; set; } object value { get; set; } void getItemByName(); } public class ItemClass : IItem { #region IItem 成员 public object name { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public object value { get { throw new Not. 阅读全文

C#中virtual与abstract的区别

2011-07-05 17:05 by Carl Xing, 4076 阅读, 3 推荐, 收藏, 编辑
摘要:C#的virtual & abstract经常让人混淆,这两个限定词都是为了让子类进行重新定义,覆盖父类的定义。但是用法上差别很大。a) virtual修饰的方法必须有方法实现(哪怕只有一对大括号),abstract修饰的方法不能有实现。b) virtual可以被子类重写,abstract必须被子类重写c) 如果类中的某一函数被abstact修饰,则类名也必须用abstact修饰d) Abstract修饰的类不能被创建实例。e) C#中如果准备在子类重写父类的方法,则该方法在父类中必须用virtual修饰,在子类中必须用overide修饰,避免了程序员在子类中不小心重写了父类父类方法。 阅读全文