示例#1
0
        void UpdateAddressesOnMap()
        {
            logger.Info("Обновляем адреса на карте...");
            addressesWithoutCoordinats = 0;
            addressesWithoutRoutes     = 0;
            totalBottlesCountAtDay     = 0;
            bottlesWithoutRL           = 0;
            addressesOverlay.Clear();

            //добавляем маркеры складов
            foreach (var b in GeographicGroupRepository.GeographicGroupsWithCoordinates(ViewModel.UoW))
            {
                addressesOverlay.Markers.Add(FillBaseMarker(b));
            }

            var ordersOnDay      = ViewModel.OrdersOnDay;
            var ordersRouteLists = OrderSingletonRepository.GetInstance().GetAllRouteListsForOrders(ViewModel.UoW, ordersOnDay);

            //добавляем маркеры адресов заказов
            foreach (var order in ordersOnDay)
            {
                totalBottlesCountAtDay += order.Total19LBottlesToDeliver;

                IEnumerable <int> orderRls;
                if (!ordersRouteLists.TryGetValue(order.Id, out orderRls))
                {
                    orderRls = new List <int>();
                }

                var route = ViewModel.RoutesOnDay.FirstOrDefault(rl => rl.Addresses.Any(a => a.Order.Id == order.Id));

                if (!orderRls.Any())
                {
                    addressesWithoutRoutes++;
                    bottlesWithoutRL += order.Total19LBottlesToDeliver;
                }

                if (order.DeliveryPoint.Latitude.HasValue && order.DeliveryPoint.Longitude.HasValue)
                {
                    FillTypeAndShapeMarker(order, route, orderRls, out PointMarkerShape shape, out PointMarkerType type);

                    if (selectedMarkers.FirstOrDefault(m => (m.Tag as Order)?.Id == order.Id) != null)
                    {
                        type = PointMarkerType.white;
                    }

                    var addressMarker = FillAddressMarker(order, type, shape, addressesOverlay, route);

                    addressesOverlay.Markers.Add(addressMarker);
                }
                else
                {
                    addressesWithoutCoordinats++;
                }
            }

            UpdateOrdersInfo();
            logger.Info("Ок.");
        }
