Exemple #1
0
        private void createGarnisheButtons()
        {
            double grnColWidth = Math.Floor(contentPanelWidth / 3d);
            double grnH = dGrid.RowDefinitions[4].Height.Value, grnW = ((AppLib.IsAppVerticalLayout)?1.1d:1.3) * grnH; // пропорции кнопки

            if (grnW > grnColWidth)
            {
                grnW = grnColWidth;
            }

            _grdGarnishes = new Grid();
            _grdGarnishes.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(grnColWidth, GridUnitType.Pixel)
            });
            _grdGarnishes.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(grnColWidth, GridUnitType.Pixel)
            });
            _grdGarnishes.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(grnColWidth, GridUnitType.Pixel)
            });

            Brush notSelTextBrush = AppLib.GetSolidColorBrushFromAppProps("dishPanelGarnishTextColor", Brushes.Black);
            Brush selTextBrush    = AppLib.GetSolidColorBrushFromAppProps("dishPanelGarnishSelectTextColor", Brushes.Black);

            MainMenuGarnish grdGarn = new MainMenuGarnish(_dishItem, 0, grnH, grnW, dGrid);

            grdGarn.NotSelectedTextBrush = notSelTextBrush;
            grdGarn.SelectedTextBrush    = selTextBrush;
            grdGarn.HorizontalAlignment  = HorizontalAlignment.Left;
            grdGarn.SetValue(Grid.ColumnProperty, 0);
            grdGarn.SelectGarnish += GrdGarn_SelectGarnish;
            _grdGarnishes.Children.Add(grdGarn);

            if (_dishItem.Garnishes.Count >= 2)
            {
                grdGarn = new MainMenuGarnish(_dishItem, 1, grnH, grnW, dGrid);
                grdGarn.NotSelectedTextBrush = notSelTextBrush;
                grdGarn.SelectedTextBrush    = selTextBrush;
                grdGarn.HorizontalAlignment  = HorizontalAlignment.Center;
                grdGarn.SetValue(Grid.ColumnProperty, 1);
                grdGarn.SelectGarnish += GrdGarn_SelectGarnish;
                _grdGarnishes.Children.Add(grdGarn);
            }
            if (_dishItem.Garnishes.Count >= 3)
            {
                grdGarn = new MainMenuGarnish(_dishItem, 2, grnH, grnW, dGrid);
                grdGarn.NotSelectedTextBrush = notSelTextBrush;
                grdGarn.SelectedTextBrush    = selTextBrush;
                grdGarn.HorizontalAlignment  = HorizontalAlignment.Right;
                grdGarn.SetValue(Grid.ColumnProperty, 2);
                grdGarn.SelectGarnish += GrdGarn_SelectGarnish;
                _grdGarnishes.Children.Add(grdGarn);
            }

            Grid.SetRow(_grdGarnishes, 4); dGrid.Children.Add(_grdGarnishes);
        }  // method