Beispiel #1
0
        // в value ключ для основной пары кистей, в parameter - тип кисти: "back" для фона и "fore" для текста
        // также можно передать ссылку на OrderDishViewModel для более точного получения кисти
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(_defaultBrush);
            }

            Brush retVal = null;
            Dictionary <string, BrushesPair> appBrushes = BrushHelper.AppBrushes;

            string key = null;

            if (value is string)
            {
                key = value.ToString();
            }
            else if ((value is OrderStatusEnum) || (value is StatusEnum))
            {
                key = value.ToString();
            }
            else if (value is OrderDishViewModel)
            {
                key = (value as OrderDishViewModel).Status.ToString();
            }

            if (!key.IsNull() && appBrushes.ContainsKey(key) && (parameter != null))
            {
                string[]    aParam = parameter.ToString().Split(';');
                BrushesPair brPair = appBrushes[key];

                retVal = (aParam[0] == "fore") ? brPair.Foreground : brPair.Background;
            }

            return((retVal == null) ? _defaultBrush : retVal);
        }
Beispiel #2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            StatusEnum status1 = (StatusEnum)values[0]; // статус заказа из БД
            StatusEnum status2 = (StatusEnum)values[1]; // статус заказа по блюдам, разрешенным на КДСе

            Brush retVal = null;
            Dictionary <string, BrushesPair> appBrushes = BrushHelper.AppBrushes;
            string key = null;

            if (((bool)WpfHelper.GetAppGlobalValue("IsShowOrderStatusByAllShownDishes")) &&
                (status2 != StatusEnum.None) && (status2 != StatusEnum.WaitingCook) && (status2 != status1))
            {
                key = status2.ToString();
            }
            else
            {
                key = status1.ToString();
            }

            if (!key.IsNull() && appBrushes.ContainsKey(key) && (parameter != null))
            {
                string[]    aParam = parameter.ToString().Split(';');
                BrushesPair brPair = appBrushes[key];

                retVal = (aParam[0] == "fore") ? brPair.Foreground : brPair.Background;
            }

            return((retVal == null) ? _defaultBrush : retVal);
        }
Beispiel #3
0
        //private DishPanel _parentPanel;


        public DishPanel(OrderDishViewModel dishView, double panelWidth)
        {
            this.Width = panelWidth;
            InitializeComponent();

            this.MouseUp += root_MouseUp;
            _dishView     = dishView;
            //_parentPanel = parentPanel;
            grdDishLine.DataContext = _dishView;

            _isDish         = _dishView.ParentUID.IsNull(); // признак блюда
            _isIngrIndepend = (bool)WpfHelper.GetAppGlobalValue("IsIngredientsIndependent", false);

            _dishView.PropertyChanged += DishView_PropertyChanged;

            double fontScale        = (double)WpfHelper.GetAppGlobalValue("AppFontScale", 1.0d);
            double fontSizeDishName = (double)WpfHelper.GetAppGlobalValue("ordPnlDishNameFontSize");

            this.tbDishIndex.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishIndexFontSize");
            this.tbDishName.FontSize  = fontScale * (_isDish
                ? (double)WpfHelper.GetAppGlobalValue("ordPnlDishNameFontSize")
                : (double)WpfHelper.GetAppGlobalValue("ordPnlIngrNameFontSize"));
            // модификаторы
            if (dishView.Comment.IsNull() == false)
            {
                this.tbComment.Text     = string.Format("\n({0})", dishView.Comment);
                this.tbComment.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishCommentFontSize");
            }
            this.tbDishQuantity.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishQuantityFontSize");

            tbDishStatusTS.FontSize   = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlDishTimerFontSize");
            tbDishStatusTS.FontWeight = FontWeights.Bold;

            _padd           = 0.5 * fontSizeDishName; // от размера фонта наименования блюда
            brdMain.Padding = new Thickness(0, 0.5 * _padd, 0, 0.5 * _padd);

            brdTimer.Padding = new Thickness(0, _padd, 0, _padd);
            double timerCornerRadius = 0.015 * this.Width;

            brdTimer.CornerRadius = new CornerRadius(timerCornerRadius, timerCornerRadius, timerCornerRadius, timerCornerRadius);

            // рамка вокруг таймера
            setTimerBorder();

            // кисти и прочее
            //    блюдо
            if (_isDish)
            {
                tbDishName.FontWeight = FontWeights.Bold;
            }
            //    ингредиент
            else
            {
                tbDishName.FontWeight = FontWeights.Bold;
                BrushesPair brPair = BrushHelper.AppBrushes["ingrLineBase"];
                tbDishName.Background = brPair.Background;
                tbDishName.Foreground = brPair.Foreground;
            }
        }
