internal void OnCancelingEdit(DataGridItemHandledEventArgs e)
 {
     if (this.CancelingEdit != null)
     {
         this.CancelingEdit(this, e);
     }
 }
 internal void OnCancelingNewItem(DataGridItemHandledEventArgs e)
 {
     if (this.CancelingNewItem != null)
     {
         this.CancelingNewItem(this, e);
     }
 }
        /// <summary>
        /// Handler cancels editing object.
        /// </summary>
        /// <param name="sender">Data grid control sender.</param>
        /// <param name="e">Item event erags.</param>
        private void _DataGridCollectionViewSourceCancelingEdit(object sender, DataGridItemHandledEventArgs e)
        {
            // Remove handler to PropertyChanged (was added before for support editing bool fields by single click and save changes).
            ((INotifyPropertyChanged)e.Item).PropertyChanged -= _RoutesGridObjectPropertyChanged;

            e.Handled = true;

            _handler.CancelEditItem(e);
        }
        /// <summary>
        /// Handler for the Xceed.Wpf.DataGrid.DataGridCollectionViewSource.CancelingNewItem event.
        /// </summary>
        /// <param name="sender">DataGridCollectionViewSource object.</param>
        /// <param name="e">Event arguments.</param>
        private void _DataGridCollectionViewSourceCancelingNewItem(object sender, DataGridItemHandledEventArgs e)
        {
            _isEdititngInProgress = false;

            // Make the "Delete" button disabled.
            _buttonDelete.IsEnabled = false;

            // Manually handling the insertion of new items requires that the CreatingNewItem,
            // CommitingNewItem, and CancelingNewItem events must all be handled even if nothing
            // is done in the event.
            // Set property to true otherwise an InvalidOperationException will be thrown
            // (see http://doc.xceedsoft.com/products/XceedWpfDataGrid/Inserting_Data.html).
            e.Handled = true;
        }
    public virtual void CancelNew()
    {
      if( m_currentAddItem == null )
        return;

      object currentAddItem = m_currentAddItem;
      this.QueueOperationForAddNew = true;

      try
      {
        DataGridItemHandledEventArgs cancelingNewItemEventArgs = new DataGridItemHandledEventArgs( this, currentAddItem );
        this.RootDataGridCollectionViewBase.OnCancelingNewItem( cancelingNewItemEventArgs );

        if( this.CreatingNewItemIsManuallyHandled != cancelingNewItemEventArgs.Handled )
          throw new InvalidOperationException( "When manually handling the item-insertion process the CreatingNewItem, CommittingNewItem, and CancelingNewItem events must all be handled." );

        if( !cancelingNewItemEventArgs.Handled )
        {
          if( !this.HasSource )
            throw new InvalidOperationException( "The CancelingNewItem event must be handled when not using an underlying data source." );

          ItemsSourceHelper.CancelNewDataItem(
            this.Enumeration,
            null,
            m_currentAddItem,
            m_currentAddItemPosition );
        }

        this.SetCurrentAddNew( null, -1 );
      }
      finally
      {
        this.QueueOperationForAddNew = false;
      }

      if( m_deferredAddNewOperationManager != null )
      {
        m_deferredAddNewOperationManager.PurgeAddWithRemoveOrReplace();

        DeferredOperationManager deferredOperationManager = this.DeferredOperationManager;

        lock( deferredOperationManager )
        {
          if( this.ShouldDeferOperation )
          {
            deferredOperationManager.Combine( m_deferredAddNewOperationManager );
          }
          else
          {
            m_deferredAddNewOperationManager.Process();
          }
        }

        m_deferredAddNewOperationManager = null;
      }

      DataGridItemEventArgs itemEventArgs = new DataGridItemEventArgs( this, currentAddItem );
      m_rootDataGridCollectionViewBase.OnNewItemCanceled( itemEventArgs );
    }
 private void DataGridCollectionViewSource_CancelingNewItem(object sender, DataGridItemHandledEventArgs e)
 {
     // set property to true if new item was created or to false if new item wasn't created
     // otherwise an InvalidOperationException will be thrown (see http://doc.xceedsoft.com/products/XceedWpfDataGrid/Inserting_Data.html)
     e.Handled = _isNewItemCreated;
     _regionsPage.OnNewItemCancelling(e);
     IsEditingInProgress = false;
     _SetSelectionStatus();
 }
        private void DataGridCollectionViewSource_CancelingNewItem(object sender, DataGridItemHandledEventArgs e)
        {
            // set property to true if new item was created or to false if new item wasn't created
            // otherwise an InvalidOperationException will be thrown (see http://doc.xceedsoft.com/products/XceedWpfDataGrid/Inserting_Data.html)
            e.Handled = _isNewItemCreated;
            IsEditingInProgress = false;

            if (_InsertionRow.Cells["HardZones"] != null)
                _InsertionRow.Cells["HardZones"].Visibility = Visibility.Hidden;
            _SetSelectionStatus();
        }
 /// <summary>
 /// Occurs when user press "Esc" on edited grid row.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DataGridCollectionViewSource_CancelingEdit(object sender, DataGridItemHandledEventArgs e)
 {
     _isEditeStart = false;
     e.Handled = true;
 }
 private void DataGridCollectionViewSource_CancelingNewItem(object sender, DataGridItemHandledEventArgs e)
 {
     e.Handled = true;
     _EndEdit();
 }
 /// <summary>
 /// Handler cancels editing object.
 /// </summary>
 /// <param name="sender">Data grid control sender.</param>
 /// <param name="e">Item event erags.</param>
 private void _DataGridCollectionViewSourceCancelingEdit(object sender,
                                                         DataGridItemHandledEventArgs e)
 {
     e.Handled = true;
     IsEditingInProgress = false;
     _SetSelectionStatus(((ICollection<Barrier>)e.CollectionView.SourceCollection).Count);
 }
 /// <summary>
 /// Edit canceled.
 /// </summary>
 /// <param name="sender">Ignored.</param>
 /// <param name="e">Ignored.</param>
 private void _DataGridCollectionViewSourceCancelingEdit(object sender, DataGridItemHandledEventArgs e)
 {
     e.Handled = true;
     IsEditingInProgress = false;
     if (EditFinished != null)
         EditFinished(this, null);
     _SetSelectionStatus();
 }
        /// <summary>
        /// React on new item committed.
        /// </summary>
        public void CancellingNewItem(DataGridItemHandledEventArgs e)
        {
            Debug.Assert(_mapControl.EditedObject is Route);

            _mapControl.EditEnded();

            _addedRoute = null;

            string status = string.Format((string)App.Current.FindResource(OptimizeAndEditPage.NoSelectionStatusFormat),
                                          _parentPage.CurrentSchedule.Routes.Count,
                                          _parentPage.CurrentSchedule.UnassignedOrders.Count);
            App.Current.MainWindow.StatusBar.SetStatus(_parentPage, status);
        }
        /// <summary>
        /// React on cancelling edit.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Event args.</param>
        private void _CancelingEdit(object sender, DataGridItemHandledEventArgs e)
        {
            _geocodablePage.OnEditCanceled(e);
            e.Handled = true;

            CurrentItem.Address.PropertyChanged -= new PropertyChangedEventHandler(_AddressPropertyChanged);
            CurrentItem.PropertyChanged -= new PropertyChangedEventHandler(_CurrentItemPropertyChanged);
        }
        /// <summary>
        /// Handler cancels editing object.
        /// </summary>
        /// <param name="sender">Data grid control sender.</param>
        /// <param name="e">Item event erags.</param>
        private void _DataGridCollectionViewSourceCancelingEdit(object sender, DataGridItemHandledEventArgs e)
        {
            e.Handled = true;

            _handler.CancelEditItem(e);
        }
        /// <summary>
        /// Raises event about new item is cancelling.
        /// </summary>
        /// <param name="sender">Data grid control sender.</param>
        /// <param name="e">Item event args.</param>
        private void _DataGridCollectionViewSourceCancelingNewItem(object sender, DataGridItemHandledEventArgs e)
        {
            // Set property to true if new item was created or to false if new item wasn't created.
            // Otherwise an InvalidOperationException will be thrown (see http://doc.xceedsoft.com/products/XceedWpfDataGrid/Inserting_Data.html).
            e.Handled = _isNewItemCreated;
            _handler.CancellingNewItem(e);

            if (_routesInsertionRow.Cells[HARD_ZONES_PROPERTY_NAME] != null)
                _routesInsertionRow.Cells[HARD_ZONES_PROPERTY_NAME].Visibility = Visibility.Collapsed;

            // NOTE : workaround - hide cell editors when new item's cancelling.
            if (_routesInsertionRow != null)
                _routesInsertionRow.CellEditorDisplayConditions = CellEditorDisplayConditions.None;

               _isNewItemCreated = false;
        }
        /// <summary>
        /// React on cancelling edit.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Event args.</param>
        private void _CancelingEdit(object sender, DataGridItemHandledEventArgs e)
        {
            _geocodablePage.OnEditCanceled(e);
            e.Handled = true;

            // If item was cancelled - move location to fake position.
            Location canceledLocation = e.Item as Location;
            if (string.IsNullOrEmpty(canceledLocation.Name))
            {
                canceledLocation.GeoLocation = new ESRI.ArcLogistics.Geometry.Point(0, 0);
                canceledLocation.Address.FullAddress = string.Empty;
            }

            if (CurrentItem != null)
            {
                CurrentItem.Address.PropertyChanged -= new PropertyChangedEventHandler(_AddressPropertyChanged);
                CurrentItem.PropertyChanged -= new PropertyChangedEventHandler(_CurrentItemPropertyChanged);
            }
            else
            {
                // Do nothing. Current item is null after cancelling.
            }
        }
        private void DataGridCollectionViewSource_CancelingEdit(object sender, DataGridItemHandledEventArgs e)
        {
            if (!_isForcingEndEdit)
                App.Current.MainWindow.StatusBar.SetStatus(this, null);
            _isForcingEndEdit = false;

            Row parentRow = (Row)XceedGrid.GetContainerFromItem(e.Item);
            parentRow.Cells[IS_CURRENT_COLUMN_CAPTION].IsEnabled = true;

            _projectNameBeforeEditing = string.Empty;

            e.Handled = true;
        }
        /// <summary>
        /// Cancel creating new item.
        /// </summary>
        public void CancellingNewItem(DataGridItemHandledEventArgs e)
        {
            _geocodablePage.OnNewItemCancelling();

            string status = string.Format((string)App.Current.FindResource(OptimizeAndEditPage.NoSelectionStatusFormat),
                                          _currentSchedule.Routes.Count, _currentSchedule.UnassignedOrders.Count);
            App.Current.MainWindow.StatusBar.SetStatus(_parentPage, status);
        }
 private void DataGridCollectionViewSource_CancelingNewItem(object sender, DataGridItemHandledEventArgs e)
 {
     App.Current.MainWindow.StatusBar.SetStatus(this, null);
     e.Handled = true;
 }
 private void DataGridCollectionViewSource_CancelingEdit(object sender, DataGridItemHandledEventArgs e)
 {
     e.Handled = true;
     IsEditingInProgress = false;
     _SetSelectionStatus();
 }
 internal void OnCancelingNewItem( DataGridItemHandledEventArgs e )
 {
   if( this.CancelingNewItem != null )
     this.CancelingNewItem( this, e );
 }
    internal void OnCancelingNewItem( DataGridItemHandledEventArgs e )
    {
      if( this.CancelingNewItem != null )
        this.CancelingNewItem( this, e );

      if( m_parentCollectionViewSourceBase != null )
        m_parentCollectionViewSourceBase.OnCancelingNewItem( e );
    }
 internal void OnCancelingEdit( DataGridItemHandledEventArgs e )
 {
   if( this.CancelingEdit != null )
     this.CancelingEdit( this, e );
 }
    public virtual void CancelEdit()
    {
      if( !this.CanCancelEdit )
        throw new InvalidOperationException( "An attempt was made to cancel the edit process on a source that does not support cancellation." );

      if( m_currentEditItem == null )
        return;

      DataGridItemHandledEventArgs itemHandleEventArgs = new DataGridItemHandledEventArgs( this, m_currentEditItem );
      m_rootDataGridCollectionViewBase.OnCancelingEdit( itemHandleEventArgs );

      if( itemHandleEventArgs.Handled != this.ItemEditionIsManuallyHandled )
        throw new InvalidOperationException( "An attempt was made to manually handle the edit prcess without handling the BeginningEdit, CommittingEdit, and CancelingEdit events." );

      if( !itemHandleEventArgs.Handled )
      {
        bool cancelEditCalled;
        this.CancelEditInternal( m_currentEditItem, out cancelEditCalled );

        DataGridItemPropertyCollection itemProperties = this.ItemProperties;
        int count = itemProperties.Count;

        if( ( !cancelEditCalled ) && ( count > 0 ) )
        {
          itemProperties.SuspendUnboundItemPropertyChanged( m_currentEditItem );

          try
          {
            for( int i = 0; i < count; i++ )
            {
              DataGridItemPropertyBase itemProperty = itemProperties[ i ];

              bool readOnly = ( ( m_currentEditItem == m_currentAddItem )
                              && itemProperty.OverrideReadOnlyForInsertion.HasValue
                              && itemProperty.OverrideReadOnlyForInsertion.Value )
                ? false
                : itemProperty.IsReadOnly;

              if( !readOnly )
              {
                try
                {
                  itemProperty.SetValue( m_currentEditItem, m_oldValuesBeforeEdition[ i ] );
                }
                catch
                {
                  // Swallow any Exception, setting a property to is old value should not throw.
                }
              }
            }
          }
          finally
          {
            itemProperties.ResumeUnboundItemPropertyChanged( m_currentEditItem );
          }
        }
      }

      DataGridItemEventArgs itemEventArgs = new DataGridItemEventArgs( this, m_currentEditItem );
      m_currentEditItem = null;
      m_rootDataGridCollectionViewBase.OnEditCanceled( itemEventArgs );
    }
        /// <summary>
        /// React on cancelling new item.
        /// </summary>
        /// <param name="e">Cancelling item event args.</param>
        public void OnNewItemCancelling(DataGridItemHandledEventArgs e)
        {
            // Supporting API issues. Needed in case of external new item creating canceling.
            if (!_isInEditedMode)
                return;

            _canceledByGrid = true;
            ObjectLayer.DeleteObject(_currentItem, _parentLayer.MapLayer);
            _EditEnded(false);
            e.Handled = true;
            _canceledByGrid = false;

            _SetToolsEnabled(false);

            _currentItem = null;
        }