Ejemplo n.º 1
0
 def OnSelectionChanged(self, sender, e):
     obj = wpf.get_focused()
     if obj is not self.tbx:
         # Surprise, surprise this event is too early to be useful...
         # FIXME: Must be a less hackish way to get this working
         t = DispatcherTimer()
         t.Interval = TimeSpan.FromSeconds(0.1)
         
         def OnTick(sender, e):
             self.complete_from_member_list()
             self.tbx.Focus()
             t.Stop()
         
         t.Tick += OnTick
         t.Start()
Ejemplo n.º 2
0
	elif iSextant == 2:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMin), Convert.ToByte(iMax), Convert.ToByte(iMid))

	elif iSextant == 3:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMin), Convert.ToByte(iMid), Convert.ToByte(iMax))

	elif iSextant == 4:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMid), Convert.ToByte(iMin), Convert.ToByte(iMax))

	elif iSextant == 5:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMax), Convert.ToByte(iMin), Convert.ToByte(iMid))

	return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMax), Convert.ToByte(iMid), Convert.ToByte(iMin))

def onStart(s, e):
	global timer

	timer.Start()

def onStop(s, e):
	global timer
	
	timer.Stop()

idList = List[Double]()
timer = DispatcherTimer(DispatcherPriority.Background)
timer.Tick += onTick
timer.Interval = TimeSpan.FromMilliseconds(30000)
Script.Instance.Start += onStart
Script.Instance.Stop += onStop
Ejemplo n.º 3
0
            menuItem.Header = "Gmail"

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

                    if not clr.GetClrType(Separator).IsInstanceOfType(
                            window.ContextMenu.Items[10]):
                        separator = Separator()
                        window.ContextMenu.Items.Insert(10, separator)

    timer.Start()


def onStop(s, e):
    global timer

    timer.Stop()


dateTime = DateTime.Now - TimeSpan(12, 0, 0)
menuItem = None
separator = None
timer = DispatcherTimer(DispatcherPriority.Background)
timer.Tick += onTick
timer.Interval = TimeSpan.FromMinutes(1)
Script.Instance.Start += onStart
Script.Instance.Stop += onStop
Ejemplo n.º 4
0
def onStart(s, e):
	global timer, menuItem, separator
	
	for window in Application.Current.Windows:
		if window is Application.Current.MainWindow and window.ContextMenu is not None:
			if not window.ContextMenu.Items.Contains(menuItem):
				window.ContextMenu.Opened += onOpened
				window.ContextMenu.Items.Insert(window.ContextMenu.Items.Count - 4, menuItem)
				window.ContextMenu.AddHandler(Button.KeyDownEvent, RoutedEventHandler(onKeyDown), True)
				
				if not clr.GetClrType(Separator).IsInstanceOfType(window.ContextMenu.Items[10]):
					separator = Separator()
					window.ContextMenu.Items.Insert(10, separator)

	timer.Start()

def onStop(s, e):
	global timer
	
	timer.Stop()

dateTime = DateTime.Now - TimeSpan(12, 0, 0)
menuItem = MenuItem()
menuItem.Header = "Facebook"
separator = None
timer = DispatcherTimer(DispatcherPriority.Background)
timer.Tick += onTick
timer.Interval = TimeSpan.FromMinutes(1)
Script.Instance.Start += onStart
Script.Instance.Stop += onStop
Ejemplo n.º 5
0
 def create_timer(self, f, freq):
     timer = DispatcherTimer()
     timer.Tick += EventHandler(f)
     timer.Interval = TimeSpan.FromMilliseconds(freq)
     return timer
Ejemplo n.º 6
0
	elif iSextant == 2:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMin), Convert.ToByte(iMax), Convert.ToByte(iMid))

	elif iSextant == 3:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMin), Convert.ToByte(iMid), Convert.ToByte(iMax))

	elif iSextant == 4:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMid), Convert.ToByte(iMin), Convert.ToByte(iMax))

	elif iSextant == 5:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMax), Convert.ToByte(iMin), Convert.ToByte(iMid))

	return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMax), Convert.ToByte(iMid), Convert.ToByte(iMin))

def onStart(s, e):
	global timer

	timer.Start()

def onStop(s, e):
	global timer
	
	timer.Stop()

idList = List[Double]()
timer = DispatcherTimer(DispatcherPriority.Background)
timer.Tick += onTick
timer.Interval = TimeSpan.FromMilliseconds(30000)
Script.Instance.Start += onStart
Script.Instance.Stop += onStop
Ejemplo n.º 7
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()
start_time = None
iframes = ''

for t in tests:
    # TODO delete any existing files in IsoStore from this test

    iframes += '<iframe width="25%%" height="100" id=%s src="sub.html?test=%s"></iframe>' % (
        t, t)

sl_ctl = HtmlPage.Document.CreateElement("span")
sl_ctl.Id = "test-domain-loading"
sl_ctl.SetProperty("innerHTML", iframes)
HtmlPage.Document.Body.AppendChild(sl_ctl)