Beispiel #4
0
        private static void addBrushesPair(string dictionaryKey, string brushPairName, string legendText, string cfgElementName, Brush foregroundBrush, Brush backgroundBrush)
        {
            BrushesPair bp;

            bp = new BrushesPair()
            {
                Name = brushPairName, LegendText = legendText
            };
            bp.SetBrushes(cfgElementName, foregroundBrush, backgroundBrush);

            _appBrushes.Add(dictionaryKey, bp);
        }
Beispiel #5
0
        private DishDelimeterPanel createContinuePanel(bool isForward)
        {
            BrushesPair brPair = BrushHelper.AppBrushes["delimiterBreakPage"];
            string      text   = (isForward)
                ? WpfHelper.GetAppGlobalValue("ContinueOrderNextPage", "see next page").ToString()
                : WpfHelper.GetAppGlobalValue("ContinueOrderPrevPage", "see prev page").ToString();
            DishDelimeterPanel newDelimPanel = new DishDelimeterPanel(_colWidth, brPair.Foreground, brPair.Background, text);

            newDelimPanel.DelimeterType = (isForward) ? DishDelimeterPanelTypeEnum.OrderContinueNext : DishDelimeterPanelTypeEnum.OrderContinuePrev;

            return(newDelimPanel);
        }
Beispiel #6
0
        // установка рамки вокруг таймера
        private void setTimerBorder()
        {
            string brushKey = _dishView.Status.ToString();

            // состояние "Ожидание" начала готовки
            if (_dishView.Status == OrderStatusEnum.WaitingCook)
            {
                // если есть "Готовить через" - отображаем время начала автомат.перехода в сост."В процессе" по убыванию
                if (_dishView.DelayedStartTime != 0)
                {
                    brushKey = "estimateStart";
                }
                // если есть время приготовления, то отобразить время приготовления
                else if (_dishView.EstimatedTime != 0)
                {
                    brushKey = "estimateCook";
                }
            }
            else if ((_dishView.Status == OrderStatusEnum.Ready) && _dishView.EnableTimerToAutoReadyConfirm)
            {
                brushKey = OrderStatusEnum.ReadyConfirmed.ToString() + OrderStatusEnum.Ready.ToString();
            }
            else
            {
                bool negativeTimer = (!_dishView.ViewTimerString.IsNull() && _dishView.ViewTimerString.StartsWith("-"));
                // проверить на наличие кистей для отрицательных значений
                if (negativeTimer)
                {
                    brushKey += "minus";
                }
            }

            if (brushKey != _currentBrushKey)
            {
                _currentBrushKey = brushKey;

                Dictionary <string, BrushesPair> appBrushes = BrushHelper.AppBrushes;
                BrushesPair brPair = null;
                if (appBrushes.ContainsKey(_currentBrushKey))
                {
                    brPair = appBrushes[_currentBrushKey];
                }

                if (brPair != null)
                {
                    brdTimer.Background       = brPair.Background;
                    tbDishStatusTS.Foreground = brPair.Foreground;
                }
            }
        }
Beispiel #7
0
        private BrushesPair getHeaderBrushes()
        {
            StatusEnum status1 = _order.Status, status2 = _order.StatusAllowedDishes;
            string     key = null;

            if (((bool)WpfHelper.GetAppGlobalValue("IsShowOrderStatusByAllShownDishes")) &&
                (status2 != StatusEnum.None) && (status2 != StatusEnum.WaitingCook) && (status2 != status1))
            {
                key = status2.ToString();
            }
            else
            {
                key = status1.ToString();
            }

            BrushesPair retVal = null;

            if (!key.IsNull() && BrushHelper.AppBrushes.ContainsKey(key))
            {
                retVal = BrushHelper.AppBrushes[key];
            }

            return(retVal);
        }
