Exemple #1
0
def onMouseLeftButtonUp(s, e):
	global y, storyboard

	if y is not None:
		if y > s.Top and storyboard is None:
			storyboard = Storyboard()
			da = DoubleAnimation(s.Top, y, TimeSpan.FromSeconds(Math.Sqrt(2 * ((y - s.Top) * 0.1) / 9.80665)))
			bounceEase = BounceEase()

			bounceEase.EasingMode = EasingMode.EaseOut
			bounceEase.Bounces = 5
			da.EasingFunction = bounceEase

			def onCurrentStateInvalidated(sender, args):
				global storyboard

				if sender.CurrentState == ClockState.Filling:
					s.Top = da.To
					storyboard.Remove(s)
					storyboard = None

			storyboard.CurrentStateInvalidated += onCurrentStateInvalidated
			storyboard.Children.Add(da)

			Storyboard.SetTargetProperty(da, PropertyPath(Window.TopProperty))
			s.BeginStoryboard(storyboard, HandoffBehavior.SnapshotAndReplace, True)

		y = None
Exemple #2
0
            def onClose(sender, args):
                global digits

                closeTimer.Stop()

                storyboard = Storyboard()

                def onCurrentStateInvalidated(sender, args):
                    if sender.CurrentState == ClockState.Filling:
                        for element in grid1.Children:
                            element.Opacity = 0

                        storyboard.Remove(contentControl)
                        tickTimer.Stop()
                        window.Close()

                storyboard.CurrentStateInvalidated += onCurrentStateInvalidated

                r = Random(Environment.TickCount)

                for i in range(digits.Length):
                    beginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(
                        r.Next(500)))

                    for element in grid1.Children:
                        if Grid.GetColumn(element) == i:
                            doubleAnimation = DoubleAnimation(
                                element.Opacity, 0,
                                TimeSpan.FromMilliseconds(500))
                            doubleAnimation.BeginTime = beginTime
                            sineEase = SineEase()

                            sineEase.EasingMode = EasingMode.EaseIn
                            doubleAnimation.EasingFunction = sineEase

                            storyboard.Children.Add(doubleAnimation)

                            Storyboard.SetTarget(doubleAnimation, element)
                            Storyboard.SetTargetProperty(
                                doubleAnimation,
                                PropertyPath(UIElement.OpacityProperty))

                contentControl.BeginStoryboard(
                    storyboard, HandoffBehavior.SnapshotAndReplace, True)
                closeTimer.Tag = False
Exemple #3
0
			def onClose(sender, args):
				global digits

				closeTimer.Stop()

				storyboard = Storyboard()

				def onCurrentStateInvalidated(sender, args):
					if sender.CurrentState == ClockState.Filling:
						for element in grid1.Children:
							element.Opacity = 0

						storyboard.Remove(contentControl)
						tickTimer.Stop()
						window.Close()

				storyboard.CurrentStateInvalidated += onCurrentStateInvalidated

				r = Random(Environment.TickCount)

				for i in range(digits.Length):
					beginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(r.Next(500)))

					for element in grid1.Children:
						if Grid.GetColumn(element) == i:
							doubleAnimation = DoubleAnimation(element.Opacity, 0, TimeSpan.FromMilliseconds(500))
							doubleAnimation.BeginTime = beginTime
							sineEase = SineEase()

							sineEase.EasingMode = EasingMode.EaseIn
							doubleAnimation.EasingFunction = sineEase

							storyboard.Children.Add(doubleAnimation)

							Storyboard.SetTarget(doubleAnimation, element)
							Storyboard.SetTargetProperty(doubleAnimation, PropertyPath(UIElement.OpacityProperty))

				contentControl.BeginStoryboard(storyboard, HandoffBehavior.SnapshotAndReplace, True)
				closeTimer.Tag = False