ht = DispatcherTimer()
ht.Interval = TimeSpan.FromSeconds(TimerInterval)
timer_counter = 0


def CheckForDonFile(sender, args):
    # check for exception and signal
    global timer_counter
    global tests

    if remaining_tests:
        if timer_counter > MAXTIMERCOUNT - 1:
            print "Time out! %d tests didn't finish." % len(remaining_tests)
            # stop timer
            ht.Stop()

        else:
Ejemplo n.º 9
0
start_time = None
iframes = ''

for t in tests:
	# TODO delete any existing files in IsoStore from this test
	
	iframes += '<iframe width="25%%" height="100" id=%s src="sub.html?test=%s"></iframe>' % (t, t)


sl_ctl = HtmlPage.Document.CreateElement("span")
sl_ctl.Id = "test-domain-loading"
sl_ctl.SetProperty("innerHTML", iframes)
HtmlPage.Document.Body.AppendChild(sl_ctl)

ht = DispatcherTimer()
ht.Interval = TimeSpan.FromSeconds(TimerInterval)
timer_counter = 0

def CheckForDonFile(sender, args):
	# check for exception and signal
	global timer_counter
	global tests

	if remaining_tests:
		if timer_counter > MAXTIMERCOUNT - 1:
			print "Time out! %d tests didn't finish." % len(remaining_tests)
			# stop timer
			ht.Stop()
			
		else:
			timer_counter += 1
Ejemplo n.º 10
0
        me.Pause_MouseEnterValue.To = buttonOverHexValue
        me.Volume_MouseEnterValue.To = buttonOverHexValue
        me.Volume1_MouseEnterValue.To = buttonOverHexValue
        me.Volume2_MouseEnterValue.To = buttonOverHexValue
        me.NextA_MouseEnterValue.To = buttonOverHexValue
        me.NextB_MouseEnterValue.To = buttonOverHexValue
        me.PreviousA_MouseEnterValue.To = buttonOverHexValue
        me.PreviousB_MouseEnterValue.To = buttonOverHexValue
        me.FullA_MouseEnterValue.To = buttonOverHexValue
        me.FullB_MouseEnterValue.To = buttonOverHexValue
        me.FullC_MouseEnterValue.To = buttonOverHexValue
        me.FullD_MouseEnterValue.To = buttonOverHexValue

    # UI update timer
    _positionTimer = DispatcherTimer()
    _positionTimer.Interval = TimeSpan(0, 0, 0, 0, 100)
    _positionTimer.Tick += positionTimer_Tick
    _positionTimer.Start()

    #get XML from page DOM
    name = Application.Current.Host.InitParams["xamlid"].Split("-")[0]
    xmlSettings = HtmlPage.Document.GetElementById(name + "-settings").text
    settings = MediaInfo(xmlSettings)

    # assign values declared in markup
    _loop = settings.Loop
    me.Width = settings.Width
    me.Height = settings.Height

    if settings.Poster != "":
        me.Poster.Source = BitmapImage(
Ejemplo n.º 11
0
			if not String.IsNullOrEmpty(selectedTerm2) and selectedTerm1.Length < selectedTerm2.Length:
				if not selectedTermList.Contains(selectedTerm2):
					selectedTermList.Add(selectedTerm2)

				stringBuilder.Remove(0, max)

			else:
				if not selectedTermList.Contains(selectedTerm1):
					selectedTermList.Add(selectedTerm1)

				stringBuilder.Remove(0, selectedTerm1.Length)

	return selectedTermList

def onStart(s, e):
	global timer

	timer.Start()

def onStop(s, e):
	global timer
	
	timer.Stop()

dateTime = DateTime.Now
processDictionary = Dictionary[Int32, String]()
timer = DispatcherTimer(DispatcherPriority.Background)
timer.Tick += onTick
timer.Interval = TimeSpan.FromSeconds(15)
Script.Instance.Start += onStart
Script.Instance.Stop += onStop
Ejemplo n.º 12
0
    else: newText = newText.strip()

    if newText == oldText: return

    e = fracexpr(newText)
    Document.evalExpression.innerHTML= e.evaltext()
    Document.formattedExpression.innerHTML = e.html()

    try:
        r = e.eval()
        
        if r is None:
            r = ''
        elif not isinstance(r, frac):
            raise Exception('Unexpected result type.')
            
        Document.result.innerHTML = fracexpr(str(r)).html()
        Document.evalException.innerHTML = 'None'
    except Exception, exp:
        Document.result.innerHTML = 'n/a' 
        Document.evalException.innerHTML = exp.Message
        
    oldText = newText
    
oldText = ''
t = DispatcherTimer()
t.Interval = TimeSpan.FromSeconds(0.5)
t.Tick += Refract
t.Start()

Ejemplo n.º 13
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()