Exemple #1
0
 /// <summary>
 /// Get mapping of chron items to color
 /// </summary>
 /// <param name="lkpFieldName">The lkp field assocaited to colors by attribute</param>
 private IDictionary <string, Color> GetDefaultColors(string lkpFieldName)
 {
     if (!string.IsNullOrEmpty(lkpFieldName))
     {
         // build simple lookup for var name > color
         DataTable colorsDt = new LookupCodeDa().GetLookupCodesAttributeValues(lkpFieldName, "Color");
         var       lookup   = from row in colorsDt.AsEnumerable()
                              let lkpCode = row[LookupCode.LkpCode].ToString()
                                            let lkpAttributeValue = row[LookupCodeAttribute.AttributeValue].ToString()
                                                                    group lkpAttributeValue by lkpCode into g
                                                                    let lkpCode                         = g.First()
                                                                                              let color = !string.IsNullOrEmpty(lkpCode) ? (lkpCode.StartsWith("#") ? System.Drawing.ColorTranslator.FromHtml(lkpCode) : System.Drawing.Color.FromName(lkpCode)) : DEFAULT_CHRON_COLOR
                                                                                                          select new
         {
             Code  = g.Key,
             Color = color
         };
         // convert mapping to lookup of var to Color
         return(lookup.ToDictionary(k => k.Code, k => k.Color));
     }
     else
     {
         return(new Dictionary <string, Color>());
     }
 }