Пример #1
0
        private void PART_BtAddSteamGridDb_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SteamGridDbType steamGridDbType = SteamGridDbType.heroes;
                if (_IsCover)
                {
                    steamGridDbType = SteamGridDbType.grids;
                }

                var    ViewExtension   = new SteamGridDbView(_gameBackgroundImages.Name, steamGridDbType);
                Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PluginDatabase.PlayniteApi, "SteamGridDB", ViewExtension);
                windowExtension.ShowDialog();

                if (ViewExtension.steamGridDbResult != null)
                {
                    GlobalProgressOptions globalProgressOptions = new GlobalProgressOptions(
                        resources.GetString("LOCCommonGettingData"),
                        false
                        );
                    globalProgressOptions.IsIndeterminate = true;

                    var ProgressDownload = PluginDatabase.PlayniteApi.Dialogs.ActivateGlobalProgress((activateGlobalProgress) =>
                    {
                        try
                        {
                            var cachedFile = HttpFileCache.GetWebFile(ViewExtension.steamGridDbResult.url);
                            _backgroundImagesEdited.Add(new ItemImage
                            {
                                Name = cachedFile
                            });
                        }
                        catch (Exception ex)
                        {
                            Common.LogError(ex, false, true, "BackgroundChanger");
                        }
                    }, globalProgressOptions);


                    Task.Run(() =>
                    {
                        while (!(bool)ProgressDownload.Result)
                        {
                        }
                    }).ContinueWith(antecedant =>
                    {
                        this.Dispatcher.BeginInvoke((Action) delegate
                        {
                            PART_LbBackgroundImages.ItemsSource = null;
                            PART_LbBackgroundImages.ItemsSource = _backgroundImagesEdited;
                        });
                    });
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex, false, true, "BackgroundChanger");
            }
        }
        public SteamGridDbResultData SearchElement(int Id, SteamGridDbType steamGridDbType)
        {
            try
            {
                string Url = UrlSearchHeroes;
                if (steamGridDbType == SteamGridDbType.grids)
                {
                    Url = UrlSearchGrids;
                }

                string Response = DownloadStringData(string.Format(Url, Id)).GetAwaiter().GetResult();
                SteamGridDbResultData ResultData = Serialization.FromJson <SteamGridDbResultData>(Response);
                return(ResultData);
            }
            catch (Exception ex)
            {
                Common.LogError(ex, false, true, "BackgroundChanger");
            }

            return(null);
        }
Пример #3
0
        public SteamGridDbView(string Name, SteamGridDbType steamGridDbType)
        {
            InitializeComponent();

            this.steamGridDbType = steamGridDbType;

            SearchElement.Text = Name;
            SearchData(Name);


            if (steamGridDbType == SteamGridDbType.heroes)
            {
                // Set Dimensions
                List <CheckData> CheckDimensions = new List <CheckData>
                {
                    new CheckData {
                        Name = "Steam - 96:31 - 1920x620", Data = "1920x620"
                    },
                    new CheckData {
                        Name = "Steam - 96:31 - 3840x1240", Data = "3840x1240"
                    },

                    new CheckData {
                        Name = "Galaxy 2.0 - 32:13 - 1600x650", Data = "1600x650"
                    }
                };
                PART_ComboDimensions.ItemsSource = CheckDimensions;


                // Set Styles
                List <CheckData> CheckStyles = new List <CheckData>
                {
                    new CheckData {
                        Name = "Alternate", Data = "alternate"
                    },
                    new CheckData {
                        Name = "Material", Data = "material"
                    },
                    new CheckData {
                        Name = "Blurred", Data = "blurred"
                    }
                };
                PART_ComboStyles.ItemsSource = CheckStyles;
            }
            else
            {
                // Set Dimensions
                List <CheckData> CheckDimensions = new List <CheckData>
                {
                    new CheckData {
                        Name = "Steam Vertical - 2:3 - 600x900", Data = "600x900"
                    },

                    new CheckData {
                        Name = "Steam Horizontal - 92:43 - 920x430", Data = "920x430"
                    },
                    new CheckData {
                        Name = "Steam Horizontal - 92:43 - 460x215", Data = "460x215"
                    },

                    new CheckData {
                        Name = "Square - 1:1 - 1024x1024", Data = "1024x1024"
                    },
                    new CheckData {
                        Name = "Square - 1:1 - 512x512", Data = "512x512"
                    },

                    new CheckData {
                        Name = "Galaxy 2.0 - 22:31 - 660x930", Data = "660x930"
                    },
                    new CheckData {
                        Name = "Galaxy 2.0 - 22:31 - 342x482", Data = "342x482"
                    },
                };
                PART_ComboDimensions.ItemsSource = CheckDimensions;


                // Set Styles
                List <CheckData> CheckStyles = new List <CheckData>
                {
                    new CheckData {
                        Name = "Alternate", Data = "alternate"
                    },
                    new CheckData {
                        Name = "White Logo", Data = "white_logo"
                    },
                    new CheckData {
                        Name = "Material", Data = "material"
                    },
                    new CheckData {
                        Name = "Blurred", Data = "blurred"
                    },
                    new CheckData {
                        Name = "No Logo", Data = "no_logo"
                    }
                };
                PART_ComboStyles.ItemsSource = CheckStyles;
            }

            // Set Types
            List <CheckData> CheckTypes = new List <CheckData>
            {
                new CheckData {
                    Name = "Static", Data = "static"
                },
                new CheckData {
                    Name = "Animated", Data = "animated"
                }
            };

            PART_ComboTypes.ItemsSource = CheckTypes;

            // Set Tags
            List <CheckData> CheckTags = new List <CheckData>
            {
                new CheckData {
                    Name = "Humor", Data = "Humor"
                },
                new CheckData {
                    Name = "Adult Content", Data = "Adult Content", IsChecked = false
                },
                new CheckData {
                    Name = "Epilepsy", Data = "Epilepsy"
                },
                new CheckData {
                    Name = "Untagged", Data = "Untagged"
                }
            };

            PART_ComboTags.ItemsSource = CheckTags;


            ComboBox_SelectionChanged(PART_ComboDimensions, null);
            ComboBox_SelectionChanged(PART_ComboStyles, null);
            ComboBox_SelectionChanged(PART_ComboTags, null);
            ComboBox_SelectionChanged(PART_ComboTypes, null);
        }