Exemple #1
0
        protected void ConfigureDialog()
        {
            yentryName.Binding
            .AddBinding(UoWGeneric.Root, (warehouse) => warehouse.Name, (widget) => widget.Text)
            .InitializeFromSource();
            ycheckOnlineStore.Binding.AddBinding(Entity, e => e.PublishOnlineStore, w => w.Active).InitializeFromSource();
            ycheckbuttonCanReceiveBottles.Binding
            .AddBinding(UoWGeneric.Root, (warehouse) => warehouse.CanReceiveBottles, (widget) => widget.Active)
            .InitializeFromSource();
            ycheckbuttonCanReceiveEquipment.Binding
            .AddBinding(UoWGeneric.Root, (warehouse) => warehouse.CanReceiveEquipment, (widget) => widget.Active)
            .InitializeFromSource();
            ycheckbuttonArchive.Binding
            .AddBinding(UoWGeneric.Root, (warehouse) => warehouse.IsArchive, (widget) => widget.Active)
            .InitializeFromSource();
            ycheckbuttonArchive.Sensitive = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_archive_warehouse");

            comboTypeOfUse.ItemsEnum = typeof(WarehouseUsing);
            comboTypeOfUse.Binding.AddBinding(Entity, e => e.TypeOfUse, w => w.SelectedItem).InitializeFromSource();

            ySpecCmbOwner.SetRenderTextFunc <Subdivision>(s => s.Name);
            ySpecCmbOwner.ItemsList = SubdivisionsRepository.GetAllDepartments(UoW);
            ySpecCmbOwner.Binding.AddBinding(Entity, s => s.OwningSubdivision, w => w.SelectedItem).InitializeFromSource();
        }
Exemple #2
0
        public void ConfigureWidget(IUnitOfWork uow, UndeliveredOrder undeliveredOrder, bool driverCanBeGuilty)
        {
            this.uow = uow;
            this.undeliveredOrder       = undeliveredOrder;
            enumBtnGuiltySide.ItemsEnum = typeof(GuiltyTypes);
            enumBtnGuiltySide.SetSensitive(GuiltyTypes.Driver, driverCanBeGuilty);
            enumBtnGuiltySide.SetSensitive(GuiltyTypes.None, !undeliveredOrder.ObservableGuilty.Any());
            undeliveredOrder.ObservableGuilty.ElementAdded   += ObservableGuilty_ElementAdded;
            undeliveredOrder.ObservableGuilty.ElementRemoved += ObservableGuilty_ElementRemoved;
            enumBtnGuiltySide.EnumItemClicked += (sender, e) => {
                undeliveredOrder.AddGuilty(
                    new GuiltyInUndelivery {
                    GuiltySide       = (GuiltyTypes)e.ItemEnum,
                    UndeliveredOrder = undeliveredOrder
                }
                    );
                SetWidgetApperance();
            };

            var colorBlack     = new Gdk.Color(0, 0, 0);
            var colorGrey      = new Gdk.Color(96, 96, 96);
            var colorWhite     = new Gdk.Color(255, 255, 255);
            var hideEnums      = !driverCanBeGuilty ? new Enum[] { GuiltyTypes.Driver } : new Enum[] { };
            var allDepartments = SubdivisionsRepository.GetAllDepartments(uow);

            treeViewGuilty.ColumnsConfig = ColumnsConfigFactory.Create <GuiltyInUndelivery>()
                                           .AddColumn("Сторона")
                                           .HeaderAlignment(0.5f)
                                           .AddEnumRenderer(n => n.GuiltySide, true, hideEnums)
                                           .AddColumn("Отдел ВВ")
                                           .HeaderAlignment(0.5f)
                                           .AddComboRenderer(n => n.GuiltyDepartment)
                                           .SetDisplayFunc(x => x.Name)
                                           .FillItems(allDepartments)
                                           .AddSetter(
                (c, n) => {
                c.Editable = n.GuiltySide == GuiltyTypes.Department;
                if (n.GuiltySide != GuiltyTypes.Department)
                {
                    n.GuiltyDepartment = null;
                }
                if (n.GuiltySide == GuiltyTypes.Department && n.GuiltyDepartment == null)
                {
                    c.ForegroundGdk = colorGrey;
                    c.Style         = Pango.Style.Italic;
                    c.Text          = "(Нажмите для выбора отдела)";
                    c.BackgroundGdk = colorWhite;
                }
                else
                {
                    c.ForegroundGdk = colorBlack;
                    c.Style         = Pango.Style.Normal;
                    c.Background    = null;
                }
            }
                )
                                           .Finish();
            treeViewGuilty.HeadersVisible  = false;
            treeViewGuilty.ItemsDataSource = undeliveredOrder.ObservableGuilty;
            SetWidgetApperance();
        }