示例#1
0
        public void Init(IList <ProductInfo> itemInfoList)
        {
            ItemClicked = null;
            if (!itemInfoList.Any())
            {
                return;
            }
            xtraScrollableControl.Controls.Clear();
            var columOrder = 0;
            var rowOrder   = 0;

            foreach (var itemInfo in itemInfoList)
            {
                var button = new ProductItemButton(itemInfo);
                button.ColumnOrder = columOrder;
                button.RowOrder    = rowOrder;
                button.Text        = String.Format("<div align=\"center\"><font color=\"{1}\" size=\"{2}\">{0}</font></div>",
                                                   itemInfo.Title?.Replace("&", "&amp;"),
                                                   itemInfo.ButtonConfiguration.ForeColor.ToHex(),
                                                   itemInfo.ButtonConfiguration.FontSize);
                if (!itemInfo.ButtonConfiguration.BackgroundColor.IsEmpty)
                {
                    button.BackColor = itemInfo.ButtonConfiguration.BackgroundColor;
                }
                button.Height        = (Int32)(ButtonHeight * Utilities.GetScaleFactor(CreateGraphics().DpiX).Height);
                button.TextAlignment = eButtonTextAlignment.Center;
                button.ColorTable    = eButtonColor.OrangeWithBackground;
                button.Style         = eDotNetBarStyle.StyleManagerControlled;
                button.Click        += (sender, e) =>
                {
                    var clickedButton      = (ProductItemButton)sender;
                    var cllickingEventArgs = new ProductClickingEventArgs();
                    ItemClicking?.Invoke(sender, cllickingEventArgs);
                    if (!cllickingEventArgs.Cancel)
                    {
                        ItemClicked?.Invoke(sender,
                                            new ProductClickedEventArgs
                        {
                            ItemInfo = clickedButton.ItemInfo
                        });
                    }
                };
                xtraScrollableControl.Controls.Add(button);

                columOrder++;
                if (columOrder == ColumnsCount)
                {
                    columOrder = 0;
                    rowOrder++;
                }
            }
            ResizeButtons();
        }
 private void OnProductClicking(object sender, ProductClickingEventArgs e)
 {
     ItemClicking?.Invoke(this, e);
 }