예제 #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int mode = (Mode.ToLower().StartsWith("back") == true) ? 0 : 1; // 0-цвет фона, 1-цвет текста

            Brush retVal = (mode == 0) ? (SolidColorBrush)AppLib.GetAppGlobalValue("appBackgroundColor") : new SolidColorBrush(Colors.White);

            if (value == null)
            {
                return(retVal);
            }
            List <DishAdding> garList = (List <DishAdding>)value;  // SelectedGarnishes

            if (garList.Count == 0)
            {
                return(retVal);
            }

            foreach (DishAdding item in garList)
            {
                if (parameter == null)
                {
                }
                else
                {
                    if (item.Uid == parameter.ToString())
                    {
                        retVal = (mode == 0) ? (SolidColorBrush)AppLib.GetAppGlobalValue("appSelectedItemColor") : new SolidColorBrush(Colors.Black);
                    }
                }
            }

            return(retVal);
        }
예제 #2
0
        private void setLayout()
        {
            // размеры
            double scrWidth  = (double)AppLib.GetAppGlobalValue("screenWidth");
            double scrHeight = (double)AppLib.GetAppGlobalValue("screenHeight");

            // vertical
            if (AppLib.IsAppVerticalLayout)
            {
                this.Width       = scrWidth; this.Height = scrHeight;
                panelMain.Height = 0.55 * scrHeight;
                panelMain.Width  = 0.7 * panelMain.Height;
            }
            // horizontal
            else
            {
                panelMain.Height = 0.7 * scrHeight;
                panelMain.Width  = 0.7 * panelMain.Height;
            }

            // радиусы закругления
            if (panelMain is Border)
            {
                double radius  = 0.07 * panelMain.Width;
                double radius1 = 0.9 * radius;
                (panelMain as Border).CornerRadius       = new CornerRadius(radius);
                (brdTitle as Border).CornerRadius        = new CornerRadius(radius1, radius1, 0, 0);
                (brdFooterCancel as Border).CornerRadius = new CornerRadius(0, 0, 0, radius1);
                (brdFooterOk as Border).CornerRadius     = new CornerRadius(0, 0, radius1, 0);
            }

            double d1 = 0.5 * (double)AppLib.GetAppGlobalValue("appFontSize1");

            txtInput.Margin = new Thickness(d1, 0, d1, 0);
        }
예제 #3
0
        public MainMenuGarnish(DishItem dishItem, int garnIndex, double garnHeight, double garnWidth, Grid dishContentPanel)
        {
            _dishItem     = dishItem;
            _garnIndex    = garnIndex;
            _garnItem     = _dishItem.Garnishes[garnIndex];
            _height       = garnHeight;
            _width        = garnWidth;
            _contentPanel = dishContentPanel;

            _fontSize   = (double)AppLib.GetAppGlobalValue("appFontSize5");
            _fontSizeUp = (double)AppLib.GetAppGlobalValue("appFontSize4");

            _selectBackgroundBrush    = (Brush)AppLib.GetAppGlobalValue("appSelectedItemColor");
            _notSelectBackgroundBrush = (Brush)AppLib.GetAppGlobalValue("garnishBackgroundColor");
            _selectTextBrush          = (Brush)AppLib.GetAppGlobalValue("addButtonBackgroundPriceColor");
            _notSelectTextBrush       = Brushes.Black;
            //_shadow = new DropShadowEffect() { BlurRadius = 5, Opacity = 0.5, ShadowDepth = 1 };

            _isSelected = false;

            this.DishWithGarnishImageBrush = new ImageBrush()
            {
                ImageSource = _garnItem.ImageDish
            };
            createGarnishButton();

            base.MouseUp += MainMenuGarnish_PreviewMouseDown;
        }
예제 #4
0
        public DishPopup(DishItem dishItem, BitmapImage img)
        {
            InitializeComponent();

            AppLib.WriteAppAction($"DishPopup|Открывается всплывашка для блюда '{dishItem.langNames["ru"]}'...");

            this.Loaded += DishPopup_Loaded;

            // init private vars
            _notSelTextColor = new SolidColorBrush(Colors.Black);
            _selTextColor    = (SolidColorBrush)AppLib.GetAppGlobalValue("addButtonBackgroundTextColor");

            setWinLayout();

            // set Win data
            _currentDish     = dishItem;
            this.DataContext = _currentDish;

            dishImage.Fill = new ImageBrush(img);

            //if (AppLib.GetAppSetting("IsWriteWindowEvents").ToBool())
            //{
            //    _eventsLog = new UserActionsLog(this, EventsMouseEnum.Bubble, EventsKeyboardEnum.None, EventsTouchEnum.Bubble, UserActionLog.LogFilesPathLocationEnum.App_Logs, true, false);
            //}

            updatePriceControl();
        }
예제 #5
0
        private void createContentPanel()
        {
            // высота строки заголовка
            double dishPanelHeaderRowHeight = (double)AppLib.GetAppGlobalValue("dishPanelHeaderRowHeight");
            // высота строки изображения
            double dishPanelImageRowHeight = (double)AppLib.GetAppGlobalValue("dishPanelImageRowHeight");
            // высота строки гарниров
            double dishPanelGarnishesRowHeight = (double)AppLib.GetAppGlobalValue("dishPanelGarnishesRowHeight");
            // высота строки кнопки добавления
            double dishPanelAddButtonRowHeight = (double)AppLib.GetAppGlobalValue("dishPanelAddButtonRowHeight");
            //private double dishPanelAddButtonTextSize;
            // расстояния между строками панели блюда
            double dishPanelRowMargin1 = (double)AppLib.GetAppGlobalValue("dishPanelRowMargin1"),
                   dishPanelRowMargin2 = (double)AppLib.GetAppGlobalValue("dishPanelRowMargin2");

            dGrid        = new Grid();
            dGrid.Width  = contentPanelWidth;
            dGrid.Height = currentContentPanelHeight;
            //dGrid.Background = Brushes.Blue;
            //   Определение строк
            // 0. строка заголовка
            dGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(dishPanelHeaderRowHeight, GridUnitType.Pixel)
            });
            // 1. разделитель
            dGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(dishPanelRowMargin1, GridUnitType.Pixel)
            });
            // 2. строка изображения
            dGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(dishPanelImageRowHeight, GridUnitType.Pixel)
            });
            // 3. разделитель
            dGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(dishPanelRowMargin2, GridUnitType.Pixel)
            });
            if (_hasGarnishes)
            {
                // 4. строка гарниров
                dGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(dishPanelGarnishesRowHeight, GridUnitType.Pixel)
                });
                // 5. разделитель
                dGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(dishPanelRowMargin2, GridUnitType.Pixel)
                });
            }
            // 6. строка кнопок
            dGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(dishPanelAddButtonRowHeight, GridUnitType.Pixel)
            });
        }  // method
