コード例 #1
0
        public PriceTagConstructor(TagType tagType, Address address)
        {
            this.tagType = tagType;
            this.address = address;
            InitFields();
            DisplayName = tagType == TagType.PriceTag ? "Конструктор ценника" : "Конструктор стеллажной карты";
            Alignments  = new[] {
                new KeyValuePair <string, TextAlignment>("По левому краю", TextAlignment.Left),
                new KeyValuePair <string, TextAlignment>("По центру", TextAlignment.Center),
                new KeyValuePair <string, TextAlignment>("По правому краю", TextAlignment.Right),
            };
            Fields = PriceTagItem.Items(tagType);

            Items = new ObservableCollection <PriceTagItem>();
            Items.CollectionChanged += (sender, args) => {
                Preview();
            };
            Selected.Subscribe(x => {
                SelectedItem.Value = (PriceTagItem)x?.DataContext;
                foreach (var property in typeof(PriceTagItem).GetProperties())
                {
                    OnPropertyChanged(property.Name);
                }
            });
            Tag.ChangedValue().Subscribe(x => Preview());
            Tag.Subscribe(x => {
                Items.Clear();
                Items.AddEach(Tag.Value?.Items ?? Enumerable.Empty <PriceTagItem>());
            });
        }