public void UpdateAppearance(CalendarCellStyle cell)
        {
            WorkDaysCollection workDays = this.dateNavigator.SchedulerControl.WorkDays;

            if (workDays.IsHoliday(cell.Date))
            {
                switch (cell.State)
                {
                // Highlight dates hovered over with the mouse.
                case (DevExpress.Utils.Drawing.ObjectState.Hot):
                    cell.Appearance.ForeColor = Color.DarkGoldenrod;
                    cell.Appearance.BackColor = Color.PaleGreen;
                    break;

                // Highlight selection.
                case (DevExpress.Utils.Drawing.ObjectState.Selected):
                    cell.Appearance.ForeColor = Color.Gold;
                    cell.Appearance.BackColor = Color.Green;
                    break;

                default:
                    cell.Appearance.ForeColor = Color.Green;
                    cell.Appearance.BackColor = Color.Gold;
                    break;
                }
            }
            // Display an image for the dates which contains appointments.
            if (cell.IsSpecial)
            {
                cell.Appearance.Font = new Font(cell.Appearance.Font, FontStyle.Regular);
                cell.Image           = Image.FromFile("appointment_icon.png");
            }
        }
Exemple #2
0
        void ICalendarCellStyleProvider.UpdateAppearance(CalendarCellStyle cell)
        {
            MyCustomCellData cellInfo = GetCell(cell.Date);

            if (cellInfo == null)
            {
                return;
            }

            cell.Description = cellInfo.Description;
            if (cell.Description != null)
            {
                cell.DescriptionAppearance      = (AppearanceObject)cell.Appearance.Clone();
                cell.DescriptionAppearance.Font = new Font(cell.Appearance.Font.FontFamily, 7.0f, FontStyle.Bold);
                cell.DescriptionAppearance.TextOptions.WordWrap = WordWrap.Wrap;
            }
            if (!cellInfo.ForeColor.IsEmpty)
            {
                cell.Appearance.ForeColor = cellInfo.ForeColor;
            }
            if (!cellInfo.BackColor.IsEmpty)
            {
                cell.Appearance.BackColor = cellInfo.BackColor;
            }
            if (cellInfo.SpecialDate)
            {
                cell.Appearance.Font = new Font(cell.Appearance.Font.FontFamily, 7.0f, FontStyle.Bold);
            }
        }
Exemple #3
0
        public void UpdateAppearance(CalendarCellStyle cell)
        {
            string holidayText;

            if (Holidays.IsHoliday(cell.Date, out holidayText))
            {
                cell.Appearance.ForeColor = Color.Yellow;
                cell.Appearance.Font      = new Font(cell.Appearance.Font, FontStyle.Bold);
                //cell.Appearance.BackColor = cell.Active ? Color.HotPink : Color.LightPink;
                cell.Appearance.BackColor = Color.Red;
            }
        }
        private CalendarCellStyle createBloodyCellStyle() {
            CalendarCellStyle c = new CalendarCellStyle();
            c.DecorationStyle = new Style(typeof(Border));
            c.ContentStyle = new Style(typeof(TextBlock));

            ImageBrush background = new ImageBrush();
            background.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/blood-drop-icon.png"));
            c.DecorationStyle.Setters.Add(new Setter(Border.BackgroundProperty, background));

            c.ContentStyle.Setters.Add(new Setter(TextBlock.FontSizeProperty, 35));
            c.ContentStyle.Setters.Add(new Setter(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center));
            c.ContentStyle.Setters.Add(new Setter(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center));
            return c;
        }
