public async Task TweetWithMentionIsTaggedAsMentioned() { OAuth.TestUserName = "******"; try { const string json = @"[{""created_at"":""Mon Nov 26 00:18:26 +0000 2012"",""id"":272856804650782720,""id_str"":""272856804650782720"",""text"":""Mere sense is never to be talked to a mob"",""source"":""\u003ca href=\""http:\/\/itunes.apple.com\/us\/app\/twitter\/id409789998?mt=12\"" rel=\""nofollow\""\u003eTwitter for Mac\u003c\/a\u003e"",""truncated"":false,""in_reply_to_status_id"":null,""in_reply_to_status_id_str"":null,""in_reply_to_user_id"":null,""in_reply_to_user_id_str"":null,""in_reply_to_screen_name"":null,""user"":{""id"":140108433,""id_str"":""140108433"",""name"":""Angus Croll"",""screen_name"":""angustweets"",""location"":""San Francisco"",""description"":""super-fantastique"",""url"":""http:\/\/t.co\/U83LF6gR"",""entities"":{""url"":{""urls"":[{""url"":""http:\/\/t.co\/U83LF6gR"",""expanded_url"":""http:\/\/javascriptweblog.wordpress.com"",""display_url"":""javascriptweblog.wordpress.com"",""indices"":[0,20]}]},""description"":{""urls"":[]}},""protected"":false,""followers_count"":4514,""friends_count"":48,""listed_count"":390,""created_at"":""Tue May 04 16:11:55 +0000 2010"",""favourites_count"":1073,""utc_offset"":-28800,""time_zone"":""Pacific Time (US & Canada)"",""geo_enabled"":true,""verified"":false,""statuses_count"":2061,""lang"":""en"",""contributors_enabled"":false,""is_translator"":false,""profile_background_color"":""FFFFFF"",""profile_background_image_url"":""http:\/\/a0.twimg.com\/profile_background_images\/635294458\/ir7ek09fhxqjp00h6hbe.jpeg"",""profile_background_image_url_https"":""https:\/\/si0.twimg.com\/profile_background_images\/635294458\/ir7ek09fhxqjp00h6hbe.jpeg"",""profile_background_tile"":false,""profile_image_url"":""http:\/\/a0.twimg.com\/profile_images\/2777728124\/5e092d781248974754b97358565204c2_normal.png"",""profile_image_url_https"":""https:\/\/si0.twimg.com\/profile_images\/2777728124\/5e092d781248974754b97358565204c2_normal.png"",""profile_banner_url"":""https:\/\/si0.twimg.com\/profile_banners\/140108433\/1347913889"",""profile_link_color"":""2D0DE0"",""profile_sidebar_border_color"":""FFFFFF"",""profile_sidebar_fill_color"":""FFF7CC"",""profile_text_color"":""0C3E53"",""profile_use_background_image"":true,""default_profile"":false,""default_profile_image"":false,""following"":true,""follow_request_sent"":null,""notifications"":null},""geo"":null,""coordinates"":null,""place"":null,""contributors"":null,""retweet_count"":0,""entities"":{""hashtags"":[],""urls"":[],""user_mentions"":[{""screen_name"":""mikeward_aa"",""indices"":[4,11]}]},""favorited"":false,""retweeted"":false}]"; var mockWebRequest = new Mock <IWebRequest>(); var mockWebResponse = new Mock <IWebResponse>(); WebRequestWrapper.OverrideImplementation = address => mockWebRequest.Object; mockWebRequest.Setup(request => request.Headers.Add("Authorization", It.IsAny <string>())); mockWebRequest.Setup(request => request.GetResponseAsync()).Returns(Task.FromResult(mockWebResponse.Object)); var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)); mockWebResponse.Setup(response => response.GetResponseStream()).Returns(stream); var timelines = new Timelines { DispatchInvokerOverride = callback => callback() }; timelines.SwitchView(View.Mentions); timelines.Timeline.Count.Should().Be(0); await timelines.UpdateHome(); mockWebResponse.Verify(); timelines.Timeline.Count.Should().Be(1); timelines.Timeline[0].IsMention.Should().BeTrue(); } finally { OAuth.TestUserName = null; } }
public TweetTimeline() { //InitializeComponent(); _tweeterTimelines = new Timelines(); Controller = new TimelineController(_tweeterTimelines); Controller.StartTimelines(); }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Timelines.Play(TimelineAsset); animator.SetBool(Parameters.Keys.IsTimelinePlaying, true); IsActive = true; }
public override string ToString() { string result = String.Format("{0}/{1}/{2}", Discipline.Name, Chapter.Name, Topic.Name); result = result + string.Concat(Timelines.Select(timeline => String.Format("({0} - {1}),", String.Format("{0:g}", timeline.StartDate), String.Format("{0:g}", timeline.EndDate)))); return(result.Remove(result.Length - 1)); }
public void AddTimeline(string name) { Timeline timeline = _UI.Store_Timeline.Get(name); if (timeline != null) { Timelines.Add(timeline); } }
public Task <Timeline> CreateTimelineAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, CancellationToken cancellationToken) { var timeline = new Timeline { Id = timelineId }; Timelines.Add(timelineId, timeline); return(Task.FromResult(timeline)); }
private static Storyboard CreateStoryboard(Timelines timelines) { Storyboard storyboard = new Storyboard(); storyboard.FillBehavior = FillBehavior.HoldEnd; foreach (Timeline timeline in timelines) { storyboard.Children.Add(timeline); } return(storyboard); }
private static void SetupDefaultExitAnimation(Timelines exitAnimation) { exitAnimation.Add(new Operation() { Command = Command.HideMessage }); exitAnimation.Add(new SlideOut() { Direction = Direction.Left, BeginTime = TimeSpan.FromSeconds(0.3) }); }
private void AddNewGroup() { GroupTabs.Add(new GroupViewModel(this) { Header = NewGroupName, AllowClosing = true }); Timelines.Add(new TimelineVM()); SelectedTabIndex = GroupTabs.Count - 1; NewGroupName = "Group " + GroupTabs.Count.ToString(); }
private void AssociatedObject_Loaded(object sender, RoutedEventArgs e) { var items = AssociatedObject.GetChildren <UIElement>().Where(l => l.RenderTransform is TransformGroup); items = items.Where(l => (l.RenderTransform as TransformGroup).Children.Count == 4); var controls = items?.ToList(); if (controls == null || controls.Count == 0) { return; } Storyboard storyboard = new Storyboard(); for (int i = 0; i < controls.Count; i++) { foreach (var item in Timelines.OfType <DoubleAnimation>()) { TimeSpan span = TimeSpan.FromMilliseconds(i * (Split + item.Duration.TimeSpan.TotalMilliseconds)); TimeSpan end = item.Duration.TimeSpan + span; DoubleAnimationUsingKeyFrames frames = new DoubleAnimationUsingKeyFrames(); //EasingDoubleKeyFrame key1 = new EasingDoubleKeyFrame(item.From.Value, KeyTime.FromTimeSpan(TimeSpan.Zero)); //EasingDoubleKeyFrame key2 = new EasingDoubleKeyFrame(item.From.Value, KeyTime.FromTimeSpan(span)); //EasingDoubleKeyFrame key3 = new EasingDoubleKeyFrame(item.To.Value, KeyTime.FromTimeSpan(end)); //frames.KeyFrames.Add(key1); //frames.KeyFrames.Add(key2); //frames.KeyFrames.Add(key3); EasingDoubleKeyFrame key1 = new EasingDoubleKeyFrame(item.From.Value, KeyTime.FromTimeSpan(TimeSpan.Zero)); frames.KeyFrames.Add(key1); Storyboard.SetTarget(frames, controls[i]); Storyboard.SetTargetProperty(frames, Storyboard.GetTargetProperty(item)); storyboard.Children.Add(frames); DoubleAnimation animation = item.Clone(); animation.BeginTime = span; Storyboard.SetTarget(animation, controls[i]); storyboard.Children.Add(animation); } } storyboard.FillBehavior = FillBehavior.HoldEnd; storyboard.Begin(); }
public void UpdateTimeStampsShouldReturnFriendlyTime() { var timelines = new Timelines { DispatchInvokerOverride = callback => callback() }; TranslationService.Instance.TranslationProvider = new TranslationProviderNameValueFile(); timelines.SwitchView(View.Home); timelines.Timeline.Add(new Tweet { CreatedAt = DateTime.UtcNow }); timelines.Timeline[0].TimeAgo.Should().BeNull(); timelines.UpdateTimeStamps(); timelines.Timeline[0].TimeAgo.Should().EndWith("s", "Time ago should be a few seconds ago"); }
public Task <List <TimelineRecord> > UpdateTimelineRecordsAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, IEnumerable <TimelineRecord> records, CancellationToken cancellationToken) { var recordDictionary = records.ToDictionary(x => x.Id); Timeline timeline = Timelines.GetValueOrDefault(timelineId); foreach (var record in timeline.Records) { if (recordDictionary.ContainsKey(record.Id)) { MergeTimelineRecords(record, recordDictionary.GetValueOrDefault(record.Id)); recordDictionary.Remove(record.Id); } } timeline.Records.AddRange(recordDictionary.Values); return(Task.FromResult(records.ToList())); }
public override void UpdateTimeline(float dt) { if (_trees != null) { for (int i = 0; i < _trees.Count; i++) { if (_trees[i] != null) { _trees[i].rotation = Quaternion.Slerp(_trees[i].rotation, Quaternion.identity, dt * .25f); } } } if (Input.GetKeyDown(KeyCode.Return) || Input.GetButtonDown("Submit")) { Timelines.DeactiveTimeline("epilogue"); Timelines.ActivateTimeline("game"); } }
private static void SetupDefaultEnterAnimation(Timelines enterAnimation) { enterAnimation.Add(new Operation() { Command = Command.UpdateWindow }); enterAnimation.Add(new SlideIn() { Direction = Direction.Right, Position = Position.LeftBottom, BeginTime = TimeSpan.FromSeconds(0.1) }); enterAnimation.Add(new Operation() { Command = Command.ShowMessage, BeginTime = TimeSpan.FromSeconds(1.2) }); }
// Recursively deletes every child timeline and exhibit (with references and content items) form timeline with given guid. public void DeleteTimeline(Guid id) { var timelineIDs = GetChildTimelinesIds(id); // list of ids of child timelines var exhibitIDs = GetChildExhibitsIds(id); // list of ids of exhibits // recursively delete timelines while (timelineIDs.Count != 0) { DeleteTimeline(timelineIDs.First()); timelineIDs.RemoveAt(0); } // recursively delete exhibits while (exhibitIDs.Count != 0) { DeleteExhibit(exhibitIDs.First()); exhibitIDs.RemoveAt(0); } Timeline removeTimeline = Timelines.Find(id); Timelines.Remove(removeTimeline); }
// AddTimeline public void AddTimeline(Timeline timeline) { Timelines.Add(timeline); }
public IEnumerable <TimelineRaw> TimelineSubtreeQuery(Guid collectionId, Guid?leastCommonAncestor, decimal startTime, decimal endTime, decimal minSpan, int maxElements) { IEnumerable <TimelineRaw> result; Dictionary <Guid?, TimelineRaw> map = new Dictionary <Guid?, TimelineRaw>(); if (System.Configuration.ConfigurationManager.ConnectionStrings[0].ProviderName.Equals("System.Data.SqlClient")) { result = Database.SqlQuery <TimelineRaw>("EXEC TimelineSubtreeQuery {0}, {1}, {2}, {3}, {4}, {5}", collectionId, leastCommonAncestor, minSpan, startTime, endTime, maxElements); } else { bool return_entire_subtree = false; result = new Collection <TimelineRaw>(); if (leastCommonAncestor != null) { Timeline root = Timelines.Where(r => r.Id == leastCommonAncestor).FirstOrDefault(); if (root != null && root.SubtreeSize <= maxElements) { for (Timeline c = Timelines.Where(_c => _c.Id == root.FirstNodeInSubtree).FirstOrDefault(); c != root; c = Timelines.Where(_c => _c.Id == c.Successor).FirstOrDefault()) { ((Collection <TimelineRaw>)result).Add(new TimelineRaw(c)); } return_entire_subtree = true; } } if (!return_entire_subtree) { Queue <TimelineRaw> q = new Queue <TimelineRaw>(); var init_timelines = leastCommonAncestor == null?Database.SqlQuery <TimelineRaw>("SELECT * FROM [Timelines] WHERE [Depth] = 0 AND CollectionID = {0}", collectionId) : Database.SqlQuery <TimelineRaw>("SELECT * FROM [Timelines] WHERE [Id] = {0}", leastCommonAncestor); // select the root element foreach (TimelineRaw t in init_timelines) //under normal circumstances this result should only contain a single timeline { q.Enqueue(t); } while (q.Count > 0 && maxElements > 0) { bool childGreaterThanMinspan = false; TimelineRaw t = q.Dequeue(); var childTimelines = Database.SqlQuery <TimelineRaw>("SELECT * FROM [Timelines] WHERE [Timeline_ID] = {0}", t.Id); foreach (TimelineRaw c in childTimelines) { if (c.ToYear - c.FromYear > minSpan) { childGreaterThanMinspan = true; break; } } ((Collection <TimelineRaw>)result).Add(t); --maxElements; if (childGreaterThanMinspan) { if (maxElements >= t.ChildTimelines.Count()) { foreach (TimelineRaw c in childTimelines) { --maxElements; if ((c.FromYear >= startTime && c.FromYear <= endTime) || (c.ToYear >= startTime && c.ToYear <= endTime) || (c.FromYear <= startTime && c.ToYear >= endTime) || (c.FromYear >= startTime && c.ToYear <= endTime)) { //if c overlaps with current viewport, then c may be further expanded q.Enqueue(c); } } } } } } } foreach (TimelineRaw t in result) // note: results are ordered by depth in ascending order { map.Add(t.Id, t); } foreach (TimelineRaw t in result) // note: results are ordered by depth in ascending order { if (t.Timeline_ID != null && map.ContainsKey(t.Timeline_ID)) { if (map[t.Timeline_ID].ChildTimelines == null) { map[t.Timeline_ID].ChildTimelines = new Collection <Timeline>(); } map[t.Timeline_ID].ChildTimelines.Add(t); } } return(result); }
static async Task Main(string[] args) { var app = new CommandLineApplication(); app.HelpOption("-h|--help"); var optionUrl = app.Option("-u|--url <URL>", "The server url to request. If --har is used, this becomes the new based url for the .HAR file.", CommandOptionType.SingleValue); var optionConnections = app.Option <int>("-c|--connections <N>", "Total number of HTTP connections to open. Default is 10.", CommandOptionType.SingleValue); var optionWarmup = app.Option <int>("-w|--warmup <N>", "Duration of the warmup in seconds. Default is 5.", CommandOptionType.SingleValue); var optionDuration = app.Option <int>("-d|--duration <N>", "Duration of the test in seconds. Default is 5.", CommandOptionType.SingleValue); var optionHeaders = app.Option("-H|--header <HEADER>", "HTTP header to add to request, e.g. \"User-Agent: edge\"", CommandOptionType.MultipleValue); var optionVersion = app.Option("-v|--version <1.0,1.1,2.0>", "HTTP version, e.g. \"2.0\". Default is 1.1", CommandOptionType.SingleValue); var optionCertPath = app.Option("-t|--cert <filepath>", "The path to a cert pfx file.", CommandOptionType.SingleValue); var optionCertPwd = app.Option("-p|--certpwd <password>", "The password for the cert pfx file.", CommandOptionType.SingleValue); var optionFormat = app.Option("-f|--format <format>", "The format of the output, e.g., text, json. Default is text.", CommandOptionType.SingleValue); var optionQuiet = app.Option("-q|--quiet", "When set, nothing is rendered on stsdout but the results.", CommandOptionType.NoValue); var optionCookies = app.Option("-c|--cookies", "When set, cookies are ignored.", CommandOptionType.NoValue); var optionHar = app.Option("-h|--har <filename>", "A .har file representing the urls to request.", CommandOptionType.SingleValue); var optionHarNoDelay = app.Option("--har-no-delay", "when set, delays between HAR requests are not followed.", CommandOptionType.NoValue); var optionScript = app.Option("-s|--script <filename>", "A .js script file altering the current client.", CommandOptionType.SingleValue); var optionLocal = app.Option("-l|--local", "Ignore requests outside of the main domain.", CommandOptionType.NoValue); app.OnValidate(ctx => { if (!optionHar.HasValue() && !optionUrl.HasValue()) { return(new ValidationResult($"The --{optionUrl.LongName} field is required.")); } return(ValidationResult.Success); }); app.OnExecuteAsync(async cancellationToken => { NoHarDelay = optionHarNoDelay.HasValue(); SendCookies = !optionCookies.HasValue(); Quiet = optionQuiet.HasValue(); Local = optionLocal.HasValue(); Log("Http Client"); ServerUrl = optionUrl.Value(); if (optionHar.HasValue()) { var harFilename = optionHar.Value(); if (harFilename.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine($"Downloading har file {harFilename}"); var tempFile = Path.GetTempFileName(); using (var downloadStream = await _httpClient.GetStreamAsync(harFilename)) using (var fileStream = File.Create(tempFile)) { await downloadStream.CopyToAsync(fileStream); } harFilename = tempFile; } if (!File.Exists(harFilename)) { Console.WriteLine($"HAR file not found: '{Path.GetFullPath(harFilename)}'"); return; } Timelines = TimelineFactory.FromHar(harFilename); var baseUri = Timelines.First().Uri; var serverUri = String.IsNullOrEmpty(ServerUrl) ? baseUri : new Uri(ServerUrl); // Substitute the base url with the one provided foreach (var timeline in Timelines) { if (baseUri.Host == timeline.Uri.Host || timeline.Uri.Host.EndsWith("." + baseUri.Host)) { timeline.Uri = new UriBuilder(serverUri.Scheme, serverUri.Host, serverUri.Port, timeline.Uri.AbsolutePath, timeline.Uri.Query).Uri; } } if (Local) { Timelines = Timelines.Where(x => String.Equals(x.Uri.Host, baseUri.Host, StringComparison.OrdinalIgnoreCase)).ToArray(); } } else { Timelines = new[] { new Timeline { Method = "GET", Uri = new Uri(ServerUrl) } }; } ServerUrl = optionUrl.Value(); Format = optionFormat.HasValue() ? optionFormat.Value() : "text"; WarmupTimeSeconds = optionWarmup.HasValue() ? int.Parse(optionWarmup.Value()) : 5; ExecutionTimeSeconds = optionDuration.HasValue() ? int.Parse(optionDuration.Value()) : 5; Connections = optionConnections.HasValue() ? int.Parse(optionConnections.Value()) : 10; Headers = new List <string>(optionHeaders.Values); if (!optionVersion.HasValue()) { Version = HttpVersion.Version11; } else { switch (optionVersion.Value()) { case "1.0": Version = HttpVersion.Version10; break; case "1.1": Version = HttpVersion.Version11; break; case "2.0": Version = HttpVersion.Version20; break; default: Log("Unkown HTTP version: {0}", optionVersion.Value()); break; } } if (optionCertPath.HasValue()) { CertPath = optionCertPath.Value(); Log("CerPath: " + CertPath); CertPassword = optionCertPwd.Value(); if (CertPath.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { Log($"Downloading certificate: {CertPath}"); var httpClientHandler = new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }; var httpClient = new HttpClient(httpClientHandler); var bytes = await httpClient.GetByteArrayAsync(CertPath); Certificate = new X509Certificate2(bytes, CertPassword); } else { Log($"Reading certificate: {CertPath}"); Certificate = new X509Certificate2(CertPath, CertPassword); } Log("Certificate Thumbprint: " + Certificate.Thumbprint); } if (optionScript.HasValue()) { var scriptFilename = optionScript.Value(); if (scriptFilename.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine($"Downloading script file {scriptFilename}"); var tempFile = Path.GetTempFileName(); using (var downloadStream = await _httpClient.GetStreamAsync(scriptFilename)) using (var fileStream = File.Create(tempFile)) { await downloadStream.CopyToAsync(fileStream); } scriptFilename = tempFile; } if (!File.Exists(scriptFilename)) { Console.WriteLine($"Script file not found: '{Path.GetFullPath(scriptFilename)}'"); return; } Script = File.ReadAllText(scriptFilename); } await RunAsync(); }); await app.ExecuteAsync(args); }
/// <summary>Gets owner of the triplet</summary> /// <param name="name">Name of the triplet. Triplets referring to timelines, exhibits, artifacts and bNodes are supported. /// In all other cases method returns null.</param> /// <param name="bNodes">List of previously examined bNodes to avoid endless recursion</param> /// <returns>String representation of owning user ID</returns> public string GetSubjectOwner(TripleName name, List <string> bNodes = null) { name = EnsurePrefix(name); switch (name.Prefix) { case TripleName.UserPrefix: return(name.Name); case TripleName.TimelinePrefix: var timelineId = Guid.Parse(name.Name); var timeline = Timelines.Where(t => t.Id == timelineId).FirstOrDefault(); if (timeline == null) { return(null); } Entry(timeline).Reference(t => t.Collection).Load(); return(GetCollectionOwner(timeline.Collection)); case TripleName.ExhibitPrefix: var exhibitId = Guid.Parse(name.Name); var exhibit = Exhibits.Where(e => e.Id == exhibitId).FirstOrDefault(); if (exhibit == null) { return(null); } Entry(exhibit).Reference(e => e.Collection).Load(); return(GetCollectionOwner(exhibit.Collection)); case TripleName.ArtifactPrefix: var artifactId = Guid.Parse(name.Name); var artifact = ContentItems.Where(c => c.Id == artifactId).FirstOrDefault(); if (artifact == null) { return(null); } Entry(artifact).Reference(a => a.Collection).Load(); return(GetCollectionOwner(artifact.Collection)); case TripleName.TourPrefix: var tourId = Guid.Parse(name.Name); var tour = Tours.FirstOrDefault(t => t.Id == tourId); if (tour == null) { return(null); } Entry(tour).Reference(t => t.Collection).Load(); return(GetCollectionOwner(tour.Collection)); case "_": var subject = name.ToString(); // Guard against infinite loop if (bNodes != null && bNodes.Contains(subject)) { return(null); } // Find subject of any triple that uses passed subject as object var linkedSubject = Triples. Include(t => t.Objects). Where(t => t.Objects.Any(o => o.Object == subject)). Select(t => t.Subject).FirstOrDefault(); if (String.IsNullOrEmpty(linkedSubject)) { return(null); } // Get owner of linked subject if (bNodes == null) { bNodes = new List <string>(new string[] { subject }); } else { bNodes.Add(subject); } return(GetSubjectOwner(TripleName.Parse(linkedSubject), bNodes)); default: return(null); } }
protected override void RefreshAnimation() { var items = this.GetChildren <UIElement>().Where(l => l.RenderTransform is TransformGroup); items = items.Where(l => (l.RenderTransform as TransformGroup).Children.Count == 4); var controls = items?.ToList(); if (controls == null || controls.Count == 0) { return; } Storyboard storyboard = new Storyboard(); for (int i = 0; i < controls.Count; i++) { foreach (var item in Timelines.OfType <DoubleAnimation>()) { TimeSpan span = TimeSpan.FromMilliseconds(i * (SplitMilliSecond + item.Duration.TimeSpan.TotalMilliseconds)); TimeSpan end = item.Duration.TimeSpan + span; if (item.BeginTime == TimeSpan.Zero) { DoubleAnimationUsingKeyFrames frames = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame key1 = new EasingDoubleKeyFrame(item.From.Value, KeyTime.FromTimeSpan(TimeSpan.Zero)); frames.KeyFrames.Add(key1); Storyboard.SetTarget(frames, controls[i]); Storyboard.SetTargetProperty(frames, Storyboard.GetTargetProperty(item)); storyboard.Children.Add(frames); } DoubleAnimation animation = item.Clone(); animation.BeginTime = span + animation.BeginTime; Storyboard.SetTarget(animation, controls[i]); storyboard.Children.Add(animation); } foreach (var item in Timelines.OfType <ThicknessAnimation>()) { TimeSpan span = TimeSpan.FromMilliseconds(i * (SplitMilliSecond + item.Duration.TimeSpan.TotalMilliseconds)); TimeSpan end = item.Duration.TimeSpan + span; ThicknessAnimationUsingKeyFrames frames = new ThicknessAnimationUsingKeyFrames(); EasingThicknessKeyFrame key1 = new EasingThicknessKeyFrame(item.From.Value, KeyTime.FromTimeSpan(TimeSpan.Zero)); frames.KeyFrames.Add(key1); Storyboard.SetTarget(frames, controls[i]); Storyboard.SetTargetProperty(frames, Storyboard.GetTargetProperty(item)); storyboard.Children.Add(frames); ThicknessAnimation animation = item.Clone(); animation.BeginTime = span; Storyboard.SetTarget(animation, controls[i]); storyboard.Children.Add(animation); } } storyboard.FillBehavior = FillBehavior.HoldEnd; storyboard.RepeatBehavior = RepeatBehavior.Forever; storyboard.Begin(); }
protected override bool GetIsDone() => !Timelines.Any() || Timelines.All(x => x.IsDone);
public override void UpdateTimeline(float dt) { CheckForInputInvert(); // dirty dirty movement easing // instead of using physics just gain speed with input and dampen speed when no input if (HasPlayerRotationInput()) { float rotGainInverse = 1f / _rotationGain; _rotationInput += GetPlayerRotationInput() * dt * rotGainInverse; } else { float rotDampInverse = 1f / _rotationDampening; _rotationInput *= 1f - dt * rotDampInverse; } if (HasPlayerDilusionInput()) { float dilGainInverse = 1f / _dilationGain; _dilationInput += GetPlayerDilusionInput() * dt * dilGainInverse; } else { float dilDampInverse = 1f / _dilationDampening; _dilationInput *= 1f - dt * dilDampInverse; } _dilationInput = Mathf.Clamp(_dilationInput, -1f, 1f); _rotationInput = Mathf.Clamp(_rotationInput, -1f, 1f); _dilationOffset += _dilationInput * dt * _dilationSpeed; _rotationOffset += _rotationInput * dt * TWO_PI * _rotationSpeed; _dilationOffset = Mathf.Clamp(_dilationOffset, MIN_DILATION_DISTANCE, MAX_DILATION_DISTANCE); // apply new offset // poll alive elements float count = 0f; for (int i = _elements.Count - 1; i >= 0f; i--) { if (!_elements[i].Dead) { count++; } else { _elements.RemoveAt(i); } } if (count <= 1) { // game over Timelines?.DeactiveTimeline("game"); Timelines?.ActivateTimeline("epilogue"); } //fade old count to new count to avoid teleporting the orbs _count = Mathf.Lerp(_count, count, dt * 1.5f); // make sure we don't divide by zero if (_count < 0.01f) { return; } for (int i = 0; i < _elements.Count; i++) { Vector3 pos = _elements[i].transform.localPosition; // fade old position to avoid teleporting the index of removed elements float radialpos = Mathf.Lerp(_elements[i].RadialPosition, i, dt * 1.5f); _elements[i].RadialPosition = radialpos; pos.x = Mathf.Sin(radialpos / _count * TWO_PI + _rotationOffset) * _dilationOffset; pos.y = Mathf.Cos(radialpos / _count * TWO_PI + _rotationOffset) * _dilationOffset; _elements[i].transform.localPosition = pos; } }
public override string ToString() { return($"LastReadAll: {LastReadAll}, Timelines: [{String.Join("\r\n\r\n/***/\r\n\r\n", Timelines.AsEnumerable())}]"); }
void GoTimelineFederated() { Frame.Navigate(typeof(StatusListPage), new StatusListViewModel((max_id) => Timelines.Public(Settings.CurrentAccount.Domain, max_id: max_id))); }
/// <summary> 执行方法 </summary> protected override void Invoke(object parameter) { if (this.AssociatedObject == null) { return; } if (this.AutoFindParent) { this.Target = this.AssociatedObject.GetParent <Panel>(); } if (this.Target == null) { this.Target = this.AssociatedObject; } IEnumerable <UIElement> children = null; if (IsUseAll) { children = this.Target.GetChildren <UIElement>().Where(l => l.RenderTransform is TransformGroup); children = children.Where(l => (l.RenderTransform as TransformGroup).Children.Count == 4); children = children.Where(l => (l as FrameworkElement)?.Tag?.ToString() != "Except" && !InvokeRandomSplitAnimationAction.GetIsExcept(l)); } else { if (this.Target is Panel panel) { children = panel.Children?.Cast <UIElement>()?.Where(l => l.RenderTransform is TransformGroup); children = children.Where(l => (l.RenderTransform as TransformGroup).Children.Count == 4 && !InvokeRandomSplitAnimationAction.GetIsExcept(l)); } } if (children == null) { return; } var controls = children?.ToList(); if (controls == null || controls.Count == 0) { return; } if (this.UseIndex) { controls = this.RandomList(controls); } Storyboard storyboard = new Storyboard(); for (int i = 0; i < controls.Count; i++) { if (this.UseOrigin) { controls[i].RenderTransformOrigin = this.GetRandomOrigin(); } foreach (var item in Timelines.OfType <RandomDoubleAnimation>()) { TimeSpan span = TimeSpan.FromMilliseconds(i * (SplitMilliSecond + item.Duration.TimeSpan.TotalMilliseconds)); TimeSpan end = item.Duration.TimeSpan + span; DoubleAnimation animation = item.ConvertTo(); if (item.BeginTime == TimeSpan.Zero) { DoubleAnimationUsingKeyFrames frames = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame key1 = new EasingDoubleKeyFrame(animation.From.Value, KeyTime.FromTimeSpan(TimeSpan.Zero)); frames.KeyFrames.Add(key1); Storyboard.SetTarget(frames, controls[i]); Storyboard.SetTargetProperty(frames, Storyboard.GetTargetProperty(item)); storyboard.Children.Add(frames); } animation.BeginTime = span + animation.BeginTime; Storyboard.SetTarget(animation, controls[i]); storyboard.Children.Add(animation); } foreach (var item in Timelines.OfType <ThicknessAnimation>()) { TimeSpan span = TimeSpan.FromMilliseconds(i * (SplitMilliSecond + item.Duration.TimeSpan.TotalMilliseconds)); TimeSpan end = item.Duration.TimeSpan + span; ThicknessAnimationUsingKeyFrames frames = new ThicknessAnimationUsingKeyFrames(); EasingThicknessKeyFrame key1 = new EasingThicknessKeyFrame(item.From.Value, KeyTime.FromTimeSpan(TimeSpan.Zero)); frames.KeyFrames.Add(key1); Storyboard.SetTarget(frames, controls[i]); Storyboard.SetTargetProperty(frames, Storyboard.GetTargetProperty(item)); storyboard.Children.Add(frames); ThicknessAnimation animation = item.Clone(); animation.BeginTime = span; Storyboard.SetTarget(animation, controls[i]); storyboard.Children.Add(animation); } } storyboard.FillBehavior = FillBehavior.HoldEnd; storyboard.RepeatBehavior = this.RepeatBehavior; storyboard.Begin(); }