private void BindColorToStyle(Color color) { if (!IsAbleToBindProperty()) { return; } Model.StyleOption styleOption = _styleOptions[StylesVariationListSelectedId.Number]; string currentCategory = CurrentVariantCategory.Text; string targetColor = StringUtil.GetHexValue(color); if (currentCategory.Contains(PictureSlidesLabText.ColorHasEffect)) { styleOption.OptionName = "Customized"; string propName = GetPropertyName(currentCategory); System.Type type = styleOption.GetType(); System.Reflection.PropertyInfo prop = type.GetProperty(propName); prop.SetValue(styleOption, targetColor, null); } }
/////////////////////////////////////////////////////////////// // Implemented variation stage controls' binding in ViewModel /////////////////////////////////////////////////////////////// // TODO add new variation stage control Slide to adjust brightness/blurriness/transparency #region Binding funcs for color panel public void BindStyleToColorPanel() { if (!IsAbleToBindProperty()) { return; } Model.StyleOption styleOption = _styleOptions[StylesVariationListSelectedId.Number]; string currentCategory = CurrentVariantCategory.Text; BrushConverter bc = new BrushConverter(); if (currentCategory.Contains(PictureSlidesLabText.ColorHasEffect)) { string propName = GetPropertyName(currentCategory); System.Type type = styleOption.GetType(); System.Reflection.PropertyInfo prop = type.GetProperty(propName); object optValue = prop.GetValue(styleOption, null); if (!string.IsNullOrEmpty(optValue as string)) { View.SetVariantsColorPanelBackground((Brush)bc.ConvertFrom(optValue)); } } }