internal void OnBeginningEdit(DataGridItemCancelEventArgs e)
 {
     if (this.BeginningEdit != null)
     {
         this.BeginningEdit(this, e);
     }
 }
 internal void OnCommittingEdit(DataGridItemCancelEventArgs e)
 {
     if (this.CommittingEdit != null)
     {
         this.CommittingEdit(this, e);
     }
 }
 /// <summary>
 /// React on begin edit item.
 /// </summary>
 public void BeginEditItem(DataGridItemCancelEventArgs e)
 {
     if (!e.Cancel)
     {
         _geocodablePage.OnBeginningEdit(e);
         _statusBuilder.FillEditingStatus(e.Item.ToString(),
                                          (string)App.Current.FindResource("Order"), _parentPage);
     }
 }
        internal override void OnBeginningEdit(DataGridItemCancelEventArgs e)
        {
            object item = e.Item;

            // We throw instead of setting e.Cancel to True because we do not want to give the developer the chance to set it back to False.
            if (item is EmptyDataItem)
            {
                throw new DataGridException("Cannot begin edit on an empty data item or on an item that has a pending commit async operation.");
            }

            DataGridPageManagerBase pageManager = this.RootGroup.GetVirtualPageManager();

            if (pageManager.IsAsyncCommitQueuedForItem(item))
            {
                throw new DataGridException("Cannot begin edit on an empty data item or on an item that has a pending commit async operation.");
            }

            base.OnBeginningEdit(e);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Beggining edit.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _DataGridCollectionViewSourceBeginningEdit(object sender, DataGridItemCancelEventArgs e)
        {
            e.Handled = true;

            // If not canceled - raise EditBegun event and update editing status.
            IsEditingInProgress = true;
            _SetEditingStatus(e.Item.ToString());
        }
    public virtual void EditItem( object item )
    {
      if( item == null )
        throw new ArgumentNullException( "item" );

      this.CommitNew();

      if( m_currentEditItem == item )
        return;

      this.CommitEdit();

      DataGridItemCancelEventArgs itemCancelEventArgs = new DataGridItemCancelEventArgs( this, item, false );
      m_rootDataGridCollectionViewBase.OnBeginningEdit( itemCancelEventArgs );

      if( itemCancelEventArgs.Cancel )
        throw new DataGridException( "EditItem was canceled." );

      this.ItemEditionIsManuallyHandled = itemCancelEventArgs.Handled;

      if( !this.ItemEditionIsManuallyHandled )
      {
        bool beginEditCalled;
        this.EditItemInternal( item, out beginEditCalled );

        if( !beginEditCalled )
        {
          DataGridItemPropertyCollection itemProperties = this.ItemProperties;
          int count = itemProperties.Count;
          m_oldValuesBeforeEdition = new object[ count ];

          for( int i = 0; i < count; i++ )
          {
            m_oldValuesBeforeEdition[ i ] = itemProperties[ i ].GetValue( item );
          }
        }
      }

      m_currentEditItem = item;
      DataGridItemEventArgs itemEventArgs = new DataGridItemEventArgs( this, item );
      m_rootDataGridCollectionViewBase.OnEditBegun( itemEventArgs );
    }
    internal virtual void OnBeginningEdit( DataGridItemCancelEventArgs e )
    {
      // We throw instead of setting e.Cancel to True because we do not want to give the developer the chance to set it back to False.
      if( e.Item is EmptyDataItem )
        throw new DataGridException( "Cannot begin edit on an empty data item." );

      if( this.BeginningEdit != null )
        this.BeginningEdit( this, e );

      if( m_parentCollectionViewSourceBase != null )
        m_parentCollectionViewSourceBase.OnBeginningEdit( e );
    }
        /// <summary>
        /// Handler commits editing (calls CommitItem method of appropriate ContextHandler).
        /// </summary>
        /// <param name="sender">Data grid control sender.</param>
        /// <param name="e">Item event args.</param>
        private void _DataGridCollectionViewSourceCommittingEdit(object sender,
                                                                 DataGridItemCancelEventArgs e)
        {
            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((AppData.DataObject)e.Item);
            if (CommittingEdit != null)
                CommittingEdit(this, args);

            e.Handled = true;

            if (!args.Cancel)
            {
                _regionsPage.OnCommittingEdit(e);

                App.Current.Project.Save();

                _SetSelectionStatus(((ICollection<Barrier>)e.CollectionView.SourceCollection).Count);
                IsEditingInProgress = false;
            }
            else
                e.Cancel = true;
        }
        /// <summary>
        /// Occurs when user press "Enter" on edited grid row.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGridCollectionViewSource_CommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            try
            {
                if (_isEditeStart && !string.IsNullOrEmpty(_selectedProfileName))
                {
                    ReportInfo editedInfo  = App.Current.ReportGenerator.GetReportInfo(_selectedProfileName);
                    if (null != editedInfo)
                    {
                        Debug.Assert(!editedInfo.IsPredefined);

                        ReportDataWrapper selectedItem = xceedGridReports.CurrentItem as ReportDataWrapper;

                        string templatePath = ReportsGenerator.GetNewTemplatePath(selectedItem.Name, editedInfo.TemplatePath);

                        string fileSrcName = ReportsGenerator.GetTemplateAbsolutelyPath(editedInfo.TemplatePath);
                        string fileDestName = ReportsGenerator.GetTemplateAbsolutelyPath(templatePath);
                        File.Move(fileSrcName, fileDestName);

                        _selectedProfileName = editedInfo.Name = selectedItem.Name;
                        ReportDataWrapper.StartTemplatePath = templatePath;
                        ReportDataWrapper.StartTemplateName = _selectedProfileName;
                        editedInfo.TemplatePath = templatePath;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                App.Current.Messenger.AddError(ex.Message);
            }

            _isEditeStart = false;
            e.Handled = true;
        }
        /// <summary>
        /// React on committing edit.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Event args.</param>
        private void _CommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            _geocodablePage.OnCommittingEdit(e, !_skipStartGeocoding);
            e.Handled = true;

            CurrentItem.Address.PropertyChanged -= new PropertyChangedEventHandler(_AddressPropertyChanged);
            CurrentItem.PropertyChanged -= new PropertyChangedEventHandler(_CurrentItemPropertyChanged);
        }
        /// <summary>
        /// React on DataGridCollectionViewSource CommittingEdit.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Data grid item cancel event arguments </param>
        private void DataGridCollectionViewSource_CommittingEdit(object sender,
                                                                 DataGridItemCancelEventArgs e)
        {
            try
            {
                var selectedItem = xceedGrid.CurrentItem as RestrictionDataWrapper;

                IVrpSolver solver = App.Current.Solver;
                SolverSettings solverSettings = solver.SolverSettings;
                NetworkDescription networkDescription = solver.NetworkDescription;

                ICollection<NetworkAttribute> networkAttributes =
                    networkDescription.NetworkAttributes;
                foreach (NetworkAttribute attribute in networkAttributes)
                {
                    if (selectedItem.Restriction.Name.Equals(attribute.Name,
                                                             StringComparison.OrdinalIgnoreCase))
                    {
                        ICollection<NetworkAttributeParameter> paramColl = attribute.Parameters;
                        Debug.Assert(null != paramColl);
                        _UpdateValue(selectedItem, solverSettings, attribute);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }

            e.Handled = true;
        }
        /// <summary>
        /// Occurs when user press "enter" on edited grid row.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGridCollectionViewSource_CommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            App.Current.MainWindow.StatusBar.SetStatus(this, null);

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

            ProjectDataWrapper editedItem = e.Item as ProjectDataWrapper;
            _EditProject(editedItem);

            e.Handled = true;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// React on commiting edit.
        /// </summary>
        /// <param name="args">Commiting event args.</param>
        /// <param name="canStartGeocoding">Flag for accepting geocoding start.</param>
        public void OnCommittingEdit(DataGridItemCancelEventArgs args, bool canStartGeocoding)
        {
            Debug.Assert(args != null);

            _canceledByGrid = true;
            IGeocodable geocodable = (IGeocodable)args.Item;
            if (geocodable != _currentItem)
            {
                args.Cancel = true;
            }

            if (_isAddressChanged && canStartGeocoding)
            {
                _StartGeocoding(_currentItem, true);
                if (!IsGeocodingInProcess)
                {
                    _currentItem.Address.PropertyChanged -= new PropertyChangedEventHandler(_AddressPropertyChanged);
                }
            }

            EditEnded(false);

            _canceledByGrid = false;

            if (!IsGeocodingInProcess)
            {
                _currentItem = null;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// React on beginning edit.
        /// </summary>
        /// <param name="args">Beginning edit args.</param>
        public void OnBeginningEdit(DataGridItemCancelEventArgs args)
        {
            Debug.Assert(args != null);

            // if geocoding in process and try to edit not geocoding geocodable object - than cancel it
            IGeocodable current = (IGeocodable)args.Item;

            // in case of deleting edited - cancel beginning edit
            if ((IsGeocodingInProcess && current != _currentItem))
            {
                args.Cancel = true;
            }
            else
            {
                _currentItem = args.Item as IGeocodable;
                _currentItem.Address.PropertyChanged += new PropertyChangedEventHandler(_AddressPropertyChanged);

                _editStartedByGrid = true;
                _StartEdit(_currentItem);
                _editStartedByGrid = false;
            }
        }
 private void DataGridCollectionViewSource_CommittingEdit(object sender, DataGridItemCancelEventArgs e)
 {
     e.Handled = true;
     if (SymbologyManager.SymbologyType == SymbologyType.QuantitySymbology)
         _Validate((OrderQuantity)e.Item);
     _EndEdit();
 }
        private void DataGridCollectionViewSource_BeginningEdit(object sender, DataGridItemCancelEventArgs e)
        {
            _StartEdit((SymbologyRecord)e.Item);
            e.Handled = true;

            if (SymbologyManager.SymbologyType == SymbologyType.CategorySymbology)
            {
                if (((OrderCategory)e.Item).DefaultValue)
                    CategoryXceedGrid.Columns[VALUE_COLUMN_INDEX].ReadOnly = true;
            }
            else
            {
                if (((OrderQuantity)e.Item).DefaultValue)
                {
                    QuantityXceedGrid.Columns[MINVALUE_COLUMN_INDEX].ReadOnly = true;
                    QuantityXceedGrid.Columns[MAXVALUE_COLUMN_INDEX].ReadOnly = true;
                }
            }
        }
        /// <summary>
        /// Need to close current popup and open popup if current item has invalid property.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">DataGridItemCancelEventArgs.</param>
        private void _CollectionViewSourceBeginningEdit(object sender, DataGridItemCancelEventArgs e)
        {
            // Do not show callout, when pointing on invalid cell.
            _StopTimer();

            // If callout pointing at another item - close it.
            if (_InvalidItem != e.Item && _Callout.IsOpen)
            {
                _ClosePopup(true);
                _callout = new Callout();
            }

            // Remember edited item and subscribe to it's property changed event.
            _InvalidItem = e.Item as IDataErrorInfo;
            (e.Item as INotifyPropertyChanged).PropertyChanged += new PropertyChangedEventHandler
                (_EditedItemPropertyChanged);

            // If current column have error.
            if (_dataGrid.CurrentColumn != null &&
                !string.IsNullOrEmpty((e.Item as IDataErrorInfo)[_dataGrid.CurrentColumn.FieldName]))
            {
                // If callout is pointing at another column - close it.
                if (_column != _dataGrid.CurrentColumn)
                {
                    _ClosePopup(true);
                    _callout = new Callout();
                }

                // If callout closed - open it and point at current cell.
                if (!_Callout.IsOpen)
                {
                    // Detect column to show callout.
                    var column = _dataGrid.CurrentColumn;
                    if (Address.IsAddressPropertyName(column.FieldName))
                        column = _GetFirstAddressColumn();

                    _InitCallout(column);
                }
            }
            // If callout closed - seek for item's invalid properties.
            else if (!_Callout.IsOpen && !string.IsNullOrEmpty(_InvalidItem.Error))
                _ShowCalloutOnInvalidItem(e.Item as IDataErrorInfo);

            // Subscribe to cell property changed events. Doing so we will know when user change active cell.
            DataRow row = _dataGrid.GetContainerFromItem(e.Item) as DataRow;

            // If grid view is table flow - even in editing state row can be null.
            if (row != null)
                foreach (var cell in row.Cells)
                    cell.PropertyChanged += new PropertyChangedEventHandler(_CellPropertyChanged);
        }
 /// <summary>
 /// React on DataGridCollectionViewSource BeginningEdit.
 /// </summary>
 /// <param name="sender">Ignored.</param>
 /// <param name="e">Data grid item cancel event arguments </param>
 private void DataGridCollectionViewSource_BeginningEdit(object sender,
                                                         DataGridItemCancelEventArgs e)
 {
     e.Handled = true;
 }
 internal void OnBeginningEdit( DataGridItemCancelEventArgs e )
 {
   if( this.BeginningEdit != null )
     this.BeginningEdit( this, e );
 }
        /// <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);
        }
 internal void OnCommittingEdit( DataGridItemCancelEventArgs e )
 {
   if( this.CommittingEdit != null )
     this.CommittingEdit( this, e );
 }
        /// <summary>
        /// Occurs when user press start edit name.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGridCollectionViewSource_BeginningEdit(object sender, DataGridItemCancelEventArgs e)
        {
            ReportDataWrapper selectedItem = xceedGridReports.CurrentItem as ReportDataWrapper;
            if (null != selectedItem)
            {
                ReportInfo info = App.Current.ReportGenerator.GetReportInfo(selectedItem.Name);
                if (null != info)
                {
                    if (!info.IsPredefined)
                    {
                        buttonDeleteTemplate.IsEnabled = buttonEditTemplate.IsEnabled = buttonDuplicateTemplate.IsEnabled = false;
                        _isEditeStart = true;
                    }
                }
            }

            e.Handled = true;
        }
Ejemplo n.º 23
0
        private void DataGridCollectionViewSource_BeginningEdit(object sender, DataGridItemCancelEventArgs e)
        {
            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item);
            if (BeginningEdit != null)
                BeginningEdit(this, args);

            e.Handled = true;

            if (!args.Cancel)
            {
                _regionsPage.OnBeginningEdit(e);
                IsEditingInProgress = true;
                _SetEditingStatus(e.Item.ToString());
            }
            else
                e.Cancel = true;
        }
        /// <summary>
        /// React on commit item.
        /// </summary>
        public void CommitItem(DataGridItemCancelEventArgs e)
        {
            if (!e.Cancel)
            {
                _geocodablePage.OnCommittingEdit(e, true);

                Project project = App.Current.Project;
                if (project != null)
                    project.Save();

                DataGridControlEx dataGrid = _parentPage.OrdersView.OrdersGrid;
                if (dataGrid.SelectedItems == null)
                {
                    string status = string.Format((string)App.Current.FindResource(OptimizeAndEditPage.NoSelectionStatusFormat),
                                                  _currentSchedule.Routes.Count, _currentSchedule.UnassignedOrders.Count);
                    App.Current.MainWindow.StatusBar.SetStatus(_parentPage, status);
                    return;
                }

                _statusBuilder.FillSelectionStatus(e.CollectionView.Count,
                    (string)App.Current.FindResource("Order"), dataGrid.SelectedItems.Count, _parentPage);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Edit commited.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _DataGridCollectionViewSourceCommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            e.Handled = true;

            // Break changed, need to sort breaks.
            _InitDataGridCollection();

            if (!e.Cancel)
            {
                // If not canceled - saving project.
                if (App.Current.Project != null)
                    App.Current.Project.Save();

                // Update status label.
                IsEditingInProgress = false;
                _SetSelectionStatus();
            }
            else
                e.Cancel = true;
        }
        private void DataGridCollectionViewSource_CommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            if (CommonHelpers.IgnoreVirtualLocations(e.Item))
            {
                var args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item);
                if (CommittingEdit != null)
                    CommittingEdit(this, args);

                e.Handled = true;

                if (args.Cancel)
                    e.Cancel = true;
                else
                {
                    var project = App.Current.Project;
                    if (project != null)
                        project.Save();

                    _SetSelectionStatus();
                    IsEditingInProgress = false;
                }
            }
            else
            {
                e.Handled = true;
                e.Cancel = true;
            }
        }
    internal override void OnBeginningEdit( DataGridItemCancelEventArgs e )
    {
      object item = e.Item;

      // We throw instead of setting e.Cancel to True because we do not want to give the developer the chance to set it back to False.
      if( item is EmptyDataItem )
        throw new DataGridException( "Cannot begin edit on an empty data item or on an item that has a pending commit async operation." );

      DataGridPageManagerBase pageManager = this.RootGroup.GetVirtualPageManager();

      if( pageManager.IsAsyncCommitQueuedForItem( item ) )
        throw new DataGridException( "Cannot begin edit on an empty data item or on an item that has a pending commit async operation." );

      base.OnBeginningEdit( e );
    }
Ejemplo n.º 28
0
        private void DataGridCollectionViewSource_CommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item);
            if (CommittingEdit != null)
                CommittingEdit(this, args);

            e.Handled = true;

            if (!args.Cancel)
            {
                _regionsPage.OnCommittingEdit(e);
                if (App.Current.Project != null)
                    App.Current.Project.Save();

                _SetSelectionStatus();
                IsEditingInProgress = false;
            }
            else
                e.Cancel = true;
        }
        /// <summary>
        /// Handler begins edit item (calls BeginEditItem method of appropriate ContextHandler).
        /// </summary>
        /// <param name="sender">Data grid control sender.</param>
        /// <param name="e">Item event args.</param>
        private void _DataGridCollectionViewSourceBeginningEdit(object sender, DataGridItemCancelEventArgs e)
        {
            e.Handled = true;
            if (e.Item is AppData.DataObject)
            {
                // Define event args from editinf Item.
                var args = _CreateDataObjectCanceledEventArgs(e.Item);

                // Raise BeginningEdit event.
                if (BeginningEdit != null)
                    BeginningEdit(this, args);

                // Add handler to PropertyChanged event - need to support editing bool fields
                // by single click and save changes.
                ((INotifyPropertyChanged)e.Item).PropertyChanged +=
                    new PropertyChangedEventHandler(_RoutesGridObjectPropertyChanged);

                if (!args.Cancel)
                    _handler.BeginEditItem(e); // If action wasn't cancelled - begin editing
                // in appropriate handler.
                else
                    e.Cancel = true;
            }
        }
    internal void OnCommittingEdit( DataGridItemCancelEventArgs e )
    {
      if( this.CommittingEdit != null )
        this.CommittingEdit( this, e );

      if( m_parentCollectionViewSourceBase != null )
        m_parentCollectionViewSourceBase.OnCommittingEdit( e );
    }
        /// <summary>
        /// Handler commits editing (calls CommitItem method of appropriate ContextHandler).
        /// </summary>
        /// <param name="sender">Data grid control sender.</param>
        /// <param name="e">Item event args.</param>
        private void _DataGridCollectionViewSourceCommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            if (CommonHelpers.IgnoreVirtualLocations(e.Item))
            {
                // Remove handler to PropertyChanged (was added before for support
                // editing bool fields by single click and save changes).
                ((INotifyPropertyChanged)e.Item).PropertyChanged -= _RoutesGridObjectPropertyChanged;

                // Define event args from commited object.
                var args = _CreateDataObjectCanceledEventArgs(e.Item);

                // Raise commiting edit event.
                if (CommittingEdit != null)
                    CommittingEdit(this, args);

                e.Handled = true;

                if (!args.Cancel) // If action was not cancelled - commit changes.
                {
                    _handler.CommitItem(e);
                    App.Current.Project.Save();
                }
                else
                    e.Cancel = true;
            }
            else
            {
                e.Handled = true;
                e.Cancel = true;
            }
        }
    public virtual void CommitEdit()
    {
      if( m_currentEditItem == null )
        return;

      DataGridItemCancelEventArgs itemCancelEventArgs = new DataGridItemCancelEventArgs( this, m_currentEditItem, false );
      m_rootDataGridCollectionViewBase.OnCommittingEdit( itemCancelEventArgs );

      if( itemCancelEventArgs.Cancel )
        throw new DataGridException( "CommitEdit was canceled." );

      if( itemCancelEventArgs.Handled != this.ItemEditionIsManuallyHandled )
        throw new InvalidOperationException( "When manually handling the item-edition process the BeginningEdit, CommittingEdit, and CancelingEdit events must all be handled." );

      if( !itemCancelEventArgs.Handled )
      {
        bool endEditCalled;
        this.EndEditInternal( m_currentEditItem, out endEditCalled );
        m_oldValuesBeforeEdition = null;
      }

      DataGridItemEventArgs itemEventArgs = new DataGridItemEventArgs( this, m_currentEditItem );
      int index = this.IndexOfSourceItem( m_currentEditItem );
      Debug.Assert( index != -1 );

      object[] items = new object[] { m_currentEditItem };
      m_currentEditItem = null;

      // Only execute or queue a replace operation if the item is not already queued for a remove operation.
      if( !this.DeferredOperationManager.ContainsItemForRemoveOperation( items[ 0 ] ) )
      {
        this.ExecuteOrQueueSourceItemOperation( new DeferredOperation(
          DeferredOperation.DeferredOperationAction.Replace,
          -1, index, items, index, items ) );
      }

      m_rootDataGridCollectionViewBase.OnEditCommitted( itemEventArgs );
    }
 /// <summary>
 /// React on commit item.
 /// </summary>
 public void CommitItem(DataGridItemCancelEventArgs e)
 {
     _mapControl.EditEnded();
     e.Handled = true;
 }