示例#2
0
        /// <param name="provider">Используемый провайдер данных</param>
        /// <param name="points">Точки для первоначального заполенения из базы.</param>
        /// <param name="statisticsTxtAction">Функция для буфера для отображения статистики</param>
        /// <param name="multiThreadLoad">Если <c>true</c> включается моногопоточная загрузка.</param>
        public ExtDistanceCalculator(DistanceProvider provider, DeliveryPoint[] points, Action <string> statisticsTxtAction, bool multiThreadLoad = true)
        {
            this.statisticsTxtAction = statisticsTxtAction;
            UoW.Session.SetBatchSize(SaveBy);
            Provider      = provider;
            MultiTaskLoad = multiThreadLoad;
            Canceled      = false;
            var basesHashes = GeographicGroupRepository.GeographicGroupsWithCoordinates(UoW).Select(CachedDistance.GetHash);

            hashes = points.Select(CachedDistance.GetHash)
                     .Concat(basesHashes)
                     .Distinct()
                     .ToArray();

            cQueue = new ConcurrentQueue <long>(hashes);

            totalPoints       = hashes.Length;
            proposeNeedCached = hashes.Length * (hashes.Length - 1);

            hashPos = hashes.Select((hash, index) => new { hash, index })
                      .ToDictionary(x => x.hash, x => x.index);
#if DEBUG
            matrix      = new CachedDistance[hashes.Length, hashes.Length];
            matrixcount = new int[hashes.Length, hashes.Length];
#endif
            var fromDB = CachedDistanceRepository.GetCache(UoW, hashes);
            startCached = fromDB.Count;
            foreach (var distance in fromDB)
            {
#if DEBUG
                matrix[hashPos[distance.FromGeoHash], hashPos[distance.ToGeoHash]] = distance;
#endif
                AddNewCacheDistance(distance);
            }
            UpdateText();
#if DEBUG
            StringBuilder matrixText = new StringBuilder(" ");
            for (int x = 0; x < matrix.GetLength(1); x++)
            {
                matrixText.Append(x % 10);
            }

            for (int y = 0; y < matrix.GetLength(0); y++)
            {
                matrixText.Append("\n" + y % 10);
                for (int x = 0; x < matrix.GetLength(1); x++)
                {
                    matrixText.Append(matrix[y, x] != null ? 1 : 0);
                }
            }
            logger.Debug(matrixText);

            logger.Debug(string.Join(";", hashes.Select(CachedDistance.GetTextLonLat)));
#endif

            if (MultiTaskLoad && fromDB.Count < proposeNeedCached)
            {
                RunPreCalculation();
            }
            else
            {
                MultiTaskLoad = false;
            }
        }
        void ConfigureDlg()
        {
            UoW = UnitOfWorkFactory.CreateWithoutRoot();
            lstGeoGrp.SetRenderTextFunc <GeographicGroup>(g => string.Format("{0}", g.Name));
            lstGeoGrp.ItemsList = GeographicGroupRepository.GeographicGroupsWithCoordinates(UoW);

            var nomenclatureTypeParam = filter.CreateParameterSet(
                "Типы номенклатур",
                "nomenclature_type",
                new ParametersEnumFactory <NomenclatureCategory>()
                );

            var nomenclatureParam = filter.CreateParameterSet(
                "Номенклатуры",
                "nomenclature",
                new ParametersFactory(UoW, (filters) => {
                SelectableEntityParameter <Nomenclature> resultAlias = null;
                var query = UoW.Session.QueryOver <Nomenclature>()
                            .Where(x => !x.IsArchive);
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        var filterCriterion = f();
                        if (filterCriterion != null)
                        {
                            query.Where(filterCriterion);
                        }
                    }
                }

                query.SelectList(list => list
                                 .Select(x => x.Id).WithAlias(() => resultAlias.EntityId)
                                 .Select(x => x.OfficialName).WithAlias(() => resultAlias.EntityTitle)
                                 );
                query.TransformUsing(Transformers.AliasToBean <SelectableEntityParameter <Nomenclature> >());
                return(query.List <SelectableParameter>());
            })
                );

            nomenclatureParam.AddFilterOnSourceSelectionChanged(nomenclatureTypeParam,
                                                                () => {
                var selectedValues = nomenclatureTypeParam.GetSelectedValues();
                if (!selectedValues.Any())
                {
                    return(null);
                }
                return(Restrictions.On <Nomenclature>(x => x.Category).IsIn(nomenclatureTypeParam.GetSelectedValues().ToArray()));
            }
                                                                );

            //Предзагрузка. Для избежания ленивой загрузки
            UoW.Session.QueryOver <ProductGroup>().Fetch(SelectMode.Fetch, x => x.Childs).List();

            filter.CreateParameterSet(
                "Группы товаров",
                "product_group",
                new RecursiveParametersFactory <ProductGroup>(UoW,
                                                              (filters) => {
                var query = UoW.Session.QueryOver <ProductGroup>();
                if (filters != null && filters.Any())
                {
                    foreach (var f in filters)
                    {
                        query.Where(f());
                    }
                }
                return(query.List());
            },
                                                              x => x.Name,
                                                              x => x.Childs)
                );

            var viewModel    = new SelectableParameterReportFilterViewModel(filter);
            var filterWidget = new SelectableParameterReportFilterView(viewModel);

            vboxParameters.Add(filterWidget);
            filterWidget.Show();
        }
