public override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); SkinnableControl ctl = controls.FirstOrDefault(c => c.Capture); if (ctl == null) { ctl = controls.FirstOrDefault(c => c.HitTest(e.Location)); } if (ctl == null) { // Gestione click if (!this.suppressNextClick) { var capture = this.Capture; var hit = this.IsInside(e.Location); if (e.Button == MouseButtons.Left && capture && hit) { this.OnClick(new EventArgs()); } } } else { var capture = ctl.Capture; var hit = ctl.HitTest(e.Location); // Gestione click if (e.Button == MouseButtons.Left && capture && hit && !this.suppressNextClick) { ctl.OnClick(new EventArgs()); } MouseEventArgs e2 = new MouseEventArgs(e.Button, e.Clicks, e.X - (int)Math.Round(ctl.Left, 0, MidpointRounding.ToEven), e.Y - (int)Math.Round(ctl.Top, 0, MidpointRounding.ToEven), e.Delta); ctl.OnMouseUp(e2); if (capture && !hit) { // Il capturing è finito e ora ci ritroviamo su un controllo diverso... lanciamo // gli eventi MouseLeave / MouseEnter ctl.OnMouseLeave(new EventArgs()); SkinnableControl enterctl = controls.FirstOrDefault(c => c.HitTest(e.Location)); if (enterctl != null) { lastEnterControl = enterctl; enterctl.OnMouseEnter(new EventArgs()); } } } this.suppressNextClick = false; }