很久没来DFW了,很相信大家,给大家带来一份礼物:about design pattern(0分)

  • 主题发起人 主题发起人 nsj
  • 开始时间 开始时间
我要。
hnxx2003@yahoo.com
 
catcherye@you.com
 
LL7777@163.net
谢谢!!
 
我也写了几种设计模式的范例(c#)
希望学习你的!
[blue]cjc861@yahoo.com.cn[/blue]
 
给我一份renxm2003@126.com
先谢啦!
 
namespace Application
{
/// <summary>
/// Class1 的摘要说明。
/// 这是一个向自己的
/// </summary>
public delegate void ProcessBookDelegate();
public class TComponetClass :CollectionBase
{
private TComponetClass m_Class;
private ProcessBookDelegate m_Events;
public TComponetClass()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
private TComponetClass this[int index]
{
get
{
return (TComponetClass)List[index];
}
}
public ProcessBookDelegate EventsChanged
{
get
{
return m_Events;
}
set
{
m_Events = value;
}
}

public TComponetClass Parent
{
get
{
return m_Class;
}
set
{
if(value == null )
{
if( m_Class != null)
{
m_Class.List.Remove(this);
m_Class =value;
}

}
else
//value !=null m_Class != null
{
if(m_Class != value)
{
if(m_Class != null)
this.Parent = null;
value.Componets.Add(this);
m_Class = value;
}//m_Calss =value then
什模都不做
}

}
}
private void Add(TComponetClass ChildClass)
{
//建一数组
List.Add(ChildClass);
}
protected TComponetClass Componets
{
get
{
return this;
}
}
public int ComponetCount
{
get
{
return List.Count;
}

}
private void MyEvents(ProcessBookDelegate Event,string s)
{
//MessageBox.Show(s);
if(Event !=null)
Event();
}
protected void Move()
{
for(int i = 0 ;i< List.Count ;i++)
{
TComponetClass Class1 =(TComponetClass)List;
Class1.Move();
//MessageBox.Show(List.ToString());
Class1.MyEvents(Class1.m_Events,List.ToString());
}
}
//public
}
}
模仿delphi TComponent写的,请大家指教,我主要是用它派生控制类,实现广播方式
下面是我做的例子!
private void Example1()
{
MessageBox.Show("t_distress");
}
private void Example2()
{
MessageBox.Show("t_Sample");
}
private void Example3()
{
MessageBox.Show("t_FuncClass");
}
private void Example4()
{
MessageBox.Show("t_PaveType");
}
private void Example5()
{
MessageBox.Show("t_Street");
}
private void button1_Click(object sender, System.EventArgs e)
{
Sectoin t_Section = new Sectoin();//Section 类是
Street t_Street = new Street();
PaveType t_PaveType = new PaveType();
FuncClass t_FuncClass = new FuncClass();
Sample t_Sample = new Sample();
distress t_distress = new distress();
t_Street.Parent = t_Section;
t_PaveType.Parent =t_Section;
t_FuncClass.Parent = t_Section;
t_Sample.Parent = null;
//
t_Sample.Parent = t_Section;
//
//t_Sample.Parent = t_Section;
//
//t_Sample.Parent = t_Street;
//
//t_Sample.Parent = null;

t_distress.Parent = t_Street;
t_Street.EventsChanged = new ProcessBookDelegate(Example5);
t_PaveType.EventsChanged = new ProcessBookDelegate(Example4);
t_FuncClass.EventsChanged = new ProcessBookDelegate(Example3);
t_Sample.EventsChanged = new ProcessBookDelegate(Example2);
t_distress.EventsChanged = new ProcessBookDelegate(Example1);
t_Section.Move();


}
 
我要一份,cnzhw007@126.com
 
superdl@etang.com
饥渴地等待......
 
咋还没见着呢??
 
163mini@163.com
我渴呀:)
 
能给我一份吗:bvtc@tom.com
 
C#有一本书介绍模式的。
可惜没有见到delphi版的。有谁知道的请mark一下。
 
I like it,please send it to me: HjmaAsC@163.com
 
呵呵﹐﹐我正要找這方面的資料﹐請樓主也寄給小女子一份!先謝了謝了﹗﹗
jelly0228@sina.com
 
给我一份好吗?谢谢
cansoft@163.com
 
ufoyyf@163.com
非常渴望,谢谢
 
zjxnew@ynmail.com
 
后退
顶部