예제 #1
0
        private string Legend(DataGrid grid, Type type, string context = null)
        {
            var legend = new StackPanel();

            StyleHelper.ApplyStyles(type, grid, appResource, legend, context);
            return(legend.AsText());
        }
        public void Style_fixture()
        {
            var offers = new List <Offer>();

            offers.Add(new Offer(new Price("тест"), 100)
            {
                IsGrouped        = true,
                BuyingMatrixType = BuyingMatrixStatus.Denied,
            });

            WpfTestHelper.WithWindow2(async w => {
                var resources = new ResourceDictionary();
                StyleHelper.Reset();
                StyleHelper.BuildStyles(resources);
                var grid = new DataGrid2();
                grid.AutoGenerateColumns = false;
                grid.Columns.Add(new DataGridTextColumn {
                    Binding = new Binding("ProductSynonym")
                });
                grid.Columns.Add(new DataGridTextColumn {
                    Binding = new Binding("OrderCount")
                });
                w.Content = grid;
                StyleHelper.ApplyStyles(typeof(Offer), grid, resources);
                grid.ItemsSource = offers;
                await w.WaitIdle();
                var cells = grid.Descendants <DataGridCell>().ToArray();
                Assert.That(cells.Length, Is.GreaterThan(0));
                foreach (var cell in cells)
                {
                    Assert.AreEqual("#FFFF0000", cell.Background.ToString(), ((TextBlock)cell.Content).Text);
                }
            });
        }
예제 #3
0
        public void ApplyStyles()
        {
            StyleHelper.ApplyStyles(typeof(BatchLineView), ReportLines, Application.Current.Resources, Legend);
            var elements = Legend.Descendants <FrameworkElement>().Where(e => Equals(e.Tag, "generated")).ToArray();

            elements.Each(e => e.Tag = "");
            StyleHelper.ApplyStyles(typeof(Offer), Offers, Application.Current.Resources, Legend);
            elements.Each(e => e.Tag = "generated");
        }
        public void ApplyStyles()
        {
            var context = "";

            if (((BaseScreen)DataContext).User != null && ((BaseScreen)DataContext).User.IsPreprocessOrders)
            {
                context = "CorrectionEnabled";
            }
            StyleHelper.ApplyStyles(typeof(Order), Orders, Application.Current.Resources, Legend, context);
            StyleHelper.ApplyStyles(typeof(SentOrder), SentOrders, Application.Current.Resources, Legend);
        }
예제 #5
0
        public void Apply_style_to_template_column()
        {
            Build(typeof(WaybillLine));
            var grid   = new DataGrid2();
            var column = new DataGridTemplateColumn();

            column.SetValue(FrameworkElement.NameProperty, "CertificateLink");
            grid.Columns.Add(column);
            StyleHelper.ApplyStyles(typeof(WaybillLine), grid, resource);
            Assert.IsNotNull(column.CellStyle);
        }
예제 #6
0
        public SettingsView()
        {
            InitializeComponent();

            StyleHelper.ApplyStyles(typeof(MarkupConfig), Markups, Application.Current.Resources);
            StyleHelper.ApplyStyles(typeof(MarkupConfig), VitallyImportantMarkups, Application.Current.Resources);
#if !DEBUG
            DebugTab.Visibility = Visibility.Collapsed;
#endif

            DataContextChanged += (sender, args) => {
                var model = (SettingsViewModel)DataContext;

                model.ObservableForProperty(x => x.PriceTagSettings.Value.Type, skipInitial: false)
                .Subscribe(x =>
                {
                    var isConstructor              = ((SettingsViewModel)DataContext).PriceTagSettings.Value.IsConstructor;
                    PriceTagConfig.Visibility      = isConstructor ? Visibility.Collapsed : Visibility.Visible;
                    PriceTagConstructor.Visibility = isConstructor ? Visibility.Visible : Visibility.Collapsed;
                });

                model.ObservableForProperty(x => x.Settings.Value.RackingMap.Size, skipInitial: false)
                .Subscribe(x => {
                    RackingMapConfig.Visibility      = x.Value == RackingMapSize.Custom ? Visibility.Collapsed : Visibility.Visible;
                    RackingMapConstructor.Visibility = x.Value == RackingMapSize.Custom ? Visibility.Visible : Visibility.Collapsed;
                });
            };

            PriceTagSettings_Value_Type.SelectionChanged += (sender, e) =>
            {
                (sender as ComboBox).ToolTip = ((SettingsViewModel)DataContext).PriceTagSettings.Value.IsConstructor
                                        ? @"Конструктор для редактирования ценников, с учетом нужных размеров и необходимых опций. Для создания нового ценника нажмите Редактировать."
                                        : null;
            };

            Settings_RackingMap_Size.SelectionChanged += (sender, e) =>
            {
                if ((RackingMapSize)((ValueDescription)(sender as ComboBox).SelectedItem).Value == RackingMapSize.Custom)
                {
                    (sender as ComboBox).ToolTip = @"Конструктор для редактирования стеллажных карт, с учетом нужных размеров и необходимых опций. Для создания нового стеллажной карты нажмите Редактировать.";
                    return;
                }

                (sender as ComboBox).ToolTip = null;
            };
        }
