Пример #1
0
 /// <summary>
 /// Permet d'insérer un event dans un calendrier
 /// </summary>
 /// <param name="evt">L'event qu'on doit insérer.</param>
 public async Task<Event> InsertEvent(Event evt)
 {
     if (!String.IsNullOrEmpty(Calendar.Id))
     {
         StreamContent eventJson = new StreamContent(Service.Serialize(evt));
         eventJson.Headers.Add("Content-Type", "application/json;charset=utf-8");
         Task<string> test = eventJson.ReadAsStringAsync();
         Stream result = await Service.Post("https://www.googleapis.com/calendar/v3/calendars/" + Calendar.Id + "/events", eventJson);
         if (result != null)
         {
             DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(Event));
             Event evtret = (Event)deserializer.ReadObject(result);
             mEvents.Add(evtret);
             return evtret;
         }
     }
     return null;
 }
Пример #2
0
 /// <summary>
 /// Permet de mettre à jour un event.
 /// </summary>
 /// <param name="evt">Le event avec les modifications à appliquer.</param>
 public async Task<Event> UpdateEvent(Event evt)
 {
     if (!String.IsNullOrEmpty(Calendar.Id) && !String.IsNullOrEmpty(evt.Id))
     {
         StreamContent eventJson = new StreamContent(Service.Serialize(evt));
         eventJson.Headers.Add("Content-Type", "application/json;charset=utf-8");
         Stream result = await Service.Put("https://www.googleapis.com/calendar/v3/calendars/" + Calendar.Id + "/events/" + evt.Id, eventJson);
         if (result != null)
         {
             DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(Event));
             Event evtret = (Event)deserializer.ReadObject(result);
             mEvents.Remove(mEvents.Single(e => e.Id == evt.Id));
             mEvents.Add(evtret);
             return evtret;
         }
     }
     return null;
 }
Пример #3
0
 /// <summary>
 /// Permet de supprimer un event 
 /// </summary>
 /// <param name="evt">L'event à supprimer</param>
 public async void DeleteEvent(Event evt)
 {
     if (!String.IsNullOrEmpty(Calendar.Id) && !String.IsNullOrEmpty(evt.Id))
     {
         Stream result = await Service.Delete("https://www.googleapis.com/calendar/v3/calendars/" + Calendar.Id + "/events/" + evt.Id);
         if (result != null)
         {
             //mEvents.Remove(mEvents.Single(e => evt.Id == e.Id));
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Update the begin cell to make a selection.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void canvas_PointerPressed(object sender, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e)
        {
            beginCell = (Canvas)sender;
            beginCell.Background = new SolidColorBrush(new Color() { A = 100, R = 70, B = 180, G = 130 });
            lastColored = beginCell;
            int beginPos = (Grid.GetColumn(beginCell) - 1) * 24 + (Grid.GetRow(beginCell) - 1);
            DateTime begin;
            DateTime end;

            int row = Grid.GetRow(beginCell);
            if (row == 24) row = 23;
            DateTime date = Date;
            //  begin = Date.AddDays(Grid.GetColumn(beginCell) - 1).AddHours(Grid.GetRow(beginCell));
            // begin= Date.AddDays(Grid.GetColumn(beginCell) - 1);

            Debug.WriteLine(Grid.GetRow(beginCell));

            begin = Date.AddMinutes(-(Date.Minute)).AddSeconds(-(Date.Second)).AddHours(-(Date.Hour) + row);
            begin.AddHours(Grid.GetRow(beginCell));

            //end = Date.AddDays(Grid.GetColumn(beginCell) - 1).AddHours(Grid.GetRow(beginCell)+1);
            end = Date.AddMinutes(-(Date.Minute)).AddSeconds(-(Date.Second)).AddHours(-(Date.Hour) + row + 1);
            end.AddHours(Grid.GetRow(beginCell));

            GoogleCalendar.Data.Event events = new GoogleCalendar.Data.Event();
            events.Location = "";
            events.Description = "";
            events.Summary = "";
            events.Start = new EventDateTime() { DateTime = begin.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ssK") };
            events.End = new EventDateTime() { DateTime = end.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ssK") };


            DayEvent we = new DayEvent(events);

            AddEvent evtDetail = new AddEvent(we.Evt, Controler, this);
            pop = new Popup()
            {
                Child = evtDetail,
                VerticalOffset = (Window.Current.Bounds.Height - 394) / 2,
                HorizontalOffset = (Window.Current.Bounds.Width - 596) / 2,
                Visibility = Windows.UI.Xaml.Visibility.Visible,
                IsLightDismissEnabled = true,
                IsOpen = true
            };


        }