Beispiel #1
0
		def onCompleted(task):
			window = Window()
			stackPanel3 = StackPanel()
			
			def onLoaded(sender, args):
				stackPanel3.Width = Math.Ceiling(stackPanel3.ActualWidth)

			def onCloseClick(sender, args):
				window.Close()
			
			window.Owner = Application.Current.MainWindow

			if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
				window.Title = "バリデータ"
			else:
				window.Title = "Validator"
	
			window.WindowStartupLocation = WindowStartupLocation.CenterOwner
			window.ResizeMode = ResizeMode.NoResize
			window.SizeToContent = SizeToContent.WidthAndHeight
			window.Background = SystemColors.ControlBrush
			window.Loaded += onLoaded

			stackPanel1 = StackPanel()
			stackPanel1.UseLayoutRounding = True
			stackPanel1.HorizontalAlignment = HorizontalAlignment.Stretch
			stackPanel1.VerticalAlignment = VerticalAlignment.Stretch
			stackPanel1.Orientation = Orientation.Vertical

			window.Content = stackPanel1

			stackPanel2 = StackPanel()
			stackPanel2.HorizontalAlignment = HorizontalAlignment.Stretch
			stackPanel2.VerticalAlignment = VerticalAlignment.Stretch
			stackPanel2.Orientation = Orientation.Vertical
			stackPanel2.Background = SystemColors.WindowBrush
			
			stackPanel1.Children.Add(stackPanel2)

			stackPanel3.HorizontalAlignment = HorizontalAlignment.Stretch
			stackPanel3.VerticalAlignment = VerticalAlignment.Stretch
			stackPanel3.Orientation = Orientation.Vertical

			if errorList.Count == 0:
				if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
					attachStackPanel(stackPanel3, Brushes.Lime, "有効なスクリプトです。")
				else:
					attachStackPanel(stackPanel3, Brushes.Lime, "Valid.")

			for warning in warningList:
				attachStackPanel(stackPanel3, Brushes.Yellow, warning)

			for error in errorList:
				attachStackPanel(stackPanel3, Brushes.Red, error)

			stackPanel2.Children.Add(stackPanel3)
			
			solidColorBrush = SolidColorBrush(Colors.White)
			solidColorBrush.Opacity = 0.5

			if solidColorBrush.CanFreeze:
				solidColorBrush.Freeze()

			border = Border()
			border.HorizontalAlignment = HorizontalAlignment.Stretch
			border.VerticalAlignment = VerticalAlignment.Stretch
			border.BorderThickness = Thickness(0, 1, 0, 0)
			border.BorderBrush = solidColorBrush

			stackPanel1.Children.Add(border)

			closeButton = Button()
			closeButton.HorizontalAlignment = HorizontalAlignment.Right
			closeButton.VerticalAlignment = VerticalAlignment.Center
			closeButton.Margin = Thickness(10, 10, 10, 10)
			closeButton.Padding = Thickness(10, 2, 10, 2)
			closeButton.IsDefault = True

			if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
				closeButton.Content = "閉じる"
			else:
				closeButton.Content = "Close"

			closeButton.Click += onCloseClick

			border.Child = closeButton

			window.Show()
Beispiel #2
0
 def __init__(self):
     Window.__init__(self)
     wpf.LoadComponent(self, xaml_path)
     items = List[object]()
     items.Add(Test("Cyril"))
     self.item_list.ItemsSource = items
Beispiel #3
0
import clr
from spelling import *

clr.AddReferenceByPartialName("PresentationCore")
clr.AddReferenceByPartialName("PresentationFramework")
from System.Windows import Window, Application, HorizontalAlignment
from System.Windows.Controls import FlowDocumentScrollViewer, ComboBox
from System.Windows.Documents import FlowDocument, Paragraph, Run
from System.Windows.Media.Brushes import Black, PaleGreen, Red

#--GLOBALS---------------------------------------------------------------------
_temp_file = open(sys.argv[1], "r")
lines_in_file = _temp_file.readlines()
_temp_file.close()

main_window = Window()