Exemple #5
0
 public void UpdateAppearance(CalendarCellStyle cell)
 {
     if (cell.Date.Day % 2 == 0)
     {
         cell.Appearance.Font = new Font(cell.Appearance.Font, FontStyle.Bold);
     }
     else
     {
         if (cell.Active)
         {
             cell.Appearance.BackColor = Color.HotPink;
         }
         else
         {
             cell.Appearance.BackColor = Color.LightPink;
         }
     }
 }
        public DangerDayCellStyle(string color, int thickness) {
            cellStyle = new CalendarCellStyle();
            Style blackOutDecoration = new Style(typeof(Border));
            Style blackOutContent = new Style(typeof(TextBlock));

            char[] delimiter = { ',' };
            byte[] rgbColor = color.Split(delimiter).Select(e=> Byte.Parse(e)).ToArray();
            Color red = Color.FromArgb(255, rgbColor[0], rgbColor[1], rgbColor[2]);

            blackOutDecoration.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(red)));
            blackOutDecoration.Setters.Add(new Setter(Border.CornerRadiusProperty, new CornerRadius(60)));
            blackOutDecoration.Setters.Add(new Setter(Border.BorderThicknessProperty, new Thickness(thickness)));
            cellStyle.DecorationStyle = blackOutDecoration;

            blackOutContent.Setters.Add(new Setter(TextBlock.FontSizeProperty, 35));
            blackOutContent.Setters.Add(new Setter(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center));
            blackOutContent.Setters.Add(new Setter(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center));
            cellStyle.ContentStyle = blackOutContent;
        }
