Ejemplo n.º 1
0
    def area_MouseMove(self, sender, e):
        if self.StartPoint is not None:
            currentPoint = e.GetPosition(self.Content.FractalArea)

            if currentPoint.X < 0: currentPoint.X = 0
            if currentPoint.Y < 0: currentPoint.Y = 0
            if currentPoint.X > self.Content.FractalArea.Width:
                currentPoint.X = self.Content.FractalArea.Width
            if currentPoint.Y > self.Content.FractalArea.Height:
                currentPoint.Y = self.Content.FractalArea.Height

            self.Content.selection.Width = Math.Abs(currentPoint.X -
                                                    self.StartPoint.X)
            self.Content.selection.Height = self.Content.selection.Width / (
                self.Content.FractalArea.Width /
                self.Content.FractalArea.Height)

            if currentPoint.X > self.StartPoint.X:
                canvasLeft = self.StartPoint.X
            else:
                canvasLeft = currentPoint.X

            if currentPoint.Y > self.StartPoint.Y:
                canvasTop = self.StartPoint.Y
            else:
                canvasTop = currentPoint.Y

            Canvas.SetLeft(self.Content.selection, canvasLeft)
            Canvas.SetTop(self.Content.selection, canvasTop)
Ejemplo n.º 2
0
 def OnMouseLeftButtonDown(self, sender, e):
     self.click = e.GetPosition(self.root)
     self.sx = Canvas.GetLeft(self.obj)
     self.sy = Canvas.GetTop(self.obj)
     if (self.sx.IsNaN(self.sx)): self.sx = 0.0
     if (self.sy.IsNaN(self.sy)): self.sy = 0.0
     self.obj.CaptureMouse()
Ejemplo n.º 3
0
 def area_MouseLeftButtonDown(self, sender, e):
     self.StartPoint = e.GetPosition(self.Content.FractalArea)
     self.Content.selection.Visibility = Visibility.Visible
     self.Content.selection.Width = 0
     self.Content.selection.Height = 0
     Canvas.SetLeft(self.Content.selection, self.StartPoint.X)
     Canvas.SetTop(self.Content.selection, self.StartPoint.Y)
     self.Content.FractalArea.CaptureMouse()
Ejemplo n.º 4
0
 def isCollision(self, x, y):
     width = self.Width
     height = self.Height
     if y <= 0 or y >= height:
         return True
     if x >= width:
         return not ((height / 2 + 15) > y > (height / 2 - 15))
     for star in self.stars:
         testX = x - Canvas.GetLeft(star)
         testY = y - Canvas.GetTop(star)
         if mvvm.CheckCollisionPoint(Point(testX, testY), star):
             return True
Ejemplo n.º 5
0
    def RedrawScreen(self, level):
        self.canvas.Children.Clear()
        self.drawBorders(self.Width, self.Height)

        self.stars = []
        for n in range(level * 3):
            star = mvvm.XamlLoader('star.xaml').Root
            self.stars.append(star)
            Canvas.SetLeft(star, self.rand.Next(10, self.Width - 10))
            Canvas.SetTop(star, self.rand.Next(2, self.Height - 10))
            self.canvas.Children.Add(star)

        self.polyline = Polyline()
        self.polyline.Stroke = Brushes.Yellow
        self.polyline.StrokeThickness = 2.0
        self.canvas.Children.Add(self.polyline)
Ejemplo n.º 6
0
    def __init__(self):
        wpf.LoadComponent(self, 'WpfApplicationClockCalc.xaml')

        self.calc = Calc()
        self.rootCanvas.Children.Add (self.calc)

        self.clock = Clock()
        self.rootCanvas.Children.Add (self.clock)
        Canvas.SetTop(self.clock, 50)
        Canvas.SetLeft(self.clock, 10)

        Canvas.SetTop(self.calc, 50)
        Canvas.SetLeft(self.calc, 350)

        d1 = Drag(self.calc )
        d1.enable()

        d2 = Drag(self.clock)
        d2.enable()
    def _create_eat_distance_shape(self):
        self._eat_distance_canvas = Canvas()

        self._eat_distance_ellipse = Ellipse()
        self._eat_distance_ellipse.StrokeThickness = 0.007
        self._eat_distance_ellipse.Stroke = Brushes.Gray
        self._eat_distance_ellipse.Height = 1
        self._eat_distance_ellipse.Width = 1
        self._eat_distance_ellipse.RenderTransform = TranslateTransform(-0.5, -0.5)

        self._eat_distance_canvas.Children.Add(self._eat_distance_ellipse)
    def _create_smell_shape(self):
        self._smell_canvas = Canvas()
        self._smell_ellipse = Ellipse()

        color1 = Color.FromArgb(40, 220, 0, 20)
        color2 = Color.FromArgb(0, 220, 0, 20)
        self._smell_ellipse.Fill = RadialGradientBrush(color1, color2)

        self._smell_ellipse.StrokeThickness = 0.1
        self._smell_ellipse.Stroke = Brushes.Gray
        self.smell_size = self._animal.smell_size
        self._smell_canvas.Children.Add(self._smell_ellipse)