예제 #7
0
        public Frontend2()
        {
            InitializeComponent();

            Loaded += (sender, args) => {
                DataGridHelper.Focus(Lines);
            };
            KeyDown += (sender, args) => {
                if (args.Key == Key.D && ((Keyboard.Modifiers & ModifierKeys.Control) != 0))
                {
                    Model.ShowDescription();
                }
                if (args.Key == Key.F1)
                {
                    Execute(Model.Help());
                }
                if (args.Key == Key.F7)
                {
                    Execute(Model.Close());
                }
                if (args.Key == Key.F3)
                {
                    Model.Clear();
                }
                if (args.Key == Key.U && ((Keyboard.Modifiers & ModifierKeys.Control) != 0))
                {
                    Execute(Model.Unpack());
                }
                if (args.Key == Key.F4)
                {
                    Execute(Model.ReturnCheck());
                }
            };

            DataContextChanged += (sender, args) => {
                if (Model == null)
                {
                    return;
                }
                var handler = new BarcodeHandler(this, Model.Settings);
                handler.Barcode.Subscribe(x => Execute(Model.BarcodeScanned(x)));
            };

            new Editable().Attach(Lines);
            StyleHelper.ApplyStyles(typeof(CheckLine), Lines, Application.Current.Resources, Legend);
        }
예제 #8
0
        public void ApplyStyles()
        {
            var context    = "";
            var baseScreen = (BaseScreen)DataContext;

            if (baseScreen.User != null && baseScreen.User.IsPreprocessOrders)
            {
                context = "CorrectionEnabled";
            }
            StyleHelper.ApplyStyles(typeof(OrderLine), Lines, Application.Current.Resources, Legend, context);

            if (baseScreen.Settings.Value != null && baseScreen.Settings.Value.HighlightUnmatchedOrderLines)
            {
                StyleHelper.ApplyStyles(typeof(SentOrderLine), SentLines, Application.Current.Resources, Legend);
            }

            StyleHelper.ApplyStyles(typeof(Offer), Offers, Application.Current.Resources, Legend);
        }
예제 #9
0
        public void ApplyStyles()
        {
            var context = "";
            var screen  = ((OrderDetailsViewModel)DataContext);
            var user    = screen.User;

            if (screen.Settings.Value == null)
            {
                return;
            }
            if (screen.IsCurrentOrder || !screen.Settings.Value.HighlightUnmatchedOrderLines)
            {
                if (user != null && user.IsPreprocessOrders)
                {
                    context = "CorrectionEnabled";
                }
                StyleHelper.ApplyStyles(typeof(OrderLine), Lines, Application.Current.Resources, Legend, context);
            }
            else
            {
                StyleHelper.ApplyStyles(typeof(SentOrderLine), Lines, Application.Current.Resources, Legend);
            }
        }
예제 #10
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(Offer), Offers, Application.Current.Resources, Legend);
     StyleHelper.ApplyStyles(typeof(SentOrderLine), HistoryOrders, Application.Current.Resources);
 }
