private void WaitForCurrentAnimationToComplete() { if (_CurrentAnimation != null) { DateTime start = DateTime.Now; while (!_CurrentAnimation.IsDisposed) { Application.DoEvents(); if (DateTime.Now.Subtract(start).TotalMilliseconds > 1000) { AbortCurrentAnimation(); break; } } _CurrentAnimation = null; } }
private void AbortCurrentAnimation() { Animation.Animation anim = _CurrentAnimation; _CurrentAnimation = null; if (anim != null) { anim.Stop(); anim.Dispose(); } }
internal void Open() { if (_IsOpening) return; try { _IsOpening = true; this.Displayed = true; WaitForCurrentAnimationToComplete(); if (this.Parent != null) // Hosted elsewhere other than RadialMenu { IOwnerMenuSupport ownerMenu = this.GetIOwnerMenuSupport(); if (ownerMenu != null) { if (_PopupProxy == null) _PopupProxy = new RadialMenuPopupProxy(this); _PopupProxy.Expanded = true; ownerMenu.RegisterPopup(_PopupProxy); } } if (_Popup == null) { _Popup = new RadialMenuPopup(); _Popup.DisplayItem = this; if (_Font != null) _Popup.Font = _Font; else if (_RadialMenu != null) _Popup.Font = _RadialMenu.Font; _Popup.CreateControl(); } if (_MenuLocation.IsEmpty) { if (_RadialMenu != null) { Point p = _RadialMenu.PointToScreen( new Point(_RadialMenu.Width / 2, _RadialMenu.Height / 2)); p.X -= _Diameter / 2; p.Y -= _Diameter / 2; _Popup.Location = p; } else { Point p = Control.MousePosition; p.X -= _Diameter / 2; p.Y -= _Diameter / 2; _Popup.Location = p; } } else _Popup.Location = _MenuLocation; _Popup.Visible = true; _Popup.Refresh(); Animation.AnimationInt anim = new DevComponents.DotNetBar.Animation.AnimationInt( new Animation.AnimationRequest(this, "OpenState", 0, 100), Animation.AnimationEasing.EaseOutCubic, 300); anim.AutoDispose = true; _CurrentAnimation = anim; anim.Start(); } finally { _IsOpening = false; } }