internal void ShowCumulativeFactorsLegends(List <Factor> cumulativeFactors) { Width = 0; flpLegendItems.Controls.Clear(); tlpLegends.RowStyles[0].Height = 20; flpLegendItems.FlowDirection = FlowDirection.TopDown; foreach (Factor cumulativeFactor in cumulativeFactors) { MapLegendItem li = new MapLegendItem(LegendItemType.Cumulative); Color backColor = SystemColors.ControlText; Color fontColor = SystemColors.ControlText; if (cumulativeFactor.Color.Split(',').Length > 1) { backColor = ColorTranslator.FromHtml(cumulativeFactor.Color.Split(',')[0]); fontColor = ColorTranslator.FromHtml(cumulativeFactor.Color.Split(',')[1]); } Size size = TextRenderer.MeasureText(cumulativeFactor.Name, li.Font); li.Width = size.Width + 20; Width = Math.Max(li.Width, Width); li.LegendItemBackColor = backColor; li.LegendItemCumulativeTextColor = fontColor; li.LegendItemValue = cumulativeFactor.Name; flpLegendItems.Controls.Add(li); } this.Height = 25 + (20 * cumulativeFactors.Count); }
internal void SetColorScheme(ClassBreakStyle modelClassBreakStyle) { Width = 0; flpLegendItems.Controls.Clear(); foreach (ClassBreak classBreak in modelClassBreakStyle.ClassBreaks) { GeoColor gc = classBreak.DefaultAreaStyle.FillSolidBrush.Color; Color color = Color.FromArgb(gc.AlphaComponent, gc.RedComponent, gc.GreenComponent, gc.BlueComponent); if (gc != GeoColor.SimpleColors.Transparent) { MapLegendItem mapLegendItem = new MapLegendItem(LegendItemType.Scale) { LegendItemBackColor = color, LegendItemValue = Convert.ToInt32(classBreak.Value).ToString(), Padding = new Padding(0, 0, 0, 0), Margin = new Padding(0, 0, 0, 0) }; mapLegendItem.MouseDown += Legends_MouseDown; mapLegendItem.OnMouseDown += mapLegendItem_OnMouseDown; Width += mapLegendItem.Width + 3; flpLegendItems.Controls.Add(mapLegendItem); } } }