Exemple #4
0
			def onLoaded(sender, args):
				global rectList, digits

				storyboard = Storyboard()

				def onCurrentStateInvalidated(sender, args):
					if sender.CurrentState == ClockState.Filling:
						for element in grid1.Children:
							element.Opacity = 1

						storyboard.Remove(contentControl)

						if not grid1.Tag:
							closeTimer.Start()

				storyboard.CurrentStateInvalidated += onCurrentStateInvalidated

				r = Random(Environment.TickCount)
				dateTime = DateTime.Now

				digits[0] = dateTime.Hour / 10
				digits[1] = dateTime.Hour % 10
				digits[2] = dateTime.Minute / 10
				digits[3] = dateTime.Minute % 10
				digits[4] = dateTime.Second / 10
				digits[5] = dateTime.Second % 10

				for i in range(digits.Length):
					beginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(r.Next(500)))

					for element1 in grid1.Children:
						if Grid.GetColumn(element1) == i:
							doubleAnimation = DoubleAnimation(element1.Opacity, 1, TimeSpan.FromMilliseconds(500))
							doubleAnimation.BeginTime = beginTime
							sineEase = SineEase()

							sineEase.EasingMode = EasingMode.EaseOut
							doubleAnimation.EasingFunction = sineEase

							storyboard.Children.Add(doubleAnimation)
								
							Storyboard.SetTarget(doubleAnimation, element1)
							Storyboard.SetTargetProperty(doubleAnimation, PropertyPath(UIElement.OpacityProperty))

							if Grid.GetRow(element1) == 0:
								scale1 = Math.Max(element1.ActualWidth / maxWidth, element1.ActualHeight / maxHeight)

								if rectList[digits[Grid.GetColumn(element1)]].Width > maxWidth and rectList[digits[Grid.GetColumn(element1)]].Height > maxHeight:
									translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digits[Grid.GetColumn(element1)]].Width - maxWidth) / 2.0))
									translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digits[Grid.GetColumn(element1)]].Height - maxHeight) / 2.0))

								elif rectList[digits[Grid.GetColumn(element1)]].Width > maxWidth:
									translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digits[Grid.GetColumn(element1)]].Width - maxWidth) / 2.0))
									translateY = Math.Round(-rectList[digits[Grid.GetColumn(element1)]].Y)

								elif rectList[digits[Grid.GetColumn(element1)]].Height > maxHeight:
									translateX = Math.Round(-rectList[digits[Grid.GetColumn(element1)]].X)
									translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digits[Grid.GetColumn(element1)]].Height - maxHeight) / 2.0))

								else:
									translateX = Math.Round(-rectList[digits[Grid.GetColumn(element1)]].X)
									translateY = Math.Round(-rectList[digits[Grid.GetColumn(element1)]].Y)

								scale2 = Math.Max(maxWidth / rectList[digits[Grid.GetColumn(element1)]].Width, maxHeight / rectList[digits[Grid.GetColumn(element1)]].Height)

								if scale2 > 1:
									scale2 = 1

								for element2 in element1.Child.Children:
									transformGroup1 = TransformGroup()
									transformGroup1.Children.Add(TranslateTransform((element2.ActualWidth - maxWidth) / 2, (element2.ActualHeight - maxHeight) / 2))
									transformGroup1.Children.Add(ScaleTransform(scale1, scale1, element2.ActualWidth / 2, element2.ActualHeight / 2))
				
									element2.RenderTransform = transformGroup1
									
									for element3 in element2.Children:
										transformGroup2 = TransformGroup()
										transformGroup2.Children.Add(TranslateTransform(translateX, translateY))
										transformGroup2.Children.Add(ScaleTransform(scale2, scale2, maxWidth / 2, maxHeight / 2))
				
										element3.RenderTransform = transformGroup2

				contentControl.BeginStoryboard(storyboard, HandoffBehavior.SnapshotAndReplace, True)

				tickTimer.Start()
