private void Initialize(CalcultateHeightHandler calcultateHeightHandler) { for (int i = 0; i < Scopes.Count; i++) { var bin = new Bin(Scopes[i], i, calcultateHeightHandler.Invoke(Scopes[i].Sum)) { Color = brushes[i], }; bin.MouseOn += Bin_MouseOn; bin.MouseOut += Bin_MouseOut; bin.Shift(); Bins.Add(bin); addItemToLegendHandler?.Invoke(Scopes[i].EnumMember, brushes[i]); MainGrid.Children.Add(bin); } }
public BinsBunch(Scopes scopes, Brush[] brushes, CalcultateHeightHandler calcultateHeightHandler, AddItemToLegendHandler addItemToLegendHandler) { if (scopes is null) { throw new ArgumentNullException(nameof(scopes)); } Scopes = scopes; InitialDate = scopes.InitialDate; FinalDate = scopes.FinalDate; this.addItemToLegendHandler = addItemToLegendHandler ?? throw new ArgumentNullException(nameof(addItemToLegendHandler)); if (calcultateHeightHandler is null) { throw new ArgumentNullException(nameof(calcultateHeightHandler)); } this.brushes = brushes ?? throw new ArgumentNullException(nameof(brushes)); InitializeComponent(); Initialize(calcultateHeightHandler); }