示例#4
0
        public AtWorksDlg(IDefaultDeliveryDaySchedule defaultDeliveryDaySchedule)
        {
            if (defaultDeliveryDaySchedule == null)
            {
                throw new ArgumentNullException(nameof(defaultDeliveryDaySchedule));
            }

            this.Build();

            var colorWhite    = new Color(0xff, 0xff, 0xff);
            var colorLightRed = new Color(0xff, 0x66, 0x66);

            ytreeviewAtWorkDrivers.ColumnsConfig = FluentColumnsConfig <AtWorkDriver> .Create()
                                                   .AddColumn("Приоритет")
                                                   .AddNumericRenderer(x => x.PriorityAtDay)
                                                   .Editing(new Gtk.Adjustment(6, 1, 10, 1, 1, 1))
                                                   .AddColumn("Статус")
                                                   .AddTextRenderer(x => x.Status.GetEnumTitle())
                                                   .AddColumn("Причина")
                                                   .AddTextRenderer(x => x.Reason)
                                                   .AddSetter((cell, driver) => cell.Editable = driver.Status == AtWorkDriver.DriverStatus.NotWorking)
                                                   .AddColumn("Водитель")
                                                   .AddTextRenderer(x => x.Employee.ShortName)
                                                   .AddColumn("Скор.")
                                                   .AddTextRenderer(x => x.Employee.DriverSpeed.ToString("P0"))
                                                   .AddColumn("График работы")
                                                   .AddComboRenderer(x => x.DaySchedule)
                                                   .SetDisplayFunc(x => x.Name)
                                                   .FillItems(UoW.GetAll <DeliveryDaySchedule>().ToList())
                                                   .Editing()
                                                   .AddColumn("Оконч. работы")
                                                   .AddTextRenderer(x => x.EndOfDayText).Editable()
                                                   .AddColumn("Экспедитор")
                                                   .AddComboRenderer(x => x.WithForwarder)
                                                   .SetDisplayFunc(x => x.Employee.ShortName).Editing().Tag(Columns.Forwarder)
                                                   .AddColumn("Автомобиль")
                                                   .AddPixbufRenderer(x => x.Car != null && x.Car.IsCompanyCar ? vodovozCarIcon : null)
                                                   .AddTextRenderer(x => x.Car != null ? x.Car.RegistrationNumber : "нет")
                                                   .AddColumn("База")
                                                   .AddComboRenderer(x => x.GeographicGroup)
                                                   .SetDisplayFunc(x => x.Name)
                                                   .FillItems(GeographicGroupRepository.GeographicGroupsWithCoordinates(UoW))
                                                   .AddSetter(
                (c, n) => {
                c.Editable      = true;
                c.BackgroundGdk = n.GeographicGroup == null
                                                                ? colorLightRed
                                                                : colorWhite;
            }
                )
                                                   .AddColumn("Грузоп.")
                                                   .AddTextRenderer(x => x.Car != null ? x.Car.MaxWeight.ToString("D") : null)
                                                   .AddColumn("Районы доставки")
                                                   .AddTextRenderer(x => string.Join(", ", x.DistrictsPriorities.Select(d => d.District.DistrictName)))
                                                   .AddColumn("")
                                                   .AddColumn("Комментарий")
                                                   .AddTextRenderer(x => x.Comment)
                                                   .Editable(true)
                                                   .RowCells().AddSetter <CellRendererText>((c, n) => c.Foreground = n.Status == AtWorkDriver.DriverStatus.NotWorking? "gray": "black")
                                                   .Finish();

            ytreeviewAtWorkDrivers.Selection.Mode     = Gtk.SelectionMode.Multiple;
            ytreeviewAtWorkDrivers.Selection.Changed += YtreeviewDrivers_Selection_Changed;

            ytreeviewOnDayForwarders.ColumnsConfig = FluentColumnsConfig <AtWorkForwarder> .Create()
                                                     .AddColumn("Экспедитор").AddTextRenderer(x => x.Employee.ShortName)
                                                     .AddColumn("Едет с водителем").AddTextRenderer(x => RenderForwaderWithDriver(x))
                                                     .Finish();

            ytreeviewOnDayForwarders.Selection.Mode     = Gtk.SelectionMode.Multiple;
            ytreeviewOnDayForwarders.Selection.Changed += YtreeviewForwarders_Selection_Changed;

            ydateAtWorks.Date = DateTime.Today;

            int currentUserId = ServicesConfig.CommonServices.UserService.CurrentUserId;

            canReturnDriver = ServicesConfig.CommonServices.PermissionService.ValidateUserPresetPermission("can_return_driver_to_work", currentUserId);

            this.defaultDeliveryDaySchedule =
                UoW.GetById <DeliveryDaySchedule>(defaultDeliveryDaySchedule.GetDefaultDeliveryDayScheduleId());
        }
