public void CreateEvent(object sender, EventArgs e)
        {
            if (EntryTitle.Text == "")
            {
                EntryTitle.Focus();
                return;
            }
            else if (EntryDesc.Text == "")
            {
                EntryDesc.Focus();
                return;
            }

            DateTime dateAndTime = new DateTime(CalendarDate.Date.Year, CalendarDate.Date.Month, CalendarDate.Date.Day,
                                                CalendarTime.Time.Hours, CalendarTime.Time.Minutes, 0);

            Random random          = new Random(DateTime.Now.Millisecond);
            CalendarInlineEvent ev = new CalendarInlineEvent()
            {
                StartTime = dateAndTime,
                EndTime   = dateAndTime.AddSeconds(1),
                Subject   = EntryTitle.Text,
                Color     = Globals.calendarColors[(int)Math.Round(random.NextDouble() * Globals.calendarColors.Length)]
            };

            PlanBase.GetInstance().Add(new Plan(EntryTitle.Text, EntryDesc.Text, dateAndTime, (string)PriorityPicker.SelectedItem, ev));
            CalendarEvents.GetInstance().Add(ev);
            tabbedPage.CurrentPage = tabbedPage.Children[0];
        }
Exemple #2
0
        public void OnStart()
        {
            plans.Clear();
            string file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "plans.txt");

            if (File.Exists(file))
            {
                string[] _plans = File.ReadAllLines(file);
                foreach (string plan in _plans)
                {
                    Debug.WriteLine(plan);
                    string[] sepArray = new string[] { separator };
                    string[] split    = plan.Split(sepArray, 5, StringSplitOptions.None);

                    if (split.Length < 4)
                    {
                        continue;
                    }

                    Random random          = new Random(DateTime.Now.Millisecond);
                    CalendarInlineEvent ev = new CalendarInlineEvent()
                    {
                        StartTime = DateTime.ParseExact(split[2], "MM/dd/yyyy HH:mm tt", new CultureInfo("en-US")),
                        EndTime   = DateTime.ParseExact(split[2], "MM/dd/yyyy HH:mm tt", new CultureInfo("en-US")).AddSeconds(1),
                        Subject   = split[0],
                        Color     = Globals.calendarColors[(int)Math.Round(random.NextDouble() * Globals.calendarColors.Length)]
                    };
                    plans.Add(new Plan(split[0], split[1], DateTime.ParseExact(split[2], "MM/dd/yyyy HH:mm tt", new CultureInfo("en-US")), split[3], ev));
                    CalendarEvents.GetInstance().Add(ev);
                }
            }
            Sort();
        }
 public static CalendarEvents GetInstance()
 {
     if (instance == null)
     {
         instance = new CalendarEvents();
     }
     return(instance);
 }
 public Calendar()
 {
     InitializeComponent();
     calendar.BindingContext = CalendarEvents.GetInstance();
 }
 public void Destroy()
 {
     CalendarEvents.GetInstance().CalendarInlineEvents.Remove(hook);
 }