#--FUNCTIONS-------------------------------------------------------------------
def create_paragraph(file_lines):
    #Create a "Paragraph" object to hold all text from the file
    paragraph = Paragraph()
    #Text in the paragraph will have a font size of 16
    paragraph.FontSize = 16.0

    #Go through every line in the file passed in from the command
    #line...
    for x in file_lines:
        #...looking for Python/Ruby/PowerShell style comments
        if "#" in x:
	def onCompleted(task):
		global idList

		if task.Result.Key.Count > 0:
			sequenceList = List[Sequence]()

			for sequence in Script.Instance.Sequences:
				if sequence.Name.Equals("Weather"):
					sequenceList.Add(sequence)

			for s in task.Result.Key:
				Script.Instance.TryEnqueue(Script.Instance.Prepare(sequenceList, s))

		if Application.Current.MainWindow.IsVisible and task.Result.Value.Value.Value.Value.Count > 0 and not Enumerable.SequenceEqual[Double](idList, task.Result.Value.Value.Value.Key):
			width = 128
			height = 128
			max = 4
			window = Window()
			contentControl = ContentControl()
			grid = Grid()
			storyboard = Storyboard()

			def onCurrentStateInvalidated(sender, args):
				if sender.CurrentState == ClockState.Filling:
					window.Close()

			storyboard.CurrentStateInvalidated += onCurrentStateInvalidated
		
			def onLoaded(sender, args):
				time = 0
				speed = task.Result.Value.Value.Key.Key * 1000 / 60 / 60

				contentControl.Width = contentControl.ActualWidth * 1.5 if contentControl.ActualWidth > contentControl.ActualHeight else contentControl.ActualHeight * 1.5 
				contentControl.Height = contentControl.ActualWidth * 1.5 if contentControl.ActualWidth > contentControl.ActualHeight else contentControl.ActualHeight * 1.5
				contentControl.RenderTransform.CenterX = contentControl.Width / 2
				contentControl.RenderTransform.CenterY = contentControl.Height / 2

				doubleAnimation1 = DoubleAnimation(contentControl.Opacity, 1, TimeSpan.FromMilliseconds(500))
				doubleAnimation2 = DoubleAnimation(1.5, 1, TimeSpan.FromMilliseconds(500))
				doubleAnimation3 = DoubleAnimation(1.5, 1, TimeSpan.FromMilliseconds(500))
				doubleAnimation4 = DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(500))
				doubleAnimation5 = DoubleAnimation(1, 1.5, TimeSpan.FromMilliseconds(500))
				doubleAnimation6 = DoubleAnimation(1, 1.5, TimeSpan.FromMilliseconds(500))
				sineEase1 = SineEase()
				sineEase2 = SineEase()

				sineEase1.EasingMode = EasingMode.EaseOut
				sineEase2.EasingMode = EasingMode.EaseIn
				doubleAnimation1.EasingFunction = doubleAnimation2.EasingFunction = doubleAnimation3.EasingFunction = sineEase1
				doubleAnimation4.EasingFunction = doubleAnimation5.EasingFunction = doubleAnimation6.EasingFunction = sineEase2

				doubleAnimation4.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds((250 * (max - 1) * 2 + 1000 + 3000) * task.Result.Value.Value.Value.Value.Count - 500))
				doubleAnimation5.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds((250 * (max - 1) * 2 + 1000 + 3000) * task.Result.Value.Value.Value.Value.Count - 500))
				doubleAnimation6.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds((250 * (max - 1) * 2 + 1000 + 3000) * task.Result.Value.Value.Value.Value.Count - 500))

				storyboard.Children.Add(doubleAnimation1)
				storyboard.Children.Add(doubleAnimation2)
				storyboard.Children.Add(doubleAnimation3)
				storyboard.Children.Add(doubleAnimation4)
				storyboard.Children.Add(doubleAnimation5)
				storyboard.Children.Add(doubleAnimation6)

				Storyboard.SetTarget(doubleAnimation1, contentControl)
				Storyboard.SetTarget(doubleAnimation2, contentControl)
				Storyboard.SetTarget(doubleAnimation3, contentControl)
				Storyboard.SetTarget(doubleAnimation4, contentControl)
				Storyboard.SetTarget(doubleAnimation5, contentControl)
				Storyboard.SetTarget(doubleAnimation6, contentControl)
				Storyboard.SetTargetProperty(doubleAnimation1, PropertyPath(ContentControl.OpacityProperty))
				Storyboard.SetTargetProperty(doubleAnimation2, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleXProperty))
				Storyboard.SetTargetProperty(doubleAnimation3, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleYProperty))
				Storyboard.SetTargetProperty(doubleAnimation4, PropertyPath(ContentControl.OpacityProperty))
				Storyboard.SetTargetProperty(doubleAnimation5, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleXProperty))
				Storyboard.SetTargetProperty(doubleAnimation6, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleYProperty))

				for element1 in grid.Children:
					for element2 in element1.Children:
						w = element2.Width / 2 if speed > 15 else element2.Width / 2 * speed / 15;
						da1 = DoubleAnimation(element2.Opacity, 1, TimeSpan.FromMilliseconds(1000))
						da2 = DoubleAnimation(-w if Convert.ToInt32(task.Result.Value.Value.Key.Value / 180) % 2 == 0 else w, 0, TimeSpan.FromMilliseconds(1000))
						da3 = DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(1000))
						da4 = DoubleAnimation(0, w if Convert.ToInt32(task.Result.Value.Value.Key.Value / 180) % 2 == 0 else -w, TimeSpan.FromMilliseconds(1000))
						se1 = SineEase()
						se2 = SineEase()

						da1.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag))
						da2.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag))
						da3.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag * 2 + 250 * (max - 1) - 250 * element2.Tag + 3000))
						da4.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag * 2 + 250 * (max - 1) - 250 * element2.Tag + 3000))

						se1.EasingMode = EasingMode.EaseOut
						se2.EasingMode = EasingMode.EaseIn
						da1.EasingFunction = da2.EasingFunction = se1
						da3.EasingFunction = da4.EasingFunction = se2

						storyboard.Children.Add(da1)
						storyboard.Children.Add(da2)
						storyboard.Children.Add(da3)
						storyboard.Children.Add(da4)

						Storyboard.SetTarget(da1, element2)
						Storyboard.SetTarget(da2, element2)
						Storyboard.SetTarget(da3, element2)
						Storyboard.SetTarget(da4, element2)
						Storyboard.SetTargetProperty(da1, PropertyPath(Rectangle.OpacityProperty))
						Storyboard.SetTargetProperty(da2, PropertyPath("(0).(1)", Rectangle.RenderTransformProperty, TranslateTransform.XProperty))
						Storyboard.SetTargetProperty(da3, PropertyPath(Rectangle.OpacityProperty))
						Storyboard.SetTargetProperty(da4, PropertyPath("(0).(1)", Rectangle.RenderTransformProperty, TranslateTransform.XProperty))

					time += 250 * (max - 1) + 1000 + 3000

				storyboard.Begin()
			
			fs = None
			bi = BitmapImage()

			try:
				fs = FileStream("Assets\\Background-Popup.png", FileMode.Open, FileAccess.Read, FileShare.Read)

				bi.BeginInit()
				bi.StreamSource = fs
				bi.CacheOption = BitmapCacheOption.OnLoad
				bi.CreateOptions = BitmapCreateOptions.None
				bi.EndInit()

			finally:
				if fs is not None:
					fs.Close()

			window.Owner = Application.Current.MainWindow
			window.Title = Application.Current.MainWindow.Title
			window.WindowStartupLocation = WindowStartupLocation.CenterOwner
			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
			
			contentControl.UseLayoutRounding = True
			contentControl.HorizontalAlignment = HorizontalAlignment.Stretch
			contentControl.VerticalAlignment = VerticalAlignment.Stretch
			contentControl.Opacity = 0
			contentControl.RenderTransform = ScaleTransform(1, 1)

			window.Content = contentControl

			imageBrush = ImageBrush(bi)
			imageBrush.TileMode = TileMode.None
			imageBrush.Stretch = Stretch.Fill
			imageBrush.ViewboxUnits = BrushMappingMode.Absolute
			imageBrush.Viewbox = Rect(0, 0, bi.Width, bi.Height)
			imageBrush.AlignmentX = AlignmentX.Left
			imageBrush.AlignmentY = AlignmentY.Top
			imageBrush.Opacity = 0.5

			dg = DrawingGroup()
			dc = dg.Open()
			dc.DrawRectangle(SolidColorBrush(Color.FromArgb(Byte.MaxValue * 50 / 100, 0, 0, 0)), None, Rect(0, 0, bi.Width, bi.Height))
			dc.DrawRectangle(imageBrush, None, Rect(0, 0, bi.Width, bi.Height))
			dc.Close()

			backgroundBrush = ImageBrush(DrawingImage(dg))
			backgroundBrush.TileMode = TileMode.Tile
			backgroundBrush.ViewportUnits = BrushMappingMode.Absolute
			backgroundBrush.Viewport = Rect(0, 0, bi.Width, bi.Height)
			backgroundBrush.Stretch = Stretch.None

			if backgroundBrush.CanFreeze:
				backgroundBrush.Freeze()

			grid.HorizontalAlignment = HorizontalAlignment.Stretch
			grid.VerticalAlignment = VerticalAlignment.Stretch
			grid.Background = backgroundBrush
			grid.Width = 150
			grid.Height = 150
			grid.Clip = EllipseGeometry(Rect(0, 0, 150, 150))

			dropShadowEffect = DropShadowEffect()
			dropShadowEffect.BlurRadius = 1
			dropShadowEffect.Color = Colors.Black
			dropShadowEffect.Direction = 270
			dropShadowEffect.Opacity = 0.5
			dropShadowEffect.ShadowDepth = 1

			if dropShadowEffect.CanFreeze:
				dropShadowEffect.Freeze()

			grid.Effect = dropShadowEffect

			contentControl.Content = grid

			solidColorBrush = SolidColorBrush(colorFromAhsb(Byte.MaxValue, 60, 1.0, 1.0) if task.Result.Value.Key < 0 else colorFromAhsb(Byte.MaxValue, 0, 1.0, 0.4) if task.Result.Value.Key > 37 else colorFromAhsb(Byte.MaxValue, 60 - 60 * task.Result.Value.Key / 37, 1.0, 0.4 + 0.6 * Math.Pow(Math.E, (37 / 5 - task.Result.Value.Key) - 37 / 5) if task.Result.Value.Key < 37 / 5 else 0.4))

			if solidColorBrush.CanFreeze:
				solidColorBrush.Freeze()


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

				finally:
					stream.Close()

				imageBrush = ImageBrush(bi)
				imageBrush.TileMode = TileMode.None
				imageBrush.ViewportUnits = BrushMappingMode.Absolute
				imageBrush.Viewport = Rect(0, 0, width, height)
				imageBrush.Stretch = Stretch.Uniform

				if imageBrush.CanFreeze:
					imageBrush.Freeze()

				g = Grid()
				g.HorizontalAlignment = HorizontalAlignment.Center
				g.VerticalAlignment = VerticalAlignment.Center
				g.Background = Brushes.Transparent
				g.Width = width
				g.Height = height

				grid.Children.Add(g)

				for i in range(max):
					rectangle = Rectangle()
					rectangle.HorizontalAlignment = HorizontalAlignment.Left
					rectangle.VerticalAlignment = VerticalAlignment.Top
					rectangle.Width = width
					rectangle.Height = height
					rectangle.Fill = solidColorBrush
					rectangle.Opacity = 0
					rectangle.OpacityMask = imageBrush
					rectangle.Clip = RectangleGeometry(Rect(0, height / max * i, width, height / max))
					rectangle.RenderTransform = TranslateTransform(0, 0)
					rectangle.Tag = i
					
					g.Children.Add(rectangle)

			window.Show()

			idList.Clear()
			idList.AddRange(task.Result.Value.Value.Value.Key)
