From 2855d2e15921ef758120a43a501c94f0f7d973d8 Mon Sep 17 00:00:00 2001 From: Brychan Dempsey Date: Sun, 17 Oct 2021 16:28:58 +1300 Subject: [PATCH] Added filter for the board image --- PDGServer_WPF/ConnectionPage.xaml.cs | 31 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/PDGServer_WPF/ConnectionPage.xaml.cs b/PDGServer_WPF/ConnectionPage.xaml.cs index 8e1cdab..9cfc60a 100644 --- a/PDGServer_WPF/ConnectionPage.xaml.cs +++ b/PDGServer_WPF/ConnectionPage.xaml.cs @@ -114,6 +114,7 @@ namespace RBG_Server_WPF // Load sprites as they arrive if (e.CurrentActivity == CommunicationHandler.ProgressData.Activity.ImageDownloaded) { + Dispatcher.Invoke(() => StatusTextBlock.Text = $"Downloaded {e.Progress} of {App.Context.GameCommunicationHandler.ImageList.Count} images."); App.Context.GameCommunicationHandler.ImageCollection.TryGetValue(e.Message, out CachedByteArray cachedByteArray); BitmapImage image = new(); @@ -124,19 +125,29 @@ namespace RBG_Server_WPF { Source = image }; - LoadedSpriteGrid loadedSprite = null; - foreach (LoadedSpriteGrid item in ClientLoadedSprites.Children) + if (e.Message == App.Context.GameCommunicationHandler.BoardName) { - if (item.Equals(e.Message)) - { - loadedSprite = item; - break; - } + // Image is the board image + Dispatcher.Invoke(() =>BoardPreviewImage.Source = image); } - if (loadedSprite == null) loadedSprite = new LoadedSpriteGrid(spriteImage, e.Message); + else + { + // Image is a sprite, load it + LoadedSpriteGrid loadedSprite = null; + foreach (LoadedSpriteGrid item in ClientLoadedSprites.Children) + { + if (item.Equals(e.Message)) + { + loadedSprite = item; + break; + } + } + if (loadedSprite == null) loadedSprite = new LoadedSpriteGrid(spriteImage, e.Message); - // Add the loaded image into the view - Dispatcher.Invoke(() => ClientLoadedSprites.Children.Add(loadedSprite)); + // Add the loaded image into the view + Dispatcher.Invoke(() => ClientLoadedSprites.Children.Add(loadedSprite)); + } + } }