Ejemplo n.º 9
0
    def setUp(self):
        self.new_ctl = Document.CreateElement('foo')
        self.new_ctl.SetAttribute("id", "newctl")
        self.utf8_string = "aBc 西-雅-图的冬天AbC-123"
        # htmlElement tagName casing varies by browser
        if (BrowserInformation.Name == 'Microsoft Internet Explorer'):
            self.tag = "<B>%s</B>"
        else:
            self.tag = "<b>%s</b>"
        self.new_value = self.tag % self.utf8_string
        self.new_ctl.innerHTML = self.new_value
        body = Document.Body
        body.AppendChild(self.new_ctl)

        app.RootVisual = Canvas()
        self.tb = TextBlock()
        app.RootVisual.Children.Add(self.tb)
Ejemplo n.º 10
0
 def Change(self):
     self.ShooterRail = self.Shooter.Left = random.randint(0, 675)
     self.Header = "BBTan " + str(self.ShooterRail)
     Canvas.SetLeft(self.Shooter, self.ShooterRail)
     self.RaisePropertyChanged("Header")
Ejemplo n.º 11
0
#####################################################################################

#------------------------------------------------------------------------------
#--INSERTS RANDOM SQUARES

from System.Windows.Controls import Canvas
from System.Windows.Shapes import *
from System.Windows.Media import *
from System import Random

rand = Random()

for i in xrange(100):
    rect = Rectangle(Width=20, Height=20, Fill=Brushes.Blue)
    Application.Painting.Children.Add(rect)
    Canvas.SetLeft(rect, rand.Next(Application.Painting.ActualWidth))
    Canvas.SetTop(rect, rand.Next(Application.Painting.ActualHeight))

#------------------------------------------------------------------------------
#--INSERT A CIRCLE CONSISTING OF SQUARES OF DIFFERENT COLORS

# setup circle
from System.Windows.Controls import Canvas
from System.Windows.Shapes import *
from System.Windows.Media import *
import math

dim = min(Application.Painting.ActualWidth - 20,
          Application.Painting.ActualHeight - 20) / 2
for i, color in zip(xrange(0, 360, 10), dir(Brushes)):
    rect = Rectangle(Width=20, Height=20, Fill=getattr(Brushes, color))
 def _create_body_shape(self):
     self._body_canvas = Canvas()
     self._create_food_ellipse()
     self.canvas.Children.Add(self._body_canvas)
 def _create_shape(self):
     self.canvas = Canvas()
     self._create_body_shape()
     self._create_smell_shape()
     self._create_eat_distance_shape()
