private void modifyCategories_Click(object sender, RoutedEventArgs e) { CategoryEditor editor = new CategoryEditor(() => { return(AppointmentDatabase.GetCategories()); }, AppointmentDatabase.AddCategory, AppointmentDatabase.UpdateCategory, AppointmentDatabase.DeleteCategory); editor.Owner = this; editor.ShowDialog(); // We need to refresh all items with a category. CurrentCalendarView().RefreshCategories(); }
private void appointmentCategory_DropDownOpened(object sender, EventArgs e) { appointmentCategoryGallery.Items.Clear(); MenuItem clearCategory = new MenuItem(); clearCategory.Header = "_Clear Category"; clearCategory.Click += clearCategory_Click; appointmentCategoryGallery.Items.Add(clearCategory); bool enabled; if (calendarDisplayMode == CalendarMode.Month) { enabled = monthView.Selected.ActiveDetail.Appointment.CategoryID != ""; } else { enabled = ((DayDetail)_activeDetail).Appointment.CategoryID != ""; } if (!enabled) { clearCategory.Loaded += separator_Loaded; } RibbonSeparator separator = new RibbonSeparator(); separator.Margin = new Thickness(32, 1, 0, 0); separator.Loaded += separator_Loaded; appointmentCategoryGallery.Items.Add(separator); foreach (Category each in AppointmentDatabase.GetCategories()) { if (!each.ReadOnly) { MenuItem m = new MenuItem(); m.Click += Category_Click; m.Header = each.Name; m.Tag = each.ID; Border b = new Border(); b.BorderThickness = new Thickness(1); b.Width = b.Height = 14; Color c = each.Color; b.Background = new SolidColorBrush(c); b.BorderBrush = new SolidColorBrush(Color.FromRgb((byte)(c.R > 75 ? c.R - 75 : 0), (byte)(c.G > 70 ? c.G - 70 : 0), (byte)(c.B > 80 ? c.B - 80 : 0))); m.Icon = b; appointmentCategoryGallery.Items.Add(m); } } RibbonSeparator separator2 = new RibbonSeparator(); separator2.Margin = new Thickness(32, 1, 0, 0); separator2.Loaded += separator_Loaded; appointmentCategoryGallery.Items.Add(separator2); MenuItem modifyCategories = new MenuItem(); modifyCategories.Header = "_Edit Categories"; Image icon = new Image(); icon.Stretch = Stretch.None; icon.Source = new BitmapImage(new Uri("pack://application:,,,/Daytimer.Images;component/Images/categorize_sml.png", UriKind.Absolute)); modifyCategories.Icon = icon; modifyCategories.Click += modifyCategories_Click; appointmentCategoryGallery.Items.Add(modifyCategories); }