internal void OnCommittingNewItem(DataGridCommittingNewItemEventArgs e) { if (this.CommittingNewItem != null) { this.CommittingNewItem(this, e); } }
private void DataGridCollectionViewSource_CommittingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCommittingNewItemEventArgs e) { DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item); if (CommittingNewObject != null) { CommittingNewObject(this, args); } e.Handled = true; if (!args.Cancel) { ICollection <Zone> source = e.CollectionView.SourceCollection as ICollection <Zone>; Project project = App.Current.Project; Zone current = e.Item as Zone; project.Zones.Add(current); e.Index = source.Count; e.NewCount = source.Count + 1; project.Save(); e.Handled = true; _regionsPage.OnNewItemCommitted(e); _SetSelectionStatus(); IsEditingInProgress = false; } else { e.Cancel = true; } }
public override void CommitNew() { // We are not calling base since the intended behavior is quite different with Virtualizing collection views. object currentAddItem = this.CurrentAddItem; if (currentAddItem == null) { return; } DataGridCommittingNewItemEventArgs committingNewItemEventArgs = new DataGridCommittingNewItemEventArgs(this, currentAddItem, false); this.RootDataGridCollectionViewBase.OnCommittingNewItem(committingNewItemEventArgs); if (committingNewItemEventArgs.Cancel) { throw new DataGridException("CommitNew was canceled."); } if (!committingNewItemEventArgs.Handled) { throw new InvalidOperationException("When manually handling the item-insertion process the CreatingNewItem, CommittingNewItem, and CancelingNewItem events must all be handled."); } // Contrarily to the data bound collection views, we do not care about the new index or new count since we will enqueue a Refresh operation. this.SetCurrentAddNew(null, -1); this.ExecuteOrQueueSourceItemOperation(new DeferredOperation(DeferredOperation.DeferredOperationAction.Refresh, -1, null)); }
private void DataGridCollectionViewSource_CommittingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCommittingNewItemEventArgs e) { DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item); if (CommittingNewObject != null) { CommittingNewObject(this, args); } e.Handled = true; if (!args.Cancel) { ICollection <Driver> source = e.CollectionView.SourceCollection as ICollection <Driver>; Driver currentDriver = e.Item as Driver; source.Add(currentDriver); e.Index = source.Count - 1; e.NewCount = source.Count; App.Current.Project.Save(); _SetSelectionStatus(); IsEditingInProgress = false; } else { e.Cancel = true; } }
private void DataGridCollectionViewSource_CommittingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCommittingNewItemEventArgs e) { if (CommonHelpers.IgnoreVirtualLocations(e.Item)) { DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item); if (CommittingNewObject != null) { CommittingNewObject(this, args); } e.Handled = true; if (!args.Cancel) { ICollection <Route> source = e.CollectionView.SourceCollection as ICollection <Route>; Route currentRoute = e.Item as Route; source.Add(currentRoute); e.Index = source.Count - 1; e.NewCount = source.Count; App.Current.Project.Save(); _SetSelectionStatus(); IsEditingInProgress = false; if (_InsertionRow.Cells["HardZones"] != null) { _InsertionRow.Cells["HardZones"].Visibility = Visibility.Hidden; } } else { e.Cancel = true; if (_InsertionRow.Cells["HardZones"] != null) { _InsertionRow.Cells["HardZones"].Visibility = Visibility.Visible; } } } else { e.Handled = true; e.Cancel = true; if (_InsertionRow.Cells["HardZones"] != null) { _InsertionRow.Cells["HardZones"].Visibility = Visibility.Visible; } } }
/// <summary> /// New item commiting. Adding to collection. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Ignored.</param> private void _DataGridCollectionViewSourceCommittingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCommittingNewItemEventArgs e) { e.Handled = true; // Detecting breake to add. ICollection <Break> source = e.CollectionView.SourceCollection as ICollection <Break>; Break currentBreak = e.Item as Break; _AddAndSelect(currentBreak); // Set new index. e.Index = App.Current.Project.BreaksSettings.DefaultBreaks.IndexOf(currentBreak); e.NewCount = source.Count; // Saving project. App.Current.Project.Save(); _SetSelectionStatus(); IsEditingInProgress = false; }
private void DataGridCollectionViewSource_CommittingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCommittingNewItemEventArgs e) { e.Handled = true; DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item); if (CommittingNewObject != null) { CommittingNewObject(this, args); } if (!args.Cancel) { _CommitNewItem(e); IsEditingInProgress = false; _SetSelectionStatus(); } else { e.Cancel = true; } }
private void DataGridCollectionViewSource_CommittingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCommittingNewItemEventArgs e) { DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item); if (CommittingNewObject != null) { CommittingNewObject(this, args); } e.Handled = true; if (args.Cancel) { e.Cancel = true; return; } ICollection <MobileDevice> source = e.CollectionView.SourceCollection as ICollection <MobileDevice>; MobileDevice currentMobileDevice = e.Item as MobileDevice; source.Add(currentMobileDevice); if (_devicesEditor != null) { _devicesEditor.AddDevice(currentMobileDevice); } e.Index = source.Count - 1; e.NewCount = source.Count; App.Current.Project.Save(); _SetSelectionStatus(); IsEditingInProgress = false; }
private void DataGridCollectionViewSource_CommittingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCommittingNewItemEventArgs e) { DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item); if (CommittingNewObject != null) { CommittingNewObject(this, args); } e.Handled = true; if (!args.Cancel) { if (_geocodablePage.OnCommittingNewItem(e)) { ICollection <Location> source = e.CollectionView.SourceCollection as ICollection <Location>; Location geocodable = e.Item as Location; source.Add(geocodable); if (App.Current.Project != null) { App.Current.Project.Save(); } e.Index = source.Count - 1; e.NewCount = source.Count; _SetSelectionStatus(); } IsEditingInProgress = false; } else { e.Cancel = true; } }
/// <summary> /// Occurs when user press enter in inserion row. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataGridCollectionViewSource_CommittingNewItem(object sender, DataGridCommittingNewItemEventArgs e) { try { WorkingStatusHelper.SetBusy((string)App.Current.FindResource("LoadingProjectStatus")); ProjectCatalog projectBrowser = App.Current.ProjectCatalog; List<ProjectDataWrapper> source = e.CollectionView.SourceCollection as List<ProjectDataWrapper>; ProjectDataWrapper projectDataTemplate = e.Item as ProjectDataWrapper; App.Current.NewProject(projectDataTemplate.Name, projectBrowser.FolderPath, projectDataTemplate.Description); source.Add(projectDataTemplate); // update layout UpdateView(); e.Index = source.Count - 1; e.NewCount = source.Count; e.Handled = true; } catch (ApplicationException ex) { Logger.Info(ex); App.Current.Messenger.AddWarning(ex.Message); } catch (Exception ex) { Logger.Info(ex); App.Current.Messenger.AddWarning(ex.Message); } finally { WorkingStatusHelper.SetReleased(); App.Current.MainWindow.StatusBar.SetStatus(this, null); } }
/// <summary> /// Commits new item /// </summary> /// <param name="e"></param> protected abstract void _CommitNewItem(DataGridCommittingNewItemEventArgs e);
/// <summary> /// Adds created object to source collection. /// </summary> public void CommitNewItem(DataGridCommittingNewItemEventArgs e) { if (!e.Cancel && _geocodablePage.OnCommittingNewItem(e)) { ICollection<Order> source = (ICollection<Order>)e.CollectionView.SourceCollection; Order order = e.Item as Order; order.PlannedDate = _currentSchedule.PlannedDate; Project project = App.Current.Project; project.Orders.Add(order); project.Save(); e.Index = source.Count; e.NewCount = source.Count + 1; } }
/// <summary> /// Saves new item in collection /// </summary> /// <param name="e"></param> protected override void _CommitNewItem(DataGridCommittingNewItemEventArgs e) { ICollection<DriverSpecialty> source = e.CollectionView.SourceCollection as ICollection<DriverSpecialty>; DriverSpecialty currentSpecialty = e.Item as DriverSpecialty; source.Add(currentSpecialty); e.Index = source.Count - 1; e.NewCount = source.Count; App.Current.Project.Save(); }
public override void CommitNew() { // We are not calling base since the intended behavior is quite different with Virtualizing collection views. object currentAddItem = this.CurrentAddItem; if( currentAddItem == null ) return; DataGridCommittingNewItemEventArgs committingNewItemEventArgs = new DataGridCommittingNewItemEventArgs( this, currentAddItem, false ); this.RootDataGridCollectionViewBase.OnCommittingNewItem( committingNewItemEventArgs ); if( committingNewItemEventArgs.Cancel ) throw new DataGridException( "CommitNew was canceled." ); if( !committingNewItemEventArgs.Handled ) throw new InvalidOperationException( "When manually handling the item-insertion process the CreatingNewItem, CommittingNewItem, and CancelingNewItem events must all be handled." ); // Contrarily to the data bound collection views, we do not care about the new index or new count since we will enqueue a Refresh operation. this.SetCurrentAddNew( null, -1 ); this.ExecuteOrQueueSourceItemOperation( new DeferredOperation( DeferredOperation.DeferredOperationAction.Refresh, -1, null ) ); }
/// <summary> /// Handler begin commiting new item (calls CommitNewItem method of appropriate ContextHandler). /// </summary> /// <param name="sender">Data grid control sender.</param> /// <param name="e">Item event args.</param> private void _DataGridCollectionViewSourceCommittingNewItem(object sender, DataGridCommittingNewItemEventArgs e) { if (CommonHelpers.IgnoreVirtualLocations(e.Item)) { var args = _CreateDataObjectCanceledEventArgs(e.Item); // Raise event about new item starts commiting. if (CommittingNewObject != null) CommittingNewObject(this, args); e.Handled = true; if (!args.Cancel) // If action was not cancelled - commit new item. _handler.CommitNewItem(e); else e.Cancel = true; // NOTE : workaround - hide cell editors when new item's commiting. if (_routesInsertionRow != null) _routesInsertionRow.CellEditorDisplayConditions = CellEditorDisplayConditions.None; } else { e.Handled = e.Cancel = true; RoutesGrid.BeginEditCurrentCell(_routesInsertionRow); } }
/// <summary> /// Handler begin commiting new item (calls CommitNewItem method of appropriate ContextHandler). /// </summary> /// <param name="sender">Data grid control sender.</param> /// <param name="e">Item event args.</param> private void _DataGridCollectionViewSourceCommittingNewItem(object sender, DataGridCommittingNewItemEventArgs e) { DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.Item); // Raise event about new item starts commiting. if (CommittingNewObject != null) CommittingNewObject(this, args); e.Handled = true; if (!args.Cancel) // If action was not cancelled - commit new item. _handler.CommitNewItem(e); else e.Cancel = true; // NOTE : workaround - hide cell editors when new item's commiting. if (_ordersInsertionRow != null) _ordersInsertionRow.CellEditorDisplayConditions = CellEditorDisplayConditions.None; }
/// <summary> /// Handler for the Xceed.Wpf.DataGrid.DataGridCollectionViewSource.CommittingNewItem event. /// </summary> /// <param name="sender">DataGridCollectionViewSource object.</param> /// <param name="e">Event arguments.</param> private void _DataGridCollectionViewSourceCommittingNewItem(object sender, DataGridCommittingNewItemEventArgs e) { // Get collection of custom order properties bound to the Xceed DataGrid control. ICollection<CustomOrderProperty> source = e.CollectionView.SourceCollection as ICollection<CustomOrderProperty>; // Get custom order property which should be committed to collection. CustomOrderProperty currentProperty = e.Item as CustomOrderProperty; // Add custom order property to collection. source.Add(currentProperty); // Set index of new item in collection. e.Index = source.Count - 1; // Set new count of items in collection. e.NewCount = source.Count; // Set flag indicating that event was handled. e.Handled = true; }
/// <summary> /// Adds created object to source collection. /// </summary> public void CommitNewItem(DataGridCommittingNewItemEventArgs e) { Debug.Assert(e.Item is Route); _mapControl.EditEnded(); ICollection<Route> source = e.CollectionView.SourceCollection as ICollection<Route>; source.Add(_addedRoute); e.Index = source.Count - 1; e.NewCount = source.Count; App.Current.Project.Save(); _addedRoute = null; e.Handled = true; _statusBuilder.FillSelectionStatusWithoutCollectionSize(((ICollection<Route>)e.CollectionView.SourceCollection).Count, (string)App.Current.FindResource("Route"), 0, _parentPage); }
internal void OnCommittingNewItem( DataGridCommittingNewItemEventArgs e ) { if( this.CommittingNewItem != null ) this.CommittingNewItem( this, e ); if( m_parentCollectionViewSourceBase != null ) m_parentCollectionViewSourceBase.OnCommittingNewItem( e ); }
/// <summary> /// Handler begin commiting new item (calls CommitNewItem method of appropriate ContextHandler). /// </summary> /// <param name="sender">Data grid control sender.</param> /// <param name="e">Item event args.</param> private void _DataGridCollectionViewSourceCommittingNewItem(object sender, DataGridCommittingNewItemEventArgs e) { DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((AppData.DataObject)e.Item); if (CommittingNewObject != null) CommittingNewObject(this, args); e.Handled = true; if (!args.Cancel) { var source = e.CollectionView.SourceCollection as ICollection<Barrier>; Barrier current = e.Item as Barrier; if (null == current.StartDate) current.StartDate = App.Current.CurrentDate.Date; if (null == current.FinishDate) { DateTime date = current.StartDate; current.FinishDate = date.AddDays(1); } Project project = App.Current.Project; project.Barriers.Add(current); project.Save(); e.Index = source.Count; e.NewCount = source.Count + 1; _regionsPage.OnNewItemCommitted(e); _SetSelectionStatus(((ICollection<Barrier>)e.CollectionView.SourceCollection).Count); IsEditingInProgress = false; } else e.Cancel = true; }
/// <summary> /// React on commiting new item. /// </summary> /// <param name="args">New item commiting args.</param> /// <returns>Is commiting successful.</returns> public bool OnCommittingNewItem(DataGridCommittingNewItemEventArgs args) { Debug.Assert(_currentItem != null); Debug.Assert(args != null); bool commitingSuccessful = false; if (_isAddressChanged) { _StartGeocoding(_currentItem, true); if (!IsGeocodingInProcess) { _currentItem.Address.PropertyChanged -= new PropertyChangedEventHandler(_AddressPropertyChanged); } } args.Handled = true; if (IsGeocodingInProcess) { args.Cancel = true; } else { commitingSuccessful = true; } _isNewItemJustCommited = true; return commitingSuccessful; }
private void DataGridCollectionViewSource_CommittingNewItem(object sender, DataGridCommittingNewItemEventArgs e) { if (SymbologyManager.SymbologyType == SymbologyType.CategorySymbology) { ICollection<OrderCategory> source = e.CollectionView.SourceCollection as ICollection<OrderCategory>; source.Add((OrderCategory)e.Item); e.Index = source.Count - 1; e.NewCount = source.Count; } else { _Validate((OrderQuantity)e.Item); ICollection<OrderQuantity> source = e.CollectionView.SourceCollection as ICollection<OrderQuantity>; source.Add((OrderQuantity)e.Item); e.Index = source.Count - 1; e.NewCount = source.Count; } e.Handled = true; _EndEdit(); }
public virtual void CommitNew() { if( m_currentAddItem == null ) return; object item = m_currentAddItem; DeferredOperation addOperationToNotifyIfNotAlreadyQueued = null; this.QueueOperationForAddNew = true; try { DataGridCommittingNewItemEventArgs committingNewItemEventArgs = new DataGridCommittingNewItemEventArgs( this, m_currentAddItem, false ); this.RootDataGridCollectionViewBase.OnCommittingNewItem( committingNewItemEventArgs ); if( committingNewItemEventArgs.Cancel ) throw new DataGridException( "CommitNew was canceled." ); if( this.CreatingNewItemIsManuallyHandled != committingNewItemEventArgs.Handled ) throw new InvalidOperationException( "When manually handling the item-insertion process the CreatingNewItem, CommittingNewItem, and CancelingNewItem events must all be handled." ); if( !committingNewItemEventArgs.Handled ) { if( !this.HasSource ) throw new InvalidOperationException( "The CommittingNewItem event must be handled when not using an underlying data source." ); int addItemPosition = m_currentAddItemPosition; ItemsSourceHelper.EndNewDataItem( this.Enumeration, null, m_currentAddItem, ref addItemPosition ); addOperationToNotifyIfNotAlreadyQueued = new DeferredOperation( DeferredOperation.DeferredOperationAction.Add, addItemPosition + 1, addItemPosition, new object[] { m_currentAddItem } ); } else { if( committingNewItemEventArgs.Index == -1 ) throw new InvalidOperationException( "An attempt was made to handle the CommittingNewItem event without providing the index at which the new item was inserted." ); if( committingNewItemEventArgs.NewCount == -1 ) throw new InvalidOperationException( "An attempt was made to handle the CommittingNewItem event without providing the new item count." ); if( committingNewItemEventArgs.Index >= committingNewItemEventArgs.NewCount ) throw new InvalidOperationException( "The index at which the new item was inserted was greater than the new item count." ); addOperationToNotifyIfNotAlreadyQueued = new DeferredOperation( DeferredOperation.DeferredOperationAction.Add, committingNewItemEventArgs.NewCount, committingNewItemEventArgs.Index, new object[] { m_currentAddItem } ); } 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; } else { Debug.Assert( !this.IsSourceSupportingChangeNotification ); // No pending operation was in m_deferredAddNewOperationManager, // so the list have not trigger notification for the new item added. // We will, in that case, raise the notification ourself. this.ExecuteOrQueueSourceItemOperation( addOperationToNotifyIfNotAlreadyQueued ); } DataGridItemEventArgs itemEventArgs = new DataGridItemEventArgs( this, item ); m_rootDataGridCollectionViewBase.OnNewItemCommitted( itemEventArgs ); }
internal void OnCommittingNewItem( DataGridCommittingNewItemEventArgs e ) { if( this.CommittingNewItem != null ) this.CommittingNewItem( this, e ); }