class FoodShape(object):
    def __init__(self, food, renderer):
        self._food = food
        self._renderer = renderer
        self._create_shape()
        self._draw_smell = False
        self._draw_eat_distance = False

    def _create_shape(self):
        self.canvas = Canvas()
        self._create_body_shape()
        self._create_smell_shape()
        self._create_eat_distance_shape()

    def _create_body_shape(self):
        self._body_canvas = Canvas()
        self._create_food_ellipse()
        self.canvas.Children.Add(self._body_canvas)

    def _create_food_ellipse(self):
        self._food_ellipse = Ellipse()
        self._food_ellipse.Fill = Brushes.Gray
        self._food_ellipse.Height = 1
        self._food_ellipse.Width = 1
        self._food_ellipse.RenderTransform = TranslateTransform(-0.5, -0.5)
        self._body_canvas.Children.Add(self._food_ellipse)
        self._body_canvas.SetZIndex(self._food_ellipse, 1)

    def _create_smell_shape(self):
        self._smell_ellipse = Ellipse()

        color1 = Color.FromArgb(40, 0, 220, 20)
        color2 = Color.FromArgb(0, 0, 220, 20)
        self._smell_ellipse.Fill = RadialGradientBrush(color1, color2)

        self._smell_ellipse.StrokeThickness = 0.03
        self._smell_ellipse.Stroke = Brushes.Gray

        self._smell_ellipse.Height = self._renderer.world.constants.FOOD_SMELL_SIZE_RATIO * 2
        self._smell_ellipse.Width = self._renderer.world.constants.FOOD_SMELL_SIZE_RATIO * 2
        self._smell_ellipse.RenderTransform = TranslateTransform(
                -self._renderer.world.constants.FOOD_SMELL_SIZE_RATIO,
                -self._renderer.world.constants.FOOD_SMELL_SIZE_RATIO
        )

    def _create_eat_distance_shape(self):
        self._eat_distance_canvas = Canvas()

        self._eat_distance_ellipse = Ellipse()
        self._eat_distance_ellipse.StrokeThickness = 0.007
        self._eat_distance_ellipse.Stroke = Brushes.Gray
        self._eat_distance_ellipse.Height = 1
        self._eat_distance_ellipse.Width = 1
        self._eat_distance_ellipse.RenderTransform = TranslateTransform(-0.5, -0.5)

        self._eat_distance_canvas.Children.Add(self._eat_distance_ellipse)

    def update_state(self):
        if self.draw_smell != self._renderer.draw_food_smell:
            self.draw_smell = self._renderer.draw_food_smell

        if self.draw_eat_distance != self._renderer.draw_eat_distance:
            self.draw_eat_distance = self._renderer.draw_eat_distance

        self._body_canvas.RenderTransform = ScaleTransform(self._food.size, self._food.size)

        eat_distance_size = (self._renderer.world.constants.EATING_DISTANCE + self._food.size) * 2
        self._eat_distance_canvas.RenderTransform = ScaleTransform(eat_distance_size, eat_distance_size)

        self.canvas.RenderTransform = TranslateTransform(self._food.x, self._food.y)

    @property
    def draw_smell(self):
        return self._draw_smell

    @draw_smell.setter
    def draw_smell(self, value):
        self._draw_smell = bool(value)
        if value:
            _safe_add_to_canvas(self._body_canvas, self._smell_ellipse)
        else:
            _safe_remove_from_canvas(self._body_canvas, self._smell_ellipse)

    @property
    def draw_eat_distance(self):
        return self._draw_eat_distance

    @draw_eat_distance.setter
    def draw_eat_distance(self, value):
        self._draw_eat_distance = bool(value)
        if value:
            _safe_add_to_canvas(self.canvas, self._eat_distance_canvas)
        else:
            _safe_remove_from_canvas(self.canvas, self._eat_distance_canvas)
 def _create_body_shape(self):
     self._body_canvas = Canvas()
     self._create_body_ellipse()
     self._create_angle_line()
     self._body_canvas.RenderTransformOrigin = Point(0, 0)
     self.canvas.Children.Add(self._body_canvas)
Ejemplo n.º 16
0
 def OnMouseMove(self, sender, e):
     if(self.click != None):
         mouse_pos = e.GetPosition(self.root)
         Canvas.SetLeft(self.obj, (self.sx + mouse_pos.X - self.click.X))
         Canvas.SetTop(self.obj, (self.sy + mouse_pos.Y - self.click.Y))
Ejemplo n.º 17
0
 def __init__(self):
 	self.scene = Application.Current.LoadRootVisual(Canvas(), "app.xaml")
 def __init__(self, world):
     self.world = world
     self.canvas = Canvas()
     self._create_grids()
