Пример #1
0
def convert_ta(shyft_ta):
    ta = None
    if isinstance(shyft_ta, api.TimeAxisFixedDeltaT):
        # Fixed TA
        ta = TimeAxis(Calendar.Utc, UtcTime.CreateFromUnixTime(shyft_ta.start),
                      TimeSpan.FromSeconds(shyft_ta.delta_t), shyft_ta.n)
    elif isinstance(shyft_ta, api.PointTimeaxis):
        # Point TA
        ta = create_point_ta(shyft_ta)
    elif isinstance(shyft_ta, api.TimeAxis):
        # Generic TA: either Calendar | Fixed | Point
        if shyft_ta.timeaxis_type == api.TimeAxisType.FIXED:
            ta = TimeAxis(Calendar.Utc,
                          UtcTime.CreateFromUnixTime(shyft_ta.fixed_dt.start),
                          TimeSpan.FromSeconds(shyft_ta.fixed_dt.delta_t),
                          shyft_ta.fixed_dt.n)
        elif shyft_ta.timeaxis_type == api.TimeAxisType.CALENDAR:
            cal = Calendar(shyft_ta.calendar_dt.calendar.tz_info.name)
            ta = TimeAxis(
                cal, UtcTime.CreateFromUnixTime(shyft_ta.calendar_dt.start),
                TimeSpan.FromSeconds(shyft_ta.calendar_dt.delta_t),
                shyft_ta.calendar_dt.n)
        elif shyft_ta.timeaxis_type == api.TimeAxisType.POINT:
            ta = create_point_ta(shyft_ta.point_dt)
    if ta is None:
        raise SmgDataError('Unsupported shyft time-axis: ' + str(shyft_ta))
    return ta
Пример #2
0
 def On_EntityHurt(self, HurtEvent):
     if not HurtEvent.AttackerIsPlayer:
         return
     if HurtEvent.Attacker is not None and HurtEvent.Entity is not None and not HurtEvent.IsDecay:
         gun = HurtEvent.WeaponName
         if gun == "Shotgun":
             return
         OwnerID = self.GetIt(HurtEvent.Entity)
         if OwnerID is None:
             return
         id = HurtEvent.Attacker.SteamID
         ownerlong = Data.ToUlong(OwnerID)
         if Data.ToUlong(id) != ownerlong:
             if "explosive" in gun.lower() or "grenade" in gun.lower():
                 Time = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds
                 BeingRaided[Data.ToUlong(OwnerID)] = Time
                 return
         if ownerlong in BeingRaided.keys():
             Time = BeingRaided[ownerlong]
             diff = (TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds -
                     Time)
             if diff < self.RaidTimeInSeconds:
                 HurtEvent.Attacker.Message(
                     "You can't destroy while having raid cooldown! (" +
                     str(round(diff, 2)) + "/" +
                     str(self.RaidTimeInSeconds) + ")")
                 return
             BeingRaided.pop(ownerlong)
         if Data.ToUlong(id) == ownerlong or self.IsFriend(OwnerID, id):
             EntityName = HurtEvent.Entity.Name
             if DataStore.ContainsKey("DestroySystem", id):
                 if self.IsEligible(HurtEvent):
                     HurtEvent.Entity.Destroy()
                     if self.giveback == 1:
                         if EntityName in EntityList.keys():
                             HurtEvent.Attacker.Inventory.AddItem(
                                 EntityList[EntityName])
             elif DataStore.ContainsKey("DestroySystem2", id):
                 structs = HurtEvent.Entity.GetLinkedStructs()
                 if self.giveback == 1:
                     if EntityName in EntityList.keys():
                         HurtEvent.Attacker.Inventory.AddItem(
                             EntityList[EntityName])
                 for ent in structs:
                     if self.giveback == 1:
                         namef = ent.Name
                         if namef in EntityList.keys():
                             HurtEvent.Attacker.Inventory.AddItem(
                                 EntityList[namef])
                     ent.Destroy()
                 HurtEvent.Entity.Destroy()
Пример #3
0
def onMouseLeftButtonUp(s, e):
	global y, storyboard

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

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

			def onCurrentStateInvalidated(sender, args):
				global storyboard

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

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

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

		y = None
Пример #4
0
    def __init__(self):
        rd = ResourceDictionary()
        rd.Source = Uri(
            "pack://application:,,,/ClassicAssist.Shared;component/Resources/DarkTheme.xaml"
        )
        self.Resources.MergedDictionaries.Add(rd)
        self.Background = self.Resources["ThemeWindowBackgroundBrush"]

        self.Content = XamlReader.Parse(xaml)
        self.Title = "Rudder"
        self.Topmost = True
        self.Height = 250
        self.Width = 250
        self.refreshTime = TimeSpan.FromSeconds(30)

        self.events = [('forwardLeft', 'Forward Left'), ('forward', 'Forward'),
                       ('forwardRight', 'Forward Right'), ('left', 'Left'),
                       ('turnAround', 'Turn Around'), ('right', 'Right'),
                       ('backLeft', 'Back Left'), ('back', 'Back'),
                       ('backRight', 'Back Right'), ('stop', 'Stop'),
                       ('raiseAnchor', 'Raise Anchor'),
                       ('dropAnchor', 'Drop Anchor'),
                       ('turnLeft', 'Turn Left'), ('turnRight', 'Turn Right'),
                       ('start', 'Start')]
        self.setEvents()
Пример #5
0
    def __init__(self, host=None, port=None, testFile=None):
        self.ui = wpf.LoadComponent(self, 'WindowMain.xaml')
        self.sidebar = self.ui.sidebar
        self.model = AppVM(
        )  #object to which UI thread and socket thread will communicate
        self.client = Client()

        #setup ui threadupdate
        self.updater = DispatcherTimer()
        self.updater.Tick += self.update_UI
        self.updater.Interval = TimeSpan(0, 0, 0, 0, 33)
        self.updater.Start()

        if host != None and port != None:
            p = int(port)
            h = str(host)
            self.submit_message("/connect {0} {1}".format(h, p))

        #run test script
        if testFile != None:
            try:
                file = open(testFile)
                text = file.read()
                lines = text.split("\n")
                for line in lines:
                    self.submit_message(line)
                MessageBox.Show("Test file has been run.")
            except:
                MessageBox.Show("Failed to open " + testFile)
Пример #6
0
    def test_System_DateTime_binding(self):
        pydt = datetime.datetime(2015, 4, 25, 8, 39, 54)
        netdt = DateTime(2015, 4, 25, 9, 39, 54)

        result = netdt.Subtract(pydt)
        expected = TimeSpan(1, 0, 0)

        self.assertEqual(expected, result)
Пример #7
0
            def onClose(sender, args):
                global digits

                closeTimer.Stop()

                storyboard = Storyboard()

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

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

                storyboard.CurrentStateInvalidated += onCurrentStateInvalidated

                r = Random(Environment.TickCount)

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

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

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

                            storyboard.Children.Add(doubleAnimation)

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

                contentControl.BeginStoryboard(
                    storyboard, HandoffBehavior.SnapshotAndReplace, True)
                closeTimer.Tag = False
Пример #8
0
def test_add_and_remove_class_attribute():
    from System import TimeSpan

    for _ in range(100):
        TimeSpan.new_method = lambda self_: self_.TotalMinutes
        ts = TimeSpan.FromHours(1)
        assert ts.new_method() == 60
        del TimeSpan.new_method
        assert not hasattr(ts, "new_method")
Пример #9
0
def GetCachedItem(itemType, path):
    cacheKey = 'py:albumitem:' + path
    # lookup in cache
    item = HttpRuntime.Cache.Get(cacheKey)
    if item is not None: return item
    # create new
    item = itemType(path)
    # cache it
    HttpRuntime.Cache.Insert(cacheKey, item, None, DateTime.MaxValue, TimeSpan.FromMinutes(4))
    return item
Пример #10
0
def onTick(timer, e):
    global username, password

    if not String.IsNullOrEmpty(username) and not String.IsNullOrEmpty(
            password):
        update()

    timer.Stop()
    timer.Interval = TimeSpan.FromMinutes(5)
    timer.Start()
Пример #11
0
    def testAddAndRemoveClassAttribute(self):

        from System import TimeSpan

        for i in range(100):
            TimeSpan.new_method = lambda self: self.TotalMinutes
            ts = TimeSpan.FromHours(1)
            self.assertTrue(ts.new_method() == 60)
            del TimeSpan.new_method
            self.assertFalse(hasattr(ts, "new_method"))
Пример #12
0
 def Execute(self, recs):
     sw = Stopwatch.StartNew()
     if self.Name == 'copyto.over':
         copyToRecord(recs, True)
     elif self.Name == 'copyto.new':
         copyToRecord(recs, False)
     sw.Stop()
     t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)
     ScriptSupport.SendStatusText(
         'Script took %s to complete. List added to clipboard' %
         t.ToString(), Color.Blue)
Пример #13
0
		def Execute(self, recs):
			from TESVSnip.UI.Hosting import ScriptSupport
			from System.Drawing import SystemColors, Color
			from TESVSnip.UI.Hosting import ScriptSupport
		
			sw = Stopwatch.StartNew()
			print getNPCRaces(recs)
			#p = copyRecords(recs)
			#__plugins__.AddRecord(p)  # add new plugin
			sw.Stop()
			t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)            
			ScriptSupport.SendStatusText('Script took %s to complete' % t.ToString() , Color.Blue)
	def onClick(self, sender, event):
		self.Running = not self.Running
		self.startButton.Content = "Start" if not self.Running else 'Stop'
		
		if self.Running:
			print 'Starting timer...'
			self.timer.Interval = TimeSpan().FromSeconds(0)
			self.timer.Start()
			self.timer.Interval = self.refreshTime
		else:
			print 'Stopping timer...'
			self.timer.Stop()
			self.listView.Items.Clear()
Пример #15
0
    def on_loaded(self, s, e):
        bubble = Image()
        bubble.Name = "Bubble"
        #imageSource = System.Windows.Resources["think"]
        bubble.Source = self.thinkBubble
        bubble.SetValue(Canvas.TopProperty, self.currentY)
        bubble.SetValue(Canvas.LeftProperty, self.currentX)
        self.mainPanel.Children.Add(bubble)

        text = TextBox()
        text.Text = "???"
        text.FontSize = 65
        text.FontWeight = FontWeights.Bold
        text.BorderThickness = Thickness(0)
        text.SetValue(Canvas.TopProperty, self.currentY + 35)
        text.SetValue(Canvas.LeftProperty, self.currentX + 55)
        self.mainPanel.Children.Add(text)

        myDoubleAnimation = DoubleAnimation()
        myDoubleAnimation.From = 770.0
        myDoubleAnimation.To = 250.0

        myDoubleAnimation.Duration = Duration(TimeSpan.FromSeconds(3))

        myDoubleAnimationText = DoubleAnimation()
        myDoubleAnimationText.From = 770.0 + 35.0
        myDoubleAnimationText.To = 250.0 + 35.0

        myDoubleAnimationText.Duration = Duration(TimeSpan.FromSeconds(3))

        #myStoryboard = Storyboard()
        #myStoryboard.Children.Add(myDoubleAnimation)
        #Storyboard.SetTargetName(myDoubleAnimation, bubble.Name)
        #Storyboard.SetTargetProperty(myDoubleAnimation, PropertyPath(Canvas.TopProperty))

        #myStoryboard.Begin(self);

        bubble.BeginAnimation(Canvas.TopProperty, myDoubleAnimation)
        text.BeginAnimation(Canvas.TopProperty, myDoubleAnimationText)
Пример #16
0
 def __init__(self, interval=5):
     '''
     :param int interval:
         Number of milliseconds that represents interval when messages will
         be processed.
     '''
     self._subscribers = defaultdict(list)
     self._messages = Queue()
     self._lock = Lock()
     self._timer = DispatcherTimer()
     self._timer.Interval = TimeSpan.FromMilliseconds(5)
     self._timer.Tick += self._execute
     self._timer.Start()
	def __init__(self):
		rd = ResourceDictionary()
		rd.Source = Uri("pack://application:,,,/ClassicAssist.Shared;component/Resources/DarkTheme.xaml")
		self.Resources.MergedDictionaries.Add(rd)
		self.Background = self.Resources["ThemeWindowBackgroundBrush"]		
		
		self.Content = XamlReader.Parse(xaml)
		self.Title = "Durability"
		self.Topmost = True
		self.SizeToContent = SizeToContent.Width
		self.Height = 400
		self.refreshTime = TimeSpan.FromSeconds(30)
		
		self.listView = self.Content.FindName('listView')
		self.startButton = self.Content.FindName('startButton')
		self.startButton.Click += self.onClick
		
		self.timer = DispatcherTimer()
		self.timer.Tick += self.onTick
		self.timer.Interval = TimeSpan().FromSeconds(0)
		self.timer.Start()
		self.timer.Interval = self.refreshTime
		self.Running = True
Пример #18
0
        def Execute(self, recs):
            from TESVSnip.UI.Hosting import ScriptSupport
            from System.Drawing import SystemColors, Color

            sw = Stopwatch.StartNew()
            str = generateItemList(recs)
            if str:
                sw.Stop()
                t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)
                window = ScriptSupport.CreateTextWindow("Script Output")
                if window:
                    window.Focus()
                    window.SetText(str)
                ScriptSupport.SendStatusText(
                    'Script took %s to complete' % t.ToString(), Color.Blue)
Пример #19
0
    def connect(self):
        """Establish WebSocket connection to the ROS server defined for this factory.

        Returns:
            async_task: The async task for the connection.
        """
        LOGGER.debug('Started to connect...')
        socket = ClientWebSocket()
        socket.Options.KeepAliveInterval = TimeSpan.FromSeconds(5)
        connect_task = socket.ConnectAsync(self.url,
                                           self.manager.cancellation_token)

        protocol = CliRosBridgeProtocol(self, socket)
        connect_task.ContinueWith(protocol.on_open)

        return connect_task
Пример #20
0
        def Execute(self, recs):
            sw = Stopwatch.StartNew()
            str = None
            if self.Name == 'listweight':
                str = listNPCWeights(recs)
            if self.Name == 'modweight':
                str = modifyNPCWeights(recs)

            if str:
                sw.Stop()
                t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)
                toClipboard(__window__, str)
                window = ScriptSupport.CreateTextWindow("Script Output")
                if window:
                    window.Focus()
                    window.SetText(str)
                ScriptSupport.SendStatusText(
                    'Script took %s to complete. List added to clipboard' %
                    t.ToString(), Color.Blue)
Пример #21
0
class App(Form):
    def __init__(self):
        self.Title="Timer"
        self.timer1=Timer()
        self.timer1.Interval=1000
        self.timer1.Tick+=self.timer1_tick
        label1=Label()
        label1.AutoSize=True
        label1.Location=Point(41,22)
        label1.Text="00:00:00"
        label1.Font=Font("MS UI Gothic",24.0,FontStyle.Regular)
        self.label1=label1
        self.Controls.Add(self.label1)

        clientwidth=255

        b1=Button()
        b1.Location=Point((clientwidth-b1.Width*2)/3,68)
        b1.Text="Click"
        b1.Click+=self.start_Click
        self.Controls.Add(b1)

        b2=Button()
        b2.Location=Point((clientwidth-b1.Width*2)*2/3+b1.Width,68)
        b2.Text="Stop"

        b2.Click+=self.stop_Click
        self.Controls.Add(b2)
        self.ClientSize=Size(clientwidth,103)
        self.Text="Stop Watch"
        self.StartPosition=FormStartPosition.CenterScreen

    def timer1_tick(self,sender,e):
        self.starttime=self.starttime+TimeSpan(0,0,1)
        self.label1.Text=self.starttime.ToString()

    def start_Click(self,sender,e):
        self.starttime=TimeSpan(0,0,0)
        self.label1.Text=self.starttime.ToString()
        self.timer1.Start()

    def stop_Click(self,sender,e):
        self.timer1.Stop()
Пример #22
0
    def __init__(
        self,
        server=None,
        username=None,
        password=None,
        domain=None,
        authentication_mode=AuthenticationMode.PI_USER_AUTHENTICATION,
        timeout=None,
    ):
        if server and server not in self.servers:
            message = 'Server "{server}" not found, using the default server.'
            warn(message=message.format(server=server), category=UserWarning)
        if bool(username) != bool(password):
            raise ValueError(
                "When passing credentials both the username and password must be specified."
            )
        if domain and not username:
            raise ValueError(
                "A domain can only specified together with a username and password."
            )
        if username:
            from System.Net import NetworkCredential
            from System.Security import SecureString

            secure_pass = SecureString()
            for c in password:
                secure_pass.AppendChar(c)
            cred = [username, secure_pass] + ([domain] if domain else [])
            self._credentials = (NetworkCredential(*cred), int(authentication_mode))
        else:
            self._credentials = None

        self.connection = self.servers.get(server, self.default_server)

        if timeout:
            from System import TimeSpan

            # System.TimeSpan(hours, minutes, seconds)
            self.connection.ConnectionInfo.OperationTimeOut = TimeSpan(0, 0, timeout)
Пример #23
0
    def delete_jobs(self):
        current_time = DateTime.Now
        hours = self.delete_days * 24

        jobs = list(RepositoryUtils.GetJobs(True))
        self.log_verbose("Found {0} jobs. Scanning...".format(len(jobs)))

        older_than = current_time.Subtract(TimeSpan(hours, 0, 0))
        for job in jobs:
            submitted = job.JobSubmitDateTime
            if submitted == DateTime.MinValue:
                continue
            if DateTime.Compare(submitted, older_than) < 0:
                if not self.dry_run:
                    self.log_verbose(
                        "Removing job {1} - {0}. Submitted on {2}.".format(
                            job.JobName, job.JobId, submitted))
                    RepositoryUtils.ArchiveJob(job, True, None)
                else:
                    self.log_verbose(
                        "Would have removed job {1} - {0}. Submitted on {2}.".
                        format(job.JobName, job.JobId, submitted))

        print("Older than {0}".format(older_than))
Пример #24
0
 def duration(self, time):
     mins, secs = divmod(time, 60)
     hours, mins = divmod(mins, 60)
     return TimeSpan(hours, mins, secs)
Пример #25
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
Пример #26
0
import clr
from System import DateTime, DateTimeOffset, TimeSpan
clr.AddReference("WorkTasks")
from WorkTasks import WorkTask

cut_start = DateTimeOffset(1997, 3, 3, 15, 31, 34, 361,
                           TimeSpan.FromMinutes(500))
cut_details = "artio"
account = WorkTask(cut_start, cut_details)

cut_duration = TimeSpan.FromSeconds(25570)
account.Duration = cut_duration

abutting_task = WorkTask(cut_start + cut_duration, "corollarii")
not_abutting_task = WorkTask(cut_start + cut_duration + TimeSpan.FromTicks(1),
                             "poenae")


def test_abutting():
    "Do two WorkTasks abut?"
    return account.IsAbutting(abutting_task)


def test_not_abutting():
    "Do two WorkTasks NOT abut?"
    return account.IsAbutting(not_abutting_task)
Пример #27
0
gameDir = util.getGameDirectory()

import System
from System.Diagnostics import Stopwatch
from System import TimeSpan

sw = Stopwatch.StartNew()

import TESVSnip.Domain
import ListItems
plugins = TESVSnip.Domain.Model.PluginList.All

excludeList = 'RGDL;CLDC;PWAT;SCOL;SCPT;HAIR;REGN;NAVI;WRLD;DIAL;CELL;IMAD;WTHR'.Split(
    ';')
filter = System.Func[str, bool](lambda x: x not in excludeList)

pluginList = util.loadMasterPluginIndex()
from System import Random
rand = Random()
pluginName = pluginList.items()[rand.Next(0, len(pluginList) - 1)][0]
plugins.AddRecord(TESVSnip.Domain.Model.Plugin(gameDir + pluginName, filter))
#plugins.AddRecord(TESVSnip.Domain.Model.Plugin(gameDir + 'skyrim.esm', filter))
print ListItems.generateItemList(plugins)

import ModWeight
print ModWeight.listNPCWeights(plugins)
print ModWeight.modifyNPCWeights(plugins)

sw.Stop()
t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)
print 'Script took', t, 'to complete'
Пример #28
0
 def create_timer(self, f, freq):
     timer = DispatcherTimer()
     timer.Tick += EventHandler(f)
     timer.Interval = TimeSpan.FromMilliseconds(freq)
     return timer
Пример #29
0
			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()
Пример #30
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)
	
	Task.Factory.StartNew[KeyValuePair[List[String], KeyValuePair[Double, KeyValuePair[KeyValuePair[Double, Double], KeyValuePair[List[Double], List[MemoryStream]]]]]](onUpdate, TaskCreationOptions.LongRunning).ContinueWith(Action[Task[KeyValuePair[List[String], KeyValuePair[Double, KeyValuePair[KeyValuePair[Double, Double], KeyValuePair[List[Double], List[MemoryStream]]]]]]](onCompleted), TaskScheduler.FromCurrentSynchronizationContext())

	timer.Stop()
	timer.Interval = TimeSpan.FromMinutes(5)
	timer.Start()

def urlEncode(value):
	unreserved = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~"
	sb = StringBuilder()
	bytes = Encoding.UTF8.GetBytes(value)

	for b in bytes:
		if b < 0x80 and unreserved.IndexOf(Convert.ToChar(b)) != -1:
			sb.Append(Convert.ToChar(b))
		else:
			sb.Append('%' + String.Format("{0:X2}", Convert.ToInt32(b)))

	return sb.ToString()