private FrameworkElement CreateDragVisual(Category c) { Grid visual = new Grid(); visual.SetResourceReference(Window.BackgroundProperty, "SystemControlHighlightAccent3RevealBackgroundBrush"); visual.SetResourceReference(Window.ForegroundProperty, "SystemControlPageTextBaseHighBrush"); visual.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); visual.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); var label = new TextBlock() { Text = c.Name, Margin = new Thickness(5), FontSize = this.FontSize, FontFamily = this.FontFamily }; var swatch = new Border() { Margin = new Thickness(5), Width = 8, Height = 8, Background = new SolidColorBrush() { Color = ColorAndBrushGenerator.GenerateNamedColor(c.InheritedColor) } }; visual.Children.Add(label); visual.Children.Add(swatch); Grid.SetColumn(swatch, 1); return(visual); }
void SetCategory(Category c) { this.category = c; this.transfer = null; this.comboBoxType.IsEnabled = this.textBoxDescription.IsEnabled = true; if (category == null) { this.comboBoxCategory.Text = string.Empty; this.textBoxDescription.Text = string.Empty; this.comboBoxType.Text = string.Empty; this.comboTaxCategory.SelectedItem = null; ColorPicker.Color = Colors.Transparent; } else { this.textBoxDescription.Text = category.Description; this.comboBoxType.SelectedItem = category.Type; this.comboBoxCategory.Text = c.Name; this.comboTaxCategory.SelectedItem = taxCategories.Find(c.TaxRefNum); ColorPicker.Color = Colors.Transparent; try { string ic = category.InheritedColor; if (!string.IsNullOrEmpty(ic)) { ColorPicker.Color = ColorAndBrushGenerator.GenerateNamedColor(ic); } } catch { } } }
void Add() { if (this.transfer != null) { return; } money.Categories.BeginUpdate(true); try { IntelliComboBoxItem item = (IntelliComboBoxItem)this.comboBoxCategory.SelectedItem; string cat = this.comboBoxCategory.Text; if (item != null) { if (cat == item.ToString()) { cat = item.EditValue.ToString(); } } CategoryType type = (CategoryType)StringHelpers.ParseEnum(typeof(CategoryType), this.comboBoxType.Text, (int)CategoryType.None); string text = cat; if (text != null && text.Length > 0) { this.category = this.categories.GetOrCreateCategory(text, type); } TaxCategory tc = this.comboTaxCategory.SelectedItem as TaxCategory; if (tc != null) { this.category.TaxRefNum = tc.RefNum; } else { this.category.TaxRefNum = 0; } this.category.Description = this.textBoxDescription.Text; if (this.category.Type != type) { this.category.Type = type; PropagateCategoryTypeToChildren(this.category); } this.category.Budget = StringHelpers.ParseDecimal(this.textBoxBudget.Text, 0); var picker = this.ColorPicker; Color color = picker.Color; this.category.Color = color.ToString(); ColorAndBrushGenerator.SetNamedColor(this.category.GetFullName(), color); } finally { // if parent categories were added then set their type & color also. money.Categories.EndUpdate(); } }
public static Color GetColorFromCategoryName(string name) { Color color; if (name == "Transfer") { return(Colors.Transparent); } else if (IsSpecialCategory(name)) { // Special cases were we want these in Black color = Colors.Black; } else { color = ColorAndBrushGenerator.GenerateNamedColor(name); } return(color); }
void SetCategory(Category c) { this.category = c; this.transfer = null; this.comboBoxType.IsEnabled = this.textBoxDescription.IsEnabled = true; if (category == null) { this.comboBoxCategory.Text = string.Empty; this.textBoxDescription.Text = string.Empty; this.comboBoxType.Text = string.Empty; this.textBoxBudget.Text = string.Empty; this.comboTaxCategory.SelectedItem = null; ColorPicker.Color = Colors.Transparent; } else { this.textBoxDescription.Text = category.Description; this.comboBoxType.SelectedItem = category.Type; this.comboBoxCategory.Text = c.Name; if (c.BudgetRange != CalendarRange.Monthly) { // convert to monthly since that's all we support right now. switch (c.BudgetRange) { case CalendarRange.Daily: c.Budget = (c.Budget * 365) / 12; break; case CalendarRange.Weekly: c.Budget = (c.Budget * 52) / 12; break; case CalendarRange.BiWeekly: c.Budget = (c.Budget * 26) / 12; break; case CalendarRange.BiMonthly: c.Budget = (c.Budget / 2); break; case CalendarRange.TriMonthly: c.Budget = (c.Budget / 3); break; case CalendarRange.Quarterly: c.Budget = (c.Budget * 4) / 12; break; case CalendarRange.SemiAnnually: c.Budget = (c.Budget * 2) / 12; break; case CalendarRange.Annually: c.Budget = (c.Budget / 12); break; } c.BudgetRange = CalendarRange.Monthly; } this.textBoxBudget.Text = c.Budget.ToString("n", this.nfi); this.comboTaxCategory.SelectedItem = taxCategories.Find(c.TaxRefNum); ColorPicker.Color = Colors.Transparent; try { if (!string.IsNullOrEmpty(category.InheritedColor)) { ColorPicker.Color = ColorAndBrushGenerator.GenerateNamedColor(category.InheritedColor); } } catch { } } ShowHistoricalRange(c); ShowActual(); }