예제 #6
0
        public MainMenuDishPanel(DishItem dishItem, double leftPos, double topPos)
        {
            _parentWindow              = (Window)App.Current.MainWindow;
            _dishItem                  = dishItem;
            _leftPos                   = leftPos; _topPos = topPos;
            _hasGarnishes              = (_dishItem.Garnishes != null);
            currentPanelHeight         = (_hasGarnishes) ? (double)AppLib.GetAppGlobalValue("dishPanelHeightWithGarnish") : (double)AppLib.GetAppGlobalValue("dishPanelHeight");
            _brushSelectedItem         = (SolidColorBrush)AppLib.GetAppGlobalValue("appSelectedItemColor");
            _dishPanelAddButtoFontSize = Convert.ToDouble(AppLib.GetAppGlobalValue("dishPanelAddButtoFontSize"));
            _animBCol                  = (ColorAnimation)AppLib.GetAppGlobalValue("AddDishButtonBackgroundColorAnimation");
            // анимация текста на кнопке добавления блюда
            _tAnim = new TextAnimation()
            {
                IsAnimFontSize         = true,
                DurationFontSize       = 200,
                FontSizeKoef           = 1.2,
                RepeatBehaviorFontSize = 3,
                IsAnimTextBlur         = false,
            };
            _tAnim.Completed += _tAnim_Completed;

            // декоратор для панели блюда (должен быть для корректной работы ручного скроллинга)
            setDishPanel();
            // панель содержания
            createContentPanel();
            // Заголовок панели
            setDishPanelHeader();
            // изображение блюда и описание
            setDishDescription();
            // гарниры для Воков
            if (_hasGarnishes)
            {
                createGarnisheButtons();
            }
            // изображения кнопок добавления
            setDishAddButton();

            // прочитать и установить длительность анимации
            double cfgDuration = getDuration();

            if (cfgDuration > 0)
            {
                // показать подсказку
                _sbDescrShow            = getDescrStoryboard(true, cfgDuration);
                _sbDescrShow.Completed += _sbDescrShow_Completed;
                // скрыть подсказку
                _sbDescrHide            = getDescrStoryboard(false, 0.7 * cfgDuration);
                _sbDescrHide.Completed += _sbDescrHide_Completed;
            }

            base.Children.Add(dGrid); Grid.SetRow(dGrid, 1); Grid.SetColumn(dGrid, 1);

            _daAddBtnShow            = new DoubleAnimation(0d, 1d, TimeSpan.FromMilliseconds(300));
            _daAddBtnHide            = new DoubleAnimation(1d, 0d, TimeSpan.FromMilliseconds(300));
            _daAddBtnShow.Completed += _daOpacity_Completed;
        }
예제 #7
0
        private void setWinLayout()
        {
            // размеры
            this.Width  = (double)AppLib.GetAppGlobalValue("screenWidth");
            this.Height = (double)AppLib.GetAppGlobalValue("screenHeight");
            this.Top    = 0; this.Left = 0;

            double pnlMenuWidth  = (double)AppLib.GetAppGlobalValue("categoriesPanelWidth");
            double pnlMenuHeight = (double)AppLib.GetAppGlobalValue("categoriesPanelHeight");

            brdAboveFolderMenu.Height = pnlMenuHeight;
            brdAboveFolderMenu.Width  = pnlMenuWidth;
            // грид блюд
            double pnlDishesWidth = (double)AppLib.GetAppGlobalValue("dishesPanelWidth");
            double pnlDishesHeight = (double)AppLib.GetAppGlobalValue("dishesPanelHeight");
            double pnlContentWidth, pnlContentHeight, pnlContentTop, pnlContentLeft;

            double dH;
            double btnTextFontSize;

            // вертикальное размещение
            if (AppLib.IsAppVerticalLayout == true)
            {
                DockPanel.SetDock(brdAboveFolderMenu, Dock.Top);
                pnlContentWidth  = 0.8 * pnlDishesWidth;
                pnlContentHeight = 0.1 * pnlDishesHeight;
                pnlContentTop    = (pnlDishesHeight - pnlContentHeight) / 2d;
                pnlContentTop   *= 0.5;
                pnlContentLeft   = (pnlDishesWidth - pnlContentWidth) / 2d;
            }
            // горизонтальное размещение
            else
            {
                DockPanel.SetDock(brdAboveFolderMenu, Dock.Left);
                pnlContentWidth  = 0.7 * pnlDishesWidth;
                pnlContentHeight = 0.2 * pnlDishesHeight;
                pnlContentTop    = (pnlDishesHeight - pnlContentHeight) / 2d;
                pnlContentLeft   = (pnlDishesWidth - pnlContentWidth) / 2d;
            }

            // панель содержания
            brdDialog.Width  = pnlContentWidth; brdDialog.Height = pnlContentHeight;
            brdDialog.Margin = new Thickness(pnlContentLeft, pnlContentTop,
                                             pnlDishesWidth - pnlContentWidth - pnlContentLeft,
                                             pnlDishesHeight - pnlContentHeight - pnlContentTop);
            dH = pnlContentHeight / gridDialog.RowDefinitions.Sum(r => r.Height.Value);

            btnTextFontSize     = 0.5 * dH;
            txtTakeOut.FontSize = btnTextFontSize;
            txtWordOr.FontSize  = btnTextFontSize;
            txtTakeIn.FontSize  = btnTextFontSize;
        }  // method
예제 #8
0
        private int getLineMargin(string appSettingKey)
        {
            int retVal = 0;

            object sAppSet = AppLib.GetAppGlobalValue(appSettingKey);

            if (sAppSet != null)
            {
                retVal = Convert.ToInt32(sAppSet);
            }

            return(retVal);
        }