Exemple #5
0
			def onTick(sender, args):
				global rectList, digits

				if rectList.Count > 0:
					dateTime = DateTime.Now

					for element1 in grid1.Children:
						if Grid.GetRow(element1) == 0:
							if Grid.GetColumn(element1) == 0:
								digit = dateTime.Hour / 10
							elif Grid.GetColumn(element1) == 1:
								digit = dateTime.Hour % 10
							elif Grid.GetColumn(element1) == 2:
								digit = dateTime.Minute / 10
							elif Grid.GetColumn(element1) == 3:
								digit = dateTime.Minute % 10
							elif Grid.GetColumn(element1) == 4:
								digit = dateTime.Second / 10
							else:
								digit = dateTime.Second % 10

							if digit != digits[Grid.GetColumn(element1)]:
								for element2 in element1.Child.Children:
									for element3 in element2.Children:
										storyboard = Storyboard()

										for transform in element3.RenderTransform.Children:
											if clr.GetClrType(TranslateTransform).IsInstanceOfType(transform):
												if rectList[digit].Width > maxWidth and rectList[digit].Height > maxHeight:
													translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digit].X + (rectList[digit].Width - maxWidth) / 2.0 - rectList[digits[Grid.GetColumn(element1)]].X)))
													translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digit].Y + (rectList[digit].Height - maxHeight) / 2.0 - rectList[digits[Grid.GetColumn(element1)]].Y)))

												elif rectList[digit].Width > maxWidth:
													translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digit].X + (rectList[digit].Width - maxWidth) / 2.0 - rectList[digits[Grid.GetColumn(element1)]].X)))
													translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digit].Y - rectList[digits[Grid.GetColumn(element1)]].Y)))

												elif rectList[digit].Height > maxHeight:
													translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digit].X - rectList[digits[Grid.GetColumn(element1)]].X)))
													translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digit].Y + (rectList[digit].Height - maxHeight) / 2.0 - rectList[digits[Grid.GetColumn(element1)]].Y)))

												else:
													translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digit].X - rectList[digits[Grid.GetColumn(element1)]].X)))
													translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digit].Y - rectList[digits[Grid.GetColumn(element1)]].Y)))

												doubleAnimation1 = DoubleAnimation(translateX, TimeSpan.FromMilliseconds(500))
												doubleAnimation2 = DoubleAnimation(translateY, TimeSpan.FromMilliseconds(500))
												sineEase = SineEase()

												sineEase.EasingMode = EasingMode.EaseInOut
												doubleAnimation1.EasingFunction = sineEase
												doubleAnimation2.EasingFunction = sineEase

												storyboard.Children.Add(doubleAnimation1)
												storyboard.Children.Add(doubleAnimation2)
								
												Storyboard.SetTarget(doubleAnimation1, element3)
												Storyboard.SetTarget(doubleAnimation2, element3)
												Storyboard.SetTargetProperty(doubleAnimation1, PropertyPath("(0).(1)[0].(2)", Canvas.RenderTransformProperty, TransformGroup.ChildrenProperty, TranslateTransform.XProperty))
												Storyboard.SetTargetProperty(doubleAnimation2, PropertyPath("(0).(1)[0].(2)", Canvas.RenderTransformProperty, TransformGroup.ChildrenProperty, TranslateTransform.YProperty))

											else:
												scale1 = Math.Max(maxWidth / rectList[digits[Grid.GetColumn(element1)]].Width, maxHeight / rectList[digits[Grid.GetColumn(element1)]].Height)
												scale2 = Math.Max(maxWidth / rectList[digit].Width, maxHeight / rectList[digit].Height)

												if scale1 > 1:
													scale1 = 1

												if scale2 > 1:
													scale2 = 1

												transform.ScaleX = transform.ScaleY = scale1 + (scale2 - scale1)

												doubleAnimation1 = DoubleAnimation(scale1 + (scale2 - scale1), TimeSpan.FromMilliseconds(500))
												doubleAnimation2 = DoubleAnimation(scale1 + (scale2 - scale1), TimeSpan.FromMilliseconds(500))
												sineEase = SineEase()

												sineEase.EasingMode = EasingMode.EaseInOut
												doubleAnimation1.EasingFunction = sineEase
												doubleAnimation2.EasingFunction = sineEase

												storyboard.Children.Add(doubleAnimation1)
												storyboard.Children.Add(doubleAnimation2)
								
												Storyboard.SetTarget(doubleAnimation1, element3)
												Storyboard.SetTarget(doubleAnimation2, element3)
												Storyboard.SetTargetProperty(doubleAnimation1, PropertyPath("(0).(1)[1].(2)", Canvas.RenderTransformProperty, TransformGroup.ChildrenProperty, ScaleTransform.ScaleXProperty))
												Storyboard.SetTargetProperty(doubleAnimation2, PropertyPath("(0).(1)[1].(2)", Canvas.RenderTransformProperty, TransformGroup.ChildrenProperty, ScaleTransform.ScaleYProperty))

										element3.BeginStoryboard(storyboard, HandoffBehavior.SnapshotAndReplace)

								digits[Grid.GetColumn(element1)] = digit
