コード例 #1
0
        private void PopulateCollections(ObservableCollection <object> datetime)
        {
            //Populate Date
            int noofdays = DateTime.DaysInMonth(DateTime.Now.Date.Year, DateTime.Now.Date.Month);

            for (int i = 1; i <= noofdays; i++)
            {
                string date = string.Empty;
                if (i != DateTime.Now.Date.Day)
                {
                    DayOfWeek name = new DateTime(DateTime.Now.Date.Year, DateTime.Now.Date.Month, i).DayOfWeek;

                    date  = name.ToString().Substring(0, 3) + " ";
                    date += CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Date.Month).Substring(0, 3) + " ";

                    if (i < 10)
                    {
                        date += "0" + i.ToString();
                    }
                    else
                    {
                        date += i.ToString();
                    }
                }
                else
                {
                    date = "Today";
                }
                //Populate Day with Month
                Date.Add(date);
            }

            //Populate Hour
            for (int i = 1; i <= 12; i++)
            {
                Hour.Add(i.ToString());
            }
            //Populate Minute
            for (int j = 0; j < 60; j++)
            {
                if (j < 10)
                {
                    Minute.Add("0" + j);
                }
                else
                {
                    Minute.Add(j.ToString());
                }
            }

            //Populate Format
            Format.Add("AM");
            Format.Add("PM");

            Datetime.Add(Date);
            Datetime.Add(Hour);
            Datetime.Add(Minute);
            Datetime.Add(Format);
        }
コード例 #2
0
    void initDay()
    {
        Datetime baseTime = new Datetime(8, 0, 0);//8 o'clock

        for (int a = 0; a < 8; a++)
        {
            Appointments.Add(new Appointment(new Datetime(H, M, 0), new Timespan(1, 0, 0)));
            baseTime.Add(new timespan(0, 15, 0));   //Add 15 minutes
        }
        //Now you have a list of appointents where you can ask for all openings
        //of all appointments by simply asking
        var UnFilled = Appointments.Where(a => !a.isFilled());
        var Filled   = Appointments.Where(a => a.isFilled());
    }