示例#5
0
        private void UpdateMarkersInDriverDistricts(Employee driver)
        {
            driverAddressesOverlay.Clear();

            foreach (var b in GeographicGroupRepository.GeographicGroupsWithCoordinates(ViewModel.UoW))
            {
                driverAddressesOverlay.Markers.Add(FillBaseMarker(b));
            }

            var driverAddresses = ViewModel.RoutesOnDay
                                  .Where(r => r.Driver.Id == driver.Id)
                                  .SelectMany(x => x.Addresses)
                                  .ToList();

            // добавляем маркеры заказов из маршрутников водителя
            if (driverAddresses.Any())
            {
                foreach (var address in driverAddresses)
                {
                    var addressMarker = FillAddressMarker(address.Order,
                                                          ViewModel.GetAddressMarker(ViewModel.RoutesOnDay.IndexOf(address.RouteList)),
                                                          ViewModel.GetMarkerShapeFromBottleQuantity(address.Order.Total19LBottlesToDeliver),
                                                          driverAddressesOverlay,
                                                          address.RouteList);

                    driverAddressesOverlay.Markers.Add(addressMarker);
                }
            }

            var driverDistricts = driver.DriverDistrictPrioritySets
                                  .SingleOrDefault(x => x.IsActive)
                                  ?.DriverDistrictPriorities.Select(x => x.District)
                                  .ToList();

            if (driverDistricts == null || !driverDistricts.Any())
            {
                return;
            }

            var ordersOnDay      = ViewModel.OrdersOnDay.Select(x => x).Where(x => !x.IsService).ToList();
            var ordersRouteLists = OrderSingletonRepository.GetInstance().GetAllRouteListsForOrders(ViewModel.UoW, ordersOnDay);

            //добавляем маркеры нераспределенных заказов из районов водителя
            foreach (var order in ordersOnDay)
            {
                var route = ViewModel.RoutesOnDay.FirstOrDefault(rl => rl.Addresses.Any(a => a.Order.Id == order.Id));

                if (order.DeliveryPoint.Latitude.HasValue && order.DeliveryPoint.Longitude.HasValue)
                {
                    if (!ordersRouteLists.TryGetValue(order.Id, out var orderRls))
                    {
                        orderRls = new List <int>();
                    }

                    if (driverDistricts.Contains(order.DeliveryPoint.District) && route == null)
                    {
                        FillTypeAndShapeMarker(order, null, orderRls, out PointMarkerShape shape, out PointMarkerType type);
                        var addressMarker = FillAddressMarker(order, type, shape, driverAddressesOverlay, null);
                        driverAddressesOverlay.Markers.Add(addressMarker);
                    }
                }
            }
        }