예제 #11
0
        private void Init()
        {
            if (model?.Waybill == null)
            {
                return;
            }
            //борьба за производительность
            //операции установки стиля приводят к перестроению дерева элементов wpf
            //что негативно отражается на производительности
            //что бы избежать ненужных перестроений дерева
            //сначала конструируем таблицу и настраиваем ее а затем добавляем в дерево элементов
            lines         = new DataGrid2();
            lines.Loaded += (sender, args) => {
                DataGridHelper.Focus(lines);
            };
            lines.IsReadOnly = false;
            lines.Name       = "Lines";
            lines.Columns.Add(new DataGridTextColumnEx {
                Header        = "Наименование",
                Binding       = new Binding("Product"),
                Width         = new DataGridLength(180, DataGridLengthUnitType.Star),
                SortDirection = ListSortDirection.Ascending,
                IsReadOnly    = model.User.IsStockEnabled
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header     = "Производитель",
                Binding    = new Binding("Producer"),
                Width      = new DataGridLength(180, DataGridLengthUnitType.Star),
                IsReadOnly = model.User.IsStockEnabled
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Страна",
                Binding = new Binding("Country"),
                Width   = new DataGridLength(100, DataGridLengthUnitType.Star),
            });
            lines.Columns.Add(DataGridHelper.CheckBoxColumn("Печатать", "Print",
                                                            x => lines.Items.OfType <WaybillLine>().Each(l => l.Print = x), true));
            lines.Columns.Add(new DataGridTextColumnEx {
                Header         = "Срок годности",
                Binding        = new Binding("Period"),
                SortMemberPath = "Exp",
                Width          = new DataGridLength(160, DataGridLengthUnitType.Star),
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Серия товара",
                Binding = new Binding("SerialNumber"),
                Width   = new DataGridLength(160, DataGridLengthUnitType.Star),
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Width   = new DataGridLength(13, DataGridLengthUnitType.Star),
                Header  = "Штрихкод",
                Binding = new Binding("EAN13"),
            });
            lines.Columns.Add(new CustomDataGridColumn((c, i) => null)
            {
                Header    = "Сертификаты",
                Name      = "CertificateLink",
                Width     = new DataGridLength(1, DataGridLengthUnitType.SizeToHeader),
                Generator = (c, i) => new ContentControl {
                    Style = (Style)FindResource("DownloadLink")
                }
            });
            if (model.Waybill.IsCreatedByUser == true)
            {
                lines.CanUserAddRows    = !model.User.IsStockEnabled;
                lines.CanUserDeleteRows = true;
                lines.Columns.Add(new CustomDataGridColumn {
                    Header    = "ЖНВЛС",
                    Width     = new DataGridLength(1, DataGridLengthUnitType.SizeToHeader),
                    Generator = (c, i) => {
                        var el = new CheckBox {
                            VerticalAlignment   = VerticalAlignment.Center,
                            HorizontalAlignment = HorizontalAlignment.Center
                        };
                        BindingOperations.SetBinding(el, CheckBox.IsCheckedProperty, new Binding("VitallyImportant")
                        {
                            UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                        });
                        return(el);
                    }
                });
            }
            lines.Columns.Add(new DataGridTextColumnEx {
                Header     = "Номер сертификата",
                Binding    = new Binding("Certificates"),
                Width      = new DataGridLength(180, DataGridLengthUnitType.Star),
                Visibility = Visibility.Collapsed
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Цена производителя без НДС",
                Binding = new Binding("ProducerCost"),
                Width   = new DataGridLength(1, DataGridLengthUnitType.Star),
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Цена ГР",
                Binding = new Binding("RegistryCost"),
                Width   = new DataGridLength(1, DataGridLengthUnitType.Star),
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Торговая наценка оптовика",
                Binding = new Binding("SupplierPriceMarkup"),
                Width   = new DataGridLength(1, DataGridLengthUnitType.Star),
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Цена поставщика без НДС",
                Binding = new Binding("SupplierCostWithoutNds"),
                Width   = new DataGridLength(1, DataGridLengthUnitType.Star),
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "НДС",
                Binding = new Binding("Nds"),
                Width   = new DataGridLength(1, DataGridLengthUnitType.Star),
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Цена поставщика с НДС",
                Binding = new Binding("SupplierCost")
                {
                    Converter = InputConverter.Instance, ValidatesOnExceptions = true,
                },
                Width      = new DataGridLength(1, DataGridLengthUnitType.Star),
                IsReadOnly = false
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header     = "Макс. розничная наценка",
                Binding    = new Binding("MaxRetailMarkup"),
                Width      = new DataGridLength(1, DataGridLengthUnitType.Star),
                IsReadOnly = true,
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Розничная наценка",
                Binding = new Binding("RetailMarkup")
                {
                    Converter = InputConverter.Instance, ValidatesOnExceptions = true,
                },
                Width      = new DataGridLength(1, DataGridLengthUnitType.Star),
                IsReadOnly = false,
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Реальная наценка",
                Binding = new Binding("RealRetailMarkup")
                {
                    Converter = InputConverter.Instance, ValidatesOnExceptions = true,
                },
                Width      = new DataGridLength(1, DataGridLengthUnitType.Star),
                IsReadOnly = false,
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Розничная цена",
                Binding = new Binding("RetailCost")
                {
                    Converter = InputConverter.Instance, ValidatesOnExceptions = true,
                },
                Width      = new DataGridLength(1, DataGridLengthUnitType.Star),
                IsReadOnly = false,
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header  = "Заказ",
                Binding = new Binding("Quantity")
                {
                    Converter = InputConverter.Instance, ValidatesOnExceptions = true,
                },
                Width      = new DataGridLength(1, DataGridLengthUnitType.Star),
                IsReadOnly = false
            });
            lines.Columns.Add(new DataGridTextColumnEx {
                Header     = "Розничная сумма",
                Binding    = new Binding("RetailSum"),
                Width      = new DataGridLength(1, DataGridLengthUnitType.Star),
                IsReadOnly = true,
            });

            var grid = lines;

            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Цена производителя без НДС");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Цена ГР");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Торговая наценка оптовика");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Цена поставщика без НДС");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Цена поставщика с НДС");
            DataGridHelper.CalculateColumnWidth(grid, "000", "НДС");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Макс. розничная наценка");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Розничная наценка");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Реальная наценка");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Розничная цена");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Заказ");
            DataGridHelper.CalculateColumnWidth(grid, "00000", "Оприходовано");
            DataGridHelper.CalculateColumnWidth(grid, "00000.00", "Розничная сумма");
            DataGridHelper.CalculateColumnWidth(grid, "0000000000000", "Штрихкод");

            StyleHelper.ApplyStyles(typeof(WaybillLine), lines, Application.Current.Resources, Legend);
            Conventions.ConfigureDataGrid(lines, typeof(WaybillLine));

            Grid.SetRow(lines, 2);
            Grid.SetColumn(lines, 1);
            Editable.AutoEditOnDigit(grid, "Розничная наценка");
            if (model != null)
            {
                model.TableSettings.Restore(lines);
                model.TableSettings.Restore(OrderLines);

                foreach (var gridColumn in lines.Columns.OfType <DataGridTextColumn>().Where(c => !c.IsReadOnly))
                {
                    if (gridColumn.ReadLocalValue(DataGridColumn.IsReadOnlyProperty) == DependencyProperty.UnsetValue)
                    {
                        gridColumn.IsReadOnly = model.Waybill.IsReadOnly;
                    }
                }
                model.Waybill.PropertyChanged += (sender, args) => {
                    if (args.PropertyName == "IsCreatedByUser")
                    {
                        MainGrid.Children.Remove(lines);
                        Init();
                        lines.ItemsSource = model.Lines.Value;
                    }
                    else if (args.PropertyName == "Status")
                    {
                        lines.CommitEdit();                        //Завершаем редактирование, чтобы не исчезла текущая строка
                        lines.IsReadOnly = model.Waybill.Status == DocStatus.Posted;
                    }
                };

                lines.IsReadOnly = model.Waybill.Status == DocStatus.Posted;
            }
            grid.BeginningEdit += (sender, args) => {
                var line = args.Row.DataContext as WaybillLine;
                if (line == null)
                {
                    return;
                }
                if (line.ServerRetailCost != null)
                {
                    MessageBox.Show(Application.Current.MainWindow, "Редактирование розничной цены запрещено поставщиком",
                                    Consts.WarningTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
                    args.Cancel = true;
                }
                else if (model.Waybill.Status == DocStatus.Posted)
                {
                    MessageBox.Show(Application.Current.MainWindow, "Накладная оприходована, редактирование запрещено",
                                    Consts.WarningTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
                    args.Cancel = true;
                }
            };

            MainGrid.Children.Add(lines);

            DataGridHelper.CalculateColumnWidth(OrderLines, "00000.00", "Цена");
            DataGridHelper.CalculateColumnWidth(OrderLines, "00000.00", "Заказ");
            DataGridHelper.CalculateColumnWidth(OrderLines, "00000.00", "Сумма");
        }
예제 #12
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(WaybillLine), lines, Application.Current.Resources, Legend);
 }
