/// <summary> /// 委托函数 /// </summary> /// <param name="e"></param> protected virtual void OnButtonRepeatState(HMIButtonEventArgs e) { if (this.ButtonRepeatState != null) { this.ButtonRepeatState(this, e); } }
/// <summary> /// 鼠标按下事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnMouseDown(object sender, MouseEventArgs e) { // 改变状态 if (ButtonType == ButtonTypeenum.AutoReset) { this.State = ButtonState.Pressed; this.Invalidate(); } else { if (this.State == ButtonState.Pressed) { this.State = ButtonState.Normal; } else { this.State = ButtonState.Pressed; } } // 调用事件 HMIButtonEventArgs ev = new HMIButtonEventArgs(); ev.State = this.State; this.OnButtonChangeState(ev); // 使能定时器 if (this.RepeatState != false) { this.tmrRepeat.Interval = this.StartRepeatInterval; this.tmrRepeat.Enabled = true; } }
/// <summary> /// 定时器事件处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Timer_Tick(object sender, EventArgs e) { this.tmrRepeat.Enabled = false; // 更新刷新间隔 if (tmrRepeat.Interval == this.startRepeatInterval) { this.tmrRepeat.Interval = this.repeatInterval; } // 调用事件 HMIButtonEventArgs ev = new HMIButtonEventArgs(); ev.State = this.State; this.OnButtonRepeatState(ev); this.tmrRepeat.Enabled = true; }
/// <summary> /// 鼠标事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnMuoseUp(object sender, MouseEventArgs e) { // 改变状态 if (ButtonType == ButtonTypeenum.AutoReset) { this.State = ButtonState.Normal; this.Invalidate(); } // 调用事件 HMIButtonEventArgs ev = new HMIButtonEventArgs(); ev.State = this.State; this.OnButtonChangeState(ev); //关定时器 this.tmrRepeat.Enabled = false; }