/// <summary> /// React on match found. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Ignored.</param> private void _MatchFound(object sender, EventArgs e) { _SetSubPage(_matchFoundSubPage); mapCtrl.map.UpdateLayout(); // Get item container. DependencyObject itemContainer = DataGridControl.GetContainerFromItem(CurrentItem); DataRow row = itemContainer as DataRow; if (row != null) { // Invoke redraw. ControlTemplate template = row.Cells[ADDRESS_LINE_COLUMN_INDEX].Template; row.Cells[ADDRESS_LINE_COLUMN_INDEX].Template = null; row.Cells[ADDRESS_LINE_COLUMN_INDEX].Template = template; } else { // Incorrect functionality in Xceed grid. Sometimes item container is not returned. } // Zooming to current item suspended because zooming should go after suspended zoom // restoring in mapextentmanager. Suspended zoom restoring invoked in case of saved // old extent(zoom was changed by mouse) and because of map control size changed // after showing subpage. Dispatcher.BeginInvoke(new Action <Location>(delegate(Location item) { _ZoomOnLocation(item); } ), DispatcherPriority.Background, CurrentItem); // Do not need to finish editing there if match was found by tool. if (_skipStartGeocoding) { // Do nothing. } else { _skipStartGeocoding = true; try { DataGridControl.EndEdit(); } catch { // Exception in cycle end editing. } _skipStartGeocoding = false; } // If current location has no name - get next name for it. if (string.IsNullOrWhiteSpace(CurrentItem.Name)) { CurrentItem.Name = DataObjectNamesConstructor.GetNameForNewDataObject( _locations, CurrentItem, true); } }
/// <summary> /// React on beginning edit. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Event args.</param> private void _BeginningEdit(object sender, DataGridItemCancelEventArgs e) { // If location has no or whitespace name - get new name for it // and turn on validation on address fields. Location location = e.Item as Location; if (string.IsNullOrWhiteSpace(location.Name)) { location.Name = DataObjectNamesConstructor.GetNameForNewDataObject( _locations, location, true); } (e.Item as Location).IsAddressValidationEnabled = true; _geocodablePage.OnBeginningEdit(e); e.Handled = true; CurrentItem.Address.PropertyChanged += new PropertyChangedEventHandler(_AddressPropertyChanged); CurrentItem.PropertyChanged += new PropertyChangedEventHandler(_CurrentItemPropertyChanged); }
/// <summary> /// Change item's name. /// </summary> /// <param name="e">DataGridItemEventArgs.</param> private void _ChangeName(Xceed.Wpf.DataGrid.DataGridItemEventArgs e) { // Check that item's name is null. if (!string.IsNullOrEmpty((e.Item as Driver).Name)) { return; } // Get new item's name. (e.Item as Driver).Name = DataObjectNamesConstructor.GetNameForNewDataObject( App.Current.Project.Drivers, e.Item as Driver, true); // Find TextBox inside the cell and select new name. Cell currentCell = _InsertionRow.Cells[XceedGrid.CurrentContext.CurrentColumn]; TextBox textBox = XceedVisualTreeHelper.FindTextBoxInsideElement(currentCell); if (textBox != null) { textBox.SelectAll(); } }
/// <summary> /// Change item's name. /// </summary> /// <param name="e">DataGridItemEventArgs.</param> private void _ChangeName(Xceed.Wpf.DataGrid.DataGridItemEventArgs e) { // Check that item's name is null. if (!string.IsNullOrEmpty((e.Item as Order).Name)) { return; } (e.Item as Order).Name = DataObjectNamesConstructor.GetNameForNewDataObject( (IDataObjectCollection <Order>)_collectionSource.Source, e.Item as Order, false); Cell currentCell = _ordersInsertionRow.Cells[OrdersGrid.CurrentContext.CurrentColumn]; // Find TextBox inside the cell and select new name. TextBox textBox = XceedVisualTreeHelper.FindTextBoxInsideElement(currentCell); if (textBox != null) { textBox.SelectAll(); } }