Ejemplo n.º 19
0
		def onCompleted(task):
			global maxWidth, maxHeight
			
			window = Window()
			contentControl = ContentControl()
			grid1 = Grid()
			tickTimer = DispatcherTimer(DispatcherPriority.Normal)
			closeTimer = DispatcherTimer(DispatcherPriority.Background)
		
			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()

			def onWindowMouseEnter(sender, args):
				closeTimer.Stop()
				grid1.Tag = True

			def onWindowMouseLeave(sender, args):
				if closeTimer.Tag:
					closeTimer.Start()

				grid1.Tag = False

			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

			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

			tickTimer.Tick += onTick
			tickTimer.Interval = TimeSpan.FromMilliseconds(100)

			closeTimer.Tick += onClose
			closeTimer.Interval = TimeSpan.FromSeconds(3)
			closeTimer.Tag = True

			window.Owner = Application.Current.MainWindow
			window.Title = Application.Current.MainWindow.Title
			window.WindowStartupLocation = WindowStartupLocation.CenterScreen
			window.AllowsTransparency = True
			window.WindowStyle = WindowStyle.None
			window.ResizeMode = ResizeMode.NoResize
			window.ShowActivated = False
			window.ShowInTaskbar = Application.Current.MainWindow.ContextMenu.Items[5].IsChecked
			window.Topmost = True
			window.SizeToContent = SizeToContent.WidthAndHeight
			window.Background = Brushes.Transparent
			window.Loaded += onLoaded
			window.MouseEnter += onWindowMouseEnter
			window.MouseLeave += onWindowMouseLeave

			contentControl.UseLayoutRounding = True
			contentControl.HorizontalAlignment = HorizontalAlignment.Stretch
			contentControl.VerticalAlignment = VerticalAlignment.Stretch

			window.Content = contentControl

			grid1.HorizontalAlignment = HorizontalAlignment.Center
			grid1.VerticalAlignment = VerticalAlignment.Center
			grid1.Background = Brushes.Transparent
			grid1.Tag = False

			contentControl.Content = grid1

			bitmapImageList1 = List[BitmapImage]()
			bitmapImageList2 = List[BitmapImage]()
			width = 0
			height = 0

			for stream in task.Result.Key:
				try:
					bitmapImage = BitmapImage()
					bitmapImage.BeginInit()
					bitmapImage.StreamSource = stream
					bitmapImage.CacheOption = BitmapCacheOption.OnLoad
					bitmapImage.CreateOptions = BitmapCreateOptions.None
					bitmapImage.EndInit()
					
					width += bitmapImage.PixelWidth

					if bitmapImage.PixelHeight > height:
						height = bitmapImage.PixelHeight

					bitmapImageList1.Add(bitmapImage)

				finally:
					stream.Close()

			for stream in task.Result.Value:
				try:
					bitmapImage = BitmapImage()
					bitmapImage.BeginInit()
					bitmapImage.StreamSource = stream
					bitmapImage.CacheOption = BitmapCacheOption.OnLoad
					bitmapImage.CreateOptions = BitmapCreateOptions.None
					bitmapImage.EndInit()
					
					bitmapImageList2.Add(bitmapImage)

				finally:
					stream.Close()

			x = 0
			kvpList = List[KeyValuePair[Point, BitmapImage]]()

			for bitmapImage in bitmapImageList1:
				rect = Rect(x, (height - bitmapImage.PixelHeight) / 2, bitmapImage.PixelWidth, bitmapImage.PixelHeight)

				rectList.Add(rect)
				kvpList.Add(KeyValuePair[Point, BitmapImage](rect.Location, bitmapImage))

				x += bitmapImage.PixelWidth

			rowDefinition1 = RowDefinition()
			rowDefinition1.Height = GridLength(1, GridUnitType.Auto)

			grid1.RowDefinitions.Add(rowDefinition1)

			for i in range(digits.Length):
				columnDefinition = ColumnDefinition()
				columnDefinition.Width = GridLength(1, GridUnitType.Star)

				grid1.ColumnDefinitions.Add(columnDefinition)

				border = Border()
				border.HorizontalAlignment = HorizontalAlignment.Stretch
				border.VerticalAlignment = VerticalAlignment.Stretch
				border.Margin = Thickness(4)
				border.BorderBrush = Brushes.Black
				border.BorderThickness = Thickness(1)
				border.Padding = Thickness(0)
				border.Width = 160
				border.Height = 480
				border.Background = Brushes.White
				border.Opacity = 0

				grid1.Children.Add(border)
			
				Grid.SetColumn(border, i);
				Grid.SetRow(border, 0)

				grid2 = Grid()
				grid2.HorizontalAlignment = HorizontalAlignment.Stretch
				grid2.VerticalAlignment = VerticalAlignment.Stretch
				grid2.Background = Brushes.Transparent
				grid2.ClipToBounds = True

				border.Child = grid2

				grid3 = Grid()
				grid3.HorizontalAlignment = HorizontalAlignment.Left
				grid3.VerticalAlignment = VerticalAlignment.Top
				grid3.Width = 160
				grid3.Height = 480
				grid3.Background = Brushes.Transparent

				grid2.Children.Add(grid3)

				canvas = Canvas()
				canvas.HorizontalAlignment = HorizontalAlignment.Left
				canvas.VerticalAlignment = VerticalAlignment.Top
				canvas.Width = width
				canvas.Height = maxHeight
				canvas.Background = Brushes.Transparent

				grid3.Children.Add(canvas)

				for kvp in kvpList:
					image = Image()
					image.HorizontalAlignment = HorizontalAlignment.Left
					image.VerticalAlignment = VerticalAlignment.Top
					image.Source = kvp.Value
					image.Width = kvp.Value.PixelWidth
					image.Height = kvp.Value.PixelHeight
					image.Stretch = Stretch.Fill
					
					canvas.Children.Add(image)

					Canvas.SetLeft(image, kvp.Key.X)
					Canvas.SetTop(image, kvp.Key.Y)
			
			column = 1

			rowDefinition2 = RowDefinition()
			rowDefinition2.Height = GridLength(1, GridUnitType.Auto)

			grid1.RowDefinitions.Add(rowDefinition2)

			for bitmapImage in bitmapImageList2:
				image = Image()
				image.HorizontalAlignment = HorizontalAlignment.Right
				image.VerticalAlignment = VerticalAlignment.Top
				image.Margin = Thickness(0, 0, 8, 0)
				image.Source = bitmapImage
				image.Width = bitmapImage.PixelWidth / 2
				image.Height = bitmapImage.PixelHeight / 2
				image.Stretch = Stretch.Fill

				grid1.Children.Add(image)
			
				Grid.SetColumn(image, column);
				Grid.SetRow(image, 1);

				column += 2

			window.Show()
