public SuccessStory(IPlayniteAPI api) : base(api) { settings = new SuccessStorySettings(this); // Get plugin's location pluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // Add plugin localization in application ressource. PluginCommon.Localization.SetPluginLanguage(pluginFolder, api.ApplicationSettings.Language); // Add common in application ressource. PluginCommon.Common.Load(pluginFolder); // Check version if (settings.EnableCheckVersion) { CheckVersion cv = new CheckVersion(); if (cv.Check("SuccessStory", pluginFolder)) { cv.ShowNotification(api, "SuccessStory - " + resources.GetString("LOCUpdaterWindowTitle")); } } // Init ui interagration successStoryUI = new SuccessStoryUI(api, settings, this.GetPluginUserDataPath(), this); // Custom theme button if (settings.EnableIntegrationInCustomTheme) { EventManager.RegisterClassHandler(typeof(Button), Button.ClickEvent, new RoutedEventHandler(successStoryUI.OnCustomThemeButtonClick)); } // Load database var TaskLoadDatabase = Task.Run(() => { achievementsDatabase = new AchievementsDatabase(this, PlayniteApi, settings, this.GetPluginUserDataPath()); achievementsDatabase.Initialize(); }); // Add Event for WindowBase for get the "WindowSettings". EventManager.RegisterClassHandler(typeof(Window), Window.LoadedEvent, new RoutedEventHandler(WindowBase_LoadedEvent)); }
private async Task <GameAchievements> LoadData(IPlayniteAPI PlayniteApi, string PluginUserDataPath, SuccessStorySettings settings) { // Refresh database if (SuccessStory.isFirstLoad) { achievementsDatabase = new AchievementsDatabase(PlayniteApi, settings, this.GetPluginUserDataPath()); achievementsDatabase.Initialize(); SuccessStory.isFirstLoad = false; } GameAchievements SelectedGameAchievements = achievementsDatabase.Get(GameSelected.Id); // Download Achievements if not exist in database. if (SelectedGameAchievements == null) { logger.Info("SuccessStory - Download achievements for " + GameSelected.Name); achievementsDatabase.Add(GameSelected, settings); achievementsDatabase.Initialize(); SelectedGameAchievements = achievementsDatabase.Get(GameSelected.Id); } return(SelectedGameAchievements); }
private void Integration() { bool noAchievements = false; try { AchievementsDatabase achievementsDatabase = new AchievementsDatabase(PlayniteApi, this.GetPluginUserDataPath()); achievementsDatabase.Initialize(); GameAchievements SelectedGameAchievements = achievementsDatabase.Get(GameSelected.Id); // Download Achievements if not exist in database. if (SelectedGameAchievements == null) { logger.Info("SuccesStory - Download achievements for " + GameSelected.Name); achievementsDatabase.Add(GameSelected, settings); achievementsDatabase.Initialize(); SelectedGameAchievements = achievementsDatabase.Get(GameSelected.Id); } if (SelectedGameAchievements == null || !SelectedGameAchievements.HaveAchivements) { logger.Info("SuccessStory - No achievement for " + GameSelected.Name); if (settings.EnableIntegrationInDescription || settings.EnableIntegrationInDescriptionWithToggle) { Button PART_ScButton = (Button)LogicalTreeHelper.FindLogicalNode(PART_ActionButtons, "PART_ScButton"); // Delete old ButtonDetails if (settings.EnableIntegrationButtonDetails) { PART_ActionButtons.Children.Remove(PART_ScButton); PART_ScButton = null; } ToggleButton PART_ScToggleButton = (ToggleButton)LogicalTreeHelper.FindLogicalNode(PART_ActionButtons, "PART_ScToggleButton"); // Delete old ToggleDetails if (settings.IntegrationToggleDetails) { PART_ActionButtons.Children.Remove(PART_ScToggleButton); PART_ScToggleButton = null; } // Delete old string NameControl = "PART_Achievements"; StackPanel PART_Achievements = (StackPanel)LogicalTreeHelper.FindLogicalNode(PART_ElemDescription, NameControl); if (PART_Achievements != null) { PART_ElemDescription.Children.Remove(PART_Achievements); } } noAchievements = true; } // Auto integration if (settings.EnableIntegrationInDescription || settings.EnableIntegrationInDescriptionWithToggle) { // Search parent action buttons if (PART_ActionButtons == null) { foreach (Button bt in Tools.FindVisualChildren <Button>(Application.Current.MainWindow)) { if (bt.Name == "PART_ButtonEditGame") { PART_ActionButtons = (StackPanel)bt.Parent; break; } } } //Adding togglebutton if (settings.EnableIntegrationInDescriptionWithToggle && PART_ActionButtons != null) { ToggleButton PART_ScToggleButton = (ToggleButton)LogicalTreeHelper.FindLogicalNode(PART_ActionButtons, "PART_ScToggleButton"); // Delete old ToggleDetails if (settings.IntegrationToggleDetails) { PART_ActionButtons.Children.Remove(PART_ScToggleButton); PART_ScToggleButton = null; } if (PART_ScToggleButton == null && !noAchievements) { ToggleButton tb = new ToggleButton(); if (settings.IntegrationToggleDetails) { tb = new SuccessStoryToggleButtonDetails(SelectedGameAchievements.Unlocked, SelectedGameAchievements.Total); } else { tb.Content = resources.GetString("LOCSucessStoryAchievements"); } tb.IsChecked = false; tb.Name = "PART_ScToggleButton"; tb.Width = 150; tb.Height = 40; tb.HorizontalAlignment = HorizontalAlignment.Right; tb.VerticalAlignment = VerticalAlignment.Stretch; tb.Margin = new Thickness(10, 0, 0, 0); tb.Click += ScToggleButton_Click; PART_ActionButtons.Children.Add(tb); PART_ActionButtons.UpdateLayout(); } } // Search game description if (PART_ElemDescription == null) { foreach (StackPanel sp in Tools.FindVisualChildren <StackPanel>(Application.Current.MainWindow)) { if (sp.Name == "PART_ElemDescription") { PART_ElemDescription = sp; break; } } } // Adding control if (PART_ElemDescription != null) { // Delete old string NameControl = "PART_Achievements"; StackPanel PART_Achievements = (StackPanel)LogicalTreeHelper.FindLogicalNode(PART_ElemDescription, NameControl); if (PART_Achievements != null) { if (settings.EnableIntegrationInDescription) { PART_ElemDescription.Children.Remove(PART_Achievements); } if (settings.EnableIntegrationInDescriptionWithToggle) { PART_ElemDescription.Children.Remove(PART_Achievements); } } else { logger.Error($"SuccessStory - {NameControl} not found in Integration()"); } if (SelectedGameAchievements != null && SelectedGameAchievements.HaveAchivements) { StackPanel ScA = CreateSc(achievementsDatabase, SelectedGameAchievements, settings.IntegrationShowTitle, settings.IntegrationShowGraphic, settings.IntegrationShowAchievements, false); if (settings.EnableIntegrationInDescription) { // Add if (settings.IntegrationTopGameDetails) { PART_ElemDescription.Children.Insert(0, ScA); } else { PART_ElemDescription.Children.Add(ScA); } PART_ElemDescription.UpdateLayout(); } if (settings.EnableIntegrationInDescriptionWithToggle) { ScA.Visibility = Visibility.Collapsed; PART_ElemDescription.Children.Add(ScA); PART_ElemDescription.UpdateLayout(); } } } else { logger.Error($"SuccessStory - PART_ElemDescription not found in Integration()"); } } // Auto adding button if (settings.EnableIntegrationButton || settings.EnableIntegrationButtonDetails) { // Search parent action buttons if (PART_ActionButtons == null) { foreach (Button bt in Tools.FindVisualChildren <Button>(Application.Current.MainWindow)) { if (bt.Name == "PART_ButtonEditGame") { PART_ActionButtons = (StackPanel)bt.Parent; break; } } } // Adding button if (PART_ActionButtons != null) { Button PART_ScButton = (Button)LogicalTreeHelper.FindLogicalNode(PART_ActionButtons, "PART_ScButton"); // Delete old ButtonDetails if (settings.EnableIntegrationButtonDetails) { PART_ActionButtons.Children.Remove(PART_ScButton); PART_ScButton = null; } if (PART_ScButton == null) { Button bt = new Button(); if (settings.EnableIntegrationButton) { bt.Content = resources.GetString("LOCSucessStoryAchievements"); } if (settings.EnableIntegrationButtonDetails) { bt = new SuccessStoryButtonDetails(SelectedGameAchievements.Unlocked, SelectedGameAchievements.Total); } bt.Name = "PART_ScButton"; bt.Width = 150; bt.Height = 40; bt.HorizontalAlignment = HorizontalAlignment.Right; bt.VerticalAlignment = VerticalAlignment.Stretch; bt.Margin = new Thickness(10, 0, 0, 0); bt.Click += ScButton_Click; PART_ActionButtons.Children.Add(bt); PART_ActionButtons.UpdateLayout(); } } } // Custom theme if (settings.EnableIntegrationInCustomTheme) { // Search custom element foreach (StackPanel sp in Tools.FindVisualChildren <StackPanel>(Application.Current.MainWindow)) { if (sp.Name == "PART_Achievements_Graphics") { if (SelectedGameAchievements != null && SelectedGameAchievements.HaveAchivements) { // Create StackPanel scAG = CreateSc(achievementsDatabase, SelectedGameAchievements, false, true, false, true); // Clear & add sp.Children.Clear(); sp.Children.Add(scAG); sp.UpdateLayout(); } else { sp.Children.Clear(); sp.UpdateLayout(); } } if (sp.Name == "PART_Achievements_List") { if (SelectedGameAchievements != null && SelectedGameAchievements.HaveAchivements) { // Create StackPanel scAL = CreateSc(achievementsDatabase, SelectedGameAchievements, false, false, true, true); // Clear & add sp.Children.Clear(); sp.Children.Add(scAL); sp.UpdateLayout(); } else { sp.Children.Clear(); sp.UpdateLayout(); } } } } } catch (Exception ex) { var LineNumber = new StackTrace(ex, true).GetFrame(0).GetFileLineNumber(); string FileName = new StackTrace(ex, true).GetFrame(0).GetFileName(); logger.Error(ex, $"SuccessStory [{FileName} {LineNumber}] - Impossible integration "); } }
private void RefreshData(string SourceName, bool IsGet = false) { #if DEBUG logger.Info($"SuccessStory - RefreshData() - Start"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); #endif SuccessStorySettings.IsEnabled = false; pbDataLoad.IsIndeterminate = false; pbDataLoad.Minimum = 0; pbDataLoad.Value = 0; DataLoad.Visibility = Visibility.Visible; tcSettings.Visibility = Visibility.Hidden; tokenSource = new CancellationTokenSource(); ct = tokenSource.Token; bool IsFirstLoop = true; var taskSystem = Task.Run(() => { try { // filter games IEnumerable <Game> FilterDatabaseGame = null; switch (SourceName.ToLower()) { case "all": FilterDatabaseGame = PlayniteApi.Database.Games; break; case "allrecent": FilterDatabaseGame = PlayniteApi.Database.Games.Where( x => x.LastActivity > DateTime.Now.AddMonths(-2) || (x.Added != null && x.Added > DateTime.Now.AddMonths(-2)) ); break; case "allinstalled": FilterDatabaseGame = PlayniteApi.Database.Games.Where(x => x.IsInstalled); break; default: FilterDatabaseGame = PlayniteApi.Database.Games.Where( x => PlayniteTools.GetSourceName(x, PlayniteApi).ToLower() == SourceName.ToLower() ); break; } Application.Current.Dispatcher.BeginInvoke((Action) delegate { pbDataLoad.Maximum = FilterDatabaseGame.Count(); }); #if DEBUG logger.Debug($"SuccessStory - FilterDatabaseGame: {FilterDatabaseGame.Count()}"); #endif foreach (var game in FilterDatabaseGame) { try { if (SourceName.ToLower() == "steam" && IsFirstLoop) { #if DEBUG logger.Debug($"SuccessStory - Check Steam profil with {game.GameId}"); #endif SteamAchievements steamAPI = new SteamAchievements(PlayniteApi, settings, PluginUserDataPath); int AppId = 0; int.TryParse(game.GameId, out AppId); if (!steamAPI.CheckIsPublic(AppId)) { AchievementsDatabase.ListErrors.Add(resources.GetString("LOCSuccessStoryNotificationsSteamPrivate")); break; } IsFirstLoop = false; } // Respect API limitation Thread.Sleep(1000); if (IsGet) { // Add only it's not loaded if (!achievementsDatabase.VerifAchievementsLoad(game.Id)) { achievementsDatabase.Add(game, settings); } } else { achievementsDatabase.Remove(game); achievementsDatabase.Add(game, settings); } Application.Current.Dispatcher.BeginInvoke((Action) delegate { pbDataLoad.Value += 1; }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", $"Error on RefreshData({SourceName}, {IsGet}) for {game.Name}"); } if (ct.IsCancellationRequested) { logger.Info($"IsCancellationRequested for RefreshData({ SourceName}, { IsGet})"); break; } } achievementsDatabase.Initialize(); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", $"Error on RefreshData({SourceName}, {IsGet})"); } }, tokenSource.Token) .ContinueWith(antecedent => { Application.Current.Dispatcher.BeginInvoke((Action) delegate { DataLoad.Visibility = Visibility.Collapsed; tcSettings.Visibility = Visibility.Visible; if (!WithoutMessage) { if (AchievementsDatabase.ListErrors.Get() != string.Empty) { PlayniteApi.Dialogs.ShowErrorMessage(AchievementsDatabase.ListErrors.Get(), "SuccessStory errors"); } else { PlayniteApi.Dialogs.ShowMessage((string)ResourceProvider.GetResource("LOCSuccessStoryRefreshDataMessage"), "Success Story"); } } SetTotal(); SuccessStorySettings.IsEnabled = true; #if DEBUG stopwatch.Stop(); logger.Debug($"SuccessStory - RefreshData() - End - {stopwatch.Elapsed}"); #endif }); }); }
public SuccessView(SuccessStorySettings settings, IPlayniteAPI PlayniteApi, string PluginUserDataPath, Game GameSelected = null) { this.PlayniteApi = PlayniteApi; PlayniteApiDatabase = PlayniteApi.Database; PlayniteApiPaths = PlayniteApi.Paths; this.settings = settings; this.PluginUserDataPath = PluginUserDataPath; AchievementsDatabase = new AchievementsDatabase(PlayniteApi, settings, PluginUserDataPath); AchievementsDatabase.Initialize(); InitializeComponent(); // Block hidden column. lvProgressionValue.IsEnabled = false; lvSourceName.IsEnabled = false; pbProgressionGlobalCount.Value = AchievementsDatabase.Progession().Unlocked; pbProgressionGlobalCount.Maximum = AchievementsDatabase.Progession().Total; labelProgressionGlobalCount.Content = AchievementsDatabase.Progession().Progression + "%"; pbProgressionLaunchedCount.Value = AchievementsDatabase.ProgessionLaunched().Unlocked; pbProgressionLaunchedCount.Maximum = AchievementsDatabase.ProgessionLaunched().Total; labelProgressionLaunchedCount.Content = AchievementsDatabase.ProgessionLaunched().Progression + "%"; GetListGame(); AchievementsGraphicsDataCount GraphicsData = null; if (settings.GraphicAllUnlockedByMonth) { GraphicTitleALL.Content = resources.GetString("LOCSucessStoryGraphicTitleALL"); GraphicsData = AchievementsDatabase.GetCountByMonth(null, 7); } else { GraphicTitleALL.Content = resources.GetString("LOCSucessStoryGraphicTitleALLDay"); GraphicsData = AchievementsDatabase.GetCountByDay(); } string[] StatsGraphicsAchievementsLabels = GraphicsData.Labels; SeriesCollection StatsGraphicAchievementsSeries = new SeriesCollection(); StatsGraphicAchievementsSeries.Add(new LineSeries { Title = "", Values = GraphicsData.Series }); SuccessStory_Achievements_Graphics.Children.Clear(); SuccessStory_Achievements_Graphics.Children.Add(new SuccessStoryAchievementsGraphics(StatsGraphicAchievementsSeries, StatsGraphicsAchievementsLabels)); SuccessStory_Achievements_Graphics.UpdateLayout(); // Set game selected if (GameSelected != null) { for (int i = 0; i < ListviewGames.Items.Count; i++) { if (((ListGames)ListviewGames.Items[i]).Name == GameSelected.Name) { ListviewGames.SelectedIndex = i; } } } ListviewGames.ScrollIntoView(ListviewGames.SelectedItem); if (settings.EnableLocal) { //FilterSource.Items.Add(new { SourceName = "Playnite", IsCheck = false }); FilterSourceItems.Add(new ListSource { SourceName = "Playnite", IsCheck = false }); } if (settings.EnableSteam) { //FilterSource.Items.Add(new { SourceName = "Steam", IsCheck = false }); FilterSourceItems.Add(new ListSource { SourceName = "Steam", IsCheck = false }); } if (settings.EnableGog) { //FilterSource.Items.Add(new { SourceName = "GOG", IsCheck = false }); FilterSourceItems.Add(new ListSource { SourceName = "GOG", IsCheck = false }); } if (settings.EnableOrigin) { //FilterSource.Items.Add(new { SourceName = "Origin", IsCheck = false }); FilterSourceItems.Add(new ListSource { SourceName = "Origin", IsCheck = false }); } if (settings.EnableOrigin) { //FilterSource.Items.Add(new { SourceName = "Origin", IsCheck = false }); FilterSourceItems.Add(new ListSource { SourceName = "RetroAchievements", IsCheck = false }); } //FilterSource.UpdateLayout(); FilterSource.ItemsSource = FilterSourceItems; SetGraphicsAchievementsSources(); // Set Binding data DataContext = this; }
public SuccessView(SuccessStory plugin, SuccessStorySettings settings, IPlayniteAPI PlayniteApi, string PluginUserDataPath, bool isRetroAchievements = false, Game GameSelected = null) { this.plugin = plugin; this._PlayniteApi = PlayniteApi; _PlayniteApiDatabase = PlayniteApi.Database; _PlayniteApiPaths = PlayniteApi.Paths; this.settings = settings; this.PluginUserDataPath = PluginUserDataPath; InitializeComponent(); PART_DataLoad.Visibility = Visibility.Visible; PART_Data.Visibility = Visibility.Hidden; var TaskView = Task.Run(() => { AchievementsDb = new AchievementsDatabase(plugin, PlayniteApi, settings, PluginUserDataPath, isRetroAchievements); AchievementsDb.Initialize(false); GetListGame(); SetGraphicsAchievementsSources(); AchievementsGraphicsDataCount GraphicsData = null; if (settings.GraphicAllUnlockedByMonth) { GraphicsData = AchievementsDb.GetCountByMonth(null, 6); } else { GraphicsData = AchievementsDb.GetCountByDay(null, 5); } Application.Current.Dispatcher.BeginInvoke((Action) delegate { // Block hidden column. lvProgressionValue.IsEnabled = false; lvSourceName.IsEnabled = false; pbProgressionGlobalCount.Value = AchievementsDb.Progession().Unlocked; pbProgressionGlobalCount.Maximum = AchievementsDb.Progession().Total; labelProgressionGlobalCount.Content = AchievementsDb.Progession().Progression + "%"; pbProgressionLaunchedCount.Value = AchievementsDb.ProgessionLaunched().Unlocked; pbProgressionLaunchedCount.Maximum = AchievementsDb.ProgessionLaunched().Total; labelProgressionLaunchedCount.Content = AchievementsDb.ProgessionLaunched().Progression + "%"; GraphicTitle.Content = string.Empty; // lvGames options if (!settings.lvGamesIcon100Percent) { lvGameIcon100Percent.Width = 0; } if (!settings.lvGamesIcon) { lvGameIcon.Width = 0; } if (!settings.lvGamesName) { lvGameName.Width = 0; } if (!settings.lvGamesLastSession) { lvGameLastActivity.Width = 0; } if (!settings.lvGamesSource) { lvGamesSource.Width = 0; } if (!settings.lvGamesProgression) { lvGameProgression.Width = 0; } if (settings.GraphicAllUnlockedByMonth) { GraphicTitleALL.Content = resources.GetString("LOCSuccessStoryGraphicTitleALL"); } else { GraphicTitleALL.Content = resources.GetString("LOCSuccessStoryGraphicTitleALLDay"); } string[] StatsGraphicsAchievementsLabels = GraphicsData.Labels; SeriesCollection StatsGraphicAchievementsSeries = new SeriesCollection(); StatsGraphicAchievementsSeries.Add(new LineSeries { Title = string.Empty, Values = GraphicsData.Series }); SuccessStory_Achievements_Graphics.Children.Clear(); settings.IgnoreSettings = true; SuccessStory_Achievements_Graphics.Children.Add(new SuccessStoryAchievementsGraphics(StatsGraphicAchievementsSeries, StatsGraphicsAchievementsLabels, settings)); SuccessStory_Achievements_Graphics.UpdateLayout(); // Set game selected if (GameSelected != null) { for (int i = 0; i < ListviewGames.Items.Count; i++) { if (((ListViewGames)ListviewGames.Items[i]).Name == GameSelected.Name) { ListviewGames.SelectedIndex = i; } } } ListviewGames.ScrollIntoView(ListviewGames.SelectedItem); string icon = string.Empty; if (settings.EnableRetroAchievementsView && settings.EnableRetroAchievements) { if (isRetroAchievements) { PART_GraphicBySource.Visibility = Visibility.Collapsed; Grid.SetColumn(PART_GraphicAllUnlocked, 0); Grid.SetColumnSpan(PART_GraphicAllUnlocked, 3); if (settings.EnableRetroAchievements) { icon = TransformIcon.Get("RetroAchievements") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "RetroAchievements", SourceNameShort = "RetroAchievements", IsCheck = false }); } } else { if (settings.EnableLocal) { icon = TransformIcon.Get("Playnite") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Playnite", SourceNameShort = "Playnite", IsCheck = false }); } if (settings.EnableSteam) { icon = TransformIcon.Get("Steam") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Steam", SourceNameShort = "Steam", IsCheck = false }); } if (settings.EnableGog) { icon = TransformIcon.Get("GOG") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "GOG", SourceNameShort = "GOG", IsCheck = false }); } if (settings.EnableOrigin) { icon = TransformIcon.Get("Origin") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Origin", SourceNameShort = "Origin", IsCheck = false }); } if (settings.EnableXbox) { icon = TransformIcon.Get("Xbox") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Xbox", SourceNameShort = "Xbox", IsCheck = false }); } } } else { if (settings.EnableLocal) { icon = TransformIcon.Get("Playnite") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Playnite", SourceNameShort = "Playnite", IsCheck = false }); } if (settings.EnableSteam) { icon = TransformIcon.Get("Steam") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Steam", SourceNameShort = "Steam", IsCheck = false }); } if (settings.EnableGog) { icon = TransformIcon.Get("GOG") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "GOG", SourceNameShort = "GOG", IsCheck = false }); } if (settings.EnableOrigin) { icon = TransformIcon.Get("Origin") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Origin", SourceNameShort = "Origin", IsCheck = false }); } if (settings.EnableXbox) { icon = TransformIcon.Get("Xbox") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Xbox", SourceNameShort = "Xbox", IsCheck = false }); } if (settings.EnableRetroAchievements) { icon = TransformIcon.Get("RetroAchievements") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "RetroAchievements", SourceNameShort = "RetroAchievements", IsCheck = false }); } } FilterSource.ItemsSource = FilterSourceItems; // Set Binding data DataContext = this; PART_DataLoad.Visibility = Visibility.Hidden; PART_Data.Visibility = Visibility.Visible; }); }); }