예제 #1
0
 public static Embed ToEmbed(this ITitleInfo info)
 {
     if (info is IAnimeTitleInfo iam)
     {
         return(iam.ToEmbed());
     }
     return((info as IMangaTitleInfo)?.ToEmbed());
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="ChartPanel" />
 /// class.
 /// </summary>
 /// <param name="chartdata">The chartdata.</param>
 /// <param name="title">The title.</param>
 public ChartPanel(ISeriesModel chartdata, ITitleInfo title)
     : this()
 {
     ChartData     = chartdata;
     Configuration = ChartData.GetSeriesConfiguration();
     SourceModel   = ChartData.GetSourceModel();
     TitleInfo     = title;
     DataMetric    = ChartData.GetSeriesMetric();
     DataSeries    = new DataSeries(ChartData);
     Series.Add(DataSeries);
     Titles.Add(TitleInfo.GetChartMainTitle());
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="ChartPanel" />
 /// class.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="title">The title.</param>
 public ChartPanel(ISourceModel model, ITitleInfo title)
     : this()
 {
     SourceModel   = model;
     Configuration = SourceModel.GetSeriesConfiguration();
     TitleInfo     = title;
     DataMetric    = SourceModel.GetMetric();
     ChartData     = new SeriesModel(SourceModel.GetSourceBinding());
     DataSeries    = new DataSeries(ChartData);
     Series.Add(DataSeries);
     Titles.Add(TitleInfo.GetChartMainTitle());
 }
예제 #4
0
        public static EmbedFooterBuilder GetFooter(this ITitleInfo info)
        {
            string start  = "";
            string finish = "";
            var    def    = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).ToLocalTime();

            if (info.FinishDate.IsSpecified)
            {
                finish = info.FinishDate.Date == def.Date ? "" : $" - {info.FinishDate.Date.ToShortDateString()}";
            }

            if (info.StartDate.IsSpecified)
            {
                start = info.StartDate.Date.ToShortDateString();
            }

            return(new EmbedFooterBuilder()
            {
                Text = $"{start}{finish}",
            });
        }
예제 #5
0
        public static List <EmbedFieldBuilder> GetFields(this ITitleInfo info)
        {
            var fields = new List <EmbedFieldBuilder>();

            if (info.AlternativeTitles.Count > 0)
            {
                fields.Add(new EmbedFieldBuilder()
                {
                    Name     = "Tytuły alternatywne",
                    Value    = string.Join(", ", info.AlternativeTitles).TrimToLength(EmbedFieldBuilder.MaxFieldValueLength),
                    IsInline = false
                });
            }

            foreach (var tagType in info.TagCategories)
            {
                fields.Add(new EmbedFieldBuilder()
                {
                    Name     = tagType.Name.TrimToLength(EmbedFieldBuilder.MaxFieldNameLength),
                    Value    = string.Join(", ", tagType.Tags).TrimToLength(EmbedFieldBuilder.MaxFieldValueLength),
                    IsInline = false
                });
            }

            fields.Add(new EmbedFieldBuilder()
            {
                Name     = "Id",
                Value    = info.Id,
                IsInline = true
            });

            if (info.TotalRating.HasValue)
            {
                if (info.TotalRating > 0)
                {
                    fields.Add(new EmbedFieldBuilder()
                    {
                        Name     = "Ocena ogólna",
                        Value    = info.TotalRating.Value.ToString("0.0"),
                        IsInline = true
                    });
                }
            }

            string typeVal = "--";
            string statVal = "--";

            if (info is IAnimeTitleInfo aif)
            {
                typeVal = aif.Type.ToName();
                statVal = aif.Status.ToName();

                if (aif.EpisodesCount.HasValue)
                {
                    if (aif.EpisodesCount > 0)
                    {
                        fields.Add(new EmbedFieldBuilder()
                        {
                            Name     = "Epizody",
                            Value    = aif.EpisodesCount,
                            IsInline = true
                        });
                    }
                }
            }
            else if (info is IMangaTitleInfo mif)
            {
                typeVal = mif.Type.ToName();
                statVal = mif.Status.ToName();

                if (mif.ChaptersCount.HasValue)
                {
                    if (mif.ChaptersCount > 0)
                    {
                        fields.Add(new EmbedFieldBuilder()
                        {
                            Name     = "Rozdziały",
                            Value    = mif.ChaptersCount,
                            IsInline = true
                        });
                    }
                }
            }

            fields.Add(new EmbedFieldBuilder()
            {
                Name     = "Typ",
                Value    = typeVal,
                IsInline = true
            });

            fields.Add(new EmbedFieldBuilder()
            {
                Name     = "Status",
                Value    = statVal,
                IsInline = true
            });

            return(fields);
        }