예제 #13
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(OrderLine), Lines, Application.Current.Resources, context: "Correction");
     StyleHelper.ApplyStyles(typeof(Offer), Offers, Application.Current.Resources);
 }
예제 #14
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(InventoryDoc), Items, Application.Current.Resources, Legend);
 }
 public HistoryOrdersView()
 {
     InitializeComponent();
     StyleHelper.ApplyStyles(typeof(SentOrderLine), Lines, Application.Current.Resources);
 }
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(ReassessmentDoc), Items, Application.Current.Resources, Legend);
 }
예제 #17
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(Price), Prices, Application.Current.Resources);
 }
예제 #18
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(CatalogName), CatalogNames, Application.Current.Resources);
     StyleHelper.ApplyStyles(typeof(Catalog), Catalogs, Application.Current.Resources);
 }
예제 #19
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(Reject), Rejects, Application.Current.Resources);
 }
예제 #20
0
 public Stocks()
 {
     InitializeComponent();
     StyleHelper.ApplyStyles(typeof(Stock), Items, Application.Current.Resources, Legend);
 }
예제 #21
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(CatalogDisplayItem), Items, Application.Current.Resources);
 }
예제 #22
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(Offer), Offers, Application.Current.Resources);
 }
예제 #23
0
 public void ApplyStyles()
 {
     StyleHelper.ApplyStyles(typeof(Mnn), Mnns, Application.Current.Resources);
 }