コード例 #1
0
ファイル: Calendar.cs プロジェクト: NiDaSilva/PPE4-STARS-UP
        /// <summary>
        /// Creates a new <see cref="Calendar"/> control
        /// </summary>
        public Calendar()
        {
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.Selectable, true);

            DoubleBuffered = true;

            _selectedElements = new List<CalendarSelectableElement>();
            _items = new CalendarItemCollection(this);
            _renderer = new CalendarProfessionalRenderer(this);
            _maximumFullDays = 8;
            _maximumViewDays = 35;

            HighlightRanges = new CalendarHighlightRange[] {
                new CalendarHighlightRange( DayOfWeek.Monday, new TimeSpan(8,0,0), new TimeSpan(17,0,0)),
                new CalendarHighlightRange( DayOfWeek.Tuesday, new TimeSpan(8,0,0), new TimeSpan(17,0,0)),
                new CalendarHighlightRange( DayOfWeek.Wednesday, new TimeSpan(8,0,0), new TimeSpan(17,0,0)),
                new CalendarHighlightRange( DayOfWeek.Thursday, new TimeSpan(8,0,0), new TimeSpan(17,0,0)),
                new CalendarHighlightRange( DayOfWeek.Friday, new TimeSpan(8,0,0), new TimeSpan(17,0,0)),
            };

            _timeScale = CalendarTimeScale.ThirtyMinutes;
            SetViewRange(DateTime.Now, DateTime.Now.AddDays(2));

            _itemsDateFormat = "dd/MMM";
            _itemsTimeFormat = "hh:mm tt";
            _allowItemEdit = true;
            _allowNew = true;
            _allowItemResize = true;
        }
コード例 #2
0
            public EventsResult(ElmcityController controller, CalendarRenderer cr, string id, string type, string view, string jsonp, string count, string from, string to, string eventsonly, string mobile, string test, string raw, string raw_sentinel, string style, string theme, string taglist, string tags, string template, string jsurl, string days, string bare_events, string hub, string source, string first)
            {
                this.controller      = controller;
                this.cr              = cr;
                this.cr.cache        = new ElmcityUtils.AspNetCache(controller.HttpContext.Cache);
                this.id              = id;
                this.type            = type;
                this.view            = view;
                this.jsonp           = jsonp;
                this.from            = from == null ? DateTime.MinValue : Utils.DateTimeFromISO8601DateStr(from, DateTimeKind.Local);
                this.to              = from == null ? DateTime.MinValue : Utils.DateTimeFromISO8601DateStr(to, DateTimeKind.Local);
                this.eventsonly      = String.IsNullOrEmpty(eventsonly) ? false : eventsonly.ToLower().StartsWith("y");
                this.mobile_declared = String.IsNullOrEmpty(mobile) ? false : mobile.ToLower().StartsWith("y");
                this.mobile_refused  = String.IsNullOrEmpty(mobile) ? false : mobile.ToLower().StartsWith("n");
                this.test            = String.IsNullOrEmpty(test) ? false : test.ToLower().StartsWith("y");
                this.raw             = String.IsNullOrEmpty(raw) ? false : raw.ToLower().StartsWith("y");
                this.raw_sentinel    = raw_sentinel;
                this.style           = style;
                this.theme           = theme;
                this.taglist         = String.IsNullOrEmpty(taglist) ? true : taglist.ToLower().StartsWith("y");
                this.tags            = String.IsNullOrEmpty(tags) ? false : tags.ToLower().StartsWith("y");
                this.template        = template;
                this.jsurl           = jsurl;
                this.bare_events     = String.IsNullOrEmpty(bare_events) ? false : bare_events.ToLower().StartsWith("y");
                this.hub             = hub;
                this.source          = source;

                try
                {
                    if (!String.IsNullOrEmpty(first))
                    {
                        this.first = Convert.ToInt32(first);
                    }
                    else
                    {
                        this.first = 0;
                    }
                }
                catch (Exception e)
                {
                    GenUtils.LogMsg("warning", "EventsResult: cannot convert first " + first, e.Message);
                }

                int _count = 0;

                try
                {
                    if ((type == "html") && (count != "0"))
                    {
                        _count = Convert.ToInt32(settings["max_html_events_default"]);
                    }
                    if (this.bare_events)
                    {
                        _count = 0;
                    }
                }
                catch (Exception e)
                {
                    GenUtils.PriorityLogMsg("exception", "EventsResult", e.Message);
                }

                this.count = (count == null) ? _count : Convert.ToInt32(count);

                if (!String.IsNullOrEmpty(days))
                {
                    try
                    {
                        this.days = Convert.ToInt32(days);
                        if (this.days > 0)
                        {
                            var calinfo = ElmcityApp.wrd.renderers[this.id].calinfo;
                            var from_to = Utils.ConvertDaysIntoFromTo(this.days, calinfo);
                            this.from = (DateTime)from_to["from_date"];
                            this.to   = (DateTime)from_to["to_date"];
                        }
                    }
                    catch (Exception e)
                    {
                        GenUtils.LogMsg("GetEvents", "days", e.Message);
                        this.days = 0;
                    }
                }
            }
コード例 #3
0
 public CalendarRendererTest()
 {
     this.cr       = new CalendarRenderer(Configurator.testid);
     this.cr.cache = new MockCache();
 }
コード例 #4
0
ファイル: Calendar.cs プロジェクト: jcdotnet/TrainingSchedule
        public Calendar()
        {
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            //this.DoubleBuffered = true;

            _items.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
                {
                    if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                    {
                        if (_isAddingNote) return;
                        _isAdding = true;

                        foreach (TrainingItem item in e.NewItems)
                            item.DatesChanged += new TrainingItem.ItemEventHandler(item_DatesChanged);

                        if (_isReAdding)
                        {
                            _isAdding = false;
                            _isReAdding = false;
                        }
                    }
                    else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
                    {
                        if (_isRemovingPermanently) { _isRemovingPermanently = false; return; }
                        if (!CheckDates())
                        {
                            _isReAdding = true;
                            _items.Add((TrainingItem)e.OldItems[0]);
                        }

                    }
                    InitializeMonths();
                });

            _calendarStart = DateTime.Now;

            _backgrounds = Color.FromArgb(196, 218, 250);
            _activeBackgrounds = Color.FromArgb(160, 192, 245);

            _selectedButton = -1;
            _renderer = new CalendarRenderer();

            _selectionButtons = new Area[4];

            _selectionStart = _selectionEnd = DateTime.Today;

            MonthCalendar.DaySize = new Size(27, 19);
            MonthCalendar.Size = new Size(27 * 7, 19 * 7);

            UpdateSelection();

            InitializeMonths();
        }