Ejemplo n.º 1
0
        /// <summary>
        /// React on page loaded.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _FleetSetupWizardLocationPageLoaded(object sender, RoutedEventArgs e)
        {
            // Init page if not inited yet.
            if (!_inited)
            {
                _InitLocations();

                // Set row height.
                ContentGrid.RowDefinitions[DATA_GRID_ROW_DEFINITION_INDEX].Height =
                    new System.Windows.GridLength(DEFAULT_ROW_HEIGHT * ROW_COUNT);

                // Create subpages.
                string typeName = (string)App.Current.FindResource(LOCATION_RESOURCE_NAME);
                typeName                   = typeName.ToLower();
                _matchFoundSubPage         = new MatchFoundSubPage(typeName);
                _candidatesNotFoundSubPage = new CandidatesNotFoundSubPage(typeName);
                _candidatesFoundSubPage    = new CandidatesFoundSubPage(typeName);

                _SetSubPage(null);

                // Create layer of existed locations.
                _CreateLocationsLayer();
                // Create layer of current location.
                _CreateEditedLayer();

                _geocodablePage = new GeocodablePage(typeof(Location), mapCtrl, candidateSelect,
                                                     controlsGrid, DataGridControl, splitter, _locationsLayer);
                _geocodablePage.MatchFound         += new EventHandler(_MatchFound);
                _geocodablePage.CandidatesFound    += new EventHandler(_CandidatesFound);
                _geocodablePage.CandidatesNotFound += new EventHandler(_CandidatesNotFound);
                _geocodablePage.ParentIsFleetWisard = true;

                mapCtrl.AddTool(new EditingTool(), null);

                _InitDataGridControl();

                _inited = true;
            }

            // Create ungeocoded orders list.
            _collectionSource.Source = _locations;

            _selectionBinding.UnregisterAllCollections();
            _selectionBinding.RegisterCollection(DataGridControl);
            _selectionBinding.RegisterCollection(mapCtrl.SelectedItems);
        }
        /// <summary>
        /// React on page loaded.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _FleetSetupWizardUngeocodedOrdersPageLoaded(object sender, RoutedEventArgs e)
        {
            // Init page if not inited yet.
            if (!_inited)
            {
                _isParentFleetWizard = DataKeeper != null;

                // Set row height.
                ContentGrid.RowDefinitions[DATA_GRID_ROW_DEFINITION_INDEX].Height =
                    new System.Windows.GridLength(DEFAULT_ROW_HEIGHT * ROW_COUNT + DataGridControl.Margin.Top
                                                  + DataGridControl.Margin.Bottom + ROW_COUNT);

                // Create subpages.
                string typeName = (string)App.Current.FindResource(ORDER_RESOURCE_NAME);
                typeName                   = typeName.ToLower();
                _matchFoundSubPage         = new MatchFoundSubPage(typeName);
                _candidatesNotFoundSubPage = new CandidatesNotFoundSubPage(typeName);
                _candidatesFoundSubPage    = new CandidatesFoundSubPage(typeName);

                _SetSubPage(null);

                // Init orders collection.
                _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);
                _CreateOrdersLayer();

                // Create and init geocodable page.
                _geocodablePage = new GeocodablePage(typeof(Order), mapCtrl, candidateSelect,
                                                     controlsGrid, DataGridControl, splitter, _ordersLayer);
                _geocodablePage.MatchFound         += new EventHandler(_MatchFound);
                _geocodablePage.CandidatesFound    += new EventHandler(_CandidatesFound);
                _geocodablePage.CandidatesNotFound += new EventHandler(_CandidatesNotFound);
                // Datakeeper is not null in fleetwizard.
                _geocodablePage.ParentIsFleetWisard = _isParentFleetWizard;

                mapCtrl.AddTool(new EditingTool(), null);

                _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);

                GridStructureInitializer structureInitializer = new GridStructureInitializer(GridSettingsProvider.FleetGeocodableGridStructure);
                structureInitializer.BuildGridStructure(_collectionSource, DataGridControl);

                CommonHelpers.HidePostalCode2Column(DataGridControl);

                // Load grid layout.
                GridLayoutLoader layoutLoader = new GridLayoutLoader(GridSettingsProvider.FleetLocationsSettingsRepositoryName,
                                                                     _collectionSource.ItemProperties);
                layoutLoader.LoadLayout(DataGridControl);

                if (!_isParentFleetWizard)
                {
                    _RemoveRedundantElements();
                }

                _inited = true;
            }

            // Get orders collection from datakeeper if it is not null. Otherwise - from current project.
            if (_isParentFleetWizard)
            {
                // Fill ungeocoded orders list.
                _FillUngeocodedOrders(DataKeeper.AddedOrders);
            }
            else
            {
                // Do nothing. Ungeocoded order already set by constructor.
            }

            _collectionSource.Source = _ungeocodedOrders;
            _ordersLayer.Collection  = _ungeocodedOrders;

            _selectionBinding.UnregisterAllCollections();
            _selectionBinding.RegisterCollection(DataGridControl);
            _selectionBinding.RegisterCollection(mapCtrl.SelectedItems);

            ButtonFinish.IsEnabled = _IsFinishButtonEnabled(_ungeocodedOrders);
        }
        /// <summary>
        /// React on page loaded.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _FleetSetupWizardLocationPageLoaded(object sender, RoutedEventArgs e)
        {
            // Init page if not inited yet.
            if (!_inited)
            {
                _InitLocations();

                // Set row height.
                ContentGrid.RowDefinitions[DATA_GRID_ROW_DEFINITION_INDEX].Height =
                    new System.Windows.GridLength(DEFAULT_ROW_HEIGHT * ROW_COUNT);

                // Create subpages.
                string typeName = (string)App.Current.FindResource(LOCATION_RESOURCE_NAME);
                typeName = typeName.ToLower();
                _matchFoundSubPage = new MatchFoundSubPage(typeName);
                _candidatesNotFoundSubPage = new CandidatesNotFoundSubPage(typeName);
                _candidatesFoundSubPage = new CandidatesFoundSubPage(typeName);

                _SetSubPage(null);

                // Create layer of existed locations.
                _CreateLocationsLayer();
                // Create layer of current location.
                _CreateEditedLayer();

                _geocodablePage = new GeocodablePage(typeof(Location), mapCtrl, candidateSelect,
                    controlsGrid, DataGridControl, splitter, _locationsLayer);
                _geocodablePage.MatchFound += new EventHandler(_MatchFound);
                _geocodablePage.CandidatesFound += new EventHandler(_CandidatesFound);
                _geocodablePage.CandidatesNotFound += new EventHandler(_CandidatesNotFound);
                _geocodablePage.ParentIsFleetWisard = true;

                mapCtrl.AddTool(new EditingTool(), null);

                _InitDataGridControl();

                _inited = true;
            }

            // Create ungeocoded orders list.
            _collectionSource.Source = _locations;

            _selectionBinding.UnregisterAllCollections();
            _selectionBinding.RegisterCollection(DataGridControl);
            _selectionBinding.RegisterCollection(mapCtrl.SelectedItems);
        }
        /// <summary>
        /// React on page loaded.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _FleetSetupWizardUngeocodedOrdersPageLoaded(object sender, RoutedEventArgs e)
        {
            // Init page if not inited yet.
            if (!_inited)
            {
                _isParentFleetWizard = DataKeeper != null;

                // Set row height.
                ContentGrid.RowDefinitions[DATA_GRID_ROW_DEFINITION_INDEX].Height =
                    new System.Windows.GridLength(DEFAULT_ROW_HEIGHT * ROW_COUNT + DataGridControl.Margin.Top
                    + DataGridControl.Margin.Bottom + ROW_COUNT);

                // Create subpages.
                string typeName = (string)App.Current.FindResource(ORDER_RESOURCE_NAME);
                typeName = typeName.ToLower();
                _matchFoundSubPage = new MatchFoundSubPage(typeName);
                _candidatesNotFoundSubPage = new CandidatesNotFoundSubPage(typeName);
                _candidatesFoundSubPage = new CandidatesFoundSubPage(typeName);

                _SetSubPage(null);

                // Init orders collection.
                _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);
                _CreateOrdersLayer();

                // Create and init geocodable page.
                _geocodablePage = new GeocodablePage(typeof(Order), mapCtrl, candidateSelect,
                    controlsGrid, DataGridControl, splitter, _ordersLayer);
                _geocodablePage.MatchFound += new EventHandler(_MatchFound);
                _geocodablePage.CandidatesFound += new EventHandler(_CandidatesFound);
                _geocodablePage.CandidatesNotFound += new EventHandler(_CandidatesNotFound);
                // Datakeeper is not null in fleetwizard.
                _geocodablePage.ParentIsFleetWisard = _isParentFleetWizard;

                mapCtrl.AddTool(new EditingTool(), null);

                _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY);

                GridStructureInitializer structureInitializer = new GridStructureInitializer(GridSettingsProvider.FleetGeocodableGridStructure);
                structureInitializer.BuildGridStructure(_collectionSource, DataGridControl);

                CommonHelpers.HidePostalCode2Column(DataGridControl);

                // Load grid layout.
                GridLayoutLoader layoutLoader = new GridLayoutLoader(GridSettingsProvider.FleetLocationsSettingsRepositoryName,
                    _collectionSource.ItemProperties);
                layoutLoader.LoadLayout(DataGridControl);

                if (!_isParentFleetWizard)
                    _RemoveRedundantElements();

                _inited = true;
            }

            // Get orders collection from datakeeper if it is not null. Otherwise - from current project.
            if (_isParentFleetWizard)
            {
                // Fill ungeocoded orders list.
                _FillUngeocodedOrders(DataKeeper.AddedOrders);
            }
            else
            {
                // Do nothing. Ungeocoded order already set by constructor.
            }

            _collectionSource.Source = _ungeocodedOrders;
            _ordersLayer.Collection = _ungeocodedOrders;

            _selectionBinding.UnregisterAllCollections();
            _selectionBinding.RegisterCollection(DataGridControl);
            _selectionBinding.RegisterCollection(mapCtrl.SelectedItems);

            ButtonFinish.IsEnabled = _IsFinishButtonEnabled(_ungeocodedOrders);
        }