private void SetColorForCompositeRule(FillColorSource? source, string fillAlpha, RuleItem entry, ICompositeRule r) { // NOTE: Same naivete as IdentifyColorSource(). Refer to that method for all the gory details bool bSetFill = false; foreach (ISymbolInstance symInst in r.CompositeSymbolization.SymbolInstance) { if (bSetFill) break; var symRef = GetSymbolFromReference(m_editor.ResourceService, symInst.Reference); var simpleSym = symRef as ISimpleSymbolDefinition; if (simpleSym == null) throw new NotSupportedException(Strings.CannotCreateThemeFromCompoundSymbolInstance); var symName = simpleSym.Name; //Find the first path graphic with a fill color foreach (var graphic in simpleSym.Graphics) { if (bSetFill) break; if (graphic.Type == GraphicElementType.Path) { IPathGraphic path = (IPathGraphic)graphic; if (path.FillColor != null) { string color = path.FillColor; if (source.Value == FillColorSource.PathFillColor) { path.FillColor = "0x" + fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha)); Debug.WriteLine(string.Format("Set fill color to {0} for symbol instance {1} of symbolization {2} in rule {3}", path.FillColor, symInst.GetHashCode(), r.CompositeSymbolization.GetHashCode(), r.GetHashCode())); bSetFill = true; break; } //Is this a parameter? if (color.StartsWith("%") && color.EndsWith("%")) { string paramName = color.Substring(1, color.Length - 2); if (simpleSym.ParameterDefinition != null) { foreach (var paramDef in simpleSym.ParameterDefinition.Parameter) { if (bSetFill) break; if (paramDef.Name == paramName) { if (source.Value == FillColorSource.SymbolParameterFillColorDefaultValue) { paramDef.DefaultValue = "0x" + fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha)); Debug.WriteLine(string.Format("Set fill color default parameter value to {0} for symbol instance {1} of symbolization {2} in rule {3}", paramDef.DefaultValue, symInst.GetHashCode(), r.CompositeSymbolization.GetHashCode(), r.GetHashCode())); bSetFill = true; break; } //But wait ... Is there an override for this too? var ov = symInst.ParameterOverrides; if (ov != null) { foreach (var pov in ov.Override) { if (bSetFill) break; if (pov.SymbolName == symName && pov.ParameterIdentifier == paramName) { if (source.Value == FillColorSource.SymbolParameterFillColorOverride) { pov.ParameterValue = "0x" + fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha)); Debug.WriteLine(string.Format("Set fill color parameter override value to {0} for symbol instance {1} of symbolization {2} in rule {3}", pov.ParameterValue, symInst.GetHashCode(), r.CompositeSymbolization.GetHashCode(), r.GetHashCode())); bSetFill = true; break; } } } } } } } } } else if (path.LineColor != null && simpleSym.LineUsage != null) { string color = path.LineColor; if (source.Value == FillColorSource.PathLineColor) { path.LineColor = "0x" + fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha)); Debug.WriteLine(string.Format("Set line color to {0} for symbol instance {1} of symbolization {2} in rule {3}", path.FillColor, symInst.GetHashCode(), r.CompositeSymbolization.GetHashCode(), r.GetHashCode())); bSetFill = true; break; } //Is this a parameter? if (color.StartsWith("%") && color.EndsWith("%")) { string paramName = color.Substring(1, color.Length - 2); if (simpleSym.ParameterDefinition != null) { foreach (var paramDef in simpleSym.ParameterDefinition.Parameter) { if (bSetFill) break; if (paramDef.Name == paramName) { if (source.Value == FillColorSource.SymbolParameterLineColorDefaultValue) { paramDef.DefaultValue = "0x" + fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha)); Debug.WriteLine(string.Format("Set line color default parameter value to {0} for symbol instance {1} of symbolization {2} in rule {3}", paramDef.DefaultValue, symInst.GetHashCode(), r.CompositeSymbolization.GetHashCode(), r.GetHashCode())); bSetFill = true; break; } //But wait ... Is there an override for this too? var ov = symInst.ParameterOverrides; if (ov != null) { foreach (var pov in ov.Override) { if (bSetFill) break; if (pov.SymbolName == symName && pov.ParameterIdentifier == paramName) { if (source.Value == FillColorSource.SymbolParameterLineColorOverride) { pov.ParameterValue = "0x" + fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha)); Debug.WriteLine(string.Format("Set line color parameter override value to {0} for symbol instance {1} of symbolization {2} in rule {3}", pov.ParameterValue, symInst.GetHashCode(), r.CompositeSymbolization.GetHashCode(), r.GetHashCode())); bSetFill = true; break; } } } } } } } } } } } } }