예제 #9
0
        private void addTotalLine(FlowDocument doc, double fontSize, decimal totalPrice, string currencyName, int leftMargin)
        {
            Table t = new Table();

            t.FontSize        = fontSize;
            t.CellSpacing     = 0;
            t.BorderThickness = new Thickness(0, 1, 0, 0);
            t.BorderBrush     = new SolidColorBrush(Colors.Black);
            t.Margin          = new Thickness(0);
            t.Padding         = new Thickness(leftMargin, 10, 0, 0);

            // две колонки
            t.Columns.Add(new TableColumn()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            t.Columns.Add(new TableColumn()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            TableRowGroup rg = new TableRowGroup();

            t.RowGroups.Add(rg);

            string    totalText = AppLib.GetLangText((Dictionary <string, string>)AppLib.GetAppGlobalValue("lblTotalText"));
            Run       r         = new Run(totalText);
            Paragraph p         = new Paragraph(r);

            p.TextAlignment = TextAlignment.Left;
            TableCell totalTextCell = new TableCell();

            totalTextCell.Blocks.Add(p);

            string priceText = string.Format("{0:0.00} {1}", totalPrice, currencyName);

            r               = new Run(priceText);
            r.FontWeight    = FontWeights.Bold;
            p               = new Paragraph(r);
            p.TextAlignment = TextAlignment.Right;
            TableCell priceTextCell = new TableCell();

            priceTextCell.Blocks.Add(p);

            TableRow tr = new TableRow();

            tr.Cells.Add(totalTextCell);
            tr.Cells.Add(priceTextCell);
            rg.Rows.Add(tr);

            doc.Blocks.Add(t);
        }
예제 #10
0
        public void ResetLang()
        {
            List <TextBlock> tbList = AppLib.FindLogicalChildren <TextBlock>(dGrid).ToList();

            // заголовок (состоит из элементов Run)
            var hdRuns = tbList[0].Inlines.Where(t => (t is Run)).ToList();

            if (hdRuns.Count >= 0)
            {
                ((Run)hdRuns[0]).Text = AppLib.GetLangText(_dishItem.langNames);
            }
            if (hdRuns.Count >= 3)
            {
                ((Run)hdRuns[2]).Text = " " + AppLib.GetLangText(_dishItem.langUnitNames);
            }

            // tbList[1] - буковка i на кнопке отображения описания

            // описание блюда
            if ((_hasGarnishes == true) && (this._selectedGarnIndex != -1))
            {
                _descrText.Text = AppLib.GetLangText(_dishItem.Garnishes[this._selectedGarnIndex].langDishDescr);
            }
            else
            {
                _descrText.Text = AppLib.GetLangText(_dishItem.langDescriptions);
            }

            // кнопка Добавить с тенью
            TextBlock tbAdd = tbList.First(t => t.Name == "tbAdd");

            if (tbAdd != null)
            {
                tbAdd.Text = (string)AppLib.GetLangText((Dictionary <string, string>)AppLib.GetAppGlobalValue("btnSelectDishText"));
            }

            if (_hasGarnishes == true)
            {
                TextBlock tbInv = tbList.First(t => t.Name == "tbInvitation");
                if (tbInv != null)
                {
                    tbInv.Text = (string)AppLib.GetLangText((Dictionary <string, string>)AppLib.GetAppGlobalValue("btnSelectGarnishText"));
                }

                foreach (MainMenuGarnish garn in _grdGarnishes.Children)
                {
                    garn.ResetLangName();
                }
            }
        } //  method
예제 #11
0
        private void createDishesCanvas()
        {
            //  РАЗМЕРЫ ПАНЕЛИ БЛЮД
            double dishesPanelWidth    = (double)AppLib.GetAppGlobalValue("dishesPanelWidth");
            double dishPanelLeftMargin = (double)AppLib.GetAppGlobalValue("dishPanelLeftMargin");
            double dishPanelWidth      = (double)AppLib.GetAppGlobalValue("dishPanelWidth");
            int    dColCount           = AppLib.GetAppGlobalValue("dishesColumnsCount").ToString().ToInt();

            int iRowsCount = 0;

            if (mItem.Dishes.Count > 0)
            {
                iRowsCount = ((mItem.Dishes.Count - 1) / dColCount) + 1;
            }

            DishItem dish;
            int      iRow, iCol; double leftPos, topPos;

            for (int i = 0; i < mItem.Dishes.Count; i++)
            {
                dish = mItem.Dishes[i];

                // размеры канвы с панелями блюд
                bool   isExistGarnishes   = (dish.Garnishes != null);
                double currentPanelHeight = (isExistGarnishes) ? (double)AppLib.GetAppGlobalValue("dishPanelHeightWithGarnish") : (double)AppLib.GetAppGlobalValue("dishPanelHeight");
                if (double.IsNaN(base.Width) || (base.Width == 0))
                {
                    base.Width  = dishesPanelWidth;
                    base.Height = iRowsCount * currentPanelHeight;
                }

                // положение панели блюда
                iRow    = i / dColCount; iCol = i % dColCount;
                leftPos = (dishPanelLeftMargin + iCol * dishPanelWidth);
                topPos  = iRow * currentPanelHeight;

                MainMenuDishPanel dishPanel = new MainMenuDishPanel(dish, leftPos, topPos);

                base.Children.Add(dishPanel);
            }  // for dishes

            //base.Background = Brushes.Gold;
            //base.Background = new SolidColorBrush(new Color() { R = (byte)rnd.Next(0,254), G= (byte)rnd.Next(0, 254), B= (byte)rnd.Next(0, 254), A=0xFF });
        } // method
예제 #12
0
        private MsgBoxExt getDelMsgBox()
        {
            string sYes = AppLib.GetLangTextFromAppProp("dialogBoxYesText");
            string sNo  = AppLib.GetLangTextFromAppProp("dialogBoxNoText");

            MsgBoxExt mBox = new MsgBoxExt()
            {
                TitleFontSize        = (double)AppLib.GetAppGlobalValue("appFontSize6"),
                MessageFontSize      = (double)AppLib.GetAppGlobalValue("appFontSize2"),
                MsgBoxButton         = MessageBoxButton.YesNo,
                ButtonsText          = string.Format(";;{0};{1}", sYes, sNo),
                ButtonBackground     = (System.Windows.Media.Brush)AppLib.GetAppGlobalValue("appBackgroundColor"),
                ButtonBackgroundOver = (System.Windows.Media.Brush)AppLib.GetAppGlobalValue("appBackgroundColor"),
                ButtonForeground     = Brushes.White,
                ButtonFontSize       = (double)AppLib.GetAppGlobalValue("appFontSize4")
            };

            return(mBox);
        }
예제 #13
0
        private void setDishPanel()
        {
            currentContentPanelHeight = (_hasGarnishes) ? (double)AppLib.GetAppGlobalValue("contentPanelHeightWithGarnish") : (double)AppLib.GetAppGlobalValue("contentPanelHeight");

            base.SnapsToDevicePixels = true;
            base.Width  = dishPanelWidth;
            base.Height = currentPanelHeight;
            base.SetValue(Canvas.LeftProperty, _leftPos);
            base.SetValue(Canvas.TopProperty, _topPos);

            // сетка 3х3
            double d1 = (dishPanelWidth - contentPanelWidth) / 2d;

            base.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(d1, GridUnitType.Pixel)
            });
            base.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(contentPanelWidth, GridUnitType.Pixel)
            });
            base.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(d1, GridUnitType.Pixel)
            });
            d1 = (currentPanelHeight - currentContentPanelHeight) / 2d;
            base.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(d1, GridUnitType.Pixel)
            });
            base.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(currentContentPanelHeight, GridUnitType.Pixel)
            });
            base.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(d1, GridUnitType.Pixel)
            });
        }
예제 #14
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string appPropName = null;

            if (value != null)
            {
                appPropName = value.ToString();
            }
            else if (parameter != null)
            {
                appPropName = parameter.ToString();
            }

            if (appPropName == null)
            {
                return(null);
            }

            object retVal = AppLib.GetAppGlobalValue(parameter.ToString());

            return(retVal);
        }
예제 #15
0
        // выбор блюда
        // ****** ??? процедура вызывается 2 раза!!!
        // если это MouseUp, если PreviewMouseUp - то один раз!!
        private void btnAddDish_MouseUp(object sender, MouseButtonEventArgs e)
        {
            _closeCause = "ButtonAddDish";
            AppLib.WriteAppAction("DishPopup|Нажата кнопка AddDish");
            e.Handled = true;

            // добавить блюдо в заказ
            OrderItem curOrder  = AppLib.GetCurrentOrder();
            DishItem  orderDish = _currentDish.GetCopyForOrder();  // сделать копию блюда со всеми добавками

            // изображение взять из элемента
            ImageBrush  imgBrush = (ImageBrush)dishImage.Fill;
            BitmapImage bmpImage = (imgBrush.ImageSource as BitmapImage);

            orderDish.Image = bmpImage;

            curOrder.Dishes.Add(orderDish);

            //Debug.Print("order.Dishes.Count = " + curOrder.Dishes.Count.ToString());

            // добавить в заказ рекомендации
            if ((_currentDish.SelectedRecommends != null) && (_currentDish.SelectedRecommends.Count > 0))
            {
                foreach (DishItem item in _currentDish.SelectedRecommends)
                {
                    curOrder.Dishes.Add(item);
                }
            }

            if ((bool)AppLib.GetAppGlobalValue("isAnimatedSelectVoki"))
            {
                // закрыть окно после завершения анимации
                animateDishSelection();
            }
            else
            {
                updatePriceAndClose(false);
            }
        }
