Exemple #1
0
        private void setMainMessage()
        {
            double rowHeight;

            rowHeight = WpfHelper.GetRowHeightAbsValue(mainGrid, 1);
            // размер шрифта
            double messageFontSize = (Dish == null) ? 0.3d * rowHeight : 0.2d * rowHeight;

            if (tbMessage.FontSize != messageFontSize)
            {
                tbMessage.FontSize = messageFontSize;
                tbMessage.Margin   = new Thickness(messageFontSize, 0d, messageFontSize, 0d);
            }

            // текст
            string preText = tbMessage.Text;
            string sMsg    = (Order == null) ? "---" : Order.Number.ToString();

            if (runOrderNumber.Text != sMsg)
            {
                runOrderNumber.Text = sMsg;
            }
            FontWeight fw = (Dish == null) ? FontWeights.Bold : FontWeights.Normal;

            if (runOrderNumber.FontWeight != fw)
            {
                runOrderNumber.FontWeight = fw;
            }

            sMsg = (Dish == null) ? "" : ", блюдо \"" + Dish.DishName + "\"";
            if (runDishText.Text != sMsg)
            {
                runDishText.Text = sMsg;
            }
            fw = (Dish == null) ? FontWeights.Normal : FontWeights.Bold;
            if (runDishText.FontWeight != fw)
            {
                runDishText.FontWeight = fw;
            }

            sMsg = StateGraphHelper.GetStateDescription(_currentState, (Order != null));
            if (runState.Text != sMsg)
            {
                runState.Text = sMsg;
            }

            if (preText != tbMessage.Text)
            {
                WpfHelper.AssignFontSizeByMeasureHeight(tbMessage, new Size(mainGrid.Width, mainGrid.Height), rowHeight, true);
            }
        }
Exemple #2
0
        }     // method

        // просто изменить текст и кисти кнопки, если надо
        private void changeStateButton(int buttonIndex, OrderStatusEnum eState)
        {
            Border          border    = (Border)pnlStateButtons.Children[buttonIndex];
            OrderStatusEnum tagStatus = OrderStatusEnum.None;

            // проверить статус в теге кнопки
            if ((border.Tag != null) && (border.Tag is OrderStatusEnum))
            {
                tagStatus = (OrderStatusEnum)border.Tag;
                //if (tagStatus == eState) return;  // выйти, если кнопка с таким же статусом
            }

            // если статус изменился, то поменять кисти
            if (tagStatus != eState)
            {
                border.Tag = eState;
                // получить фон и цвет шрифта
                Brush backgroundBrush = null, foregroundBrush = null;
                StateGraphHelper.SetStateButtonBrushes(eState, out backgroundBrush, out foregroundBrush);
                border.Background = backgroundBrush;
                border.SetValue(TextBlock.ForegroundProperty, foregroundBrush);
            }

            // и надписи на кнопке
            string btnText1, btnText2;
            // возврат из Готов в Приготовление
            bool isReturnCooking = (((_currentState == OrderStatusEnum.Ready) && (eState == OrderStatusEnum.Cooking)) ||
                                    ((_currentState == OrderStatusEnum.ReadyConfirmed) && (eState == OrderStatusEnum.Cooking)));

            StateGraphHelper.SetStateButtonTexts(eState, out btnText1, out btnText2, (_modelType == AppViewModelEnum.Order), isReturnCooking);
            Grid      grd = (Grid)border.Child;
            TextBlock tbStateName = (TextBlock)grd.Children[0], tbStateDescr = (TextBlock)grd.Children[1];
            Size      tbSize    = new Size(border.Width, border.Height);
            double    reqHeight = border.Height / 2d;

            if (tbStateName.Text != btnText1)
            {
                tbStateName.Text = btnText1;
                WpfHelper.AssignFontSizeByMeasureHeight(tbStateName, tbSize, reqHeight, true);
            }
            if (tbStateDescr.Text != btnText2)
            {
                tbStateDescr.Text = btnText2;
                WpfHelper.AssignFontSizeByMeasureHeight(tbStateDescr, tbSize, reqHeight, true);
            }
        }