示例#6
0
        void ConfigureDlg()
        {
            ytreeviewGeographicGroup.ColumnsConfig = FluentColumnsConfig <GeographicGroupNode>
                                                     .Create()
                                                     .AddColumn("Выбрать").AddToggleRenderer(x => x.Selected).Editing()
                                                     .AddColumn("Район города").AddTextRenderer(x => x.GeographicGroup.Name)
                                                     .Finish();

            ytreeviewGeographicGroup.Binding.AddBinding(ViewModel, vm => vm.GeographicGroupNodes, w => w.ItemsDataSource).InitializeFromSource();
            ytreeviewGeographicGroup.HeadersVisible = false;

            if (progressOrders.Adjustment == null)
            {
                progressOrders.Adjustment = new Adjustment(0, 0, 0, 1, 1, 0);
            }

            //Configure map
            districtsOverlay.IsVisibile = false;
            gmapWidget.MapProvider      = GMapProviders.YandexMap;
            gmapWidget.Position         = new PointLatLng(59.93900, 30.31646);
            gmapWidget.HeightRequest    = 150;
            gmapWidget.HasFrame         = true;
            gmapWidget.Overlays.Add(districtsOverlay);
            gmapWidget.Overlays.Add(driverDistrictsOverlay);
            gmapWidget.Overlays.Add(routeOverlay);
            gmapWidget.Overlays.Add(addressesOverlay);
            gmapWidget.Overlays.Add(driverAddressesOverlay);
            gmapWidget.Overlays.Add(selectionOverlay);
            gmapWidget.DisableAltForSelection = true;
            gmapWidget.OnSelectionChange     += GmapWidget_OnSelectionChange;
            gmapWidget.ButtonPressEvent      += GmapWidget_ButtonPressEvent;
            gmapWidget.ButtonReleaseEvent    += GmapWidget_ButtonReleaseEvent;
            gmapWidget.MotionNotifyEvent     += GmapWidget_MotionNotifyEvent;

            yenumcomboMapType.ItemsEnum         = typeof(MapProviders);
            yenumcomboMapType.SelectedItem      = MapProviders.YandexMap;
            yenumcomboMapType.EnumItemSelected += (sender, e) => gmapWidget.MapProvider = MapProvidersHelper.GetPovider((MapProviders)yenumcomboMapType.SelectedItem);

            LoadDistrictsGeometry();

            var colorPink     = new Gdk.Color(0xff, 0xc0, 0xc0);
            var colorWhite    = new Gdk.Color(0xff, 0xff, 0xff);
            var colorLightRed = new Gdk.Color(0xff, 0x66, 0x66);

            ytreeRoutes.ColumnsConfig = FluentColumnsConfig <object>
                                        .Create()
                                        .AddColumn("Маркер").AddPixbufRenderer(x => GetRowMarker(x))
                                        .AddColumn("МЛ/Адрес").AddTextRenderer(x => ViewModel.GetRowTitle(x))
                                        .AddColumn("Адр./Время").AddTextRenderer(x => ViewModel.GetRowTime(x), useMarkup: true)
                                        .AddColumn("План").AddTextRenderer(x => ViewModel.GetRowPlanTime(x), useMarkup: true)
                                        .AddColumn("Бутылей").AddTextRenderer(x => ViewModel.GetRowBottles(x), useMarkup: true)
                                        .AddColumn("Бут. 6л").AddTextRenderer(x => ViewModel.GetRowBottlesSix(x))
                                        .AddColumn("Бут. менее 6л").AddTextRenderer(x => ViewModel.GetRowBottlesSmall(x))
                                        .AddColumn("Вес, кг").AddTextRenderer(x => ViewModel.GetRowWeight(x), useMarkup: true)
                                        .AddColumn("Объём, куб.м.").AddTextRenderer(x => ViewModel.GetRowVolume(x), useMarkup: true)
                                        .AddColumn("Погрузка").Tag(RouteColumnTag.OnloadTime)
                                        .AddTextRenderer(x => ViewModel.GetRowOnloadTime(x), useMarkup: true)
                                        .AddSetter((c, n) => c.Editable = n is RouteList)
                                        .EditedEvent(OnLoadTimeEdited)
                                        .AddColumn("Километраж").AddTextRenderer(x => ViewModel.GetRowDistance(x))
                                        .AddColumn("К клиенту").AddTextRenderer(x => ViewModel.GetRowEquipmentToClient(x))
                                        .AddColumn("От клиента").AddTextRenderer(x => ViewModel.GetRowEquipmentFromClient(x))
                                        .Finish();

            ytreeRoutes.HasTooltip         = true;
            ytreeRoutes.QueryTooltip      += YtreeRoutes_QueryTooltip;
            ytreeRoutes.Selection.Changed += YtreeRoutes_Selection_Changed;

            Pixbuf vodovozCarIcon = Pixbuf.LoadFromResource("Vodovoz.icons.buttons.vodovoz-logo.png");

            ytreeviewOnDayDrivers.ColumnsConfig = FluentColumnsConfig <AtWorkDriver>
                                                  .Create()
                                                  .AddColumn("Водитель").AddTextRenderer(x => x.Employee.ShortName)
                                                  .AddColumn("Автомобиль").AddPixbufRenderer(x => x.Car != null && x.Car.IsCompanyCar ? vodovozCarIcon : null)
                                                  .AddTextRenderer(x => x.Car != null ? x.Car.RegistrationNumber : "нет")
                                                  .AddColumn("База").AddComboRenderer(x => x.GeographicGroup).SetDisplayFunc(x => x.Name)
                                                  .FillItems(GeographicGroupRepository.GeographicGroupsWithCoordinates(ViewModel.UoW))
                                                  .AddSetter(
                (c, n) => {
                c.Editable      = n.Car != null;
                c.BackgroundGdk = n.GeographicGroup == null && n.Car != null
                                                                        ? colorLightRed
                                                                        : colorWhite;
            }
                )
                                                  .AddColumn("")
                                                  .Finish();

            ytreeviewOnDayDrivers.Selection.Mode     = SelectionMode.Multiple;
            ytreeviewOnDayDrivers.Selection.Changed += (sender, e) => ViewModel.SelectedDrivers = ytreeviewOnDayDrivers.GetSelectedObjects <AtWorkDriver>().ToArray();
            ytreeviewOnDayDrivers.Binding.AddBinding(ViewModel, vm => vm.ObservableDriversOnDay, w => w.ItemsDataSource).InitializeFromSource();

            ytreeviewAddressesTypes.ColumnsConfig = FluentColumnsConfig <AddressTypeNode> .Create()
                                                    .AddColumn("").AddToggleRenderer(x => x.Selected)
                                                    .AddColumn("Тип адресов").AddTextRenderer(x => x.Title)
                                                    .Finish();

            ytreeviewAddressesTypes.ItemsDataSource = ViewModel.AddressTypes;


            buttonAddDriver.Clicked += (sender, e) => ViewModel.AddDriverCommand.Execute();

            buttonRemoveDriver.Binding.AddBinding(ViewModel, vm => vm.AreDriversSelected, w => w.Sensitive).InitializeFromSource();
            buttonRemoveDriver.Clicked += (sender, e) => ViewModel.RemoveDriverCommand.Execute(null);

            buttonDriverSelectAuto.Binding.AddBinding(ViewModel, vm => vm.AreDriversSelected, w => w.Sensitive).InitializeFromSource();

            ytreeviewOnDayForwarders.ColumnsConfig = FluentColumnsConfig <AtWorkForwarder>
                                                     .Create()
                                                     .AddColumn("Экспедитор").AddTextRenderer(x => x.Employee.ShortName)
                                                     .Finish();

            ytreeviewOnDayForwarders.Selection.Mode     = SelectionMode.Multiple;
            ytreeviewOnDayForwarders.Selection.Changed += (sender, e) => ViewModel.SelectedForwarder = ytreeviewOnDayForwarders.GetSelectedObjects <AtWorkForwarder>().FirstOrDefault();
            ytreeviewOnDayForwarders.Binding.AddBinding(ViewModel, vm => vm.ObservableForwardersOnDay, w => w.ItemsDataSource).InitializeFromSource();

            buttonAddForwarder.Clicked += (sender, e) => ViewModel.AddForwarderCommand.Execute();

            buttonRemoveForwarder.Binding.AddBinding(ViewModel, vm => vm.IsForwarderSelected, w => w.Sensitive).InitializeFromSource();
            buttonRemoveForwarder.Clicked += (sender, e) => ViewModel.RemoveForwarderCommand.Execute(ytreeviewOnDayForwarders.GetSelectedObjects <AtWorkForwarder>());

            yspinMaxTime.Binding.AddBinding(ViewModel.Optimizer, e => e.MaxTimeSeconds, w => w.ValueAsInt).InitializeFromSource();

            yspeccomboboxCashSubdivision.ShowSpecialStateNot = true;
            yspeccomboboxCashSubdivision.Binding.AddBinding(ViewModel, vm => vm.ObservableSubdivisions, w => w.ItemsList).InitializeFromSource();
            yspeccomboboxCashSubdivision.Binding.AddBinding(ViewModel, vm => vm.ClosingSubdivision, w => w.SelectedItem).InitializeFromSource();

            ydateForRoutes.Binding.AddBinding(ViewModel, vm => vm.DateForRouting, w => w.DateOrNull).InitializeFromSource();
            checkShowCompleted.Binding.AddBinding(ViewModel, vm => vm.ShowCompleted, w => w.Active).InitializeFromSource();
            ySpnMin19Btls.Binding.AddBinding(ViewModel, vm => vm.MinBottles19L, w => w.ValueAsInt).InitializeFromSource();
            ydateForRoutes.Binding.AddBinding(ViewModel, vm => vm.HasNoChanges, w => w.Sensitive).InitializeFromSource();
            checkShowCompleted.Binding.AddBinding(ViewModel, vm => vm.HasNoChanges, w => w.Sensitive).InitializeFromSource();
            checkShowOnlyDriverOrders.Binding.AddBinding(ViewModel, vm => vm.ShowOnlyDriverOrders, w => w.Active).InitializeFromSource();
            checkShowOnlyDriverOrders.Toggled += (sender, e) => GetRowFromYTreeRoutes();

            timeRngPicker.Binding.AddBinding(ViewModel, vm => vm.HasNoChanges, w => w.Sensitive).InitializeFromSource();
            ySpnMin19Btls.Binding.AddBinding(ViewModel, vm => vm.HasNoChanges, w => w.Sensitive).InitializeFromSource();

            timeRngPicker.Binding.AddBinding(ViewModel, vm => vm.DeliveryFromTime, w => w.TimeStart).InitializeFromSource();
            timeRngPicker.Binding.AddBinding(ViewModel, vm => vm.DeliveryToTime, w => w.TimeEnd).InitializeFromSource();
            timeRngPicker.TimePeriodChangedByUser += (sender, e) => FillItems();

            timeDrvShiftRngpicker.Binding.AddBinding(ViewModel, vm => vm.DriverStartTime, t => t.TimeStart).InitializeFromSource();
            timeDrvShiftRngpicker.Binding.AddBinding(ViewModel, vm => vm.DriverEndTime, t => t.TimeEnd).InitializeFromSource();
            timeDrvShiftRngpicker.Binding.AddBinding(ViewModel, vm => vm.HasNoChanges, w => w.Sensitive).InitializeFromSource();

            checkShowDistricts.Toggled += (sender, e) => districtsOverlay.IsVisibile = checkShowDistricts.Active;

            ViewModel.AutoroutingResultsSaved += (sender, e) => FillDialogAtDay();

            btnSave.Binding.AddBinding(ViewModel, e => e.IsAutoroutingModeActive, w => w.Visible).InitializeFromSource();
            btnSave.Clicked += (sender, e) => ViewModel.SaveCommand.Execute();

            btnCancel.Binding.AddBinding(ViewModel, e => e.IsAutoroutingModeActive, w => w.Visible).InitializeFromSource();
            btnCancel.Clicked += (sender, e) => {
                ViewModel.DisposeUoW();
                ViewModel.CreateUoW();
                ViewModel.HasNoChanges            = true;
                ViewModel.IsAutoroutingModeActive = false;
                FillDialogAtDay();
            };
            btnRefresh.Clicked         += (sender, e) => Refresh();
            ydateForRoutes.DateChanged += (sender, e) => Refresh();
            Refresh();
            buttonRemoveAddress.Clicked += (sender, e) => {
                ViewModel.RemoveRLItemCommand.Execute(ytreeRoutes.GetSelectedObject <RouteListItem>());
                UpdateMarkersInDriverDistricts(ViewModel.DriverFromRouteList);
                ytreeRoutes.YTreeModel.EmitModelChanged();
                UpdateAddressesOnMap();
            };
            checkShowCompleted.Toggled += (sender, e) => FillDialogAtDay();
            buttonOpen.Clicked         += (sender, e) => ViewModel.OpenOrderOrRouteListCommand.Execute(ytreeRoutes.GetSelectedObject());
            buttonMapHelp.Clicked      += (sender, e) => new RouresAtDayInfoWnd().Show();
            buttonRebuildRoute.Clicked += (sender, e) => {
                ViewModel.RebuilOneRouteCommand.Execute(ytreeRoutes.GetSelectedObject());
                ytreeRoutes.YTreeModel.EmitModelChanged();
            };
            buttonWarnings.Clicked             += (sender, e) => ViewModel.ShowWarningsCommand.Execute();
            ytreeviewOnDayDrivers.RowActivated += OnButtonDriverSelectAutoClicked;
            buttonFilter.Clicked         += (sender, e) => FillItems();
            enumCmbDeliveryType.ItemsEnum = typeof(DeliveryScheduleFilterType);
            enumCmbDeliveryType.Binding.AddBinding(ViewModel, vm => vm.DeliveryScheduleType, w => w.SelectedItem).InitializeFromSource();
            enumCmbDeliveryType.ChangedByUser += (sender, e) => FillItems();

            ytextWorkDriversInfo.Binding.AddBinding(ViewModel, vm => vm.CanTake, w => w.Buffer.Text).InitializeFromSource();
        }