protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) { var point = e.GetPosition(this); if (RippleEditor.GetOnCenter(this)) { var innercontent = Content as FrameworkElement; if (innercontent != null) { var position = innercontent.TransformToAncestor(this).Transform(new Point(0, 0)); offsetx = position.X + innercontent.ActualWidth / 2 - RippleSize / 2; offsety = position.Y + innercontent.ActualHeight / 2 - RippleSize / 2; } else { offsetx = ActualWidth / 2 - RippleSize / 2; offsety = ActualHeight / 2 - RippleSize / 2; } } else { offsetx = point.X - RippleSize / 2; offsety = point.Y - RippleSize / 2; } if (!RippleEditor.Getdisable(this)) { VisualStateManager.GoToState(this, "normal", false); VisualStateManager.GoToState(this, "click", true); instance.Add(this); } base.OnPreviewMouseLeftButtonDown(e); }
private void Ripple_SizeChanged(object sender, SizeChangedEventArgs e) { var innerContent = (Content as FrameworkElement); double width, height; if (RippleEditor.GetOnCenter(this) && innerContent != null) { width = innerContent.ActualWidth; height = innerContent.ActualHeight; } else { width = e.NewSize.Width; height = e.NewSize.Height; } var radius = Math.Sqrt(Math.Pow(width, 2) + Math.Pow(height, 2)); RippleSize = 2 * radius; }