Exemple #7
0
        public void UpdateAppearance(CalendarCellStyle cell)
        {
            string holidayText;

            if (Holidays.IsHoliday(cell.Date, out holidayText))
            {
                cell.Appearance.ForeColor = Color.Yellow;
                if (font == null)
                {
                    font = new Font(cell.Appearance.Font, FontStyle.Bold);
                }
                cell.Appearance.Font = font;
                if (cell.Active)
                {
                    cell.Appearance.BackColor = Color.HotPink;
                }
                else
                {
                    cell.Appearance.BackColor = Color.LightPink;
                }
            }
        }
        // >> calendar-features-cellstyling-evaluatecellstyle
        private CalendarCellStyle EvaluateCellStyle(CalendarCell cell)
        {
            Color     background = default(Color);
            Color     selectedCellForegroundColor = default(Color);
            Color     todayBorderColor            = Color.FromRgb(115, 174, 239);
            double    dayNamesFontSize            = default(double);
            double    fontSize             = default(double);
            Thickness todayBorderThickness = default(Thickness);

            switch (Device.RuntimePlatform)
            {
            case "iOS":
                background = Color.White;
                selectedCellForegroundColor = Color.White;
                fontSize             = 14;
                dayNamesFontSize     = 14;
                todayBorderThickness = new Thickness(2);
                break;

            case "Android":
                background = Color.White;
                selectedCellForegroundColor = Color.FromRgb(139, 209, 0);
                fontSize             = 15;
                dayNamesFontSize     = 15;
                todayBorderThickness = new Thickness(1);
                break;

            case "UWP":
                background = Color.FromRgb(30, 30, 30);
                selectedCellForegroundColor = Color.White;
                fontSize             = 17;
                dayNamesFontSize     = 17;
                todayBorderThickness = new Thickness(2);
                break;
            }

            if (cell.Type == CalendarCellType.DayName)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.LightGray,
                    FontSize = dayNamesFontSize,
                    FontAttributes = FontAttributes.Bold,
                    TextColor = Color.FromRgb(0, 122, 255)
                });
            }

            var defaultStyle = new CalendarCellStyle
            {
                BackgroundColor = background,
                FontSize        = fontSize,
                FontAttributes  = FontAttributes.None,
                TextColor       = Color.FromRgb(139, 209, 0)
            };

            if (cell is CalendarDayCell dayCell)
            {
                if (dayCell.IsFromCurrentMonth)
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.TextColor       = Color.FromRgb(0, 122, 255);
                        defaultStyle.FontAttributes  = FontAttributes.Bold;
                        defaultStyle.BorderColor     = todayBorderColor;
                        defaultStyle.BorderThickness = todayBorderThickness;
                    }
                }
                else
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.TextColor       = todayBorderColor;
                        defaultStyle.BorderColor     = todayBorderColor;
                        defaultStyle.BorderThickness = todayBorderThickness;
                    }
                    else
                    {
                        defaultStyle.TextColor = Color.FromRgb(166, 181, 137);
                    }
                }

                if (dayCell.IsSelected)
                {
                    defaultStyle.TextColor   = selectedCellForegroundColor;
                    defaultStyle.BorderColor = Color.FromHex("FF0066CC");
                }

                return(defaultStyle);
            }

            return(null); // default style
        }
 public DangerDayCellStyleSelector(List<CalendarDateRange> danger, ObservableCollection<DateTime> blood) {
     listBloodyDay = new List<DateTime>(blood);
     createDangerCellStyle(danger);
     bloodyCellStyle = createBloodyCellStyle();
 }
        // >> calendar-features-cellstyling-evaluatecellstyle
        private CalendarCellStyle EvaluateCellStyle(CalendarCell cell)
        {
            var background = Device.OnPlatform(Color.White, Color.White, Color.FromRgb(30, 30, 30));
            var selectedCellForegroundColor = Device.OnPlatform(Color.White, Color.FromRgb(139, 209, 0), Color.White);
            var dayNamesFontSize            = Device.OnPlatform(14, 15, 17);
            var fontSize             = Device.OnPlatform(14, 15, 17);
            var todayBorderThickness = Device.OnPlatform(new Thickness(2), new Thickness(1), new Thickness(2));
            var todayBorderColor     = Color.FromRgb(115, 174, 239);

            if (cell.Type == CalendarCellType.DayName)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.LightGray,
                    FontSize = dayNamesFontSize,
                    FontWeight = FontWeight.Bold,
                    ForegroundColor = Color.FromRgb(0, 122, 255)
                });
            }

            var defaultStyle = new CalendarCellStyle
            {
                BackgroundColor = background,
                FontSize        = fontSize,
                FontWeight      = FontWeight.Normal,
                ForegroundColor = Color.FromRgb(139, 209, 0)
            };

            var dayCell = cell as CalendarDayCell;

            if (dayCell != null)
            {
                if (dayCell.IsFromCurrentMonth)
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.ForegroundColor = Color.FromRgb(0, 122, 255);
                        defaultStyle.FontWeight      = FontWeight.Bold;
                        defaultStyle.BorderColor     = todayBorderColor;
                        defaultStyle.BorderThickness = todayBorderThickness;
                    }
                }
                else
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.ForegroundColor = todayBorderColor;
                        defaultStyle.BorderColor     = todayBorderColor;
                        defaultStyle.BorderThickness = todayBorderThickness;
                    }
                    else
                    {
                        defaultStyle.ForegroundColor = Color.FromRgb(166, 181, 137);
                    }
                }

                if (dayCell.IsSelected)
                {
                    defaultStyle.ForegroundColor = selectedCellForegroundColor;
                    defaultStyle.BorderColor     = Color.FromHex("FF0066CC");
                }

                return(defaultStyle);
            }

            return(null); // default style
        }
        private CalendarCellStyle SetStyleForCell(CalendarCell cell)
        {
            double    dayNameFontSize    = 0;
            double    weekNumberFontSize = 0;
            double    defaultFontSize    = 0;
            Thickness defaultThickness   = new Thickness(1);

            switch (Device.RuntimePlatform)
            {
            case Device.UWP:
            {
                dayNameFontSize    = 16;
                weekNumberFontSize = 13;
                defaultFontSize    = 0;
                defaultThickness   = new Thickness(0);
            }
            break;

            case Device.Android:
            {
                dayNameFontSize    = 16;
                weekNumberFontSize = 24;
                defaultFontSize    = 16;
                defaultThickness   = new Thickness(1);
            }
            break;

            case Device.iOS:
            {
                dayNameFontSize    = 10;
                weekNumberFontSize = 13;
                defaultFontSize    = 15;
                defaultThickness   = new Thickness(0, 0, 0, 1);
            }
            break;
            }

            if (cell.Type == CalendarCellType.DayName)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.FromHex("EEEEEE"),
                    BorderColor = Color.Transparent,
                    FontSize = dayNameFontSize,
                    FontAttributes = FontAttributes.Bold,
                    TextColor = Color.FromHex("999999")
                });
            }

            if (cell.Type == CalendarCellType.WeekNumber)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.FromHex("E5E5E5"),
                    BorderColor = Color.Transparent,
                    FontSize = weekNumberFontSize,
                    TextColor = Color.FromHex("A9A9A9")
                });
            }

            var defaultStyle = new CalendarCellStyle
            {
                BackgroundColor = Color.FromHex("EEEEEE"),
                BorderColor     = Color.FromHex("CCCCCC"),
                BorderThickness = defaultThickness,
                FontSize        = defaultFontSize,

                TextColor = Color.FromHex("333333")
            };

            var dayCell = cell as CalendarDayCell;

            if (dayCell != null)
            {
                if (dayCell.Date.DayOfWeek == DayOfWeek.Sunday)
                {
                    defaultStyle.TextColor = Color.FromHex("D42A28");
                }

                if (dayCell.IsFromCurrentMonth)
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.FontAttributes = FontAttributes.Bold;
                    }
                }
                else
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.TextColor = Color.FromRgb(115, 174, 239);
                    }
                    else
                    {
                        defaultStyle.TextColor       = Color.FromHex("999999");
                        defaultStyle.BackgroundColor = Color.FromHex("E5E5E5");
                    }
                }

                if (dayCell.IsSelected)
                {
                    defaultStyle.TextColor = Color.White;
                }

                return(defaultStyle);
            }

            return(null); // default style
        }
        private CalendarCellStyle SetStyleForCell(CalendarCell cell)
        {
            if (cell.Type == CalendarCellType.DayName)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.FromHex("EEEEEE"),
                    BorderColor = Color.Transparent,
                    FontSize = Device.OnPlatform <double>(10, 16, 16),
                    FontWeight = Telerik.XamarinForms.Common.FontWeight.Bold,
                    ForegroundColor = Color.FromHex("999999")
                });
            }

            if (cell.Type == CalendarCellType.WeekNumber)
            {
                return(new CalendarCellStyle
                {
                    BackgroundColor = Color.FromHex("E5E5E5"),
                    BorderColor = Color.Transparent,
                    FontSize = Device.OnPlatform <double>(13, 24, 13),
                    ForegroundColor = Color.FromHex("A9A9A9")
                });
            }

            var defaultStyle = new CalendarCellStyle
            {
                BackgroundColor = Color.FromHex("EEEEEE"),
                BorderColor     = Color.FromHex("CCCCCC"),
                BorderThickness = Device.OnPlatform <Thickness>(new Thickness(0, 0, 0, 1), 1, 0),
                FontSize        = Device.OnPlatform <double>(15, 16, 0),

                ForegroundColor = Color.FromHex("333333")
            };

            var dayCell = cell as CalendarDayCell;

            if (dayCell != null)
            {
                if (dayCell.Date.DayOfWeek == DayOfWeek.Sunday)
                {
                    defaultStyle.ForegroundColor = Color.FromHex("D42A28");
                }

                if (dayCell.IsFromCurrentMonth)
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.FontWeight = Telerik.XamarinForms.Common.FontWeight.Bold;
                    }
                }
                else
                {
                    if (dayCell.IsToday)
                    {
                        defaultStyle.ForegroundColor = Color.FromRgb(115, 174, 239);
                    }
                    else
                    {
                        defaultStyle.ForegroundColor = Color.FromHex("999999");
                        defaultStyle.BackgroundColor = Color.FromHex("E5E5E5");
                    }
                }

                if (dayCell.IsSelected)
                {
                    defaultStyle.ForegroundColor = Color.White;
                }

                return(defaultStyle);
            }

            return(null); // default style
        }