예제 #16
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double d1 = 0; //, d2 = 0;
            //double.TryParse((value??"0").ToString(), out d1);
            //string p = (parameter ?? "0").ToString();
            //double.TryParse(p.ToString(), out d2);
            //if (d2 == 0)
            //{
            //    if (p.Contains(".")) p = p.Replace('.', ',');
            //    else if (p.Contains(",")) p = p.Replace(',', '.');
            //    double.TryParse(p, out d2);
            //}
            //d1 *= d2;  // радиус

            var v = AppLib.GetAppGlobalValue("cornerRadiusButton");

            if (v == null)
            {
                return(null);
            }

            d1 = v.ToString().ToDouble();

            CornerRadius retVal;
            string       side = (Side == null) ? "all" : Side.ToLower();

            retVal = new CornerRadius(d1);
            if (side == "left")
            {
                retVal.TopRight = 0; retVal.BottomRight = 0;
            }
            else if (side == "right")
            {
                retVal.TopLeft = 0; retVal.BottomLeft = 0;
            }
            return(retVal);
        }
예제 #17
0
        private void initUI()
        {
            double pnlWidth = (double)AppLib.GetAppGlobalValue("categoriesPanelWidth");
            double pnlHeight = (double)AppLib.GetAppGlobalValue("categoriesPanelHeight");
            double promoFontSize, dH, d1, dKoefPortionCount;
            double pnlW, titleFontSize;
            // грид блюд
            double dishesPanelWidth  = (double)AppLib.GetAppGlobalValue("dishesPanelWidth");
            double dishesPanelHeight = (double)AppLib.GetAppGlobalValue("dishesPanelHeight");

            scrollDishes.Height = dishesPanelHeight; scrollDishes.Width = dishesPanelWidth;
            double dishNameFontSize, dishUnitFontSize;
            string backgroundImage;
            Style  stl; Setter str;

            // дизайн вертикальный: панель меню СВЕРХУ
            if (AppLib.IsAppVerticalLayout)
            {
                DockPanel.SetDock(gridMenuSide, Dock.Top);
                //                menuSidePanelLogo.Background = (Brush)AppLib.GetAppGlobalValue("appBackgroundColor");
                // грид меню
                //pnlHeight *= 0.8;
                gridMenuSide.Height = pnlHeight;
                gridMenuSide.Width  = pnlWidth;

                // панель меню на всю ширину экрана
                dH = pnlHeight / 10d;
                gridMenuSide.RowDefinitions[0].Height = new GridLength(3.0 * dH);
                gridMenuSide.RowDefinitions[1].Height = new GridLength(0.0 * dH);
                gridMenuSide.RowDefinitions[2].Height = new GridLength(3.5 * dH);
                gridMenuSide.RowDefinitions[3].Height = new GridLength(0.0 * dH);
                gridMenuSide.RowDefinitions[4].Height = new GridLength(0.0 * dH);
                gridMenuSide.RowDefinitions[5].Height = new GridLength(3.5 * dH);

                // stackPanel для Logo
                gridMenuSide.Children.Remove(imageLogo);
                StackPanel pnlLogo = new StackPanel();
                pnlLogo.Orientation = Orientation.Horizontal;
                pnlLogo.Background  = new SolidColorBrush(Color.FromRgb(0x62, 0x1C, 0x55));

                pnlW = gridMenuSide.Width - 2.0 * dH;
                // перенести кнопку Назад
                gridMenuSide.Children.Remove(btnReturn);
                pnlLogo.Children.Add(btnReturn);
                btnReturn.Width = 0.3 * pnlW;  // общая ширина = ширина элемента + отступы справа/слева
                txtReturn.HorizontalAlignment = HorizontalAlignment.Left;
                btnReturn.Margin     = new Thickness(dH, 0, 0, 0);
                btnReturn.Background = pnlLogo.Background;
                //   языковые кнопки
                gridMenuSide.Children.Remove(gridLang);
                gridLang.Height = 2.0 * dH;  // необходимо для расчета размера внутренних кнопок
                gridLang.Width  = 0.2 * pnlW;
                gridLang.Margin = new Thickness(0.1 * pnlW, 0, 0.1 * pnlW, 0);
                pnlLogo.Children.Add(gridLang);
                gridLang.Visibility = Visibility.Visible;
                // языковые кнопки, фон для внешних Border, чтобы они были кликабельные
                btnLangUa.Background = pnlLogo.Background;
                btnLangRu.Background = pnlLogo.Background;
                btnLangEn.Background = pnlLogo.Background;
                double dMin      = Math.Min(gridLang.Height, gridMenuSide.Width / (0.3 + 1.0 + 0.3 + 1.0 + 0.3 + 1.0 + 0.3));
                double dLangSize = 0.7 * dMin;
                setLngInnerBtnSizes(btnLangUaInner, lblLangUa, dLangSize);
                setLngInnerBtnSizes(btnLangRuInner, lblLangRu, dLangSize);
                setLngInnerBtnSizes(btnLangEnInner, lblLangEn, dLangSize);

                // перенести промокод
                gridMenuSide.Children.Remove(gridPromoCode);
                gridPromoCode.ColumnDefinitions[3].Width = new GridLength(0.0 * dH);
                gridPromoCode.Width = 0.3 * pnlW;
                gridPromoCode.HorizontalAlignment = HorizontalAlignment.Right;
                gridPromoCode.Height = 1.5 * dH;
                promoFontSize        = 0.5 * dH;
                pnlLogo.Children.Add(gridPromoCode);

                Grid.SetRow(pnlLogo, 0);
                gridMenuSide.Children.Add(pnlLogo);

                // строка с общей стоимостью
                pnlTotal.Orientation   = Orientation.Horizontal;
                txtOrderPrice.Margin   = new Thickness(20, 0, 0, 0);
                pnlTotalLabel.FontSize = (double)AppLib.GetAppGlobalValue("appFontSize2");
                txtOrderPrice.FontSize = (double)AppLib.GetAppGlobalValue("appFontSize1");

                // кнопка Оформить
                btnPrintCheck.Margin       = new Thickness(dH, 0.0 * dH, dH, 0.8 * dH);
                btnPrintCheck.CornerRadius = new CornerRadius((double)AppLib.GetAppGlobalValue("cornerRadiusButton"));
                txtPrintCheck.FontSize     = (double)AppLib.GetAppGlobalValue("appFontSize4");
                txtPrintCheck.FontWeight   = FontWeights.Bold;
                gridMenuSide.Children.Remove(txtCashier);
                pnlPrintCheck.Children.Add(txtCashier);
                txtCashier.Style = (Style)this.Resources["goToCashierVer"];

                // фон
                backgroundImage = AppLib.GetImageFullFileName((string)AppLib.GetAppGlobalValue("BackgroundImageVertical"));

                setLangButtonStyle(true);   // "включить" текущую языковую кнопку

                // панели блюд
                dishBorderHeight  = (dishesPanelHeight - dishesListTitle.ActualHeight) / 6.0;
                titleFontSize     = 0.015 * dishesPanelHeight;
                dishNameFontSize  = 0.09 * dishBorderHeight;
                dishUnitFontSize  = 0.08 * dishBorderHeight;
                dKoefPortionCount = 1.5d;
                // отступы кнопок изменения кол-ва блюда
                setStylePropertyValue("dishPortionImageStyle", "Margin", new Thickness(0.03 * dishBorderHeight));
                setStylePropertyValue("dishDelImageStyle", "Margin", new Thickness(0.1 * dishBorderHeight));
            }

            // дизайн горизонтальный: панель меню слева
            else
            {
                DockPanel.SetDock(dockMain, Dock.Left);

                // грид меню
                gridMenuSide.Height = pnlHeight;
                gridMenuSide.Width  = pnlWidth;
                dH = pnlHeight / 13d;

                // промокод
                gridPromoCode.Height = 0.6 * dH;
                gridPromoCode.Margin = new Thickness(0, 0, 0, 0.4 * dH);
                promoFontSize        = 0.3 * gridPromoCode.Height;

                txtCashier.Margin = new Thickness(0.5 * dH, 0, 0.5 * dH, 0);

                // фон
                backgroundImage = AppLib.GetImageFullFileName((string)AppLib.GetAppGlobalValue("BackgroundImageHorizontal"));

                dishBorderHeight  = (dishesPanelHeight - dishesListTitle.ActualHeight) / 4.0;
                titleFontSize     = 0.02 * dishesPanelHeight;
                dishNameFontSize  = 0.09 * dishBorderHeight;
                dishUnitFontSize  = 0.08 * dishBorderHeight;
                dKoefPortionCount = 1.5;
                // отступы кнопок изменения кол-ва блюда
                setStylePropertyValue("dishPortionImageStyle", "Margin", new Thickness(0.03 * dishBorderHeight));
                setStylePropertyValue("dishDelImageStyle", "Margin", new Thickness(0.15 * dishBorderHeight));
            }

            // фон
            imgBackground.Source = ImageHelper.GetBitmapImage(backgroundImage);
            // яркость фона
            imgBackground.Opacity = (double)AppLib.GetAppGlobalValue("BackgroundImageBrightness", 0.3);

            // высота рамки блюда в заказе, из стиля
            setStylePropertyValue("dishBorderStyle", "MinHeight", dishBorderHeight);
            // элементы в строке блюда, относительно ее высоты dishBorderHeight
            // внутренние поля в рамке блюда
            setStylePropertyValue("dishItemStyle", "Padding", new Thickness(0.06 * dishBorderHeight, 0.05 * dishBorderHeight, 0, 0.05 * dishBorderHeight));

            // изображение блюда (1:1.33)
            setStylePropertyValue("dishImageBorderStyle", "Height", 1.0 * dishBorderHeight);
            setStylePropertyValue("dishImageBorderStyle", "Width", 1.33 * dishBorderHeight);

            //  наименование блюда
            setStylePropertyValue("dishNameStyle", "FontSize", dishNameFontSize);
            // ед.изм. блюда
            setStylePropertyValue("dishUnitStyle", "FontSize", dishUnitFontSize);
            // маркеры блюда
            setStylePropertyValue("dishMarksItemStyle", "Height", 1.2 * dishUnitFontSize);

            // заголовок ингредиентов
            setStylePropertyValue("dishIngrTitleStyle", "FontSize", dishUnitFontSize);
            // наименование и цена ингредиента
            setStylePropertyValue("dishIngrStyle", "FontSize", dishUnitFontSize);
            setStylePropertyValue("dishIngrDelImageStyle", "Width", 2.5 * dishUnitFontSize);
            setStylePropertyValue("dishIngrDelImageStyle", "Padding", new Thickness(0.5 * dishUnitFontSize, 0.2 * dishUnitFontSize, 0.5 * dishUnitFontSize, 0.2 * dishUnitFontSize));
            // количество и цена порции
            setStylePropertyValue("dishPortionTextStyle", "FontSize", dKoefPortionCount * dishNameFontSize);

            // промокод
            AppLib.SetPromocodeTextStyle(txtPromoCode);

            // яркость фона
            string opacity = AppLib.GetAppSetting("BackgroundImageBrightness");

            if (opacity != null)
            {
                imgBackground.Opacity = opacity.ToDouble();
            }

            // заголовок списка
            dishesListTitle.Margin   = new Thickness(0, titleFontSize, 0, titleFontSize);
            dishesListTitle.FontSize = 1.5 * titleFontSize;

            // большие кнопки скроллинга
            var v = Enum.Parse(typeof(HorizontalAlignment), (string)AppLib.GetAppGlobalValue("dishesPanelScrollButtonHorizontalAlignment"));

            btnScrollDown.Width  = (double)AppLib.GetAppGlobalValue("dishesPanelScrollButtonSize");
            btnScrollDown.Height = (double)AppLib.GetAppGlobalValue("dishesPanelScrollButtonSize");
            btnScrollDown.HorizontalAlignment = (HorizontalAlignment)v;
            btnScrollUp.Width  = (double)AppLib.GetAppGlobalValue("dishesPanelScrollButtonSize");
            btnScrollUp.Height = (double)AppLib.GetAppGlobalValue("dishesPanelScrollButtonSize");
            btnScrollUp.HorizontalAlignment = (HorizontalAlignment)v;
        }  // method