Ejemplo n.º 20
0
        def onCompleted(task):
            global maxWidth, maxHeight

            window = Window()
            contentControl = ContentControl()
            grid1 = Grid()
            tickTimer = DispatcherTimer(DispatcherPriority.Normal)
            closeTimer = DispatcherTimer(DispatcherPriority.Background)

            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()

            def onWindowMouseEnter(sender, args):
                closeTimer.Stop()
                grid1.Tag = True

            def onWindowMouseLeave(sender, args):
                if closeTimer.Tag:
                    closeTimer.Start()

                grid1.Tag = False

            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

            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

            tickTimer.Tick += onTick
            tickTimer.Interval = TimeSpan.FromMilliseconds(100)

            closeTimer.Tick += onClose
            closeTimer.Interval = TimeSpan.FromSeconds(3)
            closeTimer.Tag = True

            window.Owner = Application.Current.MainWindow
            window.Title = Application.Current.MainWindow.Title
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen
            window.AllowsTransparency = True
            window.WindowStyle = WindowStyle.None
            window.ResizeMode = ResizeMode.NoResize
            window.ShowActivated = False
            window.ShowInTaskbar = Application.Current.MainWindow.ContextMenu.Items[
                5].IsChecked
            window.Topmost = True
            window.SizeToContent = SizeToContent.WidthAndHeight
            window.Background = Brushes.Transparent
            window.Loaded += onLoaded
            window.MouseEnter += onWindowMouseEnter
            window.MouseLeave += onWindowMouseLeave

            contentControl.UseLayoutRounding = True
            contentControl.HorizontalAlignment = HorizontalAlignment.Stretch
            contentControl.VerticalAlignment = VerticalAlignment.Stretch

            window.Content = contentControl

            grid1.HorizontalAlignment = HorizontalAlignment.Center
            grid1.VerticalAlignment = VerticalAlignment.Center
            grid1.Background = Brushes.Transparent
            grid1.Tag = False

            contentControl.Content = grid1

            bitmapImageList1 = List[BitmapImage]()
            bitmapImageList2 = List[BitmapImage]()
            width = 0
            height = 0

            for stream in task.Result.Key:
                try:
                    bitmapImage = BitmapImage()
                    bitmapImage.BeginInit()
                    bitmapImage.StreamSource = stream
                    bitmapImage.CacheOption = BitmapCacheOption.OnLoad
                    bitmapImage.CreateOptions = BitmapCreateOptions.None
                    bitmapImage.EndInit()

                    width += bitmapImage.PixelWidth

                    if bitmapImage.PixelHeight > height:
                        height = bitmapImage.PixelHeight

                    bitmapImageList1.Add(bitmapImage)

                finally:
                    stream.Close()

            for stream in task.Result.Value:
                try:
                    bitmapImage = BitmapImage()
                    bitmapImage.BeginInit()
                    bitmapImage.StreamSource = stream
                    bitmapImage.CacheOption = BitmapCacheOption.OnLoad
                    bitmapImage.CreateOptions = BitmapCreateOptions.None
                    bitmapImage.EndInit()

                    bitmapImageList2.Add(bitmapImage)

                finally:
                    stream.Close()

            x = 0
            kvpList = List[KeyValuePair[Point, BitmapImage]]()

            for bitmapImage in bitmapImageList1:
                rect = Rect(x, (height - bitmapImage.PixelHeight) / 2,
                            bitmapImage.PixelWidth, bitmapImage.PixelHeight)

                rectList.Add(rect)
                kvpList.Add(KeyValuePair[Point, BitmapImage](rect.Location,
                                                             bitmapImage))

                x += bitmapImage.PixelWidth

            rowDefinition1 = RowDefinition()
            rowDefinition1.Height = GridLength(1, GridUnitType.Auto)

            grid1.RowDefinitions.Add(rowDefinition1)

            for i in range(digits.Length):
                columnDefinition = ColumnDefinition()
                columnDefinition.Width = GridLength(1, GridUnitType.Star)

                grid1.ColumnDefinitions.Add(columnDefinition)

                border = Border()
                border.HorizontalAlignment = HorizontalAlignment.Stretch
                border.VerticalAlignment = VerticalAlignment.Stretch
                border.Margin = Thickness(4)
                border.BorderBrush = Brushes.Black
                border.BorderThickness = Thickness(1)
                border.Padding = Thickness(0)
                border.Width = 160
                border.Height = 480
                border.Background = Brushes.White
                border.Opacity = 0

                grid1.Children.Add(border)

                Grid.SetColumn(border, i)
                Grid.SetRow(border, 0)

                grid2 = Grid()
                grid2.HorizontalAlignment = HorizontalAlignment.Stretch
                grid2.VerticalAlignment = VerticalAlignment.Stretch
                grid2.Background = Brushes.Transparent
                grid2.ClipToBounds = True

                border.Child = grid2

                grid3 = Grid()
                grid3.HorizontalAlignment = HorizontalAlignment.Left
                grid3.VerticalAlignment = VerticalAlignment.Top
                grid3.Width = 160
                grid3.Height = 480
                grid3.Background = Brushes.Transparent

                grid2.Children.Add(grid3)

                canvas = Canvas()
                canvas.HorizontalAlignment = HorizontalAlignment.Left
                canvas.VerticalAlignment = VerticalAlignment.Top
                canvas.Width = width
                canvas.Height = maxHeight
                canvas.Background = Brushes.Transparent

                grid3.Children.Add(canvas)

                for kvp in kvpList:
                    image = Image()
                    image.HorizontalAlignment = HorizontalAlignment.Left
                    image.VerticalAlignment = VerticalAlignment.Top
                    image.Source = kvp.Value
                    image.Width = kvp.Value.PixelWidth
                    image.Height = kvp.Value.PixelHeight
                    image.Stretch = Stretch.Fill

                    canvas.Children.Add(image)

                    Canvas.SetLeft(image, kvp.Key.X)
                    Canvas.SetTop(image, kvp.Key.Y)

            column = 1

            rowDefinition2 = RowDefinition()
            rowDefinition2.Height = GridLength(1, GridUnitType.Auto)

            grid1.RowDefinitions.Add(rowDefinition2)

            for bitmapImage in bitmapImageList2:
                image = Image()
                image.HorizontalAlignment = HorizontalAlignment.Right
                image.VerticalAlignment = VerticalAlignment.Top
                image.Margin = Thickness(0, 0, 8, 0)
                image.Source = bitmapImage
                image.Width = bitmapImage.PixelWidth / 2
                image.Height = bitmapImage.PixelHeight / 2
                image.Stretch = Stretch.Fill

                grid1.Children.Add(image)

                Grid.SetColumn(image, column)
                Grid.SetRow(image, 1)

                column += 2

            window.Show()