Пример #1
0
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            // Define height & width
            var parent = ((FrameworkElement)((FrameworkElement)((FrameworkElement)((FrameworkElement)sender).Parent).Parent).Parent);

            if (!double.IsNaN(parent.Height))
            {
                ((FrameworkElement)sender).Height = parent.Height;
            }

            if (!double.IsNaN(parent.Width))
            {
                ((FrameworkElement)sender).Width = parent.Width;
            }

            if (settings.ProgressBarShowTime)
            {
                ((FrameworkElement)sender).Height = ((FrameworkElement)sender).Height - spShowTime.Height;
            }
            else
            {
                spShowTime.Height = 0;
            }

            if (settings.ProgressBarShowTimeAbove)
            {
                Grid.SetRow(spShowTime, 0);
                Grid.SetRow(PART_HltbProgressBar_Contener, 1);
            }
            if (settings.ProgressBarShowTimeInterior)
            {
                Grid.SetRow(spShowTime, 0);
            }


            // Definied data value in different component.
            int  ElIndicator = 0;
            long MaxValue    = 0;
            long MaxHltb     = 0;
            List <ListProgressBar> listProgressBars = new List <ListProgressBar>();

            if (gameData != null)
            {
                if (gameData.GameHltbData.MainStory != 0)
                {
                    ElIndicator += 1;
                    listProgressBars.Add(new ListProgressBar {
                        Indicator = ElIndicator, Value = gameData.GameHltbData.MainStory, Format = gameData.GameHltbData.MainStoryFormat
                    });
                    if (MaxValue < gameData.GameHltbData.MainStory)
                    {
                        MaxValue = gameData.GameHltbData.MainStory;
                    }
                }

                if (gameData.GameHltbData.MainExtra != 0)
                {
                    ElIndicator += 1;
                    listProgressBars.Add(new ListProgressBar {
                        Indicator = ElIndicator, Value = gameData.GameHltbData.MainExtra, Format = gameData.GameHltbData.MainExtraFormat
                    });
                    if (MaxValue < gameData.GameHltbData.MainExtra)
                    {
                        MaxValue = gameData.GameHltbData.MainExtra;
                    }
                }

                if (gameData.GameHltbData.Completionist != 0)
                {
                    ElIndicator += 1;
                    listProgressBars.Add(new ListProgressBar {
                        Indicator = ElIndicator, Value = gameData.GameHltbData.Completionist, Format = gameData.GameHltbData.CompletionistFormat
                    });
                    if (MaxValue < gameData.GameHltbData.Completionist)
                    {
                        MaxValue = gameData.GameHltbData.Completionist;
                    }
                }

                if (gameData.GameHltbData.Solo != 0)
                {
                    ElIndicator += 1;
                    listProgressBars.Add(new ListProgressBar {
                        Indicator = ElIndicator, Value = gameData.GameHltbData.Solo, Format = gameData.GameHltbData.SoloFormat
                    });
                    if (MaxValue < gameData.GameHltbData.Solo)
                    {
                        MaxValue = gameData.GameHltbData.Solo;
                    }
                }

                if (gameData.GameHltbData.CoOp != 0)
                {
                    ElIndicator += 1;
                    listProgressBars.Add(new ListProgressBar {
                        Indicator = ElIndicator, Value = gameData.GameHltbData.CoOp, Format = gameData.GameHltbData.CoOpFormat
                    });
                    if (MaxValue < gameData.GameHltbData.CoOp)
                    {
                        MaxValue = gameData.GameHltbData.CoOp;
                    }
                }

                if (gameData.GameHltbData.Vs != 0)
                {
                    ElIndicator += 1;
                    listProgressBars.Add(new ListProgressBar {
                        Indicator = ElIndicator, Value = gameData.GameHltbData.Vs, Format = gameData.GameHltbData.VsFormat
                    });
                    if (MaxValue < gameData.GameHltbData.Vs)
                    {
                        MaxValue = gameData.GameHltbData.Vs;
                    }
                }
            }

            // Define the maxvalue for progressbar & slider
            MaxHltb = MaxValue;
            if (Playtime > MaxValue)
            {
                MaxValue = Playtime;
            }

            // Adjust position tracker
            if (Playtime > 69)
            {
                SliderPlaytime.Margin = new Thickness(-8, 0, -3, 0);
            }

            // Limit MaxValue when playtime is more than MaxHltb
            long MaxPercent = (long)Math.Ceiling((double)(10 * MaxHltb / 100));

            if (MaxValue > MaxHltb + MaxPercent)
            {
                MaxValue = MaxHltb + MaxPercent;
            }


            // Add data
            ProgressHltb_El1.Maximum = MaxValue;
            ProgressHltb_El2.Maximum = MaxValue;
            ProgressHltb_El3.Maximum = MaxValue;

            SliderPlaytime.Value   = Playtime;
            SliderPlaytime.Maximum = MaxValue;

            foreach (var listProgressBar in listProgressBars)
            {
                SetDataInView(listProgressBar.Indicator, listProgressBar.Value, listProgressBar.Format);
            }


            SliderPlaytime.UpdateLayout();
        }
Пример #2
0
        private void LoadData()
        {
            try
            {
                // Definied data value in different component.
                int  ElIndicator = 0;
                long MaxValue    = 0;
                long MaxHltb     = 0;
                List <ListProgressBar> listProgressBars = new List <ListProgressBar>();
                if (_gameHowLongToBeat.HasData)
                {
                    var HltbData = _gameHowLongToBeat.GetData();

                    if (HltbData.GameHltbData.MainStory != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = HltbData.GameHltbData.MainStory, Format = HltbData.GameHltbData.MainStoryFormat
                        });
                        if (MaxValue < HltbData.GameHltbData.MainStory)
                        {
                            MaxValue = HltbData.GameHltbData.MainStory;
                        }
                        SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorFirst);
                    }

                    if (HltbData.GameHltbData.MainExtra != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = HltbData.GameHltbData.MainExtra, Format = HltbData.GameHltbData.MainExtraFormat
                        });
                        if (MaxValue < HltbData.GameHltbData.MainExtra)
                        {
                            MaxValue = HltbData.GameHltbData.MainExtra;
                        }
                        SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorSecond);
                    }

                    if (HltbData.GameHltbData.Completionist != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = HltbData.GameHltbData.Completionist, Format = HltbData.GameHltbData.CompletionistFormat
                        });
                        if (MaxValue < HltbData.GameHltbData.Completionist)
                        {
                            MaxValue = HltbData.GameHltbData.Completionist;
                        }
                        SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorThird);
                    }

                    if (HltbData.GameHltbData.Solo != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = HltbData.GameHltbData.Solo, Format = HltbData.GameHltbData.SoloFormat
                        });
                        if (MaxValue < HltbData.GameHltbData.Solo)
                        {
                            MaxValue = HltbData.GameHltbData.Solo;
                        }
                        SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorFirstMulti);
                    }

                    if (HltbData.GameHltbData.CoOp != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = HltbData.GameHltbData.CoOp, Format = HltbData.GameHltbData.CoOpFormat
                        });
                        if (MaxValue < HltbData.GameHltbData.CoOp)
                        {
                            MaxValue = HltbData.GameHltbData.CoOp;
                        }
                        SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorSecondMulti);
                    }

                    if (HltbData.GameHltbData.Vs != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = HltbData.GameHltbData.Vs, Format = HltbData.GameHltbData.VsFormat
                        });
                        if (MaxValue < HltbData.GameHltbData.Vs)
                        {
                            MaxValue = HltbData.GameHltbData.Vs;
                        }
                        SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorThirdMulti);
                    }
                }

                // Define the maxvalue for progressbar & slider
                MaxHltb = MaxValue;
                if (_Playtime > MaxValue)
                {
                    MaxValue = _Playtime;
                }

                // Adjust position tracker
                if (_Playtime > 69)
                {
                    SliderPlaytime.Margin = new Thickness(-8, 0, -3, 0);
                }

                // Limit MaxValue when playtime is more than MaxHltb
                long MaxPercent = (long)Math.Ceiling((double)(10 * MaxHltb / 100));
                if (MaxValue > MaxHltb + MaxPercent)
                {
                    MaxValue = MaxHltb + MaxPercent;
                }


                // Add data
                ProgressHltb_El1.Maximum = MaxValue;
                ProgressHltb_El2.Maximum = MaxValue;
                ProgressHltb_El3.Maximum = MaxValue;

                SliderPlaytime.Value   = _Playtime;
                SliderPlaytime.Maximum = MaxValue;

#if DEBUG
                logger.Debug($"HowLongToBeat [Ignored] - listProgressBars: {JsonConvert.SerializeObject(listProgressBars)}");
#endif

                ProgressHltb_El1.Visibility = Visibility.Hidden;
                spHltb_El1.Visibility       = Visibility.Hidden;
                spHltbTime_El1.Visibility   = Visibility.Hidden;

                ProgressHltb_El2.Visibility = Visibility.Hidden;
                spHltb_El2.Visibility       = Visibility.Hidden;
                spHltbTime_El2.Visibility   = Visibility.Hidden;

                ProgressHltb_El3.Visibility = Visibility.Hidden;
                spHltb_El3.Visibility       = Visibility.Hidden;
                spHltbTime_El3.Visibility   = Visibility.Hidden;

                foreach (var listProgressBar in listProgressBars)
                {
                    SetDataInView(listProgressBar.Indicator, listProgressBar.Value, listProgressBar.Format);
                }


                SliderPlaytime.UpdateLayout();



                // Show user hltb datas
                PartSliderFirst.Maximum     = MaxValue;
                PartSliderFirst.Visibility  = Visibility.Hidden;
                PartSliderSecond.Maximum    = MaxValue;
                PartSliderSecond.Visibility = Visibility.Hidden;
                PartSliderThird.Maximum     = MaxValue;
                PartSliderThird.Visibility  = Visibility.Hidden;

                if (_gameHowLongToBeat.HasData && PluginDatabase.PluginSettings.ProgressBarShowTimeUser)
                {
                    TitleList titleList = PluginDatabase.GetUserHltbData(_gameHowLongToBeat.GetData().Id);
#if DEBUG
                    logger.Debug($"HowLongToBeat [Ignored] - titleList: {JsonConvert.SerializeObject(titleList)}");
#endif
                    if (titleList != null)
                    {
                        ElIndicator = 0;

                        if (titleList.HltbUserData.MainStory != 0)
                        {
                            ElIndicator++;
                            SetUserData(ElIndicator, titleList.HltbUserData.MainStory, PluginDatabase.PluginSettings.ColorFirst);
                        }

                        if (titleList.HltbUserData.MainExtra != 0)
                        {
                            ElIndicator++;
                            SetUserData(ElIndicator, titleList.HltbUserData.MainExtra, PluginDatabase.PluginSettings.ColorSecond);
                        }

                        if (titleList.HltbUserData.Completionist != 0)
                        {
                            ElIndicator++;
                            SetUserData(ElIndicator, titleList.HltbUserData.Completionist, PluginDatabase.PluginSettings.ColorThird);
                        }

                        if (titleList.HltbUserData.Solo != 0)
                        {
                            ElIndicator++;
                            SetUserData(ElIndicator, titleList.HltbUserData.Solo, PluginDatabase.PluginSettings.ColorFirstMulti);
                        }

                        if (titleList.HltbUserData.CoOp != 0)
                        {
                            ElIndicator++;
                            SetUserData(ElIndicator, titleList.HltbUserData.CoOp, PluginDatabase.PluginSettings.ColorSecondMulti);
                        }

                        if (titleList.HltbUserData.Vs != 0)
                        {
                            ElIndicator++;
                            SetUserData(ElIndicator, titleList.HltbUserData.Vs, PluginDatabase.PluginSettings.ColorThirdMulti);
                        }

                        this.DataContext = new
                        {
                            ThumbFirst  = solidColorBrushFirst,
                            ThumbSecond = solidColorBrushSecond,
                            ThumbThird  = solidColorBrushThird,

                            ThumbPoint = ThumbPoint
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "HowLongToBeat", "Error on LoadData()");
            }
        }
        private void LoadData()
        {
            try
            {
                if (_gameData == null || !_gameData.hasData || _gameData.isEmpty)
                {
                    return;
                }

                if (_settings.ProgressBarShowTime && !_settings.ProgressBarShowTimeInterior)
                {
                    PART_HltbProgressBar_Contener.Height = PART_HltbProgressBar_Contener.Height - spShowTime.Height;
#if DEBUG
                    logger.Debug($"HowLongToBeat - ProgressBarShowTime & !ProgressBarShowTimeInterior -  Height: {PART_HltbProgressBar_Contener.Height} - Width: {PART_HltbProgressBar_Contener.Width}");
#endif
                }
                else
                {
                    spShowTime.Height = 0;
                }

                if (_settings.ProgressBarShowTimeAbove)
                {
                    Grid.SetRow(spShowTime, 0);
                    Grid.SetRow(PART_HltbProgressBar_Contener, 1);
                }
                if (_settings.ProgressBarShowTimeInterior)
                {
                    Grid.SetRow(spShowTime, 0);
                    spShowTime.Height = PART_HltbProgressBar_Contener.Height;
                }

                // Definied data value in different component.
                int  ElIndicator = 0;
                long MaxValue    = 0;
                long MaxHltb     = 0;
                List <ListProgressBar> listProgressBars = new List <ListProgressBar>();
                if (_gameData != null)
                {
                    if (_gameData.GetData().GameHltbData.MainStory != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = _gameData.GetData().GameHltbData.MainStory, Format = _gameData.GetData().GameHltbData.MainStoryFormat
                        });
                        if (MaxValue < _gameData.GetData().GameHltbData.MainStory)
                        {
                            MaxValue = _gameData.GetData().GameHltbData.MainStory;
                        }
                    }

                    if (_gameData.GetData().GameHltbData.MainExtra != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = _gameData.GetData().GameHltbData.MainExtra, Format = _gameData.GetData().GameHltbData.MainExtraFormat
                        });
                        if (MaxValue < _gameData.GetData().GameHltbData.MainExtra)
                        {
                            MaxValue = _gameData.GetData().GameHltbData.MainExtra;
                        }
                    }

                    if (_gameData.GetData().GameHltbData.Completionist != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = _gameData.GetData().GameHltbData.Completionist, Format = _gameData.GetData().GameHltbData.CompletionistFormat
                        });
                        if (MaxValue < _gameData.GetData().GameHltbData.Completionist)
                        {
                            MaxValue = _gameData.GetData().GameHltbData.Completionist;
                        }
                    }

                    if (_gameData.GetData().GameHltbData.Solo != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = _gameData.GetData().GameHltbData.Solo, Format = _gameData.GetData().GameHltbData.SoloFormat
                        });
                        if (MaxValue < _gameData.GetData().GameHltbData.Solo)
                        {
                            MaxValue = _gameData.GetData().GameHltbData.Solo;
                        }
                    }

                    if (_gameData.GetData().GameHltbData.CoOp != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = _gameData.GetData().GameHltbData.CoOp, Format = _gameData.GetData().GameHltbData.CoOpFormat
                        });
                        if (MaxValue < _gameData.GetData().GameHltbData.CoOp)
                        {
                            MaxValue = _gameData.GetData().GameHltbData.CoOp;
                        }
                    }

                    if (_gameData.GetData().GameHltbData.Vs != 0)
                    {
                        ElIndicator += 1;
                        listProgressBars.Add(new ListProgressBar {
                            Indicator = ElIndicator, Value = _gameData.GetData().GameHltbData.Vs, Format = _gameData.GetData().GameHltbData.VsFormat
                        });
                        if (MaxValue < _gameData.GetData().GameHltbData.Vs)
                        {
                            MaxValue = _gameData.GetData().GameHltbData.Vs;
                        }
                    }
                }

                // Define the maxvalue for progressbar & slider
                MaxHltb = MaxValue;
                if (_Playtime > MaxValue)
                {
                    MaxValue = _Playtime;
                }

                // Adjust position tracker
                if (_Playtime > 69)
                {
                    SliderPlaytime.Margin = new Thickness(-8, 0, -3, 0);
                }

                // Limit MaxValue when playtime is more than MaxHltb
                long MaxPercent = (long)Math.Ceiling((double)(10 * MaxHltb / 100));
                if (MaxValue > MaxHltb + MaxPercent)
                {
                    MaxValue = MaxHltb + MaxPercent;
                }


                // Add data
                ProgressHltb_El1.Maximum = MaxValue;
                ProgressHltb_El2.Maximum = MaxValue;
                ProgressHltb_El3.Maximum = MaxValue;

                SliderPlaytime.Value   = _Playtime;
                SliderPlaytime.Maximum = MaxValue;

#if DEBUG
                logger.Debug($"HowLongToBeat - listProgressBars: {JsonConvert.SerializeObject(listProgressBars)}");
#endif

                ProgressHltb_El1.Visibility = Visibility.Hidden;
                spHltb_El1.Visibility       = Visibility.Hidden;
                spHltbTime_El1.Visibility   = Visibility.Hidden;

                ProgressHltb_El2.Visibility = Visibility.Hidden;
                spHltb_El2.Visibility       = Visibility.Hidden;
                spHltbTime_El2.Visibility   = Visibility.Hidden;

                ProgressHltb_El3.Visibility = Visibility.Hidden;
                spHltb_El3.Visibility       = Visibility.Hidden;
                spHltbTime_El3.Visibility   = Visibility.Hidden;

                foreach (var listProgressBar in listProgressBars)
                {
                    SetDataInView(listProgressBar.Indicator, listProgressBar.Value, listProgressBar.Format);
                }


                SliderPlaytime.UpdateLayout();
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "HowLongToBeat", "Error on LoadData()");
            }
        }