Beispiel #5
0
    def onSignInClick(source, rea):
        config = None
        directory = Path.Combine(
            Environment.GetFolderPath(
                Environment.SpecialFolder.ApplicationData),
            Assembly.GetEntryAssembly().GetName().Name)
        backgroundBrush = None
        textColor = SystemColors.ControlTextBrush

        if Directory.Exists(directory):
            fileName1 = Path.GetFileName(Assembly.GetEntryAssembly().Location)

            for fileName2 in Directory.EnumerateFiles(directory, "*.config"):
                if fileName1.Equals(
                        Path.GetFileNameWithoutExtension(fileName2)):
                    exeConfigurationFileMap = ExeConfigurationFileMap()
                    exeConfigurationFileMap.ExeConfigFilename = fileName2
                    config = ConfigurationManager.OpenMappedExeConfiguration(
                        exeConfigurationFileMap, ConfigurationUserLevel.None)

        if config is None:
            config = ConfigurationManager.OpenExeConfiguration(
                ConfigurationUserLevel.None)
            directory = None

        if config.AppSettings.Settings["BackgroundImage"] is not None:
            fileName = config.AppSettings.Settings[
                "BackgroundImage"].Value if directory is None else Path.Combine(
                    directory,
                    config.AppSettings.Settings["BackgroundImage"].Value)
            fs = None
            bi = BitmapImage()

            try:
                fs = FileStream(fileName, FileMode.Open, FileAccess.Read,
                                FileShare.Read)

                bi.BeginInit()
                bi.StreamSource = fs
                bi.CacheOption = BitmapCacheOption.OnLoad
                bi.CreateOptions = BitmapCreateOptions.None
                bi.EndInit()

            finally:
                if fs is not None:
                    fs.Close()

            backgroundBrush = ImageBrush(bi)
            backgroundBrush.TileMode = TileMode.Tile
            backgroundBrush.ViewportUnits = BrushMappingMode.Absolute
            backgroundBrush.Viewport = Rect(0, 0, bi.Width, bi.Height)
            backgroundBrush.Stretch = Stretch.None

            if backgroundBrush.CanFreeze:
                backgroundBrush.Freeze()

        if backgroundBrush is None and config.AppSettings.Settings[
                "BackgroundColor"] is not None:
            if config.AppSettings.Settings["BackgroundColor"].Value.Length > 0:
                backgroundBrush = SolidColorBrush(
                    ColorConverter.ConvertFromString(
                        config.AppSettings.Settings["BackgroundColor"].Value))

                if backgroundBrush.CanFreeze:
                    backgroundBrush.Freeze()

        if config.AppSettings.Settings["TextColor"] is not None:
            if config.AppSettings.Settings["TextColor"].Value.Length > 0:
                textColor = ColorConverter.ConvertFromString(
                    config.AppSettings.Settings["TextColor"].Value)

        textBrush = SolidColorBrush(textColor)

        if textBrush.CanFreeze:
            textBrush.Freeze()

        window = Window()

        def onClick(source, args):
            global username, password

            if not String.IsNullOrEmpty(
                    usernameTextBox.Text) and not String.IsNullOrEmpty(
                        passwordBox.Password):
                username = usernameTextBox.Text
                password = passwordBox.Password

                def onSave():
                    try:
                        fs = None
                        sr = None
                        sw = None

                        try:
                            fs = FileStream(__file__, FileMode.Open,
                                            FileAccess.ReadWrite,
                                            FileShare.Read)
                            encoding = UTF8Encoding(False)
                            sr = StreamReader(fs, encoding, True)
                            lines = Regex.Replace(
                                Regex.Replace(
                                    sr.ReadToEnd(), "username\\s*=\\s*\"\"",
                                    String.Format("username = \"{0}\"",
                                                  username),
                                    RegexOptions.CultureInvariant),
                                "password\\s*=\\s*\"\"",
                                String.Format("password = \"{0}\"", password),
                                RegexOptions.CultureInvariant)
                            fs.SetLength(0)
                            sw = StreamWriter(fs, encoding)
                            sw.Write(lines)

                        finally:
                            if sw is not None:
                                sw.Close()

                            if sr is not None:
                                sr.Close()

                            if fs is not None:
                                fs.Close()

                    except Exception, e:
                        Trace.WriteLine(e.clsException.Message)
                        Trace.WriteLine(e.clsException.StackTrace)

                def onCompleted(task):
                    global menuItem

                    for window in Application.Current.Windows:
                        if window is Application.Current.MainWindow and window.ContextMenu is not None:
                            if window.ContextMenu.Items.Contains(menuItem):
                                window.ContextMenu.Items.Remove(menuItem)
                                window.ContextMenu.Opened -= onOpened

                                if window.ContextMenu.Items[10].GetType(
                                ).IsInstanceOfType(window.ContextMenu.Items[
                                        window.ContextMenu.Items.Count - 4]):
                                    window.ContextMenu.Items.RemoveAt(10)

                    menuItem = None

                Task.Factory.StartNew(
                    onSave, TaskCreationOptions.LongRunning).ContinueWith(
                        onCompleted,
                        TaskScheduler.FromCurrentSynchronizationContext())

            window.Close()
