コード例 #1
0
ファイル: DayScheduler.xaml.cs プロジェクト: hightouch67/Adam
        private void PaintAllDayEvents()
        {
            if (_scheduler == null || _scheduler.Events == null)
            {
                return;
            }

            allDayEvents.Children.Clear();

            double columnWidth = EventsGrid.ColumnDefinitions[1].Width.Value;



            foreach (Event e in TodayEvents.Where(ev => ev.End.Date > ev.Start.Date || ev.AllDay))
            {
                EventUserControl wEvent = new EventUserControl(e, false);
                wEvent.Width             = columnWidth;
                wEvent.Margin            = new Thickness(0, 0, 0, 0);
                wEvent.MouseDoubleClick += ((object sender, MouseButtonEventArgs ea) =>
                {
                    ea.Handled = true;
                    OnEventDoubleClick(sender, wEvent.Event);
                });
                allDayEvents.Children.Add(wEvent);
            }
        }
コード例 #2
0
        private void PaintAllDayEvents()
        {
            try
            {
                if (_scheduler == null || _scheduler.Events == null)
                {
                    return;
                }

                allDayEvents.Children.Clear();

                double columnWidth = EventsGrid.ColumnDefinitions[1].Width.Value;

                foreach (Event e in _scheduler.Events.Where(ev => ev.End.Date > ev.Start.Date || ev.AllDay))
                {
                    int numColumn    = (int)e.Start.Date.Subtract(FirstDay.Date).TotalDays;
                    int numEndColumn = (int)e.End.Date.Subtract(FirstDay.Date).TotalDays + 1;

                    if (numColumn >= 7 || numEndColumn <= 0)
                    {
                        continue;
                    }

                    if (numColumn < 0)
                    {
                        numColumn = 0;
                    }
                    if (numEndColumn > 7)
                    {
                        numEndColumn = 7;
                    }

                    if ((numColumn >= 0 && numColumn < 7) || (numEndColumn >= 0 && numEndColumn < 7))
                    {
                        double marginLeft = (numColumn) * columnWidth;

                        EventUserControl wEvent = new EventUserControl(e, false);
                        wEvent.Width             = columnWidth * (numEndColumn - numColumn);
                        wEvent.Margin            = new Thickness(marginLeft, 0, 0, 0);
                        wEvent.MouseDoubleClick += ((object sender, MouseButtonEventArgs ea) =>
                        {
                            ea.Handled = true;
                            OnEventDoubleClick(sender, wEvent.Event);
                        });
                        allDayEvents.Children.Add(wEvent);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #3
0
        private void PaintAllEvents()
        {
            if (_scheduler == null || _scheduler.Events == null)
            {
                return;
            }

            IEnumerable <Event> eventList = TodayEvents.Where(ev => ev.Start.Date == ev.End.Date && !ev.AllDay).OrderBy(ev => ev.Start);

            column.Children.Clear();

            double columnWidth = EventsGrid.ColumnDefinitions[1].Width.Value;

            foreach (Event e in eventList)
            {
                //column.Width = columnWidth;

                double oneHourHeight = 50;// column.ActualHeight / 46;

                var concurrentEvents = TodayEvents.Where(e1 => ((e1.Start <= e.Start && e1.End > e.Start) ||
                                                                (e1.Start > e.Start && e1.Start < e.End)) &&
                                                         e1.End.Date == e1.Start.Date).OrderBy(ev => ev.Start);

                double marginTop  = oneHourHeight * (e.Start.Hour + (e.Start.Minute / 60.0));
                double width      = columnWidth / (concurrentEvents.Count());
                double marginLeft = width * getIndex(e, concurrentEvents.ToList());

                EventUserControl wEvent = new EventUserControl(e, true);
                wEvent.Width             = width;
                wEvent.Height            = e.End.Subtract(e.Start).TotalHours *oneHourHeight;
                wEvent.Margin            = new Thickness(marginLeft, marginTop, 0, 0);
                wEvent.MouseDoubleClick += ((object sender, MouseButtonEventArgs ea) =>
                {
                    ea.Handled = true;
                    OnEventDoubleClick(sender, wEvent.Event);
                });

                column.Children.Add(wEvent);
            }
        }
コード例 #4
0
        private void PaintAllEvents(DateTime? date)
        {
            try
            {
                if (_scheduler == null || _scheduler.Events == null) return;

                IEnumerable<Event> eventList = _scheduler.Events.Where(ev => ev.Start.Date == ev.End.Date && !ev.AllDay).OrderBy(ev => ev.Start);

                //Modification par Plinio (psi) pour supprimer events
                if (date == null   
                        || (int)date.Value.Date.Subtract(FirstDay.Date).TotalDays > 6
                        || (int)date.Value.Date.Subtract(FirstDay.Date).TotalDays < 0) 
                {
                    column1.Children.Clear();
                    column2.Children.Clear();
                    column3.Children.Clear();
                    column4.Children.Clear();
                    column5.Children.Clear();
                    column6.Children.Clear();
                    column7.Children.Clear();
                }
                else
                {
                    int numColumn = (int)date.Value.Date.Subtract(FirstDay.Date).TotalDays + 1;
                    ((Canvas)this.FindName("column" + numColumn)).Children.Clear();

                    eventList = eventList.Where(ev => ev.Start.Date == date.Value.Date).OrderBy(ev => ev.Start);
                }

                double columnWidth = EventsGrid.ColumnDefinitions[1].Width.Value;

                foreach (Event e in eventList)
                {
                    int numColumn = (int)e.Start.Date.Subtract(FirstDay.Date).TotalDays + 1;
                    if (numColumn >= 1 && numColumn <= 7) // Modif Plinio (psi) if (numColumn >= 0 && numColumn < 7)
                    {
                        Canvas sp = (Canvas)this.FindName("column" + numColumn);
                        sp.Width = columnWidth;

                        double oneHourHeight = sp.ActualHeight / 22;

                        var concurrentEvents = _scheduler.Events.Where(e1 => ((e1.Start <= e.Start && e1.End > e.Start) ||
                                                                        (e1.Start > e.Start && e1.Start < e.End)) &&
                                                                       e1.End.Date == e1.Start.Date).OrderBy(ev => ev.Start);

                        double marginTop = oneHourHeight * (e.Start.Hour + (e.Start.Minute / 60.0));
                        double width = columnWidth / (concurrentEvents.Count());
                        double marginLeft = width * getIndex(e, concurrentEvents.ToList());

                        EventUserControl wEvent = new EventUserControl(e, true);
                        wEvent.Width = width;
                        wEvent.Height = e.End.Subtract(e.Start).TotalHours * oneHourHeight;
                        wEvent.Margin = new Thickness(marginLeft, marginTop, 0, 0);
                        wEvent.MouseDoubleClick += ((object sender, MouseButtonEventArgs ea) =>
                        {
                            ea.Handled = true;
                            OnEventDoubleClick(sender, wEvent.Event);
                        });

                        sp.Children.Add(wEvent);
                    }
                }
            }
            catch (Exception)
            {                
                throw;
            }
        }
コード例 #5
0
        private void SelectEvent(EventUserControl sender)
        {
            _eventSelected = sender.Event.Id;

            foreach (EventUserControl ev in column.Children)
            {
                ev.BorderElement.BorderThickness = new Thickness(1.0);
            }

            sender.BorderElement.BorderThickness = new Thickness(_selectedEventBorderThickness);
        }
コード例 #6
0
        private void PaintAllEvents()
        {
            int eventsCount = 0;

            if (_scheduler != null && _scheduler.Events != null)
            {

                IEnumerable<Event> eventList = TodayEvents
                                                .Where(ev => ev.EventInfo.StartEvent.Date == ev.EventInfo.EndEvent.Date)
                                                .OrderBy(ev => ev.EventInfo.IsCanceled)
                                                .ThenBy(ev => ev.EventInfo.StartEvent);

                column.Children.Clear();

                double columnWidth = EventsGrid.ColumnDefinitions[1].Width.Value;

                foreach (Event e in eventList)
                {
                    List<Event> concurrentEvents = new List<Event>();
                    GetConcurrentEvents(e, concurrentEvents);
                    concurrentEvents = concurrentEvents
                                        .OrderBy(ev => ev.EventInfo.StartEvent)
                                        .ThenBy(ev => ev.EventInfo.EndEvent)
                                        .ToList();

                    double marginTop = _oneHourHeight * ((e.EventInfo.StartEvent.Hour + (e.EventInfo.StartEvent.Minute / 60.0)) - _minHour);
                    double width = columnWidth / (concurrentEvents.Count());
                    double marginLeft = width * concurrentEvents.ToList().FindIndex(ev => ev.Id == e.Id);

                    EventUserControl wEvent = new EventUserControl(e);
                    wEvent.Width = width;
                    wEvent.Height = e.EventInfo.EndEvent.Subtract(e.EventInfo.StartEvent).TotalHours * _oneHourHeight;
                    wEvent.Margin = new Thickness(marginLeft, marginTop, 0, 0);
                    wEvent.BorderElement.BorderThickness = new Thickness(_eventSelected == e.Id ? _selectedEventBorderThickness : 1.0);

                    wEvent.MouseLeftButtonDown += ((object sender, MouseButtonEventArgs ea) =>
                    {
                        ea.Handled = true;

                        SelectEvent(sender as EventUserControl);

                        OnEventMouseLeftButtonDown(sender, wEvent.Event);
                    });

                    wEvent.MouseRightButtonDown += ((object sender, MouseButtonEventArgs ea) =>
                    {
                        SelectEvent(sender as EventUserControl);

                        ContextMenu cm = this.FindResource("SchedulerContextMenu") as ContextMenu;

                        if (UserLoggedIn.IsAdmin == false)
                        {
                            foreach (var item in cm.Items)
                            {
                                if (item is MenuItem && (item as MenuItem).Tag.ToString() == "VIEW_EVENT_STATUS_CHANGES")
                                {
                                    cm.Items.Remove(item as MenuItem);
                                    break;
                                }
                            }
                        }

                        cm.Tag = e;
                        cm.IsOpen = (e.EventInfo.IsCanceled == false && e.EventInfo.IsCompleted == false) || UserLoggedIn.IsAdmin;
                    });

                    column.Children.Add(wEvent);
                    eventsCount++;
                }
            }

            dayLabel.Content = _currentDay.ToString("D") + " (Citas: " + eventsCount + ")";
        }
コード例 #7
0
ファイル: DayScheduler.xaml.cs プロジェクト: hightouch67/Adam
        private void PaintAllEvents()
        {
            if (_scheduler == null || _scheduler.Events == null)
            {
                return;
            }

            IEnumerable <Event> eventList = TodayEvents.Where(ev => ev.Start.Date == ev.End.Date && !ev.AllDay).OrderBy(ev => ev.Start);

            column.Children.Clear();
            //ADD CURRENT HOUR MARKER AND SCROLL TO IT
            double bdcolumnWidth = EventsGrid.ColumnDefinitions[1].Width.Value;

            column2.Children.Clear();
            Border bd = new Border();

            bd.BorderThickness = new Thickness(2, 2, 2, 2);
            bd.BorderBrush     = new SolidColorBrush(Colors.Red);
            double bdmargintop = 100 * DateTime.Now.Hour;

            bd.Margin = new Thickness(0, bdmargintop, 0, 0);
            bd.Height = 100;
            bd.Width  = bdcolumnWidth;
            bd.HorizontalAlignment = HorizontalAlignment.Stretch;
            column2.Children.Add(bd);
            ScrollEventsViewer.ScrollToVerticalOffset(bdmargintop - 100);

            double columnWidth = EventsGrid.ColumnDefinitions[1].Width.Value;


            foreach (Event e in eventList)
            {
                //column.Width = columnWidth;

                double oneHourHeight = 100;// column.ActualHeight / 46;

                var concurrentEvents = TodayEvents.Where(e1 => ((e1.Start <= e.Start && e1.End > e.Start) ||
                                                                (e1.Start > e.Start && e1.Start < e.End)) &&
                                                         e1.End.Date == e1.Start.Date).OrderBy(ev => ev.Start);

                double marginTop = oneHourHeight * (e.Start.Hour + (e.Start.Minute / 60.0));
                double width     = (columnWidth) / (concurrentEvents.Count()) * 0.82;
                //double marginLeft = width * getIndex(e, concurrentEvents.ToList());

                double marginLeft = width * getIndex(e, concurrentEvents.ToList());


                EventUserControl wEvent = new EventUserControl(e, true);
                //if (width != 0)
                //{
                //    wEvent.Width = width ;
                //    double marginLeft = width * getIndex(e, concurrentEvents.ToList());
                //    wEvent.Margin = new Thickness(marginLeft, marginTop, 0, 0);

                //}
                //else
                //{
                //    wEvent.Width = width;
                //    double marginLeft = width * getIndex(e, concurrentEvents.ToList());
                //    wEvent.Margin = new Thickness(marginLeft, marginTop, 0, 0);

                //}
                wEvent.Width = width;

                wEvent.Margin = new Thickness(marginLeft, marginTop, 0, 0);

                wEvent.Height            = e.End.Subtract(e.Start).TotalHours *oneHourHeight;
                wEvent.MouseDoubleClick += ((object sender, MouseButtonEventArgs ea) =>
                {
                    ea.Handled = true;
                    OnEventDoubleClick(sender, wEvent.Event);
                });

                column.Children.Add(wEvent);
            }
        }