Beispiel #8
0
        public OrderPanelHeader(OrderViewModel order, double width)
        {
            _order     = order;
            this.Width = width;
            this.SnapsToDevicePixels = true;
            this.MouseDown          += root_MouseDown;
            this.MouseUp            += root_MouseUp;

            Binding     binding;
            BrushesPair brPair;

            // кисть заголовка
            BrushesPair brPairHeader = getHeaderBrushes();
            // отступы
            Thickness rowMargin = new Thickness(0.02 * width, 0, 0.02 * width, 0);
            // шрифты
            double fontScale     = (double)WpfHelper.GetAppGlobalValue("AppFontScale", 1.0d);
            double labelFontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrLabelFontSize");


            // 0. номер стола и заказа
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1.0d, GridUnitType.Star)
            });
            // 1. официант
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(0.7d, GridUnitType.Star)
            });
            // 2. дата создания заказа и таймер заказа
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1.0d, GridUnitType.Star)
            });

            // 0. номер стола и заказа
            Border brdHdrTableRow = new Border()
            {
                BorderBrush = Brushes.DarkBlue
            };

            brdHdrTableRow.SetValue(Grid.RowProperty, 0);
            brdHdrTableRow.BorderThickness = new Thickness(1, 1, 1, 0);
            if (brPairHeader != null)
            {
                brdHdrTableRow.Background = brPairHeader.Background;
                brdHdrTableRow.SetValue(TextBlock.ForegroundProperty, brPairHeader.Foreground);
            }
            // уголки рамок
            brdHdrTableRow.CornerRadius = new CornerRadius(0.03 * width, 0.03 * width, 0, 0);

            Grid grdHdrTableRow = new Grid();

            grdHdrTableRow.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(0, GridUnitType.Auto)
            });
            grdHdrTableRow.ColumnDefinitions.Add(new ColumnDefinition());
            //  стол
            TextBlock tblTable = new TextBlock()
            {
                VerticalAlignment = VerticalAlignment.Center, Margin = rowMargin
            };

            tblTable.SetValue(Grid.ColumnProperty, 0);
            Run tbTableLabel1 = new Run()
            {
                Text = "Стол №: ", FontSize = labelFontSize
            };

            tblTable.Inlines.Add(tbTableLabel1);
            Run tbTableName = new Run()
            {
                FontWeight = FontWeights.Bold
            };

            binding = new Binding("TableName")
            {
                Source = _order
            };
            tbTableName.SetBinding(Run.TextProperty, binding);
            tbTableName.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrTableNameFontSize");
            tblTable.Inlines.Add(tbTableName);
            grdHdrTableRow.Children.Add(tblTable);
            //  номер заказа
            Border brdOrderNumber = new Border();

            brdOrderNumber.SetValue(Grid.ColumnProperty, 1);
            TextBlock tblOrderNumber = new TextBlock()
            {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Margin = rowMargin
            };
            Run tbTableLabel2 = new Run()
            {
                Text = "Заказ №: ", FontSize = labelFontSize
            };

            tblOrderNumber.Inlines.Add(tbTableLabel2);
            Run tbOrderNumber = new Run()
            {
                FontWeight = FontWeights.Bold
            };

            binding = new Binding("Number")
            {
                Source = _order
            };                                                   // , Converter = new IsZeroConverter()
            tbOrderNumber.SetBinding(Run.TextProperty, binding);
            tbOrderNumber.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrOrderNumberFontSize");
            tblOrderNumber.Inlines.Add(tbOrderNumber);
            brdOrderNumber.Child = tblOrderNumber;
            grdHdrTableRow.Children.Add(brdOrderNumber);

            brdHdrTableRow.Child = grdHdrTableRow;
            this.Children.Add(brdHdrTableRow);

            // 1. официант
            Border brdHdrWaiter = new Border()
            {
                BorderBrush = Brushes.DarkBlue, BorderThickness = new Thickness(1, 0, 1, 0)
            };

            brdHdrWaiter.SetValue(Grid.RowProperty, 1);
            if (brPairHeader != null)
            {
                brdHdrWaiter.Background = brPairHeader.Background;
                brdHdrWaiter.SetValue(TextBlock.ForegroundProperty, brPairHeader.Foreground);
            }
            TextBlock tbWaiter = new TextBlock()
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left,
                TextWrapping        = TextWrapping.Wrap,
                FontWeight          = FontWeights.Bold,
                Margin = new Thickness(0.02 * width, 0, 0.02 * width, 0)
            };

            binding = new Binding("Waiter")
            {
                Source = _order
            };
            tbWaiter.SetBinding(TextBlock.TextProperty, binding);
            tbWaiter.FontSize  = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrWaiterNameFontSize");
            brdHdrWaiter.Child = tbWaiter;
            this.Children.Add(brdHdrWaiter);

            // метка отдела
            Viewbox vbxDivisionMark = new Viewbox()
            {
                HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Stretch = Stretch.Fill, ClipToBounds = true
            };

            vbxDivisionMark.Width = 0.2d * width;
            vbxDivisionMark.SetValue(Grid.ColumnProperty, 1);
            vbxDivisionMark.SetValue(Grid.RowProperty, 0);
            vbxDivisionMark.SetValue(Grid.RowSpanProperty, 2);
            Polygon divisionMark = new Polygon()
            {
                Opacity = 0.7,
                Points  = new PointCollection(new Point[] { new Point(0, 0), new Point(10, 0), new Point(10, 10) })
            };

            if (!_order.DivisionColorRGB.IsNull())
            {
                divisionMark.Fill = WpfHelper.GetBrushFromRGBString(order.DivisionColorRGB);
            }
            vbxDivisionMark.Child = divisionMark;
            this.Children.Add(vbxDivisionMark);

            // 2. дата создания заказа и таймер заказа
            Border brdHdrOrderTime = new Border()
            {
                BorderBrush = Brushes.DarkBlue, BorderThickness = new Thickness(1.0d)
            };

            brdHdrOrderTime.SetValue(Grid.RowProperty, 2);
            if (brPairHeader != null)
            {
                brdHdrOrderTime.Background = brPairHeader.Background;
                brdHdrOrderTime.SetValue(TextBlock.ForegroundProperty, brPairHeader.Foreground);
            }

            Grid grdHdrOrderTime = new Grid()
            {
                Margin = rowMargin
            };

            grdHdrOrderTime.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(4.0d, GridUnitType.Star)
            });
            grdHdrOrderTime.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(4.0d, GridUnitType.Star)
            });
            //  дата создания заказа
            WrapPanel pnlOrderDate = new WrapPanel()
            {
                Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left
            };

            pnlOrderDate.SetValue(Grid.ColumnProperty, 0);
            TextBlock tbOrderDateLabel = new TextBlock()
            {
                Text = "Создан в: ", FontSize = labelFontSize, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left
            };

            pnlOrderDate.Children.Add(tbOrderDateLabel);
            TextBlock tbOrderDate = new TextBlock()
            {
                FontWeight        = FontWeights.Bold,
                VerticalAlignment = VerticalAlignment.Center,
                TextWrapping      = TextWrapping.Wrap,
                Text = _order.CreateDate.ToKDSPanelString()
            };

            tbOrderDate.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrOrderCreateDateFontSize");
            pnlOrderDate.Children.Add(tbOrderDate);
            grdHdrOrderTime.Children.Add(pnlOrderDate);
            //  таймер
            Border brdOrderTimer = new Border()
            {
                Padding = new Thickness(5d, 3d, 5d, 3d), Margin = new Thickness(0, 3d, 0, 3d)
            };

            brdOrderTimer.SetValue(Grid.ColumnProperty, 1);
            //  уголки
            double timerCornerRadius = 0.025 * width;

            brdOrderTimer.CornerRadius = new CornerRadius(timerCornerRadius, timerCornerRadius, timerCornerRadius, timerCornerRadius);
            brPair = BrushHelper.AppBrushes["orderHeaderTimer"];
            if (brPair != null)
            {
                brdOrderTimer.Background = brPair.Background;
                brdOrderTimer.SetValue(TextBlock.ForegroundProperty, brPair.Foreground);
            }
            // панель элементов
            WrapPanel pnlOrderTimer = new WrapPanel()
            {
                Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center
            };
            TextBlock tbOrderTimerLabel = new TextBlock()
            {
                Text = "Прошло: ", FontSize = labelFontSize, FontStretch = FontStretches.Condensed
            };

            pnlOrderTimer.Children.Add(tbOrderTimerLabel);

            TextBlock tbOrderTimer = new TextBlock()
            {
                FontWeight = FontWeights.Bold, TextWrapping = TextWrapping.Wrap
            };

            tbOrderTimer.FontSize = fontScale * (double)WpfHelper.GetAppGlobalValue("ordPnlHdrOrderTimerFontSize");
            binding = new Binding("WaitingTimerString")
            {
                Source = _order
            };
            tbOrderTimer.SetBinding(TextBlock.TextProperty, binding);
            pnlOrderTimer.Children.Add(tbOrderTimer);

            brdOrderTimer.Child = pnlOrderTimer;
            grdHdrOrderTime.Children.Add(brdOrderTimer);

            brdHdrOrderTime.Child = grdHdrOrderTime;
            this.Children.Add(brdHdrOrderTime);
        }