private void LoadData(Game GameSelected)
        {
            Guid                GameId           = GameSelected.Id;
            GameAchievements    successStories   = PluginDatabase.Get(GameSelected);
            List <Achievements> ListAchievements = successStories.Items;
            List <GameStats>    ListGameStats    = successStories.ItemsStats;


            // List Achievements
            SuccessStoryAchievementsList successStoryAchievementsList = new SuccessStoryAchievementsList(true);

            successStoryAchievementsList.SetScData(successStories);
            PART_Achievements_List.Children.Add(successStoryAchievementsList);


            // Chart achievements
            int limit = 0;

            if (!PluginDatabase.PluginSettings.GraphicAllUnlockedByDay)
            {
                PART_ChartTitle.Content = resources.GetString("LOCSuccessStoryGraphicTitle");
                limit = 20;
            }
            else
            {
                PART_ChartTitle.Content = resources.GetString("LOCSuccessStoryGraphicTitleDay");
                limit = 16;
            }

            PluginDatabase.PluginSettings.IgnoreSettings = true;
            SuccessStoryAchievementsGraphics successStoryAchievementsGraphics = new SuccessStoryAchievementsGraphics();

            successStoryAchievementsGraphics.SetScData(GameId, limit);
            PART_Achievements_Graphics.Children.Add(successStoryAchievementsGraphics);


            // User stats
            SuccessStoryUserStats successStoryUserStats = new SuccessStoryUserStats();

            successStoryUserStats.SetScData(ListGameStats);
            PART_ScUserStats.Children.Add(successStoryUserStats);
        }
示例#2
0
        public override void AddCustomElements()
        {
            if (ListCustomElements.Count > 0)
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - CustomElements allready insert - {ListCustomElements.Count}");
#endif
                return;
            }

            FrameworkElement PART_ScButtonWithJustIcon        = null;
            FrameworkElement PART_ScButtonWithTitle           = null;
            FrameworkElement PART_ScButtonWithTitleAndDetails = null;

            FrameworkElement PART_Achievements_ProgressBar                 = null;
            FrameworkElement PART_Achievements_Graphics                    = null;
            FrameworkElement PART_Achievements_List                        = null;
            FrameworkElement PART_Achievements_ListComptact                = null;
            FrameworkElement PART_Achievements_ListComptactVertical        = null;
            FrameworkElement PART_Achievements_ListCompactUnlocked         = null;
            FrameworkElement PART_Achievements_ListCompactLocked           = null;
            FrameworkElement PART_Achievements_ListCompactVerticalUnlocked = null;
            FrameworkElement PART_Achievements_ListCompactVerticalLocked   = null;

            FrameworkElement PART_ScUserStats = null;
            try
            {
                PART_ScButtonWithJustIcon        = IntegrationUI.SearchElementByName("PART_ScButtonWithJustIcon", false, true);
                PART_ScButtonWithTitle           = IntegrationUI.SearchElementByName("PART_ScButtonWithTitle", false, true);
                PART_ScButtonWithTitleAndDetails = IntegrationUI.SearchElementByName("PART_ScButtonWithTitleAndDetails", false, true);

                PART_Achievements_ProgressBar                 = IntegrationUI.SearchElementByName("PART_Achievements_ProgressBar", false, true);
                PART_Achievements_Graphics                    = IntegrationUI.SearchElementByName("PART_Achievements_Graphics", false, true);
                PART_Achievements_List                        = IntegrationUI.SearchElementByName("PART_Achievements_List", false, true);
                PART_Achievements_ListComptact                = IntegrationUI.SearchElementByName("PART_Achievements_ListComptact", false, true);
                PART_Achievements_ListComptactVertical        = IntegrationUI.SearchElementByName("PART_Achievements_ListComptactVertical", false, true);
                PART_Achievements_ListCompactUnlocked         = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactUnlocked", false, true);
                PART_Achievements_ListCompactLocked           = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactLocked", false, true);
                PART_Achievements_ListCompactVerticalUnlocked = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactVerticalUnlocked", false, true);
                PART_Achievements_ListCompactVerticalLocked   = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactVerticalLocked", false, true);

                PART_ScUserStats = IntegrationUI.SearchElementByName("PART_ScUserStats", false, true);
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "SuccessStory", $"Error on find custom element");
            }

            if (PART_ScButtonWithJustIcon != null)
            {
                PART_ScButtonWithJustIcon = new SuccessStoryButton(true);
                ((Button)PART_ScButtonWithJustIcon).Click += OnBtActionBarClick;
                try
                {
                    ui.AddElementInCustomTheme(PART_ScButtonWithJustIcon, "PART_ScButtonWithJustIcon");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_ScButtonWithJustIcon", Element = PART_ScButtonWithJustIcon
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_ScButtonWithJustIcon not find");
#endif
            }

            if (PART_ScButtonWithTitle != null)
            {
                PART_ScButtonWithTitle = new SuccessStoryButton(false);
                ((Button)PART_ScButtonWithTitle).Click += OnBtActionBarClick;
                try
                {
                    ui.AddElementInCustomTheme(PART_ScButtonWithTitle, "PART_ScButtonWithTitle");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_ScButtonWithTitle", Element = PART_ScButtonWithTitle
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_ScButtonWithTitle not find");
#endif
            }

            if (PART_ScButtonWithTitleAndDetails != null)
            {
                PART_ScButtonWithTitleAndDetails = new SuccessStoryButtonDetails();
                ((Button)PART_ScButtonWithTitleAndDetails).Click += OnBtActionBarClick;
                try
                {
                    ui.AddElementInCustomTheme(PART_ScButtonWithTitleAndDetails, "PART_ScButtonWithTitleAndDetails");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_ScButtonWithTitleAndDetails", Element = PART_ScButtonWithTitleAndDetails
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_ScButtonWithTitleAndDetails not find");
#endif
            }


            if (PART_Achievements_ProgressBar != null && PluginDatabase.PluginSettings.IntegrationShowProgressBar)
            {
                PART_Achievements_ProgressBar      = new SuccessStoryAchievementsProgressBar();
                PART_Achievements_ProgressBar.Name = "Achievements_ProgressBar";
                try
                {
                    ui.AddElementInCustomTheme(PART_Achievements_ProgressBar, "PART_Achievements_ProgressBar");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_Achievements_ProgressBar", Element = PART_Achievements_ProgressBar
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ProgressBar not find");
#endif
            }

            if (PART_Achievements_Graphics != null && PluginDatabase.PluginSettings.IntegrationShowGraphic)
            {
                PART_Achievements_Graphics      = new SuccessStoryAchievementsGraphics();
                PART_Achievements_Graphics.Name = "Achievements_Graphics";
                try
                {
                    ui.AddElementInCustomTheme(PART_Achievements_Graphics, "PART_Achievements_Graphics");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_Achievements_Graphics", Element = PART_Achievements_Graphics
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_Achievements_Graphics not find");
#endif
            }

            if (PART_Achievements_ListComptact != null && PluginDatabase.PluginSettings.IntegrationShowAchievementsCompact)
            {
                PART_Achievements_ListComptact      = new ScAchievementsListCompact();
                PART_Achievements_ListComptact.Name = "Achievements_ListCompact";
                try
                {
                    ui.AddElementInCustomTheme(PART_Achievements_ListComptact, "PART_Achievements_ListComptact");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_Achievements_ListComptact", Element = PART_Achievements_ListComptact
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListComptact not find");
#endif
            }

            if (PART_Achievements_ListComptactVertical != null)// && PluginDatabase.PluginSettings.IntegrationShowAchievementsCompact)
            {
                PART_Achievements_ListComptactVertical      = new ScAchievementsListCompactVertical();
                PART_Achievements_ListComptactVertical.Name = "Achievements_ListCompactVertical";
                try
                {
                    ui.AddElementInCustomTheme(PART_Achievements_ListComptactVertical, "PART_Achievements_ListComptactVertical");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_Achievements_ListComptactVertical", Element = PART_Achievements_ListComptactVertical
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListComptactVertical not find");
#endif
            }

            if (PART_Achievements_List != null && PluginDatabase.PluginSettings.IntegrationShowAchievements)
            {
                PART_Achievements_List      = new SuccessStoryAchievementsList();
                PART_Achievements_List.Name = "Achievements_List";
                try
                {
                    ui.AddElementInCustomTheme(PART_Achievements_List, "PART_Achievements_List");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_Achievements_List", Element = PART_Achievements_List
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_Achievements_List not find");
#endif
            }

            if (PART_Achievements_ListCompactUnlocked != null && PluginDatabase.PluginSettings.IntegrationShowAchievements)
            {
                PART_Achievements_ListCompactUnlocked      = new SuccessStoryAchievementsCompact(true);
                PART_Achievements_ListCompactUnlocked.Name = "Achievements_ListCompactUnlocked";
                try
                {
                    ui.AddElementInCustomTheme(PART_Achievements_ListCompactUnlocked, "PART_Achievements_ListCompactUnlocked");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_Achievements_ListCompactUnlocked", Element = PART_Achievements_ListCompactUnlocked
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListCompactUnlocked not find");
#endif
            }

            if (PART_Achievements_ListCompactLocked != null && PluginDatabase.PluginSettings.IntegrationShowAchievements)
            {
                PART_Achievements_ListCompactLocked      = new SuccessStoryAchievementsCompact();
                PART_Achievements_ListCompactLocked.Name = "Achievements_ListCompactLocked";
                try
                {
                    ui.AddElementInCustomTheme(PART_Achievements_ListCompactLocked, "PART_Achievements_ListCompactLocked");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_Achievements_ListCompactLocked", Element = PART_Achievements_ListCompactLocked
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListCompactLocked not find");
#endif
            }

            if (PART_Achievements_ListCompactVerticalUnlocked != null)// && PluginDatabase.PluginSettings.IntegrationShowAchievements)
            {
                PART_Achievements_ListCompactVerticalUnlocked      = new SuccessStoryAchievementsCompactVertical(true);
                PART_Achievements_ListCompactVerticalUnlocked.Name = "Achievements_ListCompactVerticalUnlocked";
                try
                {
                    ui.AddElementInCustomTheme(PART_Achievements_ListCompactVerticalUnlocked, "PART_Achievements_ListCompactVerticalUnlocked");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_Achievements_ListCompactVerticalUnlocked", Element = PART_Achievements_ListCompactVerticalUnlocked
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListCompactVerticalUnlocked not find");
#endif
            }

            if (PART_Achievements_ListCompactVerticalLocked != null)// && PluginDatabase.PluginSettings.IntegrationShowAchievements)
            {
                PART_Achievements_ListCompactVerticalLocked      = new SuccessStoryAchievementsCompactVertical();
                PART_Achievements_ListCompactVerticalLocked.Name = "Achievements_ListCompactVerticalLocked";
                try
                {
                    ui.AddElementInCustomTheme(PART_Achievements_ListCompactVerticalLocked, "PART_Achievements_ListCompactVerticalLocked");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_Achievements_ListCompactVerticalLocked", Element = PART_Achievements_ListCompactVerticalLocked
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListCompactLocked not find");
#endif
            }

            if (PART_ScUserStats != null && PluginDatabase.PluginSettings.IntegrationShowUserStats)
            {
                PART_ScUserStats      = new SuccessStoryUserStats();
                PART_ScUserStats.Name = "UserStats_List";
                try
                {
                    ui.AddElementInCustomTheme(PART_ScUserStats, "PART_ScUserStats");
                    ListCustomElements.Add(new CustomElement {
                        ParentElementName = "PART_ScUserStats", Element = PART_ScUserStats
                    });
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()");
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - PART_UserStats not find");
#endif
            }
        }