Beispiel #6
0
import clr
clr.AddReference("PresentationFramework")
clr.AddReference("PresentationCore")
from System.Windows import (
    SizeToContent, Thickness, Window
)
from System.Windows.Controls import (
    Button, Label, StackPanel
)
from System.Windows.Media.Effects import DropShadowBitmapEffect

window = Window()
window.Title = 'Welcome to IronPython'
window.SizeToContent = SizeToContent.Height
window.Width = 450

stack = StackPanel()
stack.Margin = Thickness(15)
window.Content = stack

button = Button()
button.Content = 'Push Me'
button.FontSize = 24
button.BitmapEffect = DropShadowBitmapEffect()

def onClick(sender, event):
    message = Label()
    message.FontSize = 36
    message.Content = 'Welcome to IronPython!'
    stack.Children.Add(message)
Beispiel #7
0
	def onCompleted(task):
		global idList

		if task.Result.Key.Count > 0:
			sequenceList = List[Sequence]()

			for sequence in Script.Instance.Sequences:
				if sequence.Name.Equals("Weather"):
					sequenceList.Add(sequence)

			for s in task.Result.Key:
				Script.Instance.TryEnqueue(Script.Instance.Prepare(sequenceList, s))

		if Application.Current.MainWindow.IsVisible and task.Result.Value.Value.Value.Value.Count > 0 and not Enumerable.SequenceEqual[Double](idList, task.Result.Value.Value.Value.Key):
			width = 128
			height = 128
			max = 4
			window = Window()
			contentControl = ContentControl()
			grid = Grid()
			storyboard = Storyboard()

			def onCurrentStateInvalidated(sender, args):
				if sender.CurrentState == ClockState.Filling:
					window.Close()

			storyboard.CurrentStateInvalidated += onCurrentStateInvalidated
		
			def onLoaded(sender, args):
				time = 0
				speed = task.Result.Value.Value.Key.Key * 1000 / 60 / 60

				contentControl.Width = contentControl.ActualWidth * 1.5 if contentControl.ActualWidth > contentControl.ActualHeight else contentControl.ActualHeight * 1.5 
				contentControl.Height = contentControl.ActualWidth * 1.5 if contentControl.ActualWidth > contentControl.ActualHeight else contentControl.ActualHeight * 1.5
				contentControl.RenderTransform.CenterX = contentControl.Width / 2
				contentControl.RenderTransform.CenterY = contentControl.Height / 2

				doubleAnimation1 = DoubleAnimation(contentControl.Opacity, 1, TimeSpan.FromMilliseconds(500))
				doubleAnimation2 = DoubleAnimation(1.5, 1, TimeSpan.FromMilliseconds(500))
				doubleAnimation3 = DoubleAnimation(1.5, 1, TimeSpan.FromMilliseconds(500))
				doubleAnimation4 = DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(500))
				doubleAnimation5 = DoubleAnimation(1, 1.5, TimeSpan.FromMilliseconds(500))
				doubleAnimation6 = DoubleAnimation(1, 1.5, TimeSpan.FromMilliseconds(500))
				sineEase1 = SineEase()
				sineEase2 = SineEase()

				sineEase1.EasingMode = EasingMode.EaseOut
				sineEase2.EasingMode = EasingMode.EaseIn
				doubleAnimation1.EasingFunction = doubleAnimation2.EasingFunction = doubleAnimation3.EasingFunction = sineEase1
				doubleAnimation4.EasingFunction = doubleAnimation5.EasingFunction = doubleAnimation6.EasingFunction = sineEase2

				doubleAnimation4.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds((250 * (max - 1) * 2 + 1000 + 3000) * task.Result.Value.Value.Value.Value.Count - 500))
				doubleAnimation5.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds((250 * (max - 1) * 2 + 1000 + 3000) * task.Result.Value.Value.Value.Value.Count - 500))
				doubleAnimation6.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds((250 * (max - 1) * 2 + 1000 + 3000) * task.Result.Value.Value.Value.Value.Count - 500))

				storyboard.Children.Add(doubleAnimation1)
				storyboard.Children.Add(doubleAnimation2)
				storyboard.Children.Add(doubleAnimation3)
				storyboard.Children.Add(doubleAnimation4)
				storyboard.Children.Add(doubleAnimation5)
				storyboard.Children.Add(doubleAnimation6)

				Storyboard.SetTarget(doubleAnimation1, contentControl)
				Storyboard.SetTarget(doubleAnimation2, contentControl)
				Storyboard.SetTarget(doubleAnimation3, contentControl)
				Storyboard.SetTarget(doubleAnimation4, contentControl)
				Storyboard.SetTarget(doubleAnimation5, contentControl)
				Storyboard.SetTarget(doubleAnimation6, contentControl)
				Storyboard.SetTargetProperty(doubleAnimation1, PropertyPath(ContentControl.OpacityProperty))
				Storyboard.SetTargetProperty(doubleAnimation2, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleXProperty))
				Storyboard.SetTargetProperty(doubleAnimation3, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleYProperty))
				Storyboard.SetTargetProperty(doubleAnimation4, PropertyPath(ContentControl.OpacityProperty))
				Storyboard.SetTargetProperty(doubleAnimation5, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleXProperty))
				Storyboard.SetTargetProperty(doubleAnimation6, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleYProperty))

				for element1 in grid.Children:
					for element2 in element1.Children:
						w = element2.Width / 2 if speed > 15 else element2.Width / 2 * speed / 15;
						da1 = DoubleAnimation(element2.Opacity, 1, TimeSpan.FromMilliseconds(1000))
						da2 = DoubleAnimation(-w if Convert.ToInt32(task.Result.Value.Value.Key.Value / 180) % 2 == 0 else w, 0, TimeSpan.FromMilliseconds(1000))
						da3 = DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(1000))
						da4 = DoubleAnimation(0, w if Convert.ToInt32(task.Result.Value.Value.Key.Value / 180) % 2 == 0 else -w, TimeSpan.FromMilliseconds(1000))
						se1 = SineEase()
						se2 = SineEase()

						da1.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag))
						da2.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag))
						da3.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag * 2 + 250 * (max - 1) - 250 * element2.Tag + 3000))
						da4.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag * 2 + 250 * (max - 1) - 250 * element2.Tag + 3000))

						se1.EasingMode = EasingMode.EaseOut
						se2.EasingMode = EasingMode.EaseIn
						da1.EasingFunction = da2.EasingFunction = se1
						da3.EasingFunction = da4.EasingFunction = se2

						storyboard.Children.Add(da1)
						storyboard.Children.Add(da2)
						storyboard.Children.Add(da3)
						storyboard.Children.Add(da4)

						Storyboard.SetTarget(da1, element2)
						Storyboard.SetTarget(da2, element2)
						Storyboard.SetTarget(da3, element2)
						Storyboard.SetTarget(da4, element2)
						Storyboard.SetTargetProperty(da1, PropertyPath(Rectangle.OpacityProperty))
						Storyboard.SetTargetProperty(da2, PropertyPath("(0).(1)", Rectangle.RenderTransformProperty, TranslateTransform.XProperty))
						Storyboard.SetTargetProperty(da3, PropertyPath(Rectangle.OpacityProperty))
						Storyboard.SetTargetProperty(da4, PropertyPath("(0).(1)", Rectangle.RenderTransformProperty, TranslateTransform.XProperty))

					time += 250 * (max - 1) + 1000 + 3000

				storyboard.Begin()
			
			fs = None
			bi = BitmapImage()

			try:
				fs = FileStream("Assets\\Background-Popup.png", FileMode.Open, FileAccess.Read, FileShare.Read)

				bi.BeginInit()
				bi.StreamSource = fs
				bi.CacheOption = BitmapCacheOption.OnLoad
				bi.CreateOptions = BitmapCreateOptions.None
				bi.EndInit()

			finally:
				if fs is not None:
					fs.Close()

			window.Owner = Application.Current.MainWindow
			window.Title = Application.Current.MainWindow.Title
			window.WindowStartupLocation = WindowStartupLocation.CenterOwner
			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
			
			contentControl.UseLayoutRounding = True
			contentControl.HorizontalAlignment = HorizontalAlignment.Stretch
			contentControl.VerticalAlignment = VerticalAlignment.Stretch
			contentControl.Opacity = 0
			contentControl.RenderTransform = ScaleTransform(1, 1)

			window.Content = contentControl

			imageBrush = ImageBrush(bi)
			imageBrush.TileMode = TileMode.None
			imageBrush.Stretch = Stretch.Fill
			imageBrush.ViewboxUnits = BrushMappingMode.Absolute
			imageBrush.Viewbox = Rect(0, 0, bi.Width, bi.Height)
			imageBrush.AlignmentX = AlignmentX.Left
			imageBrush.AlignmentY = AlignmentY.Top
			imageBrush.Opacity = 0.5

			dg = DrawingGroup()
			dc = dg.Open()
			dc.DrawRectangle(SolidColorBrush(Color.FromArgb(Byte.MaxValue * 50 / 100, 0, 0, 0)), None, Rect(0, 0, bi.Width, bi.Height))
			dc.DrawRectangle(imageBrush, None, Rect(0, 0, bi.Width, bi.Height))
			dc.Close()

			backgroundBrush = ImageBrush(DrawingImage(dg))
			backgroundBrush.TileMode = TileMode.Tile
			backgroundBrush.ViewportUnits = BrushMappingMode.Absolute
			backgroundBrush.Viewport = Rect(0, 0, bi.Width, bi.Height)
			backgroundBrush.Stretch = Stretch.None

			if backgroundBrush.CanFreeze:
				backgroundBrush.Freeze()

			grid.HorizontalAlignment = HorizontalAlignment.Stretch
			grid.VerticalAlignment = VerticalAlignment.Stretch
			grid.Background = backgroundBrush
			grid.Width = 150
			grid.Height = 150
			grid.Clip = EllipseGeometry(Rect(0, 0, 150, 150))

			dropShadowEffect = DropShadowEffect()
			dropShadowEffect.BlurRadius = 1
			dropShadowEffect.Color = Colors.Black
			dropShadowEffect.Direction = 270
			dropShadowEffect.Opacity = 0.5
			dropShadowEffect.ShadowDepth = 1

			if dropShadowEffect.CanFreeze:
				dropShadowEffect.Freeze()

			grid.Effect = dropShadowEffect

			contentControl.Content = grid

			solidColorBrush = SolidColorBrush(colorFromAhsb(Byte.MaxValue, 60, 1.0, 1.0) if task.Result.Value.Key < 0 else colorFromAhsb(Byte.MaxValue, 0, 1.0, 0.4) if task.Result.Value.Key > 37 else colorFromAhsb(Byte.MaxValue, 60 - 60 * task.Result.Value.Key / 37, 1.0, 0.4 + 0.6 * Math.Pow(Math.E, (37 / 5 - task.Result.Value.Key) - 37 / 5) if task.Result.Value.Key < 37 / 5 else 0.4))

			if solidColorBrush.CanFreeze:
				solidColorBrush.Freeze()


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

				finally:
					stream.Close()

				imageBrush = ImageBrush(bi)
				imageBrush.TileMode = TileMode.None
				imageBrush.ViewportUnits = BrushMappingMode.Absolute
				imageBrush.Viewport = Rect(0, 0, width, height)
				imageBrush.Stretch = Stretch.Uniform

				if imageBrush.CanFreeze:
					imageBrush.Freeze()

				g = Grid()
				g.HorizontalAlignment = HorizontalAlignment.Center
				g.VerticalAlignment = VerticalAlignment.Center
				g.Background = Brushes.Transparent
				g.Width = width
				g.Height = height

				grid.Children.Add(g)

				for i in range(max):
					rectangle = Rectangle()
					rectangle.HorizontalAlignment = HorizontalAlignment.Left
					rectangle.VerticalAlignment = VerticalAlignment.Top
					rectangle.Width = width
					rectangle.Height = height
					rectangle.Fill = solidColorBrush
					rectangle.Opacity = 0
					rectangle.OpacityMask = imageBrush
					rectangle.Clip = RectangleGeometry(Rect(0, height / max * i, width, height / max))
					rectangle.RenderTransform = TranslateTransform(0, 0)
					rectangle.Tag = i
					
					g.Children.Add(rectangle)

			window.Show()

			idList.Clear()
			idList.AddRange(task.Result.Value.Value.Value.Key)