Exemple #6
0
            def onTick(sender, args):
                global rectList, digits

                if rectList.Count > 0:
                    dateTime = DateTime.Now

                    for element1 in grid1.Children:
                        if Grid.GetRow(element1) == 0:
                            if Grid.GetColumn(element1) == 0:
                                digit = dateTime.Hour / 10
                            elif Grid.GetColumn(element1) == 1:
                                digit = dateTime.Hour % 10
                            elif Grid.GetColumn(element1) == 2:
                                digit = dateTime.Minute / 10
                            elif Grid.GetColumn(element1) == 3:
                                digit = dateTime.Minute % 10
                            elif Grid.GetColumn(element1) == 4:
                                digit = dateTime.Second / 10
                            else:
                                digit = dateTime.Second % 10

                            if digit != digits[Grid.GetColumn(element1)]:
                                for element2 in element1.Child.Children:
                                    for element3 in element2.Children:
                                        storyboard = Storyboard()

                                        for transform in element3.RenderTransform.Children:
                                            if clr.GetClrType(
                                                    TranslateTransform
                                            ).IsInstanceOfType(transform):
                                                if rectList[
                                                        digit].Width > maxWidth and rectList[
                                                            digit].Height > maxHeight:
                                                    translateX = Math.Round(-(
                                                        rectList[digits[
                                                            Grid.GetColumn(
                                                                element1)]].X +
                                                        (rectList[digit].X +
                                                         (rectList[digit].Width
                                                          - maxWidth) / 2.0 -
                                                         rectList[digits[
                                                             Grid.GetColumn(
                                                                 element1)]].X)
                                                    ))
                                                    translateY = Math.Round(-(
                                                        rectList[digits[
                                                            Grid.GetColumn(
                                                                element1)]].Y +
                                                        (rectList[digit].Y +
                                                         (rectList[digit].
                                                          Height - maxHeight) /
                                                         2.0 - rectList[digits[
                                                             Grid.GetColumn(
                                                                 element1)]].Y)
                                                    ))

                                                elif rectList[
                                                        digit].Width > maxWidth:
                                                    translateX = Math.Round(-(
                                                        rectList[digits[
                                                            Grid.GetColumn(
                                                                element1)]].X +
                                                        (rectList[digit].X +
                                                         (rectList[digit].Width
                                                          - maxWidth) / 2.0 -
                                                         rectList[digits[
                                                             Grid.GetColumn(
                                                                 element1)]].X)
                                                    ))
                                                    translateY = Math.Round(-(
                                                        rectList[digits[
                                                            Grid.GetColumn(
                                                                element1)]].Y +
                                                        (rectList[digit].Y -
                                                         rectList[digits[
                                                             Grid.GetColumn(
                                                                 element1)]].Y)
                                                    ))

                                                elif rectList[
                                                        digit].Height > maxHeight:
                                                    translateX = Math.Round(-(
                                                        rectList[digits[
                                                            Grid.GetColumn(
                                                                element1)]].X +
                                                        (rectList[digit].X -
                                                         rectList[digits[
                                                             Grid.GetColumn(
                                                                 element1)]].X)
                                                    ))
                                                    translateY = Math.Round(-(
                                                        rectList[digits[
                                                            Grid.GetColumn(
                                                                element1)]].Y +
                                                        (rectList[digit].Y +
                                                         (rectList[digit].
                                                          Height - maxHeight) /
                                                         2.0 - rectList[digits[
                                                             Grid.GetColumn(
                                                                 element1)]].Y)
                                                    ))

                                                else:
                                                    translateX = Math.Round(-(
                                                        rectList[digits[
                                                            Grid.GetColumn(
                                                                element1)]].X +
                                                        (rectList[digit].X -
                                                         rectList[digits[
                                                             Grid.GetColumn(
                                                                 element1)]].X)
                                                    ))
                                                    translateY = Math.Round(-(
                                                        rectList[digits[
                                                            Grid.GetColumn(
                                                                element1)]].Y +
                                                        (rectList[digit].Y -
                                                         rectList[digits[
                                                             Grid.GetColumn(
                                                                 element1)]].Y)
                                                    ))

                                                doubleAnimation1 = DoubleAnimation(
                                                    translateX,
                                                    TimeSpan.FromMilliseconds(
                                                        500))
                                                doubleAnimation2 = DoubleAnimation(
                                                    translateY,
                                                    TimeSpan.FromMilliseconds(
                                                        500))
                                                sineEase = SineEase()

                                                sineEase.EasingMode = EasingMode.EaseInOut
                                                doubleAnimation1.EasingFunction = sineEase
                                                doubleAnimation2.EasingFunction = sineEase

                                                storyboard.Children.Add(
                                                    doubleAnimation1)
                                                storyboard.Children.Add(
                                                    doubleAnimation2)

                                                Storyboard.SetTarget(
                                                    doubleAnimation1, element3)
                                                Storyboard.SetTarget(
                                                    doubleAnimation2, element3)
                                                Storyboard.SetTargetProperty(
                                                    doubleAnimation1,
                                                    PropertyPath(
                                                        "(0).(1)[0].(2)",
                                                        Canvas.
                                                        RenderTransformProperty,
                                                        TransformGroup.
                                                        ChildrenProperty,
                                                        TranslateTransform.
                                                        XProperty))
                                                Storyboard.SetTargetProperty(
                                                    doubleAnimation2,
                                                    PropertyPath(
                                                        "(0).(1)[0].(2)",
                                                        Canvas.
                                                        RenderTransformProperty,
                                                        TransformGroup.
                                                        ChildrenProperty,
                                                        TranslateTransform.
                                                        YProperty))

                                            else:
                                                scale1 = Math.Max(
                                                    maxWidth / rectList[digits[
                                                        Grid.GetColumn(
                                                            element1)]].Width,
                                                    maxHeight / rectList[
                                                        digits[Grid.GetColumn(
                                                            element1)]].Height)
                                                scale2 = Math.Max(
                                                    maxWidth /
                                                    rectList[digit].Width,
                                                    maxHeight /
                                                    rectList[digit].Height)

                                                if scale1 > 1:
                                                    scale1 = 1

                                                if scale2 > 1:
                                                    scale2 = 1

                                                transform.ScaleX = transform.ScaleY = scale1 + (
                                                    scale2 - scale1)

                                                doubleAnimation1 = DoubleAnimation(
                                                    scale1 + (scale2 - scale1),
                                                    TimeSpan.FromMilliseconds(
                                                        500))
                                                doubleAnimation2 = DoubleAnimation(
                                                    scale1 + (scale2 - scale1),
                                                    TimeSpan.FromMilliseconds(
                                                        500))
                                                sineEase = SineEase()

                                                sineEase.EasingMode = EasingMode.EaseInOut
                                                doubleAnimation1.EasingFunction = sineEase
                                                doubleAnimation2.EasingFunction = sineEase

                                                storyboard.Children.Add(
                                                    doubleAnimation1)
                                                storyboard.Children.Add(
                                                    doubleAnimation2)

                                                Storyboard.SetTarget(
                                                    doubleAnimation1, element3)
                                                Storyboard.SetTarget(
                                                    doubleAnimation2, element3)
                                                Storyboard.SetTargetProperty(
                                                    doubleAnimation1,
                                                    PropertyPath(
                                                        "(0).(1)[1].(2)",
                                                        Canvas.
                                                        RenderTransformProperty,
                                                        TransformGroup.
                                                        ChildrenProperty,
                                                        ScaleTransform.
                                                        ScaleXProperty))
                                                Storyboard.SetTargetProperty(
                                                    doubleAnimation2,
                                                    PropertyPath(
                                                        "(0).(1)[1].(2)",
                                                        Canvas.
                                                        RenderTransformProperty,
                                                        TransformGroup.
                                                        ChildrenProperty,
                                                        ScaleTransform.
                                                        ScaleYProperty))

                                        element3.BeginStoryboard(
                                            storyboard,
                                            HandoffBehavior.SnapshotAndReplace)

                                digits[Grid.GetColumn(element1)] = digit
