Beispiel #1
0
        private void MakeScrollButton(Hottype type, CalendarDay day, Point location)
        {
            // this Hotspot is only used to restore the location of the button
            // not as a hover region
            var spot = new Hotspot
            {
                Type   = type,
                Bounds = new Rectangle(location.X, location.Y, 0, 0),
                Day    = day
            };

            var button = new MoreButton();

            button.Font       = moreFont;
            button.ForeColor  = AppColors.ControlColor;
            button.Location   = location;
            button.Text       = type == Hottype.Up ? LessGlyph : MoreGlyph;
            button.Size       = new Size(moreSize.Width + 4, moreSize.Height + 2);
            button.Tag        = spot;
            button.MouseDown += ClickScrollButton;
            Controls.Add(button);

            if (type == Hottype.Up)
            {
                day.UpButton = button;
            }
            else
            {
                day.DownButton = button;
            }
        }
Beispiel #2
0
        private void MakeDay(
            CalendarDays days, CalendarPages pages,
            DateTime date, bool modified, bool inMonth = false)
        {
            var day = new CalendarDay {
                Date = date, InMonth = inMonth
            };

            // filtering prioritizes modified over created and prevent pages from being
            // displayed twice in the month if both created and modified in the same month
            var pags = pages.Where(p =>
                                   (modified && p.Modified.Date.Equals(date)) ||
                                   (!modified && p.Created.Date.Equals(date))
                                   );

            pags.ForEach(p => day.Pages.Add(p));

            days.Add(day);
        }
Beispiel #3
0
        private void PaintDay(Graphics g, CalendarDay day)
        {
            g.FillRectangle(day.InMonth ? Brushes.White : Brushes.WhiteSmoke, day.Bounds);

            if (day.Pages.Count == 0)
            {
                return;
            }

            day.Pages.ForEach(p =>
            {
                var index = hotspots.FindIndex(h => h.Page == p);
                if (index >= 0)
                {
                    hotspots.RemoveAt(index);
                }
            });

            // content box with padding
            var box = new Rectangle(
                day.Bounds.X + 3, day.Bounds.Y + 2,
                day.Bounds.Width - 8,
                day.Bounds.Height - 8);

            for (int i = day.ScrollOffset, t = 0; i < day.Pages.Count && t < maxItems; i++, t++)
            {
                var page = day.Pages[i];

                // shrink width if showing scroller glyphs
                var width = day.Pages.Count > maxItems && i >= maxItems - 2
                                        ? box.Width - moreSize.Width
                                        : box.Width;

                // max length of string with ellipses
                var clip = new Rectangle(
                    box.Left, box.Top + (Font.Height * t),
                    width, Font.Height);

                var font = page.IsDeleted ? deletedFont : Font;
                g.DrawString(page.Title, font,
                             page.IsDeleted || !day.InMonth ? Brushes.Gray : Brushes.Black, clip, format);

                // actual length of string for hyperlink hovering
                var size = g.MeasureString(page.Title, font, clip.Width, format).ToSize();
                hotspots.Add(new Hotspot
                {
                    Type    = Hottype.Page,
                    Bounds  = new Rectangle(clip.X, clip.Y, size.Width + 2, size.Height),
                    Page    = page,
                    InMonth = day.InMonth
                });
            }

            // scroll buttons
            if (maxItems < day.Pages.Count)
            {
                if (day.UpButton == null)
                {
                    MakeScrollButton(Hottype.Up, day,
                                     new Point(box.Right - moreSize.Width - 1, box.Bottom - (moreSize.Height * 2) - 7));
                }
                else
                {
                    day.UpButton.Location =
                        new Point(box.Right - moreSize.Width - 1, box.Bottom - (moreSize.Height * 2) - 7);
                }

                if (day.DownButton == null)
                {
                    MakeScrollButton(Hottype.Down, day,
                                     new Point(box.Right - moreSize.Width - 1, box.Bottom - moreSize.Height - 4));
                }
                else
                {
                    day.DownButton.Location =
                        new Point(box.Right - moreSize.Width - 1, box.Bottom - moreSize.Height - 4);
                }
            }
            else
            {
                if (day.UpButton != null)
                {
                    day.UpButton.Dispose();
                    day.UpButton = null;
                }

                if (day.DownButton != null)
                {
                    day.DownButton.Dispose();
                    day.DownButton = null;
                }
            }
        }