Exemplo n.º 1
0
        private void moveToNewCol(OrderPanel ordPnl)
        {
            int iPagePrev = _currentPageIndex;

            setNextColumn();
            ordPnl.SetPosition(_curTopValue, getLeftOrdPnl());
            //    добавлена новая страница(канва) - перенести панель заказа из предыд.канвы в текущую
            if (iPagePrev != _currentPageIndex)
            {
                OrdersPage page = _pages[iPagePrev - 1];
                page.DelOrder(ordPnl);
                ordPnl.SetPosition(_curTopValue, getLeftOrdPnl());
                CurrentPage.AddOrder(ordPnl);
            }
        }
Exemplo n.º 2
0
        //*******************************************
        //   РАЗМЕЩЕНИЕ ПАНЕЛЕЙ ЗАКАЗОВ
        //*******************************************
        public void AddOrderPanel(OrderViewModel orderModel)
        {
            OrderPanel ordPnl; DishPanel dshPnl; //, curDshPnl = null;

            // СОЗДАТЬ ПАНЕЛЬ ЗАКАЗА вместе с ЗАГОЛОВКОМ заказа и строкой заголовка таблицы блюд
            ordPnl = new OrderPanel(orderModel, _currentPageIndex, _colWidth, true);

            // поле между заказами по вертикали
            if (_curTopValue > 0d)
            {
                _curTopValue += _hdrTopMargin;
            }

            ordPnl.SetPosition(_curTopValue, getLeftOrdPnl());
            CurrentPage.AddOrder(ordPnl);
            CurrentPage.UpdateLayout();
            // перенос в новый столбец всего заказа
            if ((_curTopValue + ordPnl.PanelHeight) >= _uiPanelSize.Height)
            {
                moveToNewCol(ordPnl);
                CurrentPage.UpdateLayout();
            }

            int curFiling = 0;

            // блюда
            foreach (OrderDishViewModel dishModel in orderModel.Dishes)
            {
                if (curFiling != dishModel.FilingNumber)
                {
                    curFiling = dishModel.FilingNumber;
                    Brush foreground = (curFiling == 1) ? Brushes.Red : Brushes.Blue;
                    DishDelimeterPanel newDelimPanel = new DishDelimeterPanel(_colWidth, foreground, Brushes.AliceBlue, "Подача " + curFiling.ToString())
                    {
                        DontTearOffNext = true
                    };
                    ordPnl.AddDelimiter(newDelimPanel); // и добавить в стек
                }

                //if (dishModel.ParentUID.IsNull()) curDshPnl = null;  // сохранить родительское блюдо
                dshPnl = new DishPanel(dishModel, _colWidth);  // , curDshPnl
                //if (dishModel.ParentUID.IsNull()) curDshPnl = dshPnl;  // сохранить родительское блюдо

                // добавить строку заказа в стек
                ordPnl.AddDish(dshPnl);
                CurrentPage.UpdateLayout();

                if ((_curTopValue + Math.Ceiling(ordPnl.PanelHeight)) > _uiPanelSize.Height)  // переход в новый столбец
                {
                    // 1. удалить из ordPnl только что добавленное блюдо
                    //    и вернуть массив удаленных элементов, возможно с "висячим" разделителем номера подачи
                    UIElement[] delItems = ordPnl.RemoveDish(dshPnl, _curTopValue, _uiPanelSize.Height);

                    // разбиваем блюда заказа по колонкам на той же странице
                    if ((ordPnl.ItemsCount > 2) &&
                        ((_curColIndex < _pageColsCount) || ((_curColIndex == _pageColsCount) && (Convert.ToDouble(ordPnl.GetValue(Canvas.TopProperty)) == 0d))))
                    {
                        setNextColumn();
                        // 2. создать новый OrderPanel для текущего блюда с заголовком таблицы
                        ordPnl = new OrderPanel(orderModel, _currentPageIndex, _colWidth, false);
                        // 3. добавить только что удаленные блюда
                        ordPnl.AddDishes(delItems);
                        // 4. привязать к канве
                        ordPnl.SetPosition(_curTopValue, getLeftOrdPnl());
                        CurrentPage.AddOrder(ordPnl);
                    }
                    // не разбиваем заказ, а полностью переносим в новую колонку
                    else
                    {
                        // 2. изменить координаты панели заказа
                        moveToNewCol(ordPnl);
                        // 3. добавить только что удаленные блюда
                        ordPnl.AddDishes(delItems);
                    }
                    CurrentPage.UpdateLayout();
                }
            }  // foreach dishes

            _curTopValue += ordPnl.PanelHeight;
        }