public DeliveryPriceDlg() { this.Build(); TabName = "Расчет стоимости доставки"; entryCity.CitySelected += (sender, e) => { entryBuilding.House = string.Empty; entryStreet.CityId = entryCity.OsmId; entryStreet.Street = string.Empty; entryStreet.StreetDistrict = string.Empty; }; entryStreet.StreetSelected += (sender, e) => { entryBuilding.Street = new OsmStreet(-1, entryStreet.CityId, entryStreet.Street, entryStreet.StreetDistrict); }; entryBuilding.CompletionLoaded += EntryBuilding_Changed; entryBuilding.Changed += EntryBuilding_Changed; //Configure map MapWidget.MapProvider = GMapProviders.GoogleMap; MapWidget.Position = new PointLatLng(59.93900, 30.31646); MapWidget.MinZoom = 0; MapWidget.MaxZoom = 24; MapWidget.Zoom = 9; MapWidget.WidthRequest = 450; MapWidget.HasFrame = true; MapWidget.Overlays.Add(addressOverlay); yenumcomboMapType.ItemsEnum = typeof(MapProviders); yenumcomboMapType.EnumItemSelected += (sender, args) => MapWidget.MapProvider = MapProvidersHelper.GetPovider((MapProviders)args.SelectedItem); }
void ConfigureDlg() { yEntryName.Binding.AddBinding(Entity, x => x.Name, w => w.Text).InitializeFromSource(); lblCoordinatesValue.Binding.AddBinding( Entity, x => x.CoordinatesText, w => w.Text ).InitializeFromSource(); gMapWidget.MapProvider = GMapProviders.GoogleMap; gMapWidget.Position = Entity.BaseCoordinatesExist ? new PointLatLng((double)Entity.BaseLatitude.Value, (double)Entity.BaseLongitude.Value) : new PointLatLng(59.93900, 30.31646); gMapWidget.MinZoom = 0; gMapWidget.MaxZoom = 24; gMapWidget.Zoom = 9; gMapWidget.HasFrame = true; gMapWidget.Overlays.Add(addressOverlay); if (Entity.Id == 0 || QSMain.User.Admin) { gMapWidget.ButtonPressEvent += GMapWidget_ButtonPressEvent; gMapWidget.ButtonReleaseEvent += GMapWidget_ButtonReleaseEvent; gMapWidget.MotionNotifyEvent += GMapWidget_MotionNotifyEvent; } comboMapProvider.TooltipText = "Если карта отображается некорректно или не отображается вовсе - смените тип карты"; comboMapProvider.ItemsEnum = typeof(MapProviders); comboMapProvider.SelectedItem = MapProviders.GoogleMap; comboMapProvider.EnumItemSelected += (sender, args) => gMapWidget.MapProvider = MapProvidersHelper.GetPovider((MapProviders)args.SelectedItem); Entity.PropertyChanged += Entity_PropertyChanged; UpdateAddressOnMap(); }
private void ConfigureMap() { gmapWidget.MapProvider = GMapProviders.GoogleMap; gmapWidget.Position = new PointLatLng(59.93900, 30.31646); gmapWidget.HeightRequest = 150; gmapWidget.MinZoom = 0; gmapWidget.MaxZoom = 24; gmapWidget.Zoom = 9; gmapWidget.MouseWheelZoomEnabled = true; gmapWidget.Overlays.Add(tracksOverlay); gmapWidget.Overlays.Add(trackToBaseOverlay); gmapWidget.Overlays.Add(trackOnGapOverlay); gmapWidget.Overlays.Add(addressesOverlay); gmapWidget.ExposeEvent += GmapWidget_ExposeEvent; gmapWidget.MotionNotifyEvent += GmapWidget_MotionNotifyEvent; comboMapProvider.TooltipText = "Если карта отображается некорректно или не отображается вовсе - смените тип карты"; comboMapProvider.ItemsEnum = typeof(MapProviders); comboMapProvider.SelectedItem = MapProviders.GoogleMap; comboMapProvider.EnumItemSelected += (sender, args) => gmapWidget.MapProvider = MapProvidersHelper.GetPovider((MapProviders)args.SelectedItem); }
protected void OnYenumcomboMapTypeChangedByUser(object sender, EventArgs e) { gmapWidget.MapProvider = MapProvidersHelper.GetPovider((MapProviders)yenumcomboMapType.SelectedItem); }
private void ConfigureView() { #region TreeView var colorRed = new Color(255, 0, 0); var colorWhite = new Color(255, 255, 255); ytreeDistricts.ColumnsConfig = FluentColumnsConfig <FinancialDistrict> .Create() .AddColumn("Код") .HeaderAlignment(0.5f) .AddTextRenderer(x => x.Id.ToString()) .AddColumn("Название") .HeaderAlignment(0.5f) .AddTextRenderer(x => x.Name) .AddSetter((c, n) => c.Editable = n.FinancialDistrictsSet.Status != DistrictsSetStatus.Active) .AddColumn("Организация") .AddComboRenderer(x => x.Organization) .SetDisplayFunc(x => x.Name) .FillItems(ViewModel.UoW.GetAll <Domain.Organizations.Organization>().ToList()) .AddSetter((c, n) => c.Editable = n.FinancialDistrictsSet.Status != DistrictsSetStatus.Active) .AddColumn("") .Finish(); ytreeDistricts.Binding.AddBinding(ViewModel.Entity, e => e.ObservableFinancialDistricts, w => w.ItemsDataSource).InitializeFromSource(); ytreeDistricts.Selection.Changed += YTreeDistrictsSelectionOnChanged; #endregion btnSave.Clicked += (sender, args) => ViewModel.Save(); btnSave.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict || vm.CanEdit, w => w.Sensitive).InitializeFromSource(); btnCancel.Clicked += (sender, args) => ViewModel.Close(true, CloseSource.Cancel); ylabelStatusString.Text = ViewModel.Entity.Status.GetEnumTitle(); entryName.Binding.AddBinding(ViewModel.Entity, e => e.Name, w => w.Text).InitializeFromSource(); entryName.Binding.AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive).InitializeFromSource(); btnAddDistrict.Binding.AddFuncBinding(ViewModel, vm => vm.CanCreateDistrict, w => w.Sensitive).InitializeFromSource(); btnAddDistrict.Clicked += BtnAddDistrictOnClicked; btnRemoveDistrict.Clicked += BtnRemoveDistrictOnClicked; btnRemoveDistrict.Binding.AddFuncBinding(ViewModel, vm => vm.SelectedDistrict != null && vm.CanDeleteDistrict, w => w.Sensitive).InitializeFromSource(); #region GMap btnAddBorder.Binding.AddFuncBinding(ViewModel, vm => !vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); btnAddBorder.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && !vm.IsCreatingNewBorder && vm.SelectedDistrict != null && vm.SelectedDistrict.Border == null, w => w.Sensitive).InitializeFromSource(); btnAddBorder.Clicked += BtnAddBorderOnClicked; btnRemoveBorder.Binding.AddFuncBinding(ViewModel, vm => !vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); btnRemoveBorder.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && !vm.IsCreatingNewBorder && vm.SelectedDistrict != null && vm.SelectedDistrict.Border != null, w => w.Sensitive).InitializeFromSource(); btnRemoveBorder.Clicked += BtnRemoveBorderOnClicked; btnConfirmNewBorder.Binding.AddFuncBinding(ViewModel, vm => vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); btnConfirmNewBorder.Binding.AddFuncBinding(ViewModel, vm => vm.SelectedDistrict != null && vm.IsCreatingNewBorder, w => w.Sensitive).InitializeFromSource(); btnConfirmNewBorder.Clicked += BtnConfirmNewBorderOnClicked; btnCancelNewBorder.Binding.AddFuncBinding(ViewModel, vm => vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); btnCancelNewBorder.Binding.AddFuncBinding(ViewModel, vm => vm.SelectedDistrict != null && vm.IsCreatingNewBorder, w => w.Sensitive).InitializeFromSource(); btnCancelNewBorder.Clicked += BtnCancelNewBorderOnClicked; toggleNewBorderPreview.Binding.AddFuncBinding(ViewModel, vm => vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); toggleNewBorderPreview.Binding.AddFuncBinding(ViewModel, vm => vm.SelectedDistrict != null && vm.IsCreatingNewBorder, w => w.Sensitive).InitializeFromSource(); toggleNewBorderPreview.Toggled += ToggleNewBorderPreviewOnToggled; cmbMapType.ItemsEnum = typeof(MapProviders); cmbMapType.TooltipText = "Если карта отображается некорректно или не отображается вовсе - смените тип карты"; cmbMapType.EnumItemSelected += (sender, args) => gmapWidget.MapProvider = MapProvidersHelper.GetPovider((MapProviders)args.SelectedItem); cmbMapType.SelectedItem = MapProviders.GoogleMap; gmapWidget.Position = new PointLatLng(59.93900, 30.31646); gmapWidget.HeightRequest = 150; gmapWidget.HasFrame = true; gmapWidget.Overlays.Add(bordersOverlay); newBordersPreviewOverlay.IsVisibile = false; gmapWidget.Overlays.Add(newBordersPreviewOverlay); gmapWidget.Overlays.Add(verticeOverlay); RefreshBorders(); gmapWidget.ButtonPressEvent += GmapWidgetOnButtonPressEvent; #endregion }
private void Configure() { notebook1.Binding .AddBinding(ViewModel, vm => vm.CurrentPage, w => w.CurrentPage) .InitializeFromSource(); notebook1.SwitchPage += (o, args) => { if (args.PageNum == 1) { radioFixedPrices.Active = true; } }; notebook1.ShowTabs = false; buttonSave.Clicked += (sender, args) => { deliverypointresponsiblepersonsview1.RemoveEmpty(); ViewModel.Save(true); }; buttonSave.Binding .AddFuncBinding(ViewModel, vm => !vm.IsInProcess && vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); buttonCancel.Clicked += (sender, args) => ViewModel.Close(false, CloseSource.Cancel); buttonCancel.Binding .AddFuncBinding(ViewModel, vm => !vm.IsInProcess, w => w.Sensitive) .InitializeFromSource(); buttonInsertFromBuffer.Clicked += (s, a) => ViewModel.SetCoordinatesFromBuffer(_clipboard.WaitForText()); buttonInsertFromBuffer.Sensitive = ViewModel.CanEdit; buttonApplyLimitsToAllDeliveryPointsOfCounterparty.Clicked += (s, a) => ViewModel.ApplyOrderSumLimitsToAllDeliveryPointsOfClient(); buttonApplyLimitsToAllDeliveryPointsOfCounterparty.Sensitive = ViewModel.CanEdit; radioInformation.Toggled += RadioInformationOnToggled; radioFixedPrices.Toggled += RadioFixedPricesOnToggled; ybuttonOpenOnMap.Binding .AddBinding(ViewModel.Entity, e => e.CoordinatesExist, w => w.Visible) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); ybuttonOpenOnMap.Clicked += (s, a) => ViewModel.OpenOnMapCommand.Execute(); #region Address entries entryCity.CitiesDataLoader = ViewModel.CitiesDataLoader; entryStreet.StreetsDataLoader = ViewModel.StreetsDataLoader; entryBuilding.HousesDataLoader = ViewModel.HousesDataLoader; entryCity.CitySelected += EntryCityOnCitySelected; entryStreet.StreetSelected += EntryStreetOnStreetSelected; entryStreet.FocusOutEvent += EntryStreetOnFocusOutEvent; entryBuilding.FocusOutEvent += EntryBuildingOnFocusOutEvent; entryCity.Binding.AddSource(ViewModel.Entity) .AddBinding(e => e.City, w => w.CityName) .AddBinding(e => e.CityFiasGuid, w => w.FiasGuid) .AddBinding(e => e.LocalityType, w => w.CityTypeName) .AddBinding(e => e.LocalityTypeShort, w => w.CityTypeNameShort) .AddSource(ViewModel) .AddBinding(vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); entryCity.FireCityChange(); entryStreet.Binding.AddSource(ViewModel.Entity) .AddBinding(e => e.Street, w => w.StreetName) .AddBinding(e => e.StreetDistrict, w => w.StreetDistrict) .AddBinding(e => e.StreetType, w => w.StreetTypeName) .AddBinding(e => e.StreetTypeShort, w => w.StreetTypeNameShort) .AddBinding(e => e.StreetFiasGuid, w => w.FiasGuid) .AddSource(ViewModel) .AddBinding(vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); entryStreet.FireStreetChange(); entryBuilding.Binding.AddSource(ViewModel.Entity) .AddBinding(e => e.BuildingFiasGuid, w => w.FiasGuid) .AddBinding(e => e.Building, w => w.BuildingName) .AddSource(ViewModel) .AddBinding(vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); ViewModel.CityBeforeChange = entryCity.CityName; ViewModel.StreetBeforeChange = entryStreet.StreetName; ViewModel.BuildingBeforeChange = entryBuilding.BuildingName; #endregion phonesview1.ViewModel = ViewModel.PhonesViewModel; ySpecCmbCategory.ItemsList = ViewModel.DeliveryPointCategories; ySpecCmbCategory.Binding .AddBinding(ViewModel.Entity, e => e.Category, w => w.SelectedItem) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); ycheckHaveResidue.Binding.AddSource(ViewModel.Entity) .AddFuncBinding(e => e.HaveResidue.HasValue, w => w.Visible) .AddFuncBinding(e => e.HaveResidue.HasValue && e.HaveResidue.Value, w => w.Active) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); comboRoomType.ItemsEnum = typeof(RoomType); comboRoomType.Binding .AddBinding(ViewModel.Entity, e => e.RoomType, w => w.SelectedItem) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); yenumEntranceType.ItemsEnum = typeof(EntranceType); yenumEntranceType.Binding .AddBinding(ViewModel.Entity, e => e.EntranceType, w => w.SelectedItem) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); entryDefaultDeliverySchedule.SetEntityAutocompleteSelectorFactory(ViewModel.DeliveryScheduleSelectorFactory); entryDefaultDeliverySchedule.Binding .AddBinding(ViewModel.Entity, e => e.DeliverySchedule, w => w.Subject) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); checkIsActive.Binding .AddBinding(ViewModel.Entity, e => e.IsActive, w => w.Active) .AddSource(ViewModel) .AddFuncBinding(vm => vm.CanArchiveDeliveryPoint, w => w.Sensitive) .InitializeFromSource(); textComment.Binding .AddBinding(ViewModel.Entity, e => e.Comment, w => w.Buffer.Text) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); labelCompiledAddress.Binding .AddBinding(ViewModel.Entity, e => e.CompiledAddress, w => w.LabelProp) .InitializeFromSource(); entryRoom.Binding .AddBinding(ViewModel.Entity, e => e.Room, w => w.Text) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); entryFloor.Binding .AddBinding(ViewModel.Entity, e => e.Floor, w => w.Text) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); entryEntrance.Binding .AddBinding(ViewModel.Entity, e => e.Entrance, w => w.Text) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); spinMinutesToUnload.Binding .AddBinding(ViewModel.Entity, e => e.MinutesToUnload, w => w.ValueAsInt) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); hboxOrganisation.Binding .AddFuncBinding(ViewModel.Entity, e => e.Counterparty != null && e.Counterparty.PersonType == PersonType.natural, w => w.Visible) .InitializeFromSource(); ylabelOrganisation.Binding .AddFuncBinding(ViewModel.Entity, e => e.Counterparty != null && e.Counterparty.PersonType == PersonType.natural, w => w.Visible) .InitializeFromSource(); yentryOrganisation.Binding .AddBinding(ViewModel.Entity, e => e.Organization, w => w.Text) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); yentryKPP.Binding .AddBinding(ViewModel.Entity, e => e.KPP, w => w.Text) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); entryDefaultWater.SetEntityAutocompleteSelectorFactory(ViewModel.NomenclatureSelectorFactory.GetDefaultWaterSelectorFactory()); entryDefaultWater.Binding .AddBinding(ViewModel.Entity, e => e.DefaultWaterNomenclature, w => w.Subject) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); #region Оставлено для корректного отображения старых заказов yentryAddress1c.Binding.AddSource(ViewModel.Entity) .AddBinding(e => e.Address1c, w => w.Text) .AddBinding(e => e.Address1c, w => w.TooltipText) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); labelAddress1c.Visible = yentryAddress1c.Visible = !string.IsNullOrWhiteSpace(ViewModel.Entity.Address1c); yentryCode1c.Binding .AddBinding(ViewModel.Entity, e => e.Code1c, w => w.Text) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); codeLabel.Visible = hboxCode.Visible = !string.IsNullOrWhiteSpace(ViewModel.Entity.Code1c); #endregion spinBottlesReserv.Binding .AddBinding(ViewModel.Entity, e => e.BottleReserv, w => w.ValueAsInt) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); ychkAlwaysFreeDelivery.Binding .AddBinding(ViewModel.Entity, e => e.AlwaysFreeDelivery, w => w.Active) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); ychkAlwaysFreeDelivery.Visible = ViewModel.CanSetFreeDelivery; lblCounterparty.LabelProp = ViewModel.Entity.Counterparty.FullName; lblId.LabelProp = ViewModel.Entity.Id.ToString(); ylabelFoundOnOsm.Binding.AddFuncBinding(ViewModel.Entity, e => e.CoordinatesExist ? string.Format("<span foreground='{1}'>{0}</span>", e.CoordinatesText, e.FoundOnOsm ? "green" : "blue") : "<span foreground='red'>Не найден на карте.</span>", w => w.LabelProp).InitializeFromSource(); ylabelChangedUser.Binding.AddFuncBinding(ViewModel, vm => vm.CoordsWasChanged ? $"Изменено: {vm.CoordsLastChangeUserName}" : "Никем не изменялись", w => w.LabelProp).InitializeFromSource(); ycheckOsmFixed.Binding .AddBinding(ViewModel.Entity, e => e.IsFixedInOsm, w => w.Active) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); ycheckOsmFixed.Visible = ViewModel.CurrentUserIsAdmin; chkAddCertificatesAlways.Binding .AddBinding(ViewModel.Entity, e => e.AddCertificatesAlways, w => w.Active) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); entryLunchTimeFrom.Binding .AddBinding(ViewModel.Entity, e => e.LunchTimeFrom, w => w.Time) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); entryLunchTimeTo.Binding .AddBinding(ViewModel.Entity, e => e.LunchTimeTo, w => w.Time) .AddBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive) .InitializeFromSource(); //make actions menu var menu = new Menu(); var openClientItem = new MenuItem("Открыть контрагента"); openClientItem.Activated += (s, a) => ViewModel.OpenCounterpartyCommand.Execute(); menu.Add(openClientItem); menuActions.Menu = menu; menu.ShowAll(); //Configure map _mapWidget = new GMapControl { MapProvider = GMapProviders.GoogleMap, Position = new PointLatLng(59.93900, 30.31646), MinZoom = 0, MaxZoom = 24, Zoom = 9, WidthRequest = 500, HasFrame = true }; _mapWidget.Overlays.Add(_addressOverlay); _mapWidget.ButtonPressEvent += MapWidgetOnButtonPressEvent; _mapWidget.ButtonReleaseEvent += MapWidgetOnButtonReleaseEvent; _mapWidget.MotionNotifyEvent += MapWidgetOnMotionNotifyEvent; _mapWidget.Sensitive = ViewModel.CanEdit; _vboxMap = new VBox(); _comboMapType = new yEnumComboBox(); _comboMapType.ItemsEnum = typeof(MapProviders); _comboMapType.SelectedItem = MapProviders.GoogleMap; _comboMapType.EnumItemSelected += (sender, args) => { _mapWidget.MapProvider = MapProvidersHelper.GetPovider((MapProviders)args.SelectedItem); }; _vboxMap.Add(_comboMapType); _vboxMap.SetChildPacking(_comboMapType, false, false, 0, PackType.Start); _vboxMap.Add(_mapWidget); _vboxMap.ShowAll(); sidePanelMap.Panel = _vboxMap; sidePanelMap.IsHided = false; ViewModel.PropertyChanged += ViewModelOnPropertyChanged; UpdateAddressOnMap(); if (ViewModel.DeliveryPoint.Counterparty.IsForRetail) { ySpinLimitMin.ValueAsInt = int.MinValue; ySpinLimitMax.ValueAsInt = int.MaxValue; ySpinLimitMin.Sensitive = ViewModel.CanEditOrderLimits; ySpinLimitMax.Sensitive = ViewModel.CanEditOrderLimits; ySpinLimitMin.Binding.AddBinding(ViewModel.Entity, e => e.MinimalOrderSumLimit, w => w.ValueAsInt).InitializeFromSource(); ySpinLimitMax.Binding.AddBinding(ViewModel.Entity, e => e.MaximalOrderSumLimit, w => w.ValueAsInt).InitializeFromSource(); //FIXME этот виджет следовало бы переписать на VM + V deliverypointresponsiblepersonsview1.UoW = ViewModel.UoW; deliverypointresponsiblepersonsview1.DeliveryPoint = ViewModel.DeliveryPoint; deliverypointresponsiblepersonsview1.ResponsiblePersons = ViewModel.ResponsiblePersons; deliverypointresponsiblepersonsview1.Sensitive = ViewModel.CanEdit; } else { labelLimit.Visible = false; hboxLimits.Visible = false; deliverypointresponsiblepersonsview1.Visible = false; labelResponsiblePersons.Visible = false; } }
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.GoogleMap; 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.TooltipText = "Если карта отображается некорректно или не отображается вовсе - смените тип карты"; yenumcomboMapType.EnumItemSelected += (sender, args) => gmapWidget.MapProvider = MapProvidersHelper.GetPovider((MapProviders)args.SelectedItem); yenumcomboMapType.SelectedItem = MapProviders.GoogleMap; 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(ViewModel.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 <OrderAddressTypeNode> .Create() .AddColumn("").AddToggleRenderer(x => x.Selected) .AddColumn("Тип адресов").AddTextRenderer(x => x.Title) .Finish(); ytreeviewAddressesTypes.ItemsDataSource = ViewModel.OrderAddressTypes; 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(); viewDeliverySummary.ColumnsConfig = FluentColumnsConfig <DeliverySummary> .Create() .AddColumn("Статус").AddTextRenderer(x => x.Name) .AddColumn("Адреса").AddTextRenderer(x => x.AddressCount.ToString()).XAlign(0.5f) .AddColumn("Бутыли").AddTextRenderer(x => x.Bottles.ToString("N0")).XAlign(0.5f) .Finish(); viewDeliverySummary.Binding.AddBinding(ViewModel, vm => vm.ObservableDeliverySummary, w => w.ItemsDataSource).InitializeFromSource(); }
private void Configure() { #region TreeViews var colorRed = new Gdk.Color(255, 0, 0); var colorWhite = new Gdk.Color(255, 255, 255); ytreeDistricts.ColumnsConfig = ColumnsConfigFactory.Create <District>() .AddColumn("Код") .HeaderAlignment(0.5f) .AddTextRenderer(x => x.Id.ToString()) .AddColumn("Название") .HeaderAlignment(0.5f) .AddTextRenderer(x => x.DistrictName) .Editable() .AddColumn("Тарифная зона") .HeaderAlignment(0.5f) .AddComboRenderer(x => x.TariffZone) .SetDisplayFunc(x => x.Name) .FillItems(ViewModel.UoW.GetAll <TariffZone>().ToList(), "Нет") .Editing() .AddColumn("Мин. бутылей") .HeaderAlignment(0.5f) .AddTextRenderer(x => x.ObservableCommonDistrictRuleItems.Any() ? x.ObservableCommonDistrictRuleItems.Min(c => c.DeliveryPriceRule.Water19LCount).ToString() : "-" ) .XAlign(0.5f) .AddColumn("") .Finish(); ytreeDistricts.Binding.AddBinding(ViewModel.Entity, e => e.ObservableDistricts, w => w.ItemsDataSource).InitializeFromSource(); ytreeDistricts.Selection.Changed += (sender, args) => { if (ViewModel.IsCreatingNewBorder) { ViewModel.CancelNewBorderCommand.Execute(); toggleNewBorderPreview.Active = false; } ViewModel.SelectedDistrict = ytreeDistricts.GetSelectedObject() as District; }; ytreeScheduleRestrictions.ColumnsConfig = ColumnsConfigFactory.Create <DeliveryScheduleRestriction>() .AddColumn("График") .MinWidth(150) .HeaderAlignment(0.5f) .AddTextRenderer(x => x.DeliverySchedule.Name) .AddColumn("Прием до") .SetTag(acceptBeforeColumnTag) .HeaderAlignment(0.5f) .AddTextRenderer(x => x.AcceptBeforeTitle) .AddSetter((c, r) => c.BackgroundGdk = r.AcceptBefore == null ? colorRed : colorWhite) .Finish(); ytreeScheduleRestrictions.Binding.AddBinding(ViewModel, vm => vm.ScheduleRestrictions, w => w.ItemsDataSource); ytreeScheduleRestrictions.Selection.Changed += (sender, args) => ViewModel.SelectedScheduleRestriction = ytreeScheduleRestrictions.GetSelectedObject() as DeliveryScheduleRestriction; ytreeCommonRulePrices.ColumnsConfig = ColumnsConfigFactory.Create <CommonDistrictRuleItem>() .AddColumn("Цена") .HeaderAlignment(0.5f) .AddNumericRenderer(p => p.Price) .Digits(2) .WidthChars(10) .Adjustment(new Adjustment(0, 0, 1000000, 1, 100, 0)) .Editing() .AddSetter((c, r) => c.BackgroundGdk = r.Price <= 0 ? colorRed : colorWhite) .AddTextRenderer(node => CurrencyWorks.CurrencyShortName, false) .AddColumn("Правило") .HeaderAlignment(0.5f) .AddTextRenderer(p => p.DeliveryPriceRule.Title) .WrapMode(Pango.WrapMode.WordChar) .WrapWidth(500) .Finish(); ytreeCommonRulePrices.Binding.AddBinding(ViewModel, vm => vm.CommonDistrictRuleItems, w => w.ItemsDataSource); ytreeCommonRulePrices.Selection.Changed += (sender, args) => ViewModel.SelectedCommonDistrictRuleItem = ytreeCommonRulePrices.GetSelectedObject() as CommonDistrictRuleItem; ytreeWeekDayRulePrices.ColumnsConfig = ColumnsConfigFactory.Create <WeekDayDistrictRuleItem>() .AddColumn("Цена") .HeaderAlignment(0.5f) .AddNumericRenderer(p => p.Price) .Digits(2) .WidthChars(10) .Adjustment(new Adjustment(0, 0, 1000000, 1, 100, 0)) .Editing() .AddSetter((c, r) => c.BackgroundGdk = r.Price <= 0 ? colorRed : colorWhite) .AddTextRenderer(node => CurrencyWorks.CurrencyShortName, false) .AddColumn("Правило") .HeaderAlignment(0.5f) .AddTextRenderer(p => p.DeliveryPriceRule.ToString()) .WrapMode(Pango.WrapMode.WordChar) .WrapWidth(390) .Finish(); ytreeWeekDayRulePrices.Binding.AddBinding(ViewModel, vm => vm.WeekDayDistrictRuleItems, w => w.ItemsDataSource); ytreeWeekDayRulePrices.Selection.Changed += (sender, args) => ViewModel.SelectedWeekDayDistrictRuleItem = ytreeWeekDayRulePrices.GetSelectedObject() as WeekDayDistrictRuleItem; #endregion btnSave.Clicked += (sender, args) => ViewModel.Save(); btnSave.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict || vm.CanEdit, w => w.Sensitive).InitializeFromSource(); btnCancel.Clicked += (sender, args) => ViewModel.Close(true, CloseSource.Cancel); ylabelStatusString.Text = ViewModel.Entity.Status.GetEnumTitle(); entryName.Binding.AddBinding(ViewModel.Entity, e => e.Name, w => w.Text).InitializeFromSource(); entryName.Binding.AddFuncBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive).InitializeFromSource(); btnAddDistrict.Binding.AddFuncBinding(ViewModel, vm => vm.CanCreateDistrict, w => w.Sensitive).InitializeFromSource(); btnAddDistrict.Clicked += (sender, args) => { ViewModel.AddDistrictCommand.Execute(); ScrollToSelectedDistrict(); }; btnRemoveDistrict.Clicked += (sender, args) => { ViewModel.RemoveDistrictCommand.Execute(); if (ViewModel.SelectedDistrict == null) { RefreshBorders(); } else { ScrollToSelectedDistrict(); } }; btnRemoveDistrict.Binding.AddFuncBinding(ViewModel, vm => vm.SelectedDistrict != null && vm.CanDeleteDistrict, w => w.Sensitive).InitializeFromSource(); ytextComment.Binding.AddBinding(ViewModel.Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource(); ytextComment.Binding.AddFuncBinding(ViewModel, vm => vm.CanEdit, w => w.Sensitive).InitializeFromSource(); btnAddCommonRule.Binding.AddFuncBinding(ViewModel, vm => vm.SelectedDistrict != null && vm.CanEditDistrict, w => w.Sensitive).InitializeFromSource(); btnAddCommonRule.Clicked += (sender, args) => { var selectRules = new OrmReference(ViewModel.UoW, DistrictRuleRepository.GetQueryOverWithAllDeliveryPriceRules()) { Mode = OrmReferenceMode.MultiSelect, ButtonMode = QS.Project.Dialogs.ReferenceButtonMode.None }; selectRules.ObjectSelected += (o, e) => ViewModel.AddCommonDistrictRuleItemCommand.Execute(e.GetEntities <DeliveryPriceRule>()); Tab.TabParent.AddSlaveTab(this.Tab, selectRules); }; btnRemoveCommonRule.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && vm.SelectedDistrict != null && vm.SelectedCommonDistrictRuleItem != null, w => w.Sensitive).InitializeFromSource(); btnRemoveCommonRule.Clicked += (sender, args) => ViewModel.RemoveCommonDistrictRuleItemCommand.Execute(); btnToday.TooltipText = "День в день.\nГрафик доставки при создании заказа сегодня и на сегодняшнюю дату доставки."; btnToday.Clicked += (sender, args) => ViewModel.SelectedWeekDayName = WeekDayName.Today; btnMonday.Clicked += (sender, args) => ViewModel.SelectedWeekDayName = WeekDayName.Monday; btnTuesday.Clicked += (sender, args) => ViewModel.SelectedWeekDayName = WeekDayName.Tuesday; btnWednesday.Clicked += (sender, args) => ViewModel.SelectedWeekDayName = WeekDayName.Wednesday; btnThursday.Clicked += (sender, args) => ViewModel.SelectedWeekDayName = WeekDayName.Thursday; btnFriday.Clicked += (sender, args) => ViewModel.SelectedWeekDayName = WeekDayName.Friday; btnSaturday.Clicked += (sender, args) => ViewModel.SelectedWeekDayName = WeekDayName.Saturday; btnSunday.Clicked += (sender, args) => ViewModel.SelectedWeekDayName = WeekDayName.Sunday; btnAddSchedule.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && vm.SelectedDistrict != null && vm.SelectedWeekDayName.HasValue, w => w.Sensitive).InitializeFromSource(); btnAddSchedule.Clicked += (sender, args) => { var selectSchedules = new OrmReference(typeof(DeliverySchedule), ViewModel.UoW) { Mode = OrmReferenceMode.MultiSelect }; selectSchedules.ObjectSelected += (o, eventArgs) => { ViewModel.AddScheduleRestrictionCommand.Execute(eventArgs.Subjects.Cast <DeliverySchedule>()); if (ViewModel.SelectedScheduleRestriction != null) { var iter = ytreeScheduleRestrictions.YTreeModel.IterFromNode(ViewModel.SelectedScheduleRestriction); var path = ytreeScheduleRestrictions.YTreeModel.GetPath(iter); ytreeScheduleRestrictions.ScrollToCell(path, ytreeScheduleRestrictions.Columns.FirstOrDefault(), false, 0, 0); } }; Tab.TabParent.AddSlaveTab(this.Tab, selectSchedules); }; btnRemoveSchedule.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && vm.SelectedDistrict != null && vm.SelectedScheduleRestriction != null, w => w.Sensitive).InitializeFromSource(); btnRemoveSchedule.Clicked += (sender, args) => ViewModel.RemoveScheduleRestrictionCommand.Execute(); btnAddAcceptBefore.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && vm.SelectedDistrict != null && vm.SelectedScheduleRestriction != null, w => w.Sensitive).InitializeFromSource(); btnAddAcceptBefore.Clicked += (sender, args) => { var acceptBeforeTimeViewModel = new SimpleEntityJournalViewModel <AcceptBefore, AcceptBeforeViewModel>( x => x.Name, () => new AcceptBeforeViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices ), node => new AcceptBeforeViewModel( EntityUoWBuilder.ForOpen(node.Id), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices ), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices ); acceptBeforeTimeViewModel.SelectionMode = JournalSelectionMode.Single; acceptBeforeTimeViewModel.SetActionsVisible(deleteActionEnabled: false, editActionEnabled: false); acceptBeforeTimeViewModel.OnEntitySelectedResult += (o, eventArgs) => { var node = eventArgs.SelectedNodes.FirstOrDefault(); if (node != null) { ViewModel.AddAcceptBeforeCommand.Execute(ViewModel.UoW.GetById <AcceptBefore>(node.Id)); } }; Tab.TabParent.AddSlaveTab(Tab, acceptBeforeTimeViewModel); }; btnRemoveAcceptBefore.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && vm.SelectedDistrict != null && vm.SelectedScheduleRestriction != null && vm.SelectedScheduleRestriction.AcceptBefore != null, w => w.Sensitive) .InitializeFromSource(); btnRemoveAcceptBefore.Clicked += (sender, args) => ViewModel.RemoveAcceptBeforeCommand.Execute(); btnAddWeekDayRule.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && vm.SelectedDistrict != null && vm.SelectedWeekDayName.HasValue, w => w.Sensitive).InitializeFromSource(); btnAddWeekDayRule.Clicked += (sender, args) => { var selectRules = new OrmReference(ViewModel.UoW, DistrictRuleRepository.GetQueryOverWithAllDeliveryPriceRules()) { Mode = OrmReferenceMode.MultiSelect, ButtonMode = QS.Project.Dialogs.ReferenceButtonMode.None }; selectRules.ObjectSelected += (o, e) => ViewModel.AddWeekDayDistrictRuleItemCommand.Execute(e.GetEntities <DeliveryPriceRule>()); Tab.TabParent.AddSlaveTab(this.Tab, selectRules); }; btnRemoveWeekDayRule.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && vm.SelectedDistrict != null && vm.SelectedWeekDayDistrictRuleItem != null, w => w.Sensitive).InitializeFromSource(); btnRemoveWeekDayRule.Clicked += (sender, args) => ViewModel.RemoveWeekDayDistrictRuleItemCommand.Execute(); cmbGeoGroup.ItemsList = ViewModel.UoW.GetAll <GeographicGroup>().ToList(); cmbGeoGroup.Binding.AddBinding(ViewModel, vm => vm.SelectedGeoGroup, w => w.SelectedItem).InitializeFromSource(); cmbGeoGroup.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && vm.SelectedDistrict != null, w => w.Sensitive).InitializeFromSource(); cmbWageDistrict.ItemsList = ViewModel.UoW.Session.QueryOver <WageDistrict>().Where(d => !d.IsArchive).List(); cmbWageDistrict.Binding.AddBinding(ViewModel, vm => vm.SelectedWageDistrict, w => w.SelectedItem).InitializeFromSource(); cmbWageDistrict.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && vm.SelectedDistrict != null && vm.CanChangeDistrictWageTypePermissionResult, w => w.Sensitive).InitializeFromSource(); cmbWageDistrict.SetRenderTextFunc <WageDistrict>(x => x.Name); #region GMap btnAddBorder.Binding.AddFuncBinding(ViewModel, vm => !vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); btnAddBorder.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && !vm.IsCreatingNewBorder && vm.SelectedDistrict != null && vm.SelectedDistrict.DistrictBorder == null, w => w.Sensitive).InitializeFromSource(); btnAddBorder.Clicked += (sender, args) => ViewModel.CreateBorderCommand.Execute(); btnRemoveBorder.Binding.AddFuncBinding(ViewModel, vm => !vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); btnRemoveBorder.Binding.AddFuncBinding(ViewModel, vm => vm.CanEditDistrict && !vm.IsCreatingNewBorder && vm.SelectedDistrict != null && vm.SelectedDistrict.DistrictBorder != null, w => w.Sensitive).InitializeFromSource(); btnRemoveBorder.Clicked += (sender, args) => { if (MessageDialogHelper.RunQuestionDialog($"Удалить границу района {ViewModel.SelectedDistrict.DistrictName}?")) { ViewModel.RemoveBorderCommand.Execute(); RefreshBorders(); } }; btnConfirmNewBorder.Binding.AddFuncBinding(ViewModel, vm => vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); btnConfirmNewBorder.Binding.AddFuncBinding(ViewModel, vm => vm.SelectedDistrict != null && vm.IsCreatingNewBorder, w => w.Sensitive).InitializeFromSource(); btnConfirmNewBorder.Clicked += (sender, args) => { if (MessageDialogHelper.RunQuestionDialog("Завершить создание границы района?")) { if (ViewModel.NewBorderVertices.Count < 3) { MessageDialogHelper.RunInfoDialog("Нельзя создать границу района меньше чем за 3 точки"); return; } toggleNewBorderPreview.Active = false; ViewModel.ConfirmNewBorderCommand.Execute(); RefreshBorders(); } }; btnCancelNewBorder.Binding.AddFuncBinding(ViewModel, vm => vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); btnCancelNewBorder.Binding.AddFuncBinding(ViewModel, vm => vm.SelectedDistrict != null && vm.IsCreatingNewBorder, w => w.Sensitive).InitializeFromSource(); btnCancelNewBorder.Clicked += (sender, args) => { if (MessageDialogHelper.RunQuestionDialog("Отменить создание границы района?")) { ViewModel.CancelNewBorderCommand.Execute(); toggleNewBorderPreview.Active = false; } }; toggleNewBorderPreview.Binding.AddFuncBinding(ViewModel, vm => vm.IsCreatingNewBorder, w => w.Visible).InitializeFromSource(); toggleNewBorderPreview.Binding.AddFuncBinding(ViewModel, vm => vm.SelectedDistrict != null && vm.IsCreatingNewBorder, w => w.Sensitive).InitializeFromSource(); toggleNewBorderPreview.Toggled += (sender, args) => { if (toggleNewBorderPreview.Active && ViewModel.NewBorderVertices.Any()) { var previewBorder = new GMapPolygon(ViewModel.NewBorderVertices.ToList(), "Предпросмотр новых границ"); newBordersPreviewOverlay.Polygons.Add(previewBorder); } else { newBordersPreviewOverlay.Clear(); } }; cmbMapType.ItemsEnum = typeof(MapProviders); cmbMapType.EnumItemSelected += (sender, args) => gmapWidget.MapProvider = MapProvidersHelper.GetPovider((MapProviders)args.SelectedItem); cmbMapType.SelectedItem = MapProviders.YandexMap; gmapWidget.Position = new PointLatLng(59.93900, 30.31646); gmapWidget.HeightRequest = 150; gmapWidget.HasFrame = true; gmapWidget.Overlays.Add(bordersOverlay); gmapWidget.Overlays.Add(newBordersPreviewOverlay); gmapWidget.Overlays.Add(verticeOverlay); RefreshBorders(); gmapWidget.ButtonPressEvent += (o, args) => { if (args.Event.Button == 1 && ViewModel.IsCreatingNewBorder) { ViewModel.AddNewVertexCommand.Execute(gmapWidget.FromLocalToLatLng((int)args.Event.X, (int)args.Event.Y)); } if (args.Event.Button == 3 && ViewModel.IsCreatingNewBorder) { var marker = verticeOverlay.Markers.FirstOrDefault(m => m.IsMouseOver); if (marker == null) { return; } var pointMarker = new PointLatLng(marker.Position.Lat, marker.Position.Lng); if (ViewModel.NewBorderVertices.Contains(pointMarker)) { Menu popupMenu = new Menu(); var item = new MenuItem("Удалить"); item.Activated += (sender, e) => ViewModel.RemoveNewBorderVertexCommand.Execute(pointMarker); popupMenu.Add(item); popupMenu.ShowAll(); popupMenu.Popup(); } } }; void RefreshBorders() { bordersOverlay.Clear(); foreach (District district in ViewModel.Entity.ObservableDistricts) { if (district.DistrictBorder != null) { bordersOverlay.Polygons.Add(new GMapPolygon( district.DistrictBorder.Coordinates.Select(p => new PointLatLng(p.X, p.Y)).ToList(), district.DistrictName) ); } } } #endregion ViewModel.PropertyChanged += (sender, args) => { Application.Invoke((o, eventArgs) => { switch (args.PropertyName) { case nameof(ViewModel.SelectedWeekDayName): var column = ytreeScheduleRestrictions.ColumnsConfig.GetColumnsByTag(acceptBeforeColumnTag).First(); column.Visible = ViewModel.SelectedWeekDayName == WeekDayName.Today; break; case nameof(ViewModel.SelectedDistrict): if (ViewModel.SelectedDistrict != null) { ytreeDistricts.SelectObject(ViewModel.SelectedDistrict); } break; case nameof(ViewModel.SelectedScheduleRestriction): if (ViewModel.SelectedScheduleRestriction != null) { ytreeScheduleRestrictions.SelectObject(ViewModel.SelectedScheduleRestriction); } break; case nameof(ViewModel.SelectedCommonDistrictRuleItem): if (ViewModel.SelectedCommonDistrictRuleItem != null) { ytreeCommonRulePrices.SelectObject(ViewModel.SelectedCommonDistrictRuleItem); } break; case nameof(ViewModel.SelectedWeekDayDistrictRuleItem): if (ViewModel.SelectedWeekDayDistrictRuleItem != null) { ytreeWeekDayRulePrices.SelectObject(ViewModel.SelectedWeekDayDistrictRuleItem); } break; case nameof(ViewModel.SelectedDistrictBorderVertices): verticeOverlay.Clear(); if (ViewModel.SelectedDistrictBorderVertices != null) { GMapPolygon polygon = new GMapPolygon(ViewModel.SelectedDistrictBorderVertices.ToList(), "polygon"); polygon.Stroke = selectedDistrictBorderPen; verticeOverlay.Polygons.Add(polygon); } break; case nameof(ViewModel.NewBorderVertices): verticeOverlay.Clear(); if (ViewModel.NewBorderVertices != null && ViewModel.NewBorderVertices.Any()) { for (int i = 0; i < ViewModel.NewBorderVertices.Count; i++) { var color = GMarkerGoogleType.red; if (i == 0) { color = GMarkerGoogleType.yellow; } else if (i == ViewModel.NewBorderVertices.Count - 1) { color = GMarkerGoogleType.green; } GMapMarker point = new GMarkerGoogle(ViewModel.NewBorderVertices[i], color); verticeOverlay.Markers.Add(point); } if (toggleNewBorderPreview.Active) { toggleNewBorderPreview.Active = false; toggleNewBorderPreview.Active = true; } } break; } }); }; }