Esempio n. 1
0
        public void CalendarDownloadComplete(DateTime start, String xml)
        {
            if (!IsSameMonth(start, current))
            {
                return;
            }
            Dictionary <DateTime, DaySchedule> dic = parseXml(xml);
            int dayZero = (int)start.DayOfWeek;

            foreach (DaySchedule ds in dic.Values)
            {
                int       day     = ds.Date.Day;
                int       x       = (day + dayZero - 1) % 7;
                int       y       = (day + dayZero) / 7 - ((day + dayZero) % 7 == 0 ? 1 : 0);
                Rectangle dayRect = new Rectangle();
                dayRect.Stroke          = CALENDAR_BRUSH;
                dayRect.Fill            = CALENDAR_FILL_BRUSH;
                dayRect.StrokeThickness = 1;
                dayRect.Width           = 24;
                dayRect.Height          = 15;
                dayRect.RadiusX         = 4;
                dayRect.RadiusY         = 4;
                Canvas.SetLeft(dayRect, 13 + x * 30);
                Canvas.SetTop(dayRect, 65 + y * 17);
                Children.Add(dayRect);
                rectangles.Add(dayRect);
                DaySchedule it = ds;
                dayRect.MouseLeftButtonUp += delegate { OpenCalendarDetailAnimation(x, y, it); };
            }
        }
Esempio n. 2
0
        public Dictionary <DateTime, DaySchedule> parseXml(String xml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            XmlNamespaceManager man = new XmlNamespaceManager(doc.NameTable);

            man.AddNamespace("atom", "http://www.w3.org/2005/Atom");
            man.AddNamespace("gd", "http://schemas.google.com/g/2005");

            Dictionary <DateTime, DaySchedule> dic = new Dictionary <DateTime, DaySchedule> ();

            foreach (XmlNode et in doc.SelectNodes("/atom:feed/atom:entry", man))
            {
                XmlNode n     = et.SelectSingleNode("atom:title[@type='text']", man);
                String  title = n != null ?  n.InnerText : "";

                String location = "";
                foreach (XmlNode w in et.SelectNodes("gd:where/@valueString", man))
                {
                    location += (location.Length > 0 ? ", " : "") + w.Value;
                }

                foreach (XmlNode w in et.SelectNodes("gd:when/@startTime", man))
                {
                    DateTime    time = DateTime.Parse(w.Value);
                    DaySchedule sched;
                    if (dic.ContainsKey(time.Date))
                    {
                        sched = dic [time.Date];
                    }
                    else
                    {
                        dic.Add(time.Date, sched = new DaySchedule(time.Date));
                    }

                    sched.Appointments.Add(new Entry(title, location, time.TimeOfDay));
                }
            }

            foreach (DaySchedule ds in dic.Values)
            {
                ds.Sort();
            }
            return(dic);
        }
Esempio n. 3
0
        public void OpenCalendarDetailAnimation(int l, int c, DaySchedule ds)
        {
            int x = (18 + l * 30) + 6;
            int y = (65 + c * 17) + 7;

            rect.Width  = 2;
            rect.Height = 2;
            Canvas.SetLeft(rect, x);
            Canvas.SetTop(rect, y);
            Children.Add(rect);

            DoubleAnimation animX = FindName("anim_x") as DoubleAnimation;
            DoubleAnimation animY = FindName("anim_y") as DoubleAnimation;
            DoubleAnimation animH = FindName("anim_h") as DoubleAnimation;
            DoubleAnimation animW = FindName("anim_w") as DoubleAnimation;

            animX.By    = -x;
            animY.By    = -y;
            animH.By    = Height - rect.Height;
            animW.By    = Width - rect.Width;
            selectedDay = ds;

            detailsStoryboard.Begin();
        }