예제 #18
0
        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
예제 #19
0
        }  // 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);
        }
예제 #20
0
        }  // method

        private void setDishPanelHeader()
        {
            // размер шрифтов
            double dishPanelHeaderFontSize    = Convert.ToDouble(AppLib.GetAppGlobalValue("dishPanelHeaderFontSize"));
            double dishPanelUnitCountFontSize = Convert.ToDouble(AppLib.GetAppGlobalValue("dishPanelUnitCountFontSize"));

            List <Inline> inlines = new List <Inline>();

            if (_dishItem.Marks != null)
            {
                foreach (DishAdding markItem in _dishItem.Marks)
                {
                    if (markItem.Image != null)
                    {
                        System.Windows.Controls.Image markImage = new System.Windows.Controls.Image();
                        //markImage.Effect = new DropShadowEffect() { Opacity = 0.7 };
                        markImage.Width = 1.5 * dishPanelHeaderFontSize;
                        //markImage.Height = 2*dishPanelHeaderFontSize;
                        markImage.Source  = markItem.Image;
                        markImage.Stretch = Stretch.Uniform;
                        InlineUIContainer iuc = new InlineUIContainer(markImage);
                        markImage.Margin = new Thickness(0, 0, 5, 5);
                        inlines.Add(iuc);
                    }
                }
            }
            inlines.Add(new Run()
            {
                Text       = AppLib.GetLangText(_dishItem.langNames),
                FontWeight = FontWeights.Bold,
                FontSize   = dishPanelHeaderFontSize
            });

            if (_dishItem.UnitCount != 0)
            {
                inlines.Add(new Run()
                {
                    Text      = "  " + _dishItem.UnitCount.ToString(),
                    FontStyle = FontStyles.Italic,
                    FontSize  = dishPanelUnitCountFontSize
                });
                inlines.Add(new Run()
                {
                    Text     = " " + AppLib.GetLangText(_dishItem.langUnitNames),
                    FontSize = dishPanelUnitCountFontSize
                });
            }

            double    dishPanelLeftMargin = (double)AppLib.GetAppGlobalValue("dishPanelLeftMargin");
            TextBlock tb = new TextBlock()
            {
                Foreground           = new SolidColorBrush(Colors.Black),
                TextWrapping         = TextWrapping.Wrap,
                VerticalAlignment    = VerticalAlignment.Center,
                TextAlignment        = TextAlignment.Center,
                LineStackingStrategy = LineStackingStrategy.BlockLineHeight, LineHeight = 1.2 * dishPanelHeaderFontSize
            };

            tb.Inlines.AddRange(inlines);

            Grid.SetRow(tb, 0); Grid.SetRowSpan(tb, 2);
            Grid.SetZIndex(tb, 5);
            dGrid.Children.Add(tb);
        }  // method
