form1.cs

来自「C#高级编程第6版随书源代码 值得下载」· CS 代码 · 共 47 行

CS
47
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Wrox.ProCSharp.Delegates
{





   public partial class Form1 : Form
   {
      public delegate void ActionEventHandler(object sender, ActionCancelEventArgs e);

      public static event ActionEventHandler Action;
      private BusEntity busEntity;

      protected void OnAction(object sender, ActionCancelEventArgs e)
      {
         if (Action != null)
            Action(sender, e);
      }


      public Form1()
      {
         InitializeComponent();
         busEntity = new BusEntity();
      }

      private void buttonRaise_Click(object sender, EventArgs e)
      {
         ActionCancelEventArgs cancelEvent = new ActionCancelEventArgs();
         OnAction(this, cancelEvent);
         if (cancelEvent.Cancel)
            labelInfo.Text = cancelEvent.Message;
         else
            labelInfo.Text = busEntity.TimeString;

      }
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?