/// <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;
            }
        }
示例#2
0
        private void CollectionView_CommittingNewItem(object sender, DataGridCommittingNewItemEventArgs e)
        {
            var customer = (Editable <Customer>)e.Item;

            _editableSet.AddNewItem(customer);
            e.NewCount = 1;
            e.Index    = 0;
            e.Handled  = true;
        }
    private void DataGridCollectionViewSource_CommittingNewItem(
        object sender, DataGridCommittingNewItemEventArgs e)
    {
        Type t = e.CollectionView.SourceCollection.GetType();

        if (t == typeof(List <ABC>))
        {
            List <ABC> source = e.CollectionView.SourceCollection as List <ABC>;
            source.Add(e.Item as ABC);
        }
    }
示例#4
0
        /// <summary>
        /// Saves new item in collection
        /// </summary>
        /// <param name="e"></param>
        protected override void _CommitNewItem(DataGridCommittingNewItemEventArgs e)
        {
            ICollection <VehicleSpecialty> source = e.CollectionView.SourceCollection as ICollection <VehicleSpecialty>;

            VehicleSpecialty currentSpecialty = e.Item as VehicleSpecialty;

            source.Add(currentSpecialty);

            e.Index    = source.Count - 1;
            e.NewCount = source.Count;

            App.Current.Project.Save();
        }
示例#5
0
        /// <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>
        /// 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;
            }
        }
示例#7
0
        /// <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);
        }
示例#8
0
        /// <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>
        /// 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);
            }
        }
示例#10
0
        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();
        }
示例#11
0
 /// <summary>
 /// Commits new item
 /// </summary>
 /// <param name="e"></param>
 protected abstract void _CommitNewItem(DataGridCommittingNewItemEventArgs e);