} // method private void setDishDescription() { // размер шрифтов double dishPanelDescriptionFontSize = Convert.ToDouble(AppLib.GetAppGlobalValue("dishPanelDescriptionFontSize")); double dishPanelTextFontSize = Convert.ToDouble(AppLib.GetAppGlobalValue("dishPanelFontSize")); double dishPanelDescrButtonSize = (double)AppLib.GetAppGlobalValue("dishPanelDescrButtonSize"); // размеры прямоугольника и углы закругления для изображения и описания блюда double dishImageHeight = (double)AppLib.GetAppGlobalValue("dishImageHeight"); double dishImageWidth = (double)AppLib.GetAppGlobalValue("dishImageWidth"); double dishImageCornerRadius = (double)AppLib.GetAppGlobalValue("cornerRadiusDishPanel"); Rect rect = new Rect(0, 0, dGrid.Width, dishImageHeight); // изображение _dishImageBrush = new ImageBrush() { ImageSource = _dishItem.Image }; _pathImage = new Path() { Name = "pathDishImage", Data = new RectangleGeometry(rect, dishImageCornerRadius, dishImageCornerRadius), Fill = _dishImageBrush }; _pathImage.PreviewMouseLeftButtonUp += CanvDescr_PreviewMouseLeftButtonUp; //pathImage.Effect = new DropShadowEffect(); // добавить в контейнер Grid.SetRow(_pathImage, 2); dGrid.Children.Add(_pathImage); // кнопка отображения описания _btnDescr = new Border() { Name = "btnDescr", Width = dishPanelDescrButtonSize, Height = dishPanelDescrButtonSize, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Tag = 0, Background = Brushes.White, CornerRadius = new CornerRadius(0.5 * dishPanelDescrButtonSize), Margin = new Thickness(0, 0.3 * dishPanelDescrButtonSize, 0.3 * dishPanelDescrButtonSize, 0) }; _btnDescr.PreviewMouseLeftButtonUp += CanvDescr_PreviewMouseLeftButtonUp; // буковка i TextBlock btnDescrText = new TextBlock(new Run("i")) { FontSize = dishPanelTextFontSize, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; _btnDescr.Child = btnDescrText; // добавить в контейнер Grid.SetRow(_btnDescr, 2); dGrid.Children.Add(_btnDescr); Grid.SetZIndex(_btnDescr, 2); // описание блюда LinearGradientBrush lgBrush = new LinearGradientBrush() { StartPoint = new Point(0.5, 0), EndPoint = new Point(0.5, 1) }; lgBrush.GradientStops.Add(new GradientStop(Colors.Black, 0)); lgBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.5)); lgBrush.GradientStops.Add(new GradientStop((Color)AppLib.GetAppResource("appColorDarkPink"), 1)); _descrTextBorder = new Border() { Name = "brdDescrText", Width = dGrid.Width, Height = dishImageHeight, CornerRadius = new CornerRadius(dishImageCornerRadius), Background = lgBrush, Opacity = 0, Visibility = Visibility.Hidden }; _descrTextBorder.PreviewMouseLeftButtonUp += CanvDescr_PreviewMouseLeftButtonUp; // добавить в контейнер Grid.SetRow(_descrTextBorder, 2); dGrid.Children.Add(_descrTextBorder); _descrText = new TextBlock() { Name = "tblDescrText", Width = dGrid.Width, Opacity = 0, Padding = new Thickness(dishPanelDescriptionFontSize), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center, TextWrapping = TextWrapping.Wrap, FontSize = dishPanelDescriptionFontSize, Foreground = Brushes.White, Text = AppLib.GetLangText(_dishItem.langDescriptions), Visibility = Visibility.Hidden }; _descrText.Effect = new BlurEffect() { Radius = 20 }; _descrText.PreviewMouseLeftButtonUp += CanvDescr_PreviewMouseLeftButtonUp; // добавить в контейнер Grid.SetRow(_descrText, 2); dGrid.Children.Add(_descrText); }
private void setDishAddButton() { // высота строки кнопки добавления double dishPanelAddButtonRowHeight = (double)AppLib.GetAppGlobalValue("dishPanelAddButtonRowHeight"); double cornerRadiusButton = (double)AppLib.GetAppGlobalValue("cornerRadiusButton"); // размеры тени под кнопками (от высоты самой кнопки, dishPanelAddButtonHeight) double addButtonShadowDepth = 0.1d * dishPanelAddButtonRowHeight; double addButtonBlurRadius = 0.35d * dishPanelAddButtonRowHeight; DropShadowEffect _shadowEffect = new DropShadowEffect() { Direction = 270, Color = Color.FromArgb(0xFF, 0xCF, 0x44, 0x6B), Opacity = 1.0, ShadowDepth = addButtonShadowDepth, BlurRadius = addButtonBlurRadius }; // кнопка с тенью _btnAddDish = new Border() { Name = "btnAddDish", Tag = _dishItem.RowGUID.ToString(), VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Center, CornerRadius = new CornerRadius(cornerRadiusButton), Background = (Brush)AppLib.GetAppGlobalValue("addButtonBackgroundTextColor"), Width = dGrid.Width, Height = Math.Floor((AppLib.IsAppVerticalLayout ? 0.5d : 0.7d) * dishPanelAddButtonRowHeight), ClipToBounds = false }; // Effect = _shadowEffect _btnAddDish.PreviewMouseUp += BtnAddDish_PreviewMouseLeftButtonUp; _btnAddDishTextBlock = new TextBlock() { Name = "tbAdd", Text = (string)AppLib.GetLangText((Dictionary <string, string>)AppLib.GetAppGlobalValue("btnSelectDishText")), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, FontSize = _dishPanelAddButtoFontSize, Foreground = Brushes.White }; if (_hasGarnishes == false) // не Воки { // грид с кнопками цены и строки "Добавить", две колонки: с ценой и текстом Grid grdPrice = new Grid(); grdPrice.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(dGrid.Width / 3d, GridUnitType.Pixel) }); grdPrice.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(dGrid.Width * 2d / 3d, GridUnitType.Pixel) }); Border brdPrice = new Border() { VerticalAlignment = VerticalAlignment.Top, Width = grdPrice.ColumnDefinitions[0].Width.Value, Height = _btnAddDish.Height, CornerRadius = new CornerRadius(cornerRadiusButton, 0, 0, cornerRadiusButton), Background = (Brush)AppLib.GetAppGlobalValue("addButtonBackgroundPriceColor"), }; TextBlock tbPrice = new TextBlock() { Text = string.Format((string)AppLib.GetAppResource("priceFormatString"), _dishItem.Price), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, FontSize = _dishPanelAddButtoFontSize, Foreground = Brushes.White }; brdPrice.Child = tbPrice; Grid.SetColumn(brdPrice, 0); grdPrice.Children.Add(brdPrice); Grid.SetColumn(_btnAddDishTextBlock, 1); grdPrice.Children.Add(_btnAddDishTextBlock); _btnAddDish.Child = grdPrice; Grid.SetRow(_btnAddDish, 4); } else // Воки { // кнопка-приглашение _btnInvitation = new Border() { Name = "btnInvitation", VerticalAlignment = VerticalAlignment.Top, Width = Math.Floor(dGrid.Width), Height = _btnAddDish.Height, CornerRadius = new CornerRadius(cornerRadiusButton), Background = Brushes.White, BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1), SnapsToDevicePixels = true }; TextBlock tbInvitation = new TextBlock() { Name = "tbInvitation", Text = (string)AppLib.GetLangText((Dictionary <string, string>)AppLib.GetAppGlobalValue("btnSelectGarnishText")), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, FontSize = _dishPanelAddButtoFontSize, Foreground = Brushes.Gray }; _btnInvitation.Child = tbInvitation; // добавить в контейнер _btnInvitation.Child = tbInvitation; _btnInvitation.SetValue(Grid.RowProperty, 6); dGrid.Children.Add(_btnInvitation); _btnAddDish.Child = _btnAddDishTextBlock; _btnAddDish.SetValue(Grid.RowProperty, 6); //_btnAddDish.Visibility = Visibility.Hidden; _btnAddDish.Opacity = 0; } dGrid.Children.Add(_btnAddDish); } // method
private void createGarnishButton() { base.Height = _height; base.Width = _width; // подложка кнопки Path _pathBase = getGarnPath(_width, _height); //if (_garnItem.Image == null) //{ // _pathBase.Fill = _notSelectBrush; //} //else //{ _pathBase.Fill = new ImageBrush() { ImageSource = _garnItem.Image }; _pathBase.Stretch = Stretch.UniformToFill; string sVal = (string)AppLib.GetAppGlobalValue("dishPanelGarnishBrightness"); _pathBase.Opacity = (sVal == null) ? 1.0 : sVal.ToDouble(); //} base.Children.Add(_pathBase); // выделение кнопки _pathSelected = getGarnPath(_width, _height); Color c = ((SolidColorBrush)AppLib.GetAppGlobalValue("appSelectedItemColor")).Color; Color c1 = new Color(); c1.A = 0xAA; c1.R = c.R; c1.G = c.G; c1.B = c.B; _pathSelected.Fill = new SolidColorBrush(c1); _pathSelected.Visibility = Visibility.Collapsed; base.Children.Add(_pathSelected); double dMarg = 0.05 * _width; string grnText = (string)AppLib.GetLangText((Dictionary <string, string>)_garnItem.langNames); _tbGarnishName = new TextBlock() { Text = grnText, Width = _width - (2 * dMarg), TextWrapping = TextWrapping.Wrap, VerticalAlignment = VerticalAlignment.Top, TextAlignment = TextAlignment.Center, FontSize = _fontSize, Margin = new Thickness(dMarg), Foreground = _notSelectTextBrush }; base.Children.Add(_tbGarnishName); string grnPrice = string.Format((string)AppLib.GetAppResource("priceFormatString"), _garnItem.Price); _tbGarnishPrice = new TextBlock() { Text = grnPrice, Width = _width, VerticalAlignment = VerticalAlignment.Bottom, TextAlignment = TextAlignment.Center, FontSize = _fontSize, FontWeight = FontWeights.Bold, Foreground = Brushes.Black }; base.Children.Add(_tbGarnishPrice); }