コード例 #1
0
    private static void GameBananaAddImages(GameBananaMod file, WebDownloadablePackage package)
    {
        if (file.PreviewMedia?.Images == null)
        {
            return;
        }

        var gbImages = file.PreviewMedia.Images;

        if (gbImages.Length <= 0)
        {
            return;
        }

        var images     = new DownloadableImage[gbImages.Length];
        var imagesSpan = new SpanList <DownloadableImage>(images);
        var thumbsSpan = new DownloadableImageThumbnail[GameBananaPreviewImage.MaxThumbnailCount];

        foreach (var gbImage in gbImages)
        {
            var baseUri = new Uri($"{gbImage.BaseUrl}/", UriKind.Absolute);
            var image   = new DownloadableImage()
            {
                Uri     = new Uri(baseUri, gbImage.File),
                Caption = gbImage.Caption
            };

            var thumbs = new SpanList <DownloadableImageThumbnail>(thumbsSpan);
            if (!string.IsNullOrEmpty(gbImage.FileWidth100))
            {
                thumbs.Add(new DownloadableImageThumbnail(new Uri(baseUri, gbImage.FileWidth100), 100));
            }

            if (!string.IsNullOrEmpty(gbImage.FileWidth220))
            {
                thumbs.Add(new DownloadableImageThumbnail(new Uri(baseUri, gbImage.FileWidth220), 220));
            }

            if (!string.IsNullOrEmpty(gbImage.FileWidth530))
            {
                thumbs.Add(new DownloadableImageThumbnail(new Uri(baseUri, gbImage.FileWidth530), 530));
            }

            if (thumbs.Length > 0)
            {
                image.Thumbnails = thumbs.AsSpan.ToArray();
            }

            imagesSpan.Add(image);
        }

        package.Images = images;
    }
コード例 #2
0
 /// <summary>
 /// 解析桥跨序列
 /// </summary>
 /// <param name="splist"></param>
 public void ReadSpanList(string splist)
 {
     if (splist.StartsWith("示例:"))
     {
         splist = string.Concat(splist.Skip(3));
     }
     string[] slist = splist.Split('+');
     foreach (string s in slist)
     {
         try
         {
             SpanList.Add(double.Parse(s) * 1000.0);
         }
         catch
         {
             SpanList.Clear();
             throw new ArgumentException("桥跨序列");
         }
     }
 }