/// <summary> /// Occurs when page loaded. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LocationsPage_Loaded(object sender, RoutedEventArgs e) { App.Current.MainWindow.NavigationCalled += new EventHandler(LocationsPage_NavigationCalled); if (!_isDataGridLayoutLoaded) { _InitDataGridLayout(); } if (!_isDataGridCollectionInited) { _IniDataGridCollection(); } _CheckPageComplete(); _needToUpdateStatus = true; _SetSelectionStatus(); // Set startup extent if (App.Current.Project.Locations.Count > 0) { List <ESRI.ArcLogistics.Geometry.Point> points = MapExtentHelpers.GetPointsInExtent(App.Current.Project.Locations); ESRI.ArcLogistics.Geometry.Envelope? extent = MapExtentHelpers.GetCollectionExtent(points); mapCtrl.StartupExtent = extent; // if new project loaded update extent if (_newProjectLoaded) { MapExtentHelpers.SetExtentOnCollection(mapCtrl, points); _newProjectLoaded = false; } } }
/// <summary> /// React on left button down. Check click on buttons or start drag otherwise. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Event args.</param> private void _PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // Check close button pressed. if (_IsElementPressed(CloseButton, e)) { // Hide hint. Visibility = Visibility.Collapsed; } // Check tool button pressed. else if (_IsElementPressed(PushpinToolButton, e)) { // Change tool state. _AddressByPointToolPressed(); } // Check link click. else if (_IsElementPressed(ZoomedAddress, e)) { // Zoom to candidates. MapExtentHelpers.ZoomToCandidates(_mapControl, _candidatesToZoom); } else { // Start drag if mouse was clicked on canvas. GeocodingHint geocodingHint = XceedVisualTreeHelper.FindParent <GeocodingHint>((DependencyObject)e.Source); if (geocodingHint != null || e.Source == this) { _isDown = true; _startPoint = e.GetPosition(_canvas); _canvas.CaptureMouse(); e.Handled = true; } } }
/// <summary> /// React on date changed. /// </summary> private void _BarriersPageCurrentDateChanged(object sender, EventArgs e) { if (App.Current.Project != null && _barriersLayer != null) { // Refresh barriers view _barriersLayer.LayerContext = App.Current.CurrentDate; // Set extent to barriers, active on current day ICollection <Barrier> barriers = App.Current.Project.Barriers.Search(App.Current.CurrentDate); // Add all geometry points to extent. var points = new List <AppGeometry.Point>(); foreach (Barrier barrier in barriers) { AppGeometry.Point?point = barrier.Geometry as AppGeometry.Point?; if (point != null) { points.Add(point.Value); } else { AppGeometry.PolyCurve polyCurve = barrier.Geometry as AppGeometry.PolyCurve; if (polyCurve != null) { AppGeometry.Point[] polyCurvePoints = polyCurve.GetPoints(0, polyCurve.TotalPointCount); points.AddRange(polyCurvePoints); } } } MapExtentHelpers.SetExtentOnCollection(mapCtrl, points); } }
/// <summary> /// React on locate button click. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Ignored.</param> private void _ButtonLocateClick(object sender, RoutedEventArgs e) { // Remove history items. try { // Endedit can lead to exception if name is empty and not commited yet. DataGridControl.EndEdit(); } catch { } if (CurrentItem.IsGeocoded) { _ZoomOnLocation(CurrentItem); } else { // Geocode location. _geocodablePage.StartGeocoding(CurrentItem); if (_geocodablePage.CandidatesToZoom != null) { MapExtentHelpers.ZoomToCandidates(mapCtrl, _geocodablePage.CandidatesToZoom); } } }
/// <summary> /// Zoom on current selected location. /// </summary> /// <param name="location">Location to zoom at.</param> private void _ZoomOnLocation(Location location) { // Current item can be null because zooming suspended. if (location != null) { // Zoom on location. List <ESRI.ArcLogistics.Geometry.Point> points = new List <ESRI.ArcLogistics.Geometry.Point>(); points.Add(location.GeoLocation.Value); MapExtentHelpers.SetExtentOnCollection(mapCtrl, points); } }
/// <summary> /// Zoom on point. /// </summary> /// <param name="point">Point to zoom at</param> private void _ZoomOnCurrentItem(Geometry.Point point) { // Current item can be null because zooming suspended. //if (CurrentItem != null) //{ // Zoom on order. List <ESRI.ArcLogistics.Geometry.Point> points = new List <ESRI.ArcLogistics.Geometry.Point>(); points.Add(point); MapExtentHelpers.SetExtentOnCollection(mapCtrl, points); //} }
/// <summary> /// Occurs when page loads. Inits page if need. Updates selection status. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Ignored.</param> private void _BarrierPageLoaded(object sender, RoutedEventArgs e) { App.Current.MainWindow.NavigationCalled += new EventHandler(_BarriersPageNavigationCalled); if (!_isLayoutLoaded) { _InitDataGridLayout(); } if (!_isDataGridCollectionInited) { _InitCollection(); } if (!_isInited) { _Init(); } _needToUpdateStatus = true; // Set label as status bar content. _SetSelectionStatus(XceedGrid.Items.Count); // Set startup extent. IEnumerable collectionInExtent; var barriers = (AppData.IDataObjectCollection <Barrier>)_collectionSource.Source; // if barriers present - set extent on them. Otherwise on locations. if (0 < barriers.Count) { collectionInExtent = barriers; } else { collectionInExtent = App.Current.Project.Locations; } List <AppGeometry.Point> points = MapExtentHelpers.GetPointsInExtent(collectionInExtent); AppGeometry.Envelope?extent = MapExtentHelpers.GetCollectionExtent(points); mapCtrl.StartupExtent = extent; // if new project loaded update extent if (_newProjectLoaded) { MapExtentHelpers.SetExtentOnCollection(mapCtrl, points); _newProjectLoaded = false; } }
/// <summary> /// React on schedule page loaded. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Ignored.</param> private void _SchedulePageLoaded(object sender, RoutedEventArgs e) { // Set startup extent. List <object> scheduleExtentCollection = _GetScheduleExtentCollection(); List <ESRI.ArcLogistics.Geometry.Point> points = MapExtentHelpers.GetPointsInExtent(scheduleExtentCollection); ESRI.ArcLogistics.Geometry.Envelope?extent = MapExtentHelpers.GetCollectionExtent(points); mapCtrl.StartupExtent = extent; // if new project loaded update extent if (_newProjectLoaded) { MapExtentHelpers.SetExtentOnCollection(mapCtrl, points); _newProjectLoaded = false; } }
private void ZonePage_Loaded(object sender, RoutedEventArgs e) { App.Current.MainWindow.NavigationCalled += new EventHandler(ZonesPage_NavigationCalled); if (!_isDataGridLayoutLoaded) { _InitDataGridLayout(); } if (!_isDataGridCollectionInited) { _InitDataGridCollection(); } _needToUpdateStatus = true; // Set label as status bar content. _SetSelectionStatus(); // Set startup extent. IEnumerable collectionInExtent; // If zones present - set extent on them. Otherwise on locations. if (App.Current.Project.Zones.Count > 0) { collectionInExtent = App.Current.Project.Zones; } else { collectionInExtent = App.Current.Project.Locations; } List <ESRI.ArcLogistics.Geometry.Point> points = MapExtentHelpers.GetPointsInExtent(collectionInExtent); ESRI.ArcLogistics.Geometry.Envelope?extent = MapExtentHelpers.GetCollectionExtent(points); mapCtrl.StartupExtent = extent; // if new project loaded update extent if (_newProjectLoaded) { MapExtentHelpers.SetExtentOnCollection(mapCtrl, points); _newProjectLoaded = false; } }
/// <summary> /// Zoom on order if geocoded or start geocoding otherwise. /// </summary> /// <param name="editingWasEndedSuccessfully">Is Locate button was pressed and endedit was successful.</param> private void _ProcessLocateOrder(bool editingWasEndedSuccessfully) { if (CurrentItem.IsGeocoded) { _ZoomOnCurrentItem(CurrentItem.GeoLocation.Value); } else { // Geocoding possibly already started by endedit. if (!editingWasEndedSuccessfully) { // Geocode order. _geocodablePage.StartGeocoding(CurrentItem); } if (_geocodablePage.CandidatesToZoom != null) { MapExtentHelpers.ZoomToCandidates(mapCtrl, _geocodablePage.CandidatesToZoom); } } }
/// <summary> /// Set collections from current schedule. /// </summary> /// <param name="afterRoutesBuilding">Bool value to define whether extent should be changed to builded routes.</param> public void OnScheduleLoad(bool afterRoutesBuilding) { if (_schedulePage != null) { Debug.Assert(_zonesLayer != null); bool dateChanged = false; if ((_currentSchedule != null && _schedulePage.CurrentSchedule != null && _currentSchedule.PlannedDate != _schedulePage.CurrentSchedule.PlannedDate) || (_currentSchedule == null && _schedulePage.CurrentSchedule != null)) { dateChanged = true; } _currentSchedule = _schedulePage.CurrentSchedule; if (_currentSchedule != null) { _InitCollections(); _zonesLayer.Collection = App.Current.Project.Zones; _SetBarriersCollection(); } else { if (_stopOrders != null) { _stopOrders.Clear(); _stopLocations.Clear(); } if (_routesLayer != null) { List <Route> empty = new List <Route>(); _routesLayer.Collection = empty; } } if (dateChanged) { if (mapCtrl.SelectedItems.Count > 0) { mapCtrl.SelectedItems.Clear(); } List <object> scheduleExtentCollection = _GetScheduleExtentCollection(); List <ESRI.ArcLogistics.Geometry.Point> points = MapExtentHelpers.GetPointsInExtent(scheduleExtentCollection); if (mapCtrl.StartupExtent != null) { MapExtentHelpers.SetExtentOnCollection(mapCtrl, points); } else { ESRI.ArcLogistics.Geometry.Envelope?extent = MapExtentHelpers.GetCollectionExtent(points); mapCtrl.StartupExtent = extent; } } // If schedule loaded after build routes finished. if (afterRoutesBuilding) { List <object> routesExtentCollection = new List <object>(); // Add routes to extent. foreach (Route route in _routesColl) { routesExtentCollection.Add(route); } mapCtrl.SetExtentOnCollection(routesExtentCollection); } _zonesLayer.LayerContext = _currentSchedule; } }