EventArgs.cs
using System;
using System.Collections.Generic;
using System.Text;
using XML;
namespace CommonToolkit.Controls.Common {
public class BatchEventArgs : EventArgs {
public Batch Batch;
public BatchEventArgs(Batch batch) {
this.Batch = batch;
}
}
public class DocumentEventArgs : EventArgs {
public Document Document;
public DocumentEventArgs(Document document) {
this.Document = document;
}
}
public class FolderEventArgs : EventArgs {
public Folder Folder;
public FolderEventArgs(Folder folder) {
this.Folder = folder;
}
}
public class PageEventArgs : EventArgs {
public Page Page;
public Document Document;
public PageEventArgs(Page page,Document document) {
this.Page = page;
this.Document = document;
}
}
public class NodeEventArgs : EventArgs {
public Folder Folder;
public Document Document;
public NodeEventArgs(Folder folder) {
this.Folder = folder;
}
public NodeEventArgs(Document document) {
this.Document = document;
}
}
}
*********************************************************************
Delegate.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace CommonToolkit.Controls.Common {
public delegate void BatchClickEventHandler(object sender, BatchEventArgs e);
public delegate void FolderClickEventHandler(object sender, FolderEventArgs e);
public delegate void DocumentClickEventHandler(object sender, DocumentEventArgs e);
public delegate void PageClickEventHandler(object sender, PageEventArgs e);
public delegate void SwitchNodeEventHandler(object sender,NodeEventArgs e);
}
*********************************************************************
CustTreeView.cs
using System.Text;
using System.Collections;
using System.Windows.Forms;
using XML;
using CommonToolkit.Controls.Common;
namespace CommonToolkit.Controls {
public partial class CustTreeView : TreeView {
public event BatchClickEventHandler BatchClick;
public event FolderClickEventHandler FolderClick;
public event DocumentClickEventHandler DocumentClick;
public event PageClickEventHandler PageClick;
public event SwitchNodeEventHandler SwitchNode;
public CustTreeView() {
InitializeComponent();
}
//定义一个具有与事件委托相同的签名的事件处理程序方法。
public virtual void OnBatchClick(object sender, BatchEventArgs args) {
if (BatchClick != null) {
BatchClick(sender, args);
}
}
public virtual void OnFolderClick(object sender, FolderEventArgs args) {
if (FolderClick != null) {
FolderClick(sender, args);
}
}
public virtual void OnDocumentClick(object sender, DocumentEventArgs args) {
if (DocumentClick != null) {
DocumentClick(sender, args);
}
}
public virtual void OnPageClick(object sender, PageEventArgs args) {
if (PageClick != null) {
PageClick(sender, args);
}
}
}
}
*********************************************************************
frmTreeView.Designer.cs
//将该委托实例添加到事件
this.ctrvBatch.PageClick += new CommonToolkit.Controls.Common.PageClickEventHandler(this.ctrvBatch_PageClick);
this.ctrvBatch.DocumentClick += new CommonToolkit.Controls.Common.DocumentClickEventHandler(this.ctrvBatch_DocumentClick);
this.ctrvBatch.BatchClick += new CommonToolkit.Controls.Common.BatchClickEventHandler(this.ctrvBatch_BatchClick);
this.ctrvBatch.FolderClick += new CommonToolkit.Controls.Common.FolderClickEventHandler(this.ctrvBatch_FolderClick);