Пример #1
0
        private void add_Click(object sender, EventArgs e)
        {
            Dictionary <int, List <Event> >            mEvents = new Dictionary <int, List <Event> >();
            SaveXML <Dictionary <int, List <Event> > > saver   = new SaveXML <Dictionary <int, List <Event> > >();

            if (File.Exists(Form1.eventFileName))
            {
                mEvents = saver.GetData(mEvents, Form1.eventFileName);
            }

            List <Event> eventslist = new List <Event>();

            if (mEvents.ContainsKey(selectedDate.Text.ToString().GetHashCode()))
            {
                eventslist = mEvents[selectedDate.Text.ToString().GetHashCode()];
            }

            eventslist.Add(new Event(eventTitle.Text, eventLocation.Text, hourTxt.Text + ":" + minuteTxt.Text + " " + am_pm.Text, selectedDate.Text));

            mEvents.Remove(selectedDate.Text.ToString().GetHashCode());

            mEvents.Add(selectedDate.Text.ToString().GetHashCode(), eventslist);

            saver.SaveData(mEvents, Form1.eventFileName);
        }
Пример #2
0
 /**
  *  加载数据
  */
 public void LoadEventData(string data_file)
 {
     mEventFile = data_file;
     if (File.Exists(data_file))
     {
         SaveXML <Dictionary <int, List <Event> > > saver = new SaveXML <Dictionary <int, List <Event> > >();
         mEvents = saver.GetData(mEvents, mEventFile);
     }
 }
Пример #3
0
        /**
         * 保存数据
         */
        public void SaveEventData()
        {
            SaveXML <Dictionary <int, List <Event> > > saver = new SaveXML <Dictionary <int, List <Event> > >();

            saver.SaveData(mEvents, mEventFile);
        }
Пример #4
0
        private void createGrid(int addMonth)
        {
            if (File.Exists(eventFileName))
            {
                SaveXML <Dictionary <int, List <Event> > > saver = new SaveXML <Dictionary <int, List <Event> > >();
                mEvents = saver.GetData(mEvents, eventFileName);
            }

            gridView.Controls.Clear();


            String[] months =
            {
                "su",
                "mo",
                "tu",
                "we",
                "th",
                "fr",
                "sa"
            };

            for (int i = 0; i < 7; i++)
            {
                CalndarGridItem item = new CalndarGridItem();
                item.setText(months[i]);
                item.setTextColor(Color.FromArgb(50, 63, 86));
                gridView.Controls.Add(item);
            }

            DateTime temp;

            DateTime today = DateTime.Today;

            if (addMonth != 0)
            {
                today = today.AddMonths(addMonth);
            }

            DateTime nextMonth = today.AddMonths(1);

            DateTime prevMonth = today.AddMonths(-1);


            temp = new DateTime(today.Year, today.Month, 1);


            int dayOfWeek = (int)temp.DayOfWeek;

            int dayOfPrevMonth = System.DateTime.DaysInMonth(prevMonth.Year, prevMonth.Month);

            for (int i = dayOfWeek - 1; i >= 0; i--)
            {
                CalndarGridItem item = new CalndarGridItem();
                item.setText((dayOfPrevMonth - i) + "");
                item.setTextColor(Color.FromArgb(50, 63, 86));
                gridView.Controls.Add(item);
            }


            int daysOfCurrentMonth = System.DateTime.DaysInMonth(today.Year, today.Month);


            for (int i = 1; i <= daysOfCurrentMonth; i++)
            {
                CalndarGridItem item = new CalndarGridItem();
                item.setText(i + "");

                if (addMonth == 0 && i == (int)DateTime.Today.Day)
                {
                    item.makeToDay();
                }

                item.setDateTime(today);

                item.getTextView().Cursor = Cursors.Hand;

                item.setOnGridItemClickListener(new EventHandler(onGridItemClickListener));

                String key = i + " " + today.ToString("MMMM").Substring(0, 3) + " " + today.Year;

                if (mEvents.ContainsKey(key.GetHashCode()))
                {
                    if (addMonth <= 0 && i < TODAY.Day)
                    {
                        item.hadNote();
                    }
                    else
                    {
                        item.hasNote();
                    }
                }

                gridView.Controls.Add(item);
            }

            int daysOfNextMonth = dayOfWeek - 1 + daysOfCurrentMonth;

            for (int i = 1; i < 35 - daysOfNextMonth; i++)
            {
                CalndarGridItem item = new CalndarGridItem();
                item.setText(i + "");
                item.setTextColor(Color.FromArgb(50, 63, 86));
                gridView.Controls.Add(item);
            }

            currentMonth.Text = today.ToString("MMMM");
            currentYear.Text  = today.Year + "";
        }