Exemple #7
0
            def onLoaded(sender, args):
                global rectList, digits

                storyboard = Storyboard()

                def onCurrentStateInvalidated(sender, args):
                    if sender.CurrentState == ClockState.Filling:
                        for element in grid1.Children:
                            element.Opacity = 1

                        storyboard.Remove(contentControl)

                        if not grid1.Tag:
                            closeTimer.Start()

                storyboard.CurrentStateInvalidated += onCurrentStateInvalidated

                r = Random(Environment.TickCount)
                dateTime = DateTime.Now

                digits[0] = dateTime.Hour / 10
                digits[1] = dateTime.Hour % 10
                digits[2] = dateTime.Minute / 10
                digits[3] = dateTime.Minute % 10
                digits[4] = dateTime.Second / 10
                digits[5] = dateTime.Second % 10

                for i in range(digits.Length):
                    beginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(
                        r.Next(500)))

                    for element1 in grid1.Children:
                        if Grid.GetColumn(element1) == i:
                            doubleAnimation = DoubleAnimation(
                                element1.Opacity, 1,
                                TimeSpan.FromMilliseconds(500))
                            doubleAnimation.BeginTime = beginTime
                            sineEase = SineEase()

                            sineEase.EasingMode = EasingMode.EaseOut
                            doubleAnimation.EasingFunction = sineEase

                            storyboard.Children.Add(doubleAnimation)

                            Storyboard.SetTarget(doubleAnimation, element1)
                            Storyboard.SetTargetProperty(
                                doubleAnimation,
                                PropertyPath(UIElement.OpacityProperty))

                            if Grid.GetRow(element1) == 0:
                                scale1 = Math.Max(
                                    element1.ActualWidth / maxWidth,
                                    element1.ActualHeight / maxHeight)

                                if rectList[digits[Grid.GetColumn(
                                        element1
                                )]].Width > maxWidth and rectList[digits[
                                        Grid.GetColumn(
                                            element1)]].Height > maxHeight:
                                    translateX = Math.Round(
                                        -(rectList[digits[Grid.GetColumn(
                                            element1)]].X +
                                          (rectList[digits[Grid.GetColumn(
                                              element1)]].Width - maxWidth) /
                                          2.0))
                                    translateY = Math.Round(
                                        -(rectList[digits[Grid.GetColumn(
                                            element1)]].Y +
                                          (rectList[digits[Grid.GetColumn(
                                              element1)]].Height - maxHeight) /
                                          2.0))

                                elif rectList[digits[Grid.GetColumn(
                                        element1)]].Width > maxWidth:
                                    translateX = Math.Round(
                                        -(rectList[digits[Grid.GetColumn(
                                            element1)]].X +
                                          (rectList[digits[Grid.GetColumn(
                                              element1)]].Width - maxWidth) /
                                          2.0))
                                    translateY = Math.Round(-rectList[digits[
                                        Grid.GetColumn(element1)]].Y)

                                elif rectList[digits[Grid.GetColumn(
                                        element1)]].Height > maxHeight:
                                    translateX = Math.Round(-rectList[digits[
                                        Grid.GetColumn(element1)]].X)
                                    translateY = Math.Round(
                                        -(rectList[digits[Grid.GetColumn(
                                            element1)]].Y +
                                          (rectList[digits[Grid.GetColumn(
                                              element1)]].Height - maxHeight) /
                                          2.0))

                                else:
                                    translateX = Math.Round(-rectList[digits[
                                        Grid.GetColumn(element1)]].X)
                                    translateY = Math.Round(-rectList[digits[
                                        Grid.GetColumn(element1)]].Y)

                                scale2 = Math.Max(
                                    maxWidth / rectList[digits[Grid.GetColumn(
                                        element1)]].Width,
                                    maxHeight / rectList[digits[Grid.GetColumn(
                                        element1)]].Height)

                                if scale2 > 1:
                                    scale2 = 1

                                for element2 in element1.Child.Children:
                                    transformGroup1 = TransformGroup()
                                    transformGroup1.Children.Add(
                                        TranslateTransform(
                                            (element2.ActualWidth - maxWidth) /
                                            2,
                                            (element2.ActualHeight - maxHeight)
                                            / 2))
                                    transformGroup1.Children.Add(
                                        ScaleTransform(
                                            scale1, scale1,
                                            element2.ActualWidth / 2,
                                            element2.ActualHeight / 2))

                                    element2.RenderTransform = transformGroup1

                                    for element3 in element2.Children:
                                        transformGroup2 = TransformGroup()
                                        transformGroup2.Children.Add(
                                            TranslateTransform(
                                                translateX, translateY))
                                        transformGroup2.Children.Add(
                                            ScaleTransform(
                                                scale2, scale2, maxWidth / 2,
                                                maxHeight / 2))

                                        element3.RenderTransform = transformGroup2

                contentControl.BeginStoryboard(
                    storyboard, HandoffBehavior.SnapshotAndReplace, True)

                tickTimer.Start()