Beispiel #8
0
import clr
clr.AddReference("PresentationFramework", "PresentationCore")

from System.Windows import (Application, SizeToContent, Thickness, Window)

from System.Windows.Controls import (Button, Label, StackPanel)

from System.Windows.Media.Effects import DropShadowBitmapEffect

win = Window(Title="Welcome to IronPython", Width=450)
win.SizeToContent = SizeToContent.Height

stack = StackPanel()
stack.Margin = Thickness(15)
win.Content = stack

button = Button(Content="Push Me",
                FontSize=24,
                BitmapEffect=DropShadowBitmapEffect())


def onClick(sender, event):
    msg = Label()
    msg.FontSize = 36
    msg.Content = 'Welcome to IronPython!'

    stack.Children.Add(msg)


button.Click += onClick
stack.Children.Add(button)
Beispiel #9
0
import clr
from   spelling import *

clr.AddReferenceByPartialName("PresentationCore")
clr.AddReferenceByPartialName("PresentationFramework") 
from System.Windows import Window, Application, HorizontalAlignment
from System.Windows.Controls import FlowDocumentScrollViewer, ComboBox
from System.Windows.Documents import FlowDocument, Paragraph, Run
from System.Windows.Media.Brushes import Black, PaleGreen, Red

#--GLOBALS---------------------------------------------------------------------
_temp_file = open(sys.argv[1], "r")
lines_in_file = _temp_file.readlines()
_temp_file.close()

