private void InitializeStoryMouseLeave() { storyMouseLeave = new Storyboard(); ColorAnimation ellipseColorAnimation = new ColorAnimation(BaseColor, AnimationDuration); ColorAnimation lineRTColorAnimation = ellipseColorAnimation.Clone(); ColorAnimation lineLTColorAnimation = ellipseColorAnimation.Clone(); this.ellipse.RegisterName("ellipseBrush", this.ellipse.Stroke); Storyboard.SetTargetName(ellipseColorAnimation, "ellipseBrush"); Storyboard.SetTargetProperty(ellipseColorAnimation, new PropertyPath(SolidColorBrush.ColorProperty)); this.rectLineLT.RegisterName("lineLTBrush", this.rectLineLT.Stroke); Storyboard.SetTargetName(lineLTColorAnimation, "lineLTBrush"); Storyboard.SetTargetProperty(lineLTColorAnimation, new PropertyPath(SolidColorBrush.ColorProperty)); this.rectLineRT.RegisterName("lineRTBrush", this.rectLineRT.Stroke); Storyboard.SetTargetName(lineRTColorAnimation, "lineRTBrush"); Storyboard.SetTargetProperty(lineRTColorAnimation, new PropertyPath(SolidColorBrush.ColorProperty)); storyMouseLeave.Children.Add(ellipseColorAnimation); storyMouseLeave.Children.Add(lineLTColorAnimation); storyMouseLeave.Children.Add(lineRTColorAnimation); }
private void InitializeStoryMouseEnter() { storyMouseEnter = new Storyboard(); DoubleAnimation dbInnerRadius = new DoubleAnimation() { To = 0.30, Duration = AnimationDuration }; ColorAnimation c1Animation = new ColorAnimation() { To = TargetColor, Duration = AnimationDuration, AutoReverse = false }; var c2Animation = c1Animation.Clone(); storyMouseEnter.Children.Add(dbInnerRadius); Storyboard.SetTarget(dbInnerRadius, this.regularPolygon); Storyboard.SetTargetProperty(dbInnerRadius, new PropertyPath("(ed:RegularPolygon.InnerRadius)")); storyMouseEnter.Children.Add(c1Animation); this.regularPolygon.RegisterName("regBrush", this.regularPolygon.Stroke); Storyboard.SetTargetName(c1Animation, "regBrush"); Storyboard.SetTargetProperty(c1Animation, new PropertyPath(SolidColorBrush.ColorProperty)); storyMouseEnter.Children.Add(c2Animation); this.ellipse.RegisterName("resizeBrush", this.ellipse.Stroke); Storyboard.SetTargetName(c2Animation, "resizeBrush"); Storyboard.SetTargetProperty(c2Animation, new PropertyPath(SolidColorBrush.ColorProperty)); }
private void InitializeStoryMouseLeave() { storyMouseLeave = new Storyboard(); DoubleAnimation dbWidth = new DoubleAnimation() { To = RectangleWidth, Duration = AnimationDuration }; DoubleAnimation dbHeight = new DoubleAnimation() { To = RectangleHeight, Duration = AnimationDuration }; ColorAnimation c1Animation = new ColorAnimation() { To = BaseColor, Duration = AnimationDuration, AutoReverse = false }; var c2Animation = c1Animation.Clone(); storyMouseLeave.Children.Add(dbWidth); Storyboard.SetTarget(dbWidth, this.rectangle); Storyboard.SetTargetProperty(dbWidth, new PropertyPath(MediaElement.WidthProperty)); storyMouseLeave.Children.Add(dbHeight); Storyboard.SetTarget(dbHeight, this.rectangle); Storyboard.SetTargetProperty(dbHeight, new PropertyPath(MediaElement.HeightProperty)); Storyboard.SetTargetName(c1Animation, "rectBrush"); storyMouseLeave.Children.Add(c1Animation); this.rectangle.RegisterName("rectBrush", this.rectangle.Stroke); Storyboard.SetTargetName(c2Animation, "rectBrush"); Storyboard.SetTargetProperty(c1Animation, new PropertyPath(SolidColorBrush.ColorProperty)); storyMouseLeave.Children.Add(c2Animation); this.ellipse.RegisterName("resizeBrush", this.ellipse.Stroke); Storyboard.SetTargetName(c2Animation, "resizeBrush"); Storyboard.SetTargetProperty(c2Animation, new PropertyPath(SolidColorBrush.ColorProperty)); }
private void InitializeStoryMouseEnter() { this.rectangle.Margin = new Thickness(7, 8.25, 7, 8.25); // This Control is a Square Rectangle with a Oval Circle in the Center of this shape // by Radius equal this Square Diagonal. // // In animate do not rectangle overlapping by oval circle, // so must be have limit a for rectangle // // rectangle (a, b) ---(Animate)---> rectangle(W, H) // // a -> W & b -> H // // H = ? // W = ? // // ____Width:W_____ // |\ /| // | \ / | // | \ / | // | \R / | // | \______/ | // | |\ /| | H // | | \r / | | e // |____|__\/ | | i : H // | | /\ |b | g // | | / \ | | h // | |/____\| | t // | / a \ | // | / \ | // | / \ | // | / \ | // |/______________\| // // a = RectangleWidth // b = RectangleHeight // // r/R = (a/2)/(W/2) = (b/2)/(H/2) // // r = √(a^2 + b^2) // // R = √(H^2 + W^2) = Diagonal of this Square = this.Height/2 = this.Width/2 // __________________________ // | | // ==> W = 2*R*a / r ==> | W = 2*R*a / √(a^2 + b^2) | // |__________________________| // & // __________________________ // | | // ==> H = 2*R*b / r ==> | H = 2*R*b / √(a^2 + b^2) | // |__________________________| // int a = (int)RectangleWidth; int b = (int)RectangleHeight; int R = (int)this.Height / 2; double W = (int)(2 * R * a / Math.Sqrt(a * a + b * b)); double H = (int)(2 * R * b / Math.Sqrt(a * a + b * b)); W -= W * 0.2; H -= H * 0.2; storyMouseEnter = new Storyboard(); DoubleAnimation dbWidth = new DoubleAnimation() { To = W, Duration = AnimationDuration }; DoubleAnimation dbHeight = new DoubleAnimation() { To = H, Duration = AnimationDuration }; ColorAnimation c1Animation = new ColorAnimation() { To = TargetColor, Duration = AnimationDuration, AutoReverse = false }; var c2Animation = c1Animation.Clone(); storyMouseEnter.Children.Add(dbWidth); Storyboard.SetTarget(dbWidth, this.rectangle); Storyboard.SetTargetProperty(dbWidth, new PropertyPath(MediaElement.WidthProperty)); storyMouseEnter.Children.Add(dbHeight); Storyboard.SetTarget(dbHeight, this.rectangle); Storyboard.SetTargetProperty(dbHeight, new PropertyPath(MediaElement.HeightProperty)); Storyboard.SetTargetName(c1Animation, "rectBrush"); storyMouseEnter.Children.Add(c1Animation); this.rectangle.RegisterName("rectBrush", this.rectangle.Stroke); Storyboard.SetTargetName(c2Animation, "rectBrush"); Storyboard.SetTargetProperty(c1Animation, new PropertyPath(SolidColorBrush.ColorProperty)); storyMouseEnter.Children.Add(c2Animation); this.ellipse.RegisterName("resizeBrush", this.ellipse.Stroke); Storyboard.SetTargetName(c2Animation, "resizeBrush"); Storyboard.SetTargetProperty(c2Animation, new PropertyPath(SolidColorBrush.ColorProperty)); }