Ejemplo n.º 1
0
 private void comic_update(object sender, EventArgs e, Comic comic, ComicSource source)
 {
     currentcomic = new CurrentComicInfo(comic, source);
     date.ResetBindings();
     date.Checked = true;
     //i keep getting argumentoutofrangeexceptions. lets try this
     date.MaxDate = DateTimePicker.MaximumDateTime;
     date.MinDate = DateTimePicker.MinimumDateTime;
     //reset mindate and maxdate values then set it again
     date.MaxDate     = source.getMaxDate(comic);
     date.MinDate     = source.getMinDate(comic);
     date.Value       = date.Value;
     statuscomic.Text = String.Format("({0}) {1}", currentcomic.source.name, currentcomic.comic.name);
     strip_update(null, null);
 }
Ejemplo n.º 2
0
    // never heard of this approach
    // this is interesting
    // https://stackoverflow.com/questions/194863/random-date-in-c-sharp

    private void strip_rando(object sender, EventArgs e)
    {
        try
        {
            ComicSource comsrc = currentcomic.source;
            Comic       com    = currentcomic.comic;
            int         r      = (comsrc.getMaxDate(com) - comsrc.getMinDate(com)).Days;
            DateTime    rd     = comsrc.getMinDate(com).AddDays(new Random().Next(r));
            if (currentcomic.comic.weekinfo.dayofweek is int butt)
            {
                date.Value = rd.AddDays(7 - ((int)rd.DayOfWeek - butt % 7));
            }
            else
            {
                date.Value = rd;
            }
        }
        catch (ArgumentOutOfRangeException suck)
        {
            //Out of range? reroll again
            strip_rando(sender, e);
            //we dun care if argumentoutofrangeexception
        }
    }