main_window = Window()

#--FUNCTIONS-------------------------------------------------------------------
def create_paragraph(file_lines):
    #Create a "Paragraph" object to hold all text from the file
    paragraph = Paragraph()
    #Text in the paragraph will have a font size of 16
    paragraph.FontSize = 16.0

    #Go through every line in the file passed in from the command
    #line...
    for x in file_lines:
        #...looking for Python/Ruby/PowerShell style comments
        if "#" in x:

            #Split the line whenever a comment is found
Beispiel #10
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()
Beispiel #11
0
        def onCompleted(task):
            window = Window()
            stackPanel3 = StackPanel()

            def onLoaded(sender, args):
                stackPanel3.Width = Math.Ceiling(stackPanel3.ActualWidth)

            def onCloseClick(sender, args):
                window.Close()

            window.Owner = Application.Current.MainWindow

            if CultureInfo.CurrentCulture.Equals(
                    CultureInfo.GetCultureInfo("ja-JP")):
                window.Title = "バリデータ"
            else:
                window.Title = "Validator"

            window.WindowStartupLocation = WindowStartupLocation.CenterOwner
            window.ResizeMode = ResizeMode.NoResize
            window.SizeToContent = SizeToContent.WidthAndHeight
            window.Background = SystemColors.ControlBrush
            window.Loaded += onLoaded

            stackPanel1 = StackPanel()
            stackPanel1.UseLayoutRounding = True
            stackPanel1.HorizontalAlignment = HorizontalAlignment.Stretch
            stackPanel1.VerticalAlignment = VerticalAlignment.Stretch
            stackPanel1.Orientation = Orientation.Vertical

            window.Content = stackPanel1

            stackPanel2 = StackPanel()
            stackPanel2.HorizontalAlignment = HorizontalAlignment.Stretch
            stackPanel2.VerticalAlignment = VerticalAlignment.Stretch
            stackPanel2.Orientation = Orientation.Vertical
            stackPanel2.Background = SystemColors.WindowBrush

            stackPanel1.Children.Add(stackPanel2)

            stackPanel3.HorizontalAlignment = HorizontalAlignment.Stretch
            stackPanel3.VerticalAlignment = VerticalAlignment.Stretch
            stackPanel3.Orientation = Orientation.Vertical

            if errorList.Count == 0:
                if CultureInfo.CurrentCulture.Equals(
                        CultureInfo.GetCultureInfo("ja-JP")):
                    attachStackPanel(stackPanel3, Brushes.Lime, "有効なスクリプトです。")
                else:
                    attachStackPanel(stackPanel3, Brushes.Lime, "Valid.")

            for warning in warningList:
                attachStackPanel(stackPanel3, Brushes.Yellow, warning)

            for error in errorList:
                attachStackPanel(stackPanel3, Brushes.Red, error)

            stackPanel2.Children.Add(stackPanel3)

            solidColorBrush = SolidColorBrush(Colors.White)
            solidColorBrush.Opacity = 0.5

            if solidColorBrush.CanFreeze:
                solidColorBrush.Freeze()

            border = Border()
            border.HorizontalAlignment = HorizontalAlignment.Stretch
            border.VerticalAlignment = VerticalAlignment.Stretch
            border.BorderThickness = Thickness(0, 1, 0, 0)
            border.BorderBrush = solidColorBrush

            stackPanel1.Children.Add(border)

            closeButton = Button()
            closeButton.HorizontalAlignment = HorizontalAlignment.Right
            closeButton.VerticalAlignment = VerticalAlignment.Center
            closeButton.Margin = Thickness(10, 10, 10, 10)
            closeButton.Padding = Thickness(10, 2, 10, 2)
            closeButton.IsDefault = True

            if CultureInfo.CurrentCulture.Equals(
                    CultureInfo.GetCultureInfo("ja-JP")):
                closeButton.Content = "閉じる"
            else:
                closeButton.Content = "Close"

            closeButton.Click += onCloseClick

            border.Child = closeButton

            window.Show()
