private static void TestUniqueValuesThemesEqual <T>(UniqueValuesTheme <T> lhs, UniqueValuesTheme <T> rhs) { Assert.AreEqual(lhs.AttributeName, rhs.AttributeName, "AttributeName differs"); var uvS = lhs.UniqueValues; var uvD = rhs.UniqueValues; Assert.AreEqual(uvS.Length, uvD.Length, "UniqueValues length differs"); for (var i = 0; i < uvS.Length; i++) { Assert.AreEqual(uvS[i], uvD[i], "Unique values differ at index {0} [{1}:{2}]", i, uvS[i], uvD[i]); } Assert.IsTrue(StylesTest.AreVectorStylesEqual((VectorStyle)lhs.DefaultStyle, (VectorStyle)rhs.DefaultStyle), "DefaultStyle differs"); for (var i = 0; i < uvS.Length; i++) { Assert.IsTrue(StylesTest.AreVectorStylesEqual( (VectorStyle)lhs.GetStyle(uvS.ToString()), (VectorStyle)rhs.GetStyle(uvD.ToString())), "Style at {0} differs", i); } }
ILegendItem CreateUniqueValuesLegendItems <T>(ILegendSettings settings, UniqueValuesTheme <T> uvt) where T : IConvertible { var res = new LegendItem { Label = " (" + uvt.AttributeName + ")", LabelFont = settings.ItemFont, LabelBrush = settings.ForeColor, Indentation = settings.SymbolSize.Width }; var defaultItem = Factory[uvt.DefaultStyle].Create(settings, uvt.DefaultStyle); defaultItem.Label = "(default)"; defaultItem.LabelBrush = settings.ForeColor; defaultItem.LabelFont = settings.ItemFont; defaultItem.Parent = res; defaultItem.Item = uvt.DefaultStyle; res.SubItems.Add(defaultItem); using (var fdt = CreateTable(uvt.AttributeName, typeof(T))) { for (var i = 0; i < uvt.UniqueValues.Length; i++) { var row = fdt.NewRow(); T val = default(T); row[0] = Convert.ChangeType(uvt.UniqueValues[i], val.GetTypeCode()); var style = uvt.GetStyle(row); var item = Factory[style].Create(settings, style); item.Label = uvt.UniqueValues[i]; item.LabelFont = settings.ItemFont; item.LabelBrush = settings.ForeColor; item.Parent = res; item.Item = style; res.SubItems.Add(item); } } return(res); }