/// <summary> /// A visual representation of a <see cref="Rulesets.Ruleset"/>. /// </summary> /// <param name="ruleset">The ruleset being repesented.</param> protected RulesetContainer(Ruleset ruleset) { Ruleset = ruleset; playfield = new Lazy <Playfield>(CreatePlayfield); Cursor = CreateCursor(); }
protected override void LoadComplete() { base.LoadComplete(); AddInternal(ratioContainer = new RatioAdjust { Children = new[] { Cursor = new OsuCursorContainer { Depth = float.MinValue } } }); }
public async Task <IEnumerable <BlogPost> > GetAllAsync(CursorContainer cursor, CancellationToken cancellationToken) { _logger.LogDebug("Get all async"); using (var ctx = new DataContext(_setting.BlogSqlConnectionString)) { return(await ctx.BlogPosts .Include(x => x.BlogPostTags) .ThenInclude(x => x.Tag) .OrderByDescending(x => x.PublishDate) .ToListAsync(cancellationToken)); } }
/// <summary> /// A visual representation of a <see cref="Rulesets.Ruleset"/>. /// </summary> /// <param name="ruleset">The ruleset being repesented.</param> protected RulesetContainer(Ruleset ruleset) { Ruleset = ruleset; playfield = new Lazy <Playfield>(CreatePlayfield); IsPaused.ValueChanged += paused => { if (HasReplayLoaded) { return; } KeyBindingInputManager.UseParentInput = !paused; }; Cursor = CreateCursor(); }
public async Task <List <DropboxFileModel> > GetFilesAsync(string path, CursorContainer cursor, CancellationToken cancellationToken) { var uri = new Uri(DropboxApiUri + "/2/files/list_folder"); var continueUri = new Uri(DropboxApiUri + "/2/files/list_folder/continue"); List <DropboxFileModel> results; DropboxApiResponseListFiles response; if (string.IsNullOrWhiteSpace(cursor?.Cursor)) { var jsonResponse = await _httpClientHelper.PostAsync(uri, $@"{{""path"":""/Blog{path}"", ""recursive"": true}}", _settings.DropboxAccessToken, cancellationToken); response = JsonConvert.DeserializeObject <DropboxApiResponseListFiles>(jsonResponse); results = response.entries.Select(x => new DropboxFileModel(x.name, x.path_lower)).ToList(); } else { results = new List <DropboxFileModel>(); response = new DropboxApiResponseListFiles { cursor = cursor.Cursor, has_more = true }; } while (response.has_more) { var json = $@"{{""cursor"": ""{response.cursor}""}}"; var jsonResponse = await _httpClientHelper.PostAsync(continueUri, json, _settings.DropboxAccessToken, cancellationToken); response = JsonConvert.DeserializeObject <DropboxApiResponseListFiles>(jsonResponse); if (response.entries != null) { results.AddRange(response.entries.Select(x => new DropboxFileModel(x.name, x.path_lower)).ToList()); } if (cursor != null) { cursor.Cursor = response.cursor; } } return(results); }
private void generateTest(bool cursorlessTooltip) { testContainer.Clear(); testContainer.Add(new FillFlowContainer { RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), Children = new Drawable[] { new TooltipSpriteText("this text has a tooltip!"), new TooltipSpriteText("this one too!"), new TooltipTextbox { Text = "with real time updates!", Size = new Vector2(400, 30), }, new Container() { AutoSizeAxes = Axes.Both, Children = new Drawable[] { new TooltipSpriteText("Nested tooltip; uses no cursor in all cases!"), new TooltipContainer(), } }, }, }); testContainer.Add(makeBox(Anchor.BottomLeft)); testContainer.Add(makeBox(Anchor.TopRight)); testContainer.Add(makeBox(Anchor.BottomRight)); CursorContainer cursor = null; if (!cursorlessTooltip) { cursor = new RectangleCursorContainer(); testContainer.Add(cursor); } testContainer.Add(new TooltipContainer(cursor)); }
public VisualTestGameBoyEgg() { CursorContainer cursor = new CursorContainer(); Add(cursor); Add(new TooltipContainer(cursor) { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { gameBoyContainer = new GameBoyContainer { Scale = new Vector2(1.0f) } } }); InitialTestStep(); }
/// <summary> /// Checks if a cursor is at the current inputmanager screen position. /// </summary> /// <param name="cursorContainer">The cursor to check.</param> private bool checkAtMouse(CursorContainer cursorContainer) => Precision.AlmostEquals(InputManager.CurrentState.Mouse.NativeState.Position, cursorContainer.ToScreenSpace(cursorContainer.ActiveCursor.DrawPosition));
/// <summary> /// Checks if a cursor is visible. /// </summary> /// <param name="cursorContainer">The cursor to check.</param> private bool checkVisible(CursorContainer cursorContainer) => cursorContainer.State == Visibility.Visible;
private void generateTest(bool cursorlessTooltip) { testContainer.Clear(); CursorContainer cursor = null; if (!cursorlessTooltip) { cursor = new RectangleCursorContainer(); testContainer.Add(cursor); } TooltipContainer ttc; testContainer.Add(ttc = new TooltipContainer(cursor) { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, Children = new[] { new TooltipBox { TooltipText = "Outer Tooltip", Colour = Color4.CornflowerBlue, Size = new Vector2(300, 300), Anchor = Anchor.Centre, Origin = Anchor.Centre }, new TooltipBox { TooltipText = "Inner Tooltip", Size = new Vector2(150, 150), Anchor = Anchor.Centre, Origin = Anchor.Centre }, } }, new FillFlowContainer { RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), Children = new Drawable[] { new TooltipSpriteText("this text has a tooltip!"), new TooltipSpriteText("this one too!"), new TooltipTextbox { Text = "with real time updates!", Size = new Vector2(400, 30), }, new TooltipContainer { AutoSizeAxes = Axes.Both, Child = new TooltipSpriteText("Nested tooltip; uses no cursor in all cases!"), }, new TooltipTooltipContainer("This tooltip container has a tooltip itself!") { AutoSizeAxes = Axes.Both, Child = new Container { AutoSizeAxes = Axes.Both, Child = new TooltipSpriteText("Nested tooltip; uses no cursor in all cases; parent TooltipContainer has a tooltip"), } }, new Container { Child = new FillFlowContainer { Direction = FillDirection.Vertical, Spacing = new Vector2(0, 8), Children = new[] { new Container { Child = new Container { Child = new TooltipSpriteText("Tooltip within containers with zero size; i.e. parent is never hovered."), } }, new Container { Child = new TooltipSpriteText("Other tooltip within containers with zero size; different nesting; overlap."), } } } } }, } } }); ttc.Add(makeBox(Anchor.BottomLeft)); ttc.Add(makeBox(Anchor.TopRight)); ttc.Add(makeBox(Anchor.BottomRight)); }
public TestTooltipContainer(CursorContainer cursor) : base(cursor) { }
public async Task <IEnumerable <BlogPost> > GetAllAsync(CursorContainer cursor, CancellationToken cancellationToken) { return((await GetPublishedAsync(null, null, null, cancellationToken)).Posts); }
public async Task <IEnumerable <BlogPost> > GetAllAsync(CursorContainer cursor, CancellationToken cancellationToken) { List <DropboxFileModel> dropboxFiles = null; if (cursor == null) { _logger.LogInformation("Processing files from Dropbox ..."); } else { _logger.LogInformation("Processing updated files from Dropbox ..."); dropboxFiles = await _dropboxHelper.GetFilesAsync("", cursor, cancellationToken); _logger.LogInformation("Files dropbox thinks has been updated:"); foreach (var updatedFile in dropboxFiles) { _logger.LogDebug($" Name: \"{updatedFile.Name}\", PathLower: \"{updatedFile.PathLower}\""); } } var blogPosts = new List <BlogPost>(); _logger.LogInformation("Reading blog.json ..."); var blogMetaDataFile = await _dropboxHelper.GetFileContentAsync("/Blog.json", cancellationToken); var blogJson = Encoding.UTF8.GetString(blogMetaDataFile); _logger.LogTrace($"Blog.json content was {blogJson}"); var blogPostList = JsonConvert.DeserializeObject <List <BlogJsonItem> >(blogJson); var blogPostsToUpdate = cursor == null ? blogPostList : blogPostList.Where(x => dropboxFiles.Any(y => y.PathLower == $"/blog{x.Folder}/post.md".ToLower())).ToList(); _logger.LogInformation($"Enumerating through {blogPostsToUpdate.Count} posts downloading the file contents ..."); foreach (var blogPost in blogPostsToUpdate) { var imagePath = $"{blogPost.Folder}/images/"; //(todo) Refactor so that in the case of an incremental sync, I'm only getting images that have changed since the cursor. var images = (await _dropboxHelper.GetFilesAsync(imagePath, cancellationToken)).Where(ImageFileFilter) .Select(x => $"{imagePath}{x.Name}") .Select(i => new BlogImageData { FileName = Path.GetFileName(i), PostFolder = blogPost.Folder, ImageDataTask = _dropboxHelper.GetFileContentAsync(i, cancellationToken), }).ToList(); _logger.LogInformation($"Reading content for {blogPost.Folder} ..."); var postFile = await _dropboxHelper.GetFileContentAsync($"{blogPost.Folder}/post.md", cancellationToken); var postFileText = Encoding.UTF8.GetString(postFile); var post = new BlogPost { Id = blogPost.Id, Title = blogPost.Title, PublishDate = string.IsNullOrWhiteSpace(blogPost.PublishDate) ? null : (DateTime?)DateTime.ParseExact(blogPost.PublishDate, "yyyy-MM-dd", new CultureInfo("en-GB")), HtmlText = _renderer.Render(postFileText, blogPost.Folder), HtmlShortText = _renderer.Render(_blogPostSummaryHelper.GetSummaryText(postFileText), blogPost.Folder), Route = blogPost.Route, Featured = blogPost.Featured, Published = blogPost.Status.ToLower() == "published", ImageData = images }; post.BlogPostTags = blogPost.Tags.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(x => new BlogPostTag(post, new Tag(x))).ToList(); blogPosts.Add(post); } return(blogPosts); }
public async Task SynchronizeBlogPostsAsync(IBlogPostRepository sourceRepo, IBlogPostRepository destRepo, bool incremental, string overrideCursor, CancellationToken cancellationToken) { try { await _lockRepository.AcquireLockAsync("synchelperlock", 10, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(1), cancellationToken); _logger.LogInformation($"SynchronizeBlogPostsAsync with incremental = {incremental}"); var dropboxCursor = new CursorContainer(); if (incremental) { // Try to get a persisted cursor from our SQL database, if that's null (so we haven't got one), then we'll do a full update dropboxCursor.Cursor = overrideCursor ?? await destRepo.GetDropboxCursorAsync(cancellationToken); _logger.LogDebug($"Cursor = {dropboxCursor.Cursor}"); } var cursor = incremental && !string.IsNullOrWhiteSpace(dropboxCursor.Cursor) ? dropboxCursor : null; var sourcePosts = (await sourceRepo.GetAllAsync(cursor, cancellationToken)).ToList(); if (string.IsNullOrWhiteSpace(dropboxCursor.Cursor)) { _logger.LogInformation("No current dropbox cursor, so explicitly requesting current cursor ..."); dropboxCursor.Cursor = await _dropboxHelper.GetCurrentCursorAsync(cancellationToken); _logger.LogInformation($"Returned cursor {dropboxCursor.Cursor}"); } _logger.LogInformation($"Processing {sourcePosts.Count} source posts ..."); foreach (var sourcePost in sourcePosts) { await destRepo.AddOrUpdateAsync(sourcePost, cancellationToken); } _logger.LogInformation("Processing images ..."); var imageTasks = new List <Task>(); foreach (var sourcePost in sourcePosts) { foreach (var imageData in sourcePost.ImageData) { var imageContent = await imageData.ImageDataTask; var resizedImageFileContent = imageData.FileName.ToLower().Contains("noresize") ? imageContent : _imageResizer.Resize(imageContent, _settings.MaxResizedImageSize); imageTasks.Add(_imageRepository.AddAsync(imageData.PostFolder, imageData.FileName, resizedImageFileContent, cancellationToken)); } } await Task.WhenAll(imageTasks); if (!incremental) // Do not delete posts when in incremental mode (todo) Is this comment correct? Surely as we're reading the json file even on incremental sync, we can still delete on incremental? { var destPosts = (await destRepo.GetAllAsync(null, cancellationToken)).ToList(); var postsToDelete = destPosts.Where(d => sourcePosts.All(s => s.Id != d.Id)).ToList(); _logger.LogInformation($"Found {postsToDelete.Count} to delete out of {destPosts.Count} posts"); await destRepo.DeleteAsync(postsToDelete, cancellationToken); } await destRepo.RemoveUnusedTagsAsync(cancellationToken); _logger.LogInformation($"Saving new Dropbox cursor: {dropboxCursor.Cursor}"); await destRepo.SetDropboxCursorAsync(dropboxCursor.Cursor, cancellationToken); } finally { await _lockRepository.ReleaseLockAsync(cancellationToken); } }