Beispiel #12
0
    def __init__(self):
        '''
        get the window design from Window.xaml
        FindLogicalNode maps each component to a variable
        += maps an event to a function, the name of the event can be found in Windows class help file
        '''
        Window.__init__(self)

        stream = StreamReader("Window.xaml")
        window = XamlReader.Load(stream.BaseStream)

        self._timer = DispatcherTimer()
        self._timer.Tick += self._timer_Tick
        self._timer.Interval = TimeSpan.FromMilliseconds(10) 'run the timer every 10ms'
        self._timer.Start()

        initializing = True
        print("main window")
        while Transfer.all_connected() == False and initializing:
            if MessageBox.Show("Devices not initialized, retry?","warning", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes:
                Transfer.reinitialize()
            else:
                initializing = False

        if initializing == False:
            Application.Current.Shutdown()
            return

        self.UI_x = LogicalTreeHelper.FindLogicalNode(window, "UI_x")
        self.UI_x.Content = KCubeDCServoUI.CreateLargeView(Transfer.x)
        self.UI_y = LogicalTreeHelper.FindLogicalNode(window, "UI_y")
        self.UI_y.Content = KCubeDCServoUI.CreateLargeView(Transfer.y)
        self.UI_z = LogicalTreeHelper.FindLogicalNode(window, "UI_z")
        self.UI_z.Content = KCubeDCServoUI.CreateLargeView(Transfer.z)
        self.UI_rx = LogicalTreeHelper.FindLogicalNode(window, "UI_rx")
        self.UI_rx.Content = KCubeDCServoUI.CreateLargeView(Transfer.rx)
        self.UI_ry = LogicalTreeHelper.FindLogicalNode(window, "UI_ry")
        self.UI_ry.Content = KCubeDCServoUI.CreateLargeView(Transfer.ry)
        self.UI_r = LogicalTreeHelper.FindLogicalNode(window, "UI_r")
        self.UI_r.Content = KCubeDCServoUI.CreateLargeView(Transfer.r)

        self.Help = LogicalTreeHelper.FindLogicalNode(window, "Help")
        self.Help.Click += self.Help_Click

        self.ZUp = LogicalTreeHelper.FindLogicalNode(window, "ZUp")
        self.ZUp.Checked += self.ZUp_Checked
        self.ZUp.Unchecked += self.ZUp_Unchecked
        self.ZDown = LogicalTreeHelper.FindLogicalNode(window, "ZDown")
        self.ZDown.Checked += self.ZDown_Checked
        self.ZDown.Unchecked += self.ZDown_Unchecked

        self.ViewMode = LogicalTreeHelper.FindLogicalNode(window, "ViewMode")
        self.ViewMode.SelectionChanged += self.ViewMode_Changed

        self.Button1 = LogicalTreeHelper.FindLogicalNode(window, "Button1")
        self.Button1.Click += self.Button1_Click

        self.Mode = LogicalTreeHelper.FindLogicalNode(window, "Mode")
        self.Mode.Text = "High speed mode"

        self.RotateAngle = LogicalTreeHelper.FindLogicalNode(window, "Angle")

        self.Title = "Gaming..."
        '''lock the size'''

        Application().Run(window)
Beispiel #13
0
from System.Windows.Markup import XamlReader
from System.Windows import Window, Application

if len(sys.argv) == 1:
    from Microsoft.Win32 import OpenFileDialog
    
    dialog = OpenFileDialog()
    dialog.ShowDialog()
    
    filename = dialog.FileName
    if filename is None:
        sys.exit()
    stream = dialog.OpenFile()
elif len(sys.argv) > 2:
    print 'display_xaml [xaml_file]'
    sys.exit(1)
else:
    from System.IO import File
    filename = sys.argv[1]
    stream = File.OpenRead(filename)

reader = FlowDocumentReader()
flowDocument = XamlReader.Load(stream)
stream.Close()
reader.Document = flowDocument
w = Window()
w.Title = "Displaying %r" % filename
w.Content = reader
Application().Run(w)

Beispiel #14
0
import clr
clr.AddReference("PresentationFramework")
clr.AddReference("PresentationCore")
from System.Windows import (SizeToContent, Thickness, Window)
from System.Windows.Controls import (Button, Label, StackPanel)
from System.Windows.Media.Effects import DropShadowBitmapEffect

window = Window()
window.Title = 'Welcome to IronPython'
window.SizeToContent = SizeToContent.Height
window.Width = 450

stack = StackPanel()
stack.Margin = Thickness(15)
window.Content = stack

button = Button()
button.Content = 'Push Me'
button.FontSize = 24
button.BitmapEffect = DropShadowBitmapEffect()


def onClick(sender, event):
    message = Label()
    message.FontSize = 36
    message.Content = 'Welcome to IronPython!'
    stack.Children.Add(message)


button.Click += onClick
stack.Children.Add(button)
Beispiel #15
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()