예제 #21
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string retVal = null;

            if (parameter == null)
            {
                retVal = AppLib.GetLangText((Dictionary <string, string>)value);
                if (IsUpper == true)
                {
                    retVal = retVal.ToUpper(culture);
                }
                if (IsLower == true)
                {
                    retVal = retVal.ToLower(culture);
                }
            }
            else
            {
                string mode = (string)parameter;
                int    i1   = mode.IndexOf('.');
                if (i1 > -1)
                {
                    string key = mode.Substring(0, i1);
                    string val = mode.Substring(i1 + 1);
                    if (key == "appSet")
                    {
                        Dictionary <string, string> lDict = (Dictionary <string, string>)AppLib.GetAppGlobalValue(val);
                        retVal = AppLib.GetLangText(lDict);
                        if (IsUpper == true)
                        {
                            retVal = retVal.ToUpper(culture);
                        }
                        if (IsLower == true)
                        {
                            retVal = retVal.ToLower(culture);
                        }
                    }
                }
            }

            return(retVal);
        }
예제 #22
0
        public bool CreateBill(out string msgBoxText)
        {
            bool retVal = true;

            msgBoxText = null;
            string userErrMsgSuffix = Environment.NewLine + AppLib.GetLangTextFromAppProp("userErrMsgSuffix");

            userErrMsgSuffix = userErrMsgSuffix.Replace("\\n", Environment.NewLine);

            AppLib.WriteLogTraceMessage("Создание пречека для заказа " + _order.OrderNumberForPrint.ToString());

            // свойства заказа, созадаваемые перед печатью чека:
            //      1. BarCodeValue - значение штрих-кода, 12 цифр (6 - yymmdd, 2 - код источника, 4 - номер чека для печати)
            //      2. LanguageTypeId - язык, который был выбран при создании чека (ua/en/ru)
            //--------------------------------------------------

            string deviceName = (string)AppLib.GetAppGlobalValue("ssdID", string.Empty);

            if (deviceName == string.Empty)
            {
                AppLib.WriteLogErrorMessage("В config-файле не найден элемент \"ssdID\" - идентификатор терминала самообслуживания.\n\t\tTrace: PrintBill.cs, CreateBill()");
                msgBoxText = "App config error: don't find 'ssdID' element." + userErrMsgSuffix;
                return(false);
            }
            if (deviceName.Length > 2)
            {
                deviceName = deviceName.Substring(0, 2);
            }

            // 1. OrderNumberForPrint
            if (_order.OrderNumberForPrint == -1)
            {
                AppLib.WriteLogErrorMessage("Класс PrintBill. Не указан номер заказа");
                msgBoxText = "App error: no order number." + userErrMsgSuffix;
                return(false);
            }

            // дату заказа создаем ПЕРЕД печатью
            _order.OrderDate = DateTime.Now;

            // 2. BarCodeValue
            //    идент.устройства - 2 символа
            if (deviceName.Length <= 2)
            {
                deviceName = string.Format("{0:D2}", deviceName);
            }
            else
            {
                deviceName = deviceName.Substring(0, 2);
            }
            //    дата заказа в формате yyMMdd - 6 символов
            //    номер заказа (для печати - случайный) в формате 0000 - 4 символа
            // т.к. в формате EAN-13 если первый символ - 0, то он удаляется, используем в начале дату
            string sBuf = (_order.OrderDate == null) ? "000000" : string.Format("{0:yyMMdd}", _order.OrderDate);

            _order.BarCodeValue = sBuf + _order.OrderNumberForPrint.ToString("000000");

            // 3. LanguageTypeId
            _order.LanguageTypeId = AppLib.AppLang;

            // ширина из config-файла
            int width = (int)AppLib.GetAppGlobalValue("BillPageWidht", 0);

            if (width == 0)
            {
                AppLib.WriteLogErrorMessage("В config-файле не указан элемент BillPageWidht с шириной чека. Берется значение по умолчанию - 300 (7,8см)");
                width = 300;
            }

            // принтеры в системе
            List <PrintQueue> printers = PrintHelper.getPrintersList();

            if (printers == null)
            {
                AppLib.WriteLogErrorMessage("В системе не зарегистрирован ни один принтер!!");
                msgBoxText = AppLib.GetLangTextFromAppProp("printConfigError");
                return(false);
            }
            else
            {
                try
                {
                    string sLog = string.Join(Environment.NewLine + "\t", printers.Select(pq => pq.Name + ", status '" + getPrinterStatus(pq) + "', driver '" + pq.QueueDriver.Name + "'"));
                    AppLib.WriteLogTraceMessage("Системные принтеры: " + Environment.NewLine + "\t" + sLog);
                }
                catch (Exception) { }
            }

            // имя принтера для печати чека
            string printerName = null;
            string result      = null;

            #region поиск принтера для печати чека
            printerName = AppLib.GetAppSetting("PrinterName");
            PrintQueue printer = PrintHelper.GetPrintQueueByName(printerName);
            if (printer == null)
            {
                AppLib.WriteLogErrorMessage("В config-файле не указан элемент PrinterName или в системе не найден принтер: " + printerName);
                printerName = null;
            }
            else
            {
                result = getPrinterStatus(printer);
                AppLib.WriteLogTraceMessage($"Принтер '{printerName}' находится в состоянии '{result}'");
            }

            // если принтер из настроек не Ок, то берем принтер по умолчанию
            if ((printer == null) || ((result != null) && (result != "OK")))
            {
                AppLib.WriteLogTraceMessage("Предпринимается попытка использовать принтер по умолчанию...");
                printer = PrintHelper.GetDefaultPrinter();
                if ((printer != null) &&
                    ((printerName == null) || ((printerName != null) && (printer.Name != printerName))))
                {
                    printerName = printer.Name;
                    result      = getPrinterStatus(printer);
                    AppLib.WriteLogTraceMessage($"Найден принтер по умолчанию: {printerName}");
                    AppLib.WriteLogTraceMessage($"Принтер '{printerName}' находится в состоянии '{result}'");
                }
            }

            // если принтер по умолчанию не ОК, то берем первый в системе
            if (printer == null)
            {
                AppLib.WriteLogTraceMessage("Предпринимается попытка использовать первый найденный принтер в ОС...");
                printer = PrintHelper.GetFirstPrinter();
                if ((printer != null) &&
                    ((printerName == null) || ((printerName != null) && (printer.Name != printerName))))
                {
                    printerName = printer.Name;
                    result      = getPrinterStatus(printer);
                    AppLib.WriteLogTraceMessage($"Найден первый принтер: {printerName}");
                    AppLib.WriteLogTraceMessage($"Принтер '{printerName}' находится в состоянии '{result}'");
                }
            }
            // принтер не найден - досвидос
            if (printer == null)
            {
                msgBoxText = "App print error: not found any printer." + userErrMsgSuffix;
                return(false);
            }
            // найден, но статус не ОК - досвидос
            else if ((result != null) && (result != "OK"))
            {
                string sFormat = AppLib.GetLangTextFromAppProp("printerStatusMsg");
                if (sFormat != null)
                {
                    sFormat = sFormat.Replace("\\n", Environment.NewLine);
                }
                msgBoxText = string.Format(sFormat, printerName, result) + userErrMsgSuffix;
                return(false);
            }
            #endregion

            // создание документа
            AppLib.WriteLogTraceMessage($" Создаю документ для печати...");
            FlowDocument doc = null;
            try
            {
                doc = createDocument(width);
                AppLib.WriteLogTraceMessage($" - документ создан успешно");
            }
            catch (Exception ex)
            {
                result = AppLib.GetLangTextFromAppProp("afterPrintingErrMsg");
                if (result != null)
                {
                    result = result.Replace("\\n", Environment.NewLine);
                }
                msgBoxText = result + userErrMsgSuffix;
                AppLib.WriteLogErrorMessage(" Ошибка формирования документа: " + ex.ToString());
                return(false);
            }

            // имя задания на принтер
            string prnTaskName = "bill " + _order.OrderNumberForPrint.ToString();
            // вывод документа на принтер
            AppLib.WriteLogTraceMessage($" Вывожу пречек на принтер...");
            retVal = PrintHelper.PrintFlowDocument(doc, prnTaskName, printerName, out msgBoxText);
            if (retVal == false)
            {
                // сообщение об ошибке в лог
                AppLib.WriteLogErrorMessage(" Ошибка печати документа: " + msgBoxText);
                // и на экран пользователю
                result = AppLib.GetLangTextFromAppProp("afterPrintingErrMsg");
                if (result != null)
                {
                    result = result.Replace("\\n", Environment.NewLine);
                }
                msgBoxText = result + userErrMsgSuffix;
            }
            else
            {
                AppLib.WriteLogTraceMessage("Пречек распечатан успешно");
                if (msgBoxText != null)
                {
                    AppLib.WriteLogErrorMessage(msgBoxText);
                }
            }

            return(retVal);
        }
예제 #23
0
        private FlowDocument createDocument(int width)
        {
            // создать объекты верхнего и нижнего колонтитулов
            XmlDocument xmlHeader = new XmlDocument();

            xmlHeader.Load(AppDomain.CurrentDomain.BaseDirectory + string.Format(@"PrinterBill\Header-{0}.xml", _langId));
            XmlDocument xmlFooter = new XmlDocument();

            xmlFooter.Load(AppDomain.CurrentDomain.BaseDirectory + string.Format(@"PrinterBill\Footer-{0}.xml", _langId));
            TextModel textHeader = new TextModel();
            TextModel textFooter = new TextModel();

            textHeader = DeSerialize <TextModel>(xmlHeader.OuterXml);
            textFooter = DeSerialize <TextModel>(xmlFooter.OuterXml);
            int       leftMargin     = getLineMargin("BillLineLeftMargin");
            Thickness lineMargin     = getLineMargin();
            Thickness lineMarginIngr = lineMargin;

            lineMarginIngr.Top = getLineMargin("BillLineIngrTopMargin");
            Thickness lineMarginPrice = lineMargin;

            lineMarginPrice.Top = getLineMargin("BillLinePriceTopMargin");

            var doc = new FlowDocument();

            doc.PageWidth = width;
            // значения по умолчанию
            doc.FontFamily = new FontFamily("Panton-Bold");
            doc.FontWeight = FontWeights.Normal;
            doc.FontStyle  = FontStyles.Normal;
            doc.FontSize   = Convert.ToInt32(AppLib.GetAppGlobalValue("BillLineFontSize", 12));

            // вставить изображение в заголовок
            addImageToDoc(textHeader, doc);
            // метка, если заказ С СОБОЙ
            if (_order.takeAway == true)
            {
                string langText = AppLib.GetLangTextFromAppProp("takeOrderOut");
                langText = string.Concat(" **** ", langText.ToUpper(), " ****");
                addParagraph(doc, langText, 1.5 * doc.FontSize, FontWeights.Bold, FontStyles.Normal, new Thickness(leftMargin, 20, 0, 10), TextAlignment.Center);
            }
            // добавить форматированный заголовок
            addSectionToDoc(textHeader, doc);

            // добавить строки заказа
            string  currencyName = AppLib.GetLangTextFromAppProp("CurrencyName");
            string  sAppSet;
            decimal totalPrice = 0; string itemName, stringRow;

            foreach (DishItem item in _order.Dishes)
            {
                // блюдо
                itemName = AppLib.GetLangText(item.langNames);
                // c гарниром?
                if ((item.SelectedGarnishes != null) && (item.SelectedGarnishes.Count > 0))
                {
                    DishAdding garn     = item.SelectedGarnishes[0];
                    string     garnName = AppLib.GetLangText(garn.langNames);
                    // 2017-02-02 Формирование полного наименования блюда с гарниром
                    // если DishFullNameInGargnish = true, то полное имя берем из гарнира,
                    // иначе к имени блюда добавляем имя гарнира
                    sAppSet = AppLib.GetAppSetting("DishFullNameInGarnish");
                    if (sAppSet != null && sAppSet.ToBool())
                    {
                        itemName = garnName;
                    }
                    else
                    {
                        itemName += " " + AppLib.GetLangTextFromAppProp("withGarnish") + " " + garnName;
                    }
                }
                //string stringRow = itemName.Substring(0, itemName.Count() > 30 ? 30 : itemName.Count());
                addParagraph(doc, itemName, doc.FontSize, doc.FontWeight, doc.FontStyle, lineMargin);

                // добавить ингредиенты
                if (item.SelectedIngredients != null)
                {
                    stringRow = "  + "; bool isFirst = true;
                    foreach (DishAdding ingr in item.SelectedIngredients)
                    {
                        itemName   = AppLib.GetLangText(ingr.langNames);
                        stringRow += ((isFirst) ? "" : "; ") + itemName;
                        isFirst    = false;
                    }
                    addParagraph(doc, stringRow, 0.9 * doc.FontSize, doc.FontWeight, FontStyles.Italic, lineMarginIngr);
                }

                // стоимость блюда
                decimal price       = item.GetPrice();
                string  priceString = string.Format("{0} x {1:0.00} {3} = {2:0.00} {3}", item.Count, price, item.Count * price, currencyName);
                addParagraph(doc, priceString, doc.FontSize, doc.FontWeight, doc.FontStyle, lineMarginPrice, TextAlignment.Right);
                totalPrice += item.Count * price;
            }
            // итог
            addTotalLine(doc, doc.FontSize, totalPrice, currencyName, leftMargin);

            // добавить форматированный "подвал"
            addSectionToDoc(textFooter, doc);
            // вставить изображение в "подвал"
            addImageToDoc(textFooter, doc);

            // печать штрих-кода
            string           bcVal13      = _order.BarCodeValue + BarCodeLib.getUPCACheckDigit(_order.BarCodeValue);
            Image            imageBarCode = BarCodeLib.GetBarcodeImage(bcVal13, (int)(1.2 * doc.PageWidth), 50);
            BlockUIContainer bcContainer  = new BlockUIContainer()
            {
                Child  = imageBarCode,
                Margin = new Thickness(leftMargin, 10, 0, 0)
            };

            doc.Blocks.Add(bcContainer);
            // вывести значение баркода в чек
            //string bcDisplay = string.Format("{0} {1} {2} {3}", bcVal13.Substring(0,2), bcVal13.Substring(2, 6), bcVal13.Substring(8, 4), bcVal13.Substring(12,1));
            string bcDisplay = string.Format("{0}  {1}  {2}", bcVal13.Substring(0, 1), bcVal13.Substring(1, 6), bcVal13.Substring(7));

            addParagraph(doc, bcDisplay, 0.75 * doc.FontSize, doc.FontWeight, doc.FontStyle, new Thickness(leftMargin, 5, 0, 0), TextAlignment.Center);

            return(doc);
        }
예제 #24
0
        private void setWinLayout()
        {
            // размеры
            this.Width  = (double)AppLib.GetAppGlobalValue("screenWidth");
            this.Height = (double)AppLib.GetAppGlobalValue("screenHeight");
            this.Top    = 0; this.Left = 0;

            double pnlMenuWidth, pnlMenuHeight;
            //pnlMenuHeight = (double)AppLib.GetAppGlobalValue("categoriesPanelHeight");
            //pnlMenuWidth = (double)AppLib.GetAppGlobalValue("categoriesPanelWidth");
            // высоту и ширину панели управления взять из главного окна
            MainWindow mainWin = (MainWindow)App.Current.MainWindow;

            pnlMenuHeight             = mainWin.gridMenuSide.ActualHeight;
            pnlMenuWidth              = mainWin.gridMenuSide.ActualWidth;
            brdAboveFolderMenu.Height = pnlMenuHeight;
            brdAboveFolderMenu.Width  = pnlMenuWidth;

            double dW, dH, d1;
            double grdContentWidth = getAbsColWidth(gridWindow, 1, ((this.Width <= pnlMenuWidth) ? this.Width : this.Width - pnlMenuWidth));
            double grdContentHeight = AppLib.GetRowHeightAbsValue(gridWindow, 1, ((this.Height <= pnlMenuHeight) ? this.Height : this.Height - pnlMenuHeight));
            double itemWidth = 10, itemHeight = 10, garnTextFontSize = 10;

            Setter st; Thickness thMargin;
            Style  lbiStyle      = (Style)this.Resources["addingsListBoxItemStyle"];
            Style  garnTextStyle = (Style)this.Resources["garnishTextStyle"];

            // вертикальное размещение
            if (AppLib.IsAppVerticalLayout == true)
            {
                DockPanel.SetDock(brdAboveFolderMenu, Dock.Top);

                gridWindow.RowDefinitions[1].Height   = new GridLength(5d, GridUnitType.Star);
                gridWindow.ColumnDefinitions[1].Width = new GridLength(10d, GridUnitType.Star);

                // строка изображения
                gridMain.RowDefinitions[2].Height = new GridLength(2.5, GridUnitType.Star);
                // строки добавок
                gridMain.RowDefinitions[5].Height = new GridLength(1.2, GridUnitType.Star);
                gridMain.RowDefinitions[8].Height = new GridLength(1.2, GridUnitType.Star);
                // Кнопка Добавить
                gridAddButtonSection.RowDefinitions[1].Height = new GridLength(2.0, GridUnitType.Star);

                grdContentWidth  = getAbsColWidth(gridWindow, 1, ((this.Width == pnlMenuWidth) ? this.Width : this.Width - pnlMenuWidth));
                grdContentHeight = AppLib.GetRowHeightAbsValue(gridWindow, 1, ((this.Height == pnlMenuHeight) ? this.Height : this.Height - pnlMenuHeight));

                // ширина изображения
                dW = getAbsColWidth(gridMain, 1, grdContentWidth);
                dishImage.Width = 0.4d * dW;
                // текст добавки
                dH = AppLib.GetRowHeightAbsValue(gridMain, 5, grdContentHeight);
                garnTextFontSize = (0.4d * dH) * 0.3d;
            }

            // горизонтальное размещение
            else
            {
                DockPanel.SetDock(brdAboveFolderMenu, Dock.Left);

                // ширина изображения
                dW = getAbsColWidth(gridMain, 1, grdContentWidth);
                dishImage.Width = 0.35d * dW;

                dH = AppLib.GetRowHeightAbsValue(gridMain, 5, grdContentHeight);
                garnTextFontSize = (0.4d * dH) * 0.3d;
            }

            // ширина элемента списка добавок
            dW        = getAbsColWidth(gridMain, 1, grdContentWidth); // + getAbsColWidth(gridMain, 2, grdContentWidth);
            dW       /= 5d;
            itemWidth = 0.9d * dW;
            thMargin  = new Thickness(0, 0, 0.1 * dW, 0);

            st       = (Setter)lbiStyle.Setters.FirstOrDefault(s => (s as Setter).Property.Name == "Margin");
            st.Value = thMargin;

            st       = (Setter)lbiStyle.Setters.FirstOrDefault(s => (s as Setter).Property.Name == "Width");
            st.Value = itemWidth;

            st       = (Setter)garnTextStyle.Setters.FirstOrDefault(s => (s as Setter).Property.Name == "FontSize");
            st.Value = garnTextFontSize;
            if (AppLib.IsAppVerticalLayout)
            {
                st       = (Setter)garnTextStyle.Setters.FirstOrDefault(s => (s as Setter).Property.Name == "Margin");
                thMargin = new Thickness(-0.4 * 0.1 * dW, 0, -0.4 * 0.1 * dW, 0);
                st.Value = thMargin;
            }
        }  // method
예제 #25
0
        private void addSectionToDoc(TextModel sectionModel, FlowDocument doc)
        {
            foreach (ParagraphModel item in sectionModel.Paragraphs)
            {
                Paragraph par  = null;
                string    sBuf = null;

                // обработка строк шаблона заголовка
                if (item.Text.Contains("{OrderDate}") == true)
                {
                    sBuf = item.Text.Replace("{OrderDate}", string.Format("{0:dd.MM.yyyy HH:mm:ss}", _order.OrderDate));
                    Run inLineObj = getRunFromModel(item, sBuf);
                    par = new Paragraph(inLineObj);
                }
                else if (item.Text.Contains("{OrderNumber}") == true)
                {
                    // форматированный текст до и после номера счета
                    List <Run> runBlocks = new List <Run>();
                    Run        r;

                    string[] aStr = item.Text.Split(new string[] { "{OrderNumber}" }, StringSplitOptions.RemoveEmptyEntries);
                    // текст перед номером
                    if (aStr.Length > 0)
                    {
                        sBuf = aStr[0];
                        r    = getRunFromModel(item, sBuf); r.FontWeight = FontWeights.Bold;
                        runBlocks.Add(r);
                    }
                    // номер заказа
                    r          = getRunFromModel(item, _order.OrderNumberForPrint.ToString());
                    r.FontSize = item.FontSize + 3; r.FontWeight = FontWeights.Bold;
                    runBlocks.Add(r);

                    // идентификатор устройства
                    if ((aStr.Length > 1) && (aStr[1].Contains("{ssdId}")))
                    {
                        sBuf = (string)AppLib.GetAppGlobalValue("ssdID");
                        if (sBuf != null)
                        {
                            aStr = aStr[1].Split(new string[] { "{ssdId}" }, StringSplitOptions.RemoveEmptyEntries);
                            // текст до идентификатора
                            if (aStr.Length > 0)
                            {
                                runBlocks.Add(getRunFromModel(item, aStr[0]));
                            }
                            // идентификатор
                            r = getRunFromModel(item, sBuf); runBlocks.Add(r);
                            // текст после идент.
                            if (aStr.Length > 1)
                            {
                                runBlocks.Add(getRunFromModel(item, aStr[1]));
                            }
                        }
                    }

                    par = new Paragraph();  // собрать тексты в абзац
                    par.Inlines.AddRange(runBlocks);
                }
                else
                {
                    Run inLineObj = getRunFromModel(item, item.Text);
                    par = new Paragraph(inLineObj);
                }

                // формат абзаца
                if (par != null)
                {
                    par.Margin = new Thickness(item.LeftMargin, item.TopMargin, item.RightMargin, item.ButtomMargin);
                    doc.Blocks.Add(par);
                    par = null;
                }
            }
        }
예제 #26
0
        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);
        }