/// <summary> /// Sets color for attribute's value. /// </summary> /// <param name="value"> /// Attribute's value. /// </param> /// <param name="newColor"> /// The new color. /// </param> public void SetAttributeValueColor(object value, Color newColor) { string strValue = value == null ? string.Empty : value.ToString(); Color defaultColor = GetDefaultColor(value); AttributeConfigurationChangeEventArgs args = new AttributeConfigurationChangeEventArgs(this, "Colors") { Color = newColor, Value = strValue }; if (!Colors.ContainsKey(strValue)) { if (newColor != defaultColor) { Colors.Add(strValue, CustomColorConverter.ColorToString(newColor)); RaisePropertyChanged(this, "Colors", args); } } else { if (newColor != defaultColor) { Colors[strValue] = CustomColorConverter.ColorToString(newColor); } else { Colors.Remove(strValue); } RaisePropertyChanged(this, "Colors", args); } }
/// <summary> /// The update extended attribute configuration. /// </summary> /// <param name="attributeName"> /// The attribute name. /// </param> /// <param name="zipEntry"> /// The zip entry. /// </param> private void UpdateExtendedAttributeConfiguration(string attributeName, ZipEntry zipEntry) { if (!this.attributeConfigurations.ContainsKey(attributeName)) { return; } MemoryStream ms = new MemoryStream(); zipEntry.Extract(ms); ms.Position = 0; using (StreamReader streamReader = new StreamReader(ms)) { CsvReader csvReader = new CsvReader(streamReader); IEnumerable <AttributeExtendedConfiguration> records = csvReader.GetRecords <AttributeExtendedConfiguration>(); foreach (AttributeExtendedConfiguration attributeExtConfiguration in records) { this.attributeConfigurations[attributeName].SetAttributeValueColor( attributeExtConfiguration.Value, CustomColorConverter.StringToColor(attributeExtConfiguration.Color)); this.attributeConfigurations[attributeName].SetAttributeValueVisibility( attributeExtConfiguration.Value, attributeExtConfiguration.Visibility); } } }
/// <summary> /// Gets color for attribute's value. /// </summary> /// <param name="value"> /// Attribute's value. /// </param> /// <returns> /// The color. /// </returns> public Color GetAttributeValueColor(object value) { string strValue = value == null ? string.Empty : value.ToString(); if (Colors.ContainsKey(strValue)) { return CustomColorConverter.StringToColor(Colors[strValue]); } return GetDefaultColor(value); }
/// <summary> /// The get extended configuration. /// </summary> /// <returns> /// The <see cref="List{AttributeExtendedConfiguration}"/>. /// </returns> public List<AttributeExtendedConfiguration> GetExtendedConfiguration() { List<AttributeExtendedConfiguration> result = new List<AttributeExtendedConfiguration>(); foreach (object value in Values) { string strValue = value == null ? string.Empty : value.ToString(); if (Visibility.ContainsKey(strValue) || Colors.ContainsKey(strValue)) { result.Add(new AttributeExtendedConfiguration { Value = strValue, Color = Colors.ContainsKey(strValue) ? Colors[strValue] : CustomColorConverter.ColorToString(GetDefaultColor(value)), Visibility = !Visibility.ContainsKey(strValue) }); } } return result; }
/// <summary> /// sets color of calendar state /// </summary> /// <param name="color">The color.</param> public void SetColor(Color color) { CalendarStateColor = CustomColorConverter.ColorToString(color); RaisePropertyChanged("Color"); }
/// <summary> /// Gets color of calendar state /// </summary> /// <returns>the color</returns> public Color GetColor() { return(CustomColorConverter.StringToColor(CalendarStateColor)); }
/// <summary> /// Initializes a new instance of the <see cref="CalendarStateConfiguration" /> class. /// </summary> /// <param name="name">The name.</param> /// <param name="color">The color.</param> public CalendarStateConfiguration(string name, Color color) { IsVisible = true; Name = name; CalendarStateColor = CustomColorConverter.ColorToString(color); }
/// <summary> /// The load extended attribute configuration. /// </summary> private void LoadExtendedAttributeConfiguration() { foreach (string attributeName in this.attributeConfigurations.Keys) { string extAttributePath = Path.Combine(this.ConfigurationFolder, string.Format(AttributeExtendedConfigurationFile, attributeName)); if (this.FileExists(extAttributePath)) { using (StreamReader streamReader = new StreamReader(this.GetFileStream(extAttributePath, FileMode.Open))) { CsvReader csvReader = new CsvReader(streamReader); IEnumerable <AttributeExtendedConfiguration> records = csvReader.GetRecords <AttributeExtendedConfiguration>(); foreach (AttributeExtendedConfiguration attributeExtendedConfiguration in records) { this.attributeConfigurations[attributeName].SetAttributeValueColor(attributeExtendedConfiguration.Value, CustomColorConverter.StringToColor(attributeExtendedConfiguration.Color)); this.attributeConfigurations[attributeName].SetAttributeValueVisibility(attributeExtendedConfiguration.Value, attributeExtendedConfiguration.Visibility); } } } } }