当前位置: 首页>>代码示例>>C#>>正文


C# Timeline.Update方法代码示例

本文整理汇总了C#中Timeline.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Timeline.Update方法的具体用法?C# Timeline.Update怎么用?C# Timeline.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timeline的用法示例。


在下文中一共展示了Timeline.Update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestTimelineData

    public void TestTimelineData()
    {
        Keyframe<KeyframeParams>[] keyframes = new Keyframe<KeyframeParams>[] {
            new Keyframe<KeyframeParams>() { time=0, value=new KeyframeParams() { a=0,b=10 } },
            new Keyframe<KeyframeParams>() { time=0.5f, value=new KeyframeParams() { a=1,b=5 } },
            new Keyframe<KeyframeParams>() { time=0.1f, value=new KeyframeParams() { a=3,b=1 } }
        };

        KeyframeObject keyframeObject = new KeyframeObject();

        Func<int,float,string> formatMsg = (a,b)=>string.Format( "{0}-{1}", a, b );

        Timeline<KeyframeParams,KeyframeObject> timeline = new Timeline<KeyframeParams, KeyframeObject>() {
            timelineEntity=keyframeObject,
            keyframes=keyframes,
            tweenFunction=(p1,p2,t)=>{
                return new KeyframeParams() {
                    a=(int)Lerp(p1.a,p2.a,t),
                    b=Lerp(p1.b,p2.b,t)
                };
            },
            applyKeyframeParameters=(kfo,p)=>kfo.msg = formatMsg(p.a,p.b)
        };

        Assert.AreEqual( -1, timeline.CurrentKeyframeIndex );

        timeline.Update(0);
        Assert.AreEqual( 0, timeline.CurrentKeyframeIndex );
        Assert.AreEqual( formatMsg(0,10), keyframeObject.msg );

        timeline.Update(0.1f);
        Assert.AreEqual( 0, timeline.CurrentKeyframeIndex );
        Assert.AreEqual( formatMsg(0,9f), keyframeObject.msg );

        timeline.Update(0.4f);
        Assert.AreEqual( 0, timeline.CurrentKeyframeIndex );
        Assert.AreEqual( formatMsg(1,5f), keyframeObject.msg );

        timeline.Update(0.1f);
        Assert.AreEqual( 1, timeline.CurrentKeyframeIndex );
        Assert.AreEqual( formatMsg(3,0.999999f), keyframeObject.msg );

        timeline.Update(0.1f);
        Assert.AreEqual( 2, timeline.CurrentKeyframeIndex );
        Assert.AreEqual( formatMsg(0,10f), keyframeObject.msg ); // this frame has no length

        timeline.Update(0.1f);
        Assert.AreEqual( 0, timeline.CurrentKeyframeIndex ); // loop around
        Assert.AreEqual( formatMsg(0,8f), keyframeObject.msg );
    }
开发者ID:johnsietsma,项目名称:csharp-kit,代码行数:50,代码来源:TestTimeline.cs

示例2: HashtagCommand_Executed

        private void HashtagCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var value = e.Parameter as string;

            if (value != null)
            {
                var timeline = new Timeline
                {
                    Name = value,
                    Type = TimelineType.Search,
                    Tag = value,
                };

                Timelines.Add(timeline);

                ThreadPool.QueueUserWorkItem(state =>
                {
                    this.Invoke(p => timeline.Update(p), TClient.Search(timeline.Tag, timeline.SinceID));
                });

                TimelineTabControl.SelectedItem = timeline;
            }
        }
开发者ID:iyomumx,项目名称:MiniTwitter-Mod,代码行数:23,代码来源:MainWindow.xaml.cs

示例3: ViewConversationCommand_Executed

        private void ViewConversationCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var status = (Status)(e.Parameter ?? GetSelectedItem());

            if (status == null || status.InReplyToStatusID == 0)
            {
                return;
            }

            var value = "Conversation:" + status.Sender.ScreenName;
            var timeline = new Timeline
            {
                Name = value,
                Type = TimelineType.Conversation,
                Tag = value,
            };

            timeline.Items.Add(status);

            timeline.View.Filter = new Predicate<object>(item =>
            {
                if (!(item is Status))
                {
                    return false;
                }
                if (item == status)
                {
                    return true;
                }
                var s = item as Status;
                if (status.HasRelationshipTo(s))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            });

            Timelines.Add(timeline);

            ThreadPool.QueueUserWorkItem(state =>
            {
                this.Invoke(p => timeline.Update(p), Timelines.Where(tl => tl.Type == TimelineType.Recent).Single().Items);
                this.Invoke(() => timeline.Sort(Settings.Default.SortCategory, Settings.Default.SortDirection));
            });

            TimelineTabControl.SelectedItem = timeline;
        }
开发者ID:iyomumx,项目名称:MiniTwitter-Mod,代码行数:50,代码来源:MainWindow.xaml.cs

示例4: ViewUserCommand_Executed

        private void ViewUserCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var value = (ITwitterItem)e.Parameter ?? GetSelectedItem();
            if (Keyboard.GetKeyStates(Key.LeftCtrl) == KeyStates.Down ||
                Keyboard.GetKeyStates(Key.RightCtrl) == KeyStates.Down ||
                (((Timeline)TimelineTabControl.SelectedItem).Type == TimelineType.OtherUser &&
                    ((Timeline)TimelineTabControl.SelectedItem).Tag == value.Sender.ScreenName))
            {
                try
                {
                    Process.Start(Settings.Default.LinkUrl + value.Sender.ScreenName);
                }
                catch
                {
                    MessageBox.Show("无法打开浏览器", App.NAME);
                }
                return;
            }

            if (value != null)
            {
                var timeline = new Timeline
                {
                    Name = "User:" + value.Sender.ScreenName,
                    Type = TimelineType.OtherUser,
                    Tag = value.Sender.ScreenName,
                };

                timeline.Filters.Add(new Filter() { Pattern = value.Sender.ScreenName, Type = FilterType.Name });
                Timelines.Add(timeline);

                ThreadPool.QueueUserWorkItem(state =>
                {
                    this.Invoke(p => timeline.Update(p), TClient.GetUserTimeline(timeline.Tag));
                });

                TimelineTabControl.SelectedItem = timeline;
            }
        }
开发者ID:iyomumx,项目名称:MiniTwitter-Mod,代码行数:39,代码来源:MainWindow.xaml.cs

示例5: ViewUserCommand_Executed

        private void ViewUserCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var value = e.Parameter as string;

            if (value != null)
            {
                var timeline = new Timeline
                {
                    Name = "User:" + value,
                    Type = TimelineType.OtherUser,
                    Tag = value,
                };

                Timelines.Add(timeline);

                ThreadPool.QueueUserWorkItem(state =>
                {
                    this.Invoke(p => timeline.Update(p), client.GetUserTimeline(timeline.Tag));
                });

                TimelineTabControl.SelectedItem = timeline;
            }
        }
开发者ID:Provence,项目名称:MiniTwitter-Mod,代码行数:23,代码来源:MainWindow.xaml.cs


注:本文中的Timeline.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。