ShowMessage() public static method

public static ShowMessage ( string message, MessageType type ) : void
message string
type MessageType
return void
示例#1
0
        public static async Task AddGamesFromImages(string[] files)
        {
            var list = new List <string>();
            var i    = 0;

            while (i < files.Length)
            {
                try {
                    var cleanSerial = await new SerialFinder().ExtractSerial(files[i]);
                    var text        = GameDatabase
                                      .FirstOrDefault(g =>
                                                      g
                                                      .Trim()
                                                      .Split('\n')[0]
                                                      .Trim() == cleanSerial.Trim() ||
                                                      g
                                                      .Trim()
                                                      .Split('\n')[0]
                                                      .Replace("-", "")
                                                      .Trim() == cleanSerial.Trim()
                                                      );
                    if (text.IsEmpty())
                    {
                        list.Add(files[i].FileNameNoExt());
                        goto IL_358;
                    }
                    var array  = text.Trim().Split('\n');
                    var serial = array[0].Trim();
                    var title  = array[1].Trim();
                    var region = array[2].Trim();
                    var num    = 0;
                    var text2  = array.FirstOrDefault(s => s.Contains("Compat"));
                    if (!string.IsNullOrWhiteSpace(text2))
                    {
                        num = (int.TryParse(text2.Replace("Compat = ", ""), out num) ? num : 0);
                    }
                    var g2 = new Game {
                        Serial          = serial,
                        Title           = title,
                        Region          = region,
                        Compatibility   = num,
                        Location        = files[i],
                        MetacriticScore = "n/a",
                        Publisher       = "n/a",
                        ReleaseDate     = "n/a",
                        Description     = "n/a*",
                        ImagePath       = ""
                    };
                    AddToLibrary(g2);
                }
                catch {
                    list.Add(files[i].FileNameNoExt());
                }
                goto IL_31D;
IL_358:
                i++;
                continue;
IL_31D:
                if (list.Count > 0)
                {
                    var arg = string.Join("\n", list);
                    Tools.ShowMessage(string.Format("There was an error adding the following games to the library\n{0}", arg), MessageType.Error);
                }
                list.Clear();
                goto IL_358;
            }
        }
示例#2
0
        public static async Task <List <string> > FetchScreenshots(Game g)
        {
            var           list   = new List <string>();
            var           search = g.Title.CleanFileName().Replace(" ", "+");
            List <string> result;

            try {
                var num = 0;
                if (Directory.Exists(Path.Combine(UserSettings.ScreensDir, g.FileSafeTitle)))
                {
                    var array = Directory.GetFiles(Path.Combine(UserSettings.ScreensDir, g.FileSafeTitle)).ToArray();
                    if (array.Length > 0)
                    {
                        var array2 = array;
                        foreach (var item in array2)
                        {
                            list.Add(item);
                            num++;
                        }
                    }
                    if (array.Length == 6)
                    {
                        result = list;
                        return(result);
                    }
                }
                await Task.Run(() => _doc = Web.Load(string.Format("https://www.google.com/search?q={0}+ign", search)));

                Console.WriteLine(search);
                var htmlNode = (
                    from n in _doc.DocumentNode.SelectNodes("//h3[@class='r']//a")
                    where n.Attributes["href"].Value.Contains("www.ign.com/games/") &&
                    GameData.Consoles.Any(n.Attributes["href"].Value.Contains) &&
                    n.Attributes["href"].Value.Contains("xbox-360") == false
                    select n
                    ).FirstOrDefault <HtmlNode>();
                if (htmlNode == null)
                {
                    throw new Exception("Source node cannot be null");
                }
                var num2     = 0;
                var loadPage = htmlNode.Attributes["href"].Value.Between("/url?q=", "&amp").Replace("/games/", "/images/games/").Replace("/ps2", "-ps2").Replace("/xbox", "-xbox").Replace("/gcn", "-gcn");
                Console.WriteLine(loadPage);
                await Task.Run(() => _doc = Web.Load(loadPage));

                foreach (var current in _doc.DocumentNode.SelectNodes("//a[@class='imageGalleryThumbLink']//img"))
                {
                    if (num2 < num)
                    {
                        num2++;
                    }
                    else
                    {
                        var value = current.Attributes["src"].Value;
                        var item2 = value.Replace("160w", "640w");
                        if (num2 >= 6)
                        {
                            break;
                        }
                        list.Add(item2);
                        num2++;
                    }
                }
            }
            catch {
                Tools.ShowMessage("Error loading screenshots", MessageType.Error);
            }
            result = list;
            return(result);
        }