Exemplo n.º 1
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="icon">Иконка.</param>
 /// <param name="engine">Движок.</param>
 public MakabaBoardInfoIcon(MakabaIconReference icon, string engine)
 {
     if (icon == null) throw new ArgumentNullException(nameof(icon));
     if (engine == null) throw new ArgumentNullException(nameof(engine));
     this.icon = icon;
     Icon = new ImageSourceViewModel(new MediaLink() { Engine = engine, IsAbsolute = false, RelativeUri = icon.Url});
     Icon.Load.Start();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="icon">Иконка.</param>
 /// <param name="engine">Движок.</param>
 public PostingIconElement(MakabaIconReference icon, string engine)
 {
     if (icon == null) throw new ArgumentNullException(nameof(icon));
     if (engine == null) throw new ArgumentNullException(nameof(engine));
     Value = icon.Number;
     Name = icon.Name;
     Image = new ImageSourceViewModel(new MediaLink() { Engine = engine, RelativeUri = icon.Url, IsAbsolute = false });
     Image.Load.Start();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="value">Значение.</param>
 /// <param name="name">Имя.</param>
 /// <param name="iconLink">Ссылка.</param>
 public PostingIconElement(int? value, string name, BoardLinkBase iconLink)
 {
     Value = value;
     Name = name;
     if (iconLink != null)
     {
         Image = new ImageSourceViewModel(iconLink);
         Image.Load.Start();
     }
 }
Exemplo n.º 4
0
 private async Task SetData()
 {
     try
     {
         var linkTransform = ServiceLocator.Current.GetServiceOrThrow<ILinkTransformService>();
         var hashService = ServiceLocator.Current.GetServiceOrThrow<ILinkHashService>();
         string newName = null;
         if (postData != null)
         {
             var boardLink = linkTransform.BoardLinkFromAnyLink(postData.Link);
             if (postData.Extensions != null)
             {
                 var nameExtension = postData.Extensions.OfType<PostTreePosterExtension>().FirstOrDefault();
                 if (nameExtension != null)
                 {
                     newName = nameExtension.Name ?? "";
                     TripCode = nameExtension.Tripcode ?? "";
                 }
             }
             if (newName == null)
             {
                 if (boardLink?.Engine != null)
                 {
                     newName = await GetDefaultName(boardLink, hashService);
                 }
             }
         }
         if (newName == null)
         {
             newName = "Аноним";
         }
         Name = newName;
         if (postData?.Extensions != null)
         {
             var flagExtension = postData.Extensions.OfType<PostTreeCountryExtension>().FirstOrDefault();
             if (flagExtension != null)
             {
                 Flag = new ImageSourceViewModel(new MediaLink() { Engine = postData?.Link?.Engine ?? "", IsAbsolute = false, RelativeUri = flagExtension.Uri });
                 if (!Flag.SetImageCache(StaticImageCache.IconsAndFlags))
                 {
                     Flag.Load.Start();
                 }
             }
             var iconExtension = postData.Extensions.OfType<PostTreeIconExtension>().FirstOrDefault();
             if (iconExtension != null)
             {
                 Icon = new ImageSourceViewModel(new MediaLink() { Engine = postData?.Link?.Engine ?? "", IsAbsolute = false, RelativeUri = iconExtension.Uri });
                 if (!Icon.SetImageCache(StaticImageCache.IconsAndFlags))
                 {
                     Icon.Load.Start();
                 }
                 IconName = iconExtension.Description ?? "";
             }
         }
     }
     catch (Exception ex)
     {
         DebugHelper.BreakOnError(ex);
     }
 }