private void ButtonWatch_Click(object sender, EventArgs e) { buttonWatch.Enabled = false;//2度押し防止 if (labelWatchStatus.Text == "監視中") { if (cbw != null) { cbw.Dispose(); cbw = null; } labelWatchStatus.Text = "監視停止中"; } else { labelWatchStatus.Text = "監視中"; cbw = new ClipBoardWatcher(); cbw.DrawClipBoard += (sender2, e2) => { if (Clipboard.ContainsImage()) { buttonClip_Click(sender, null); buttonSave_Click(sender, null); } }; } buttonWatch.Enabled = true;//2度押し防止 }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (cbw != null) { cbw.Dispose(); cbw = null; } }
public Form1() { InitializeComponent(); cbw = null; }