Beispiel #1
0
        /// <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>
        /// 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);
            }
        }
Beispiel #3
0
        /// <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;
        }
Beispiel #4
0
        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;
            }
        }
Beispiel #5
0
        /// <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>
        /// 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;

            ESRI.ArcLogistics.Data.DataObject dataObject = e.Item as ESRI.ArcLogistics.Data.DataObject;
            if (dataObject != null)
            {
                // Define event args from editinf Item.
                DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs(dataObject);

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

                if (!args.Cancel)
                {
                    _handler.BeginEditItem(e); // If action wasn't cancelled - begin editing in appropriate handler.
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
        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)
            {
                if (App.Current.Project != null)
                {
                    App.Current.Project.Save();
                }

                _SetSelectionStatus();
                IsEditingInProgress = false;
            }
            else
            {
                e.Cancel = true;
            }
        }
Beispiel #8
0
        /// <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 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>
        /// 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());
        }
Beispiel #11
0
 private void DataGridCollectionViewSource_CommittingEdit(object sender, DataGridItemCancelEventArgs e)
 {
     e.Handled = true;
     if (SymbologyManager.SymbologyType == SymbologyType.QuantitySymbology)
     {
         _Validate((OrderQuantity)e.Item);
     }
     _EndEdit();
 }
 /// <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);
     }
 }
Beispiel #13
0
        /// <summary>
        /// React on begin edit item.
        /// </summary>
        public void BeginEditItem(DataGridItemCancelEventArgs e)
        {
            Route route = e.Item as Route;

            if (null == route)
            {   // stop selected
                IEnumerable <DataGridContext> childContexts = _dataGridControl.GetChildContexts();
                foreach (DataGridContext dataGridContext in childContexts)
                {
                    if (dataGridContext.CurrentItem != null)
                    {
                        if (!dataGridContext.CurrentColumn.Equals(dataGridContext.Columns["IsLocked"]))
                        {
                            e.Cancel = true;
                            dataGridContext.CancelEdit();
                        }

                        break;
                    }
                }
            }

            if (!e.Cancel)
            {
                if (null != route)
                {
                    // if route already has stops we should watch it's properties changes because some of them can have influence to route's validity
                    if (route.Stops != null && route.Stops.Count > 0)
                    {
                        // create list of affect routing properties
                        _CreateListOfInitialRouteAffectRoutingProperties((Route)e.Item);
                        ((INotifyPropertyChanged)e.Item).PropertyChanged += new PropertyChangedEventHandler(RouteViewContextHandler_PropertyChanged);
                    }
                }

                e.Handled = true;
                if (_mapControl.IsInEditedMode)
                {
                    e.Cancel = true;
                }
                else
                {
                    _mapControl.StartEdit(e.Item);

                    if (null != route)
                    {
                        _statusBuilder.FillEditingStatus(e.Item.ToString(), (string)App.Current.FindResource("Route"), _parentPage);
                    }
                }
            }
            // else do nothing
        }
Beispiel #14
0
        /// <summary>
        /// React on beginning edit item.
        /// </summary>
        /// <param name="e">Beginning edit item event args.</param>
        public void OnBeginningEdit(DataGridItemCancelEventArgs e)
        {
            // If geocoding in process and try to edit not geocoding geocodable object - than cancel it.
            object current = (object)e.Item;

            // If new item is the same with currently editing item - cancel current editing.
            if (_currentItem == current && _IsAnyToolActivated())
            {
                _CancelEdit();
            }

            _currentItem = e.Item as object;
            _EditStarted(_currentItem);
        }
        /// <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;
        }
Beispiel #16
0
        /// <summary>
        /// React on commiting edited item.
        /// </summary>
        /// <param name="e">Committing item event args.</param>
        public void OnCommittingEdit(DataGridItemCancelEventArgs e)
        {
            _canceledByGrid = true;
            object obj = (object)e.Item;

            if (obj != _currentItem)
            {
                e.Cancel = true;
            }

            // If commiting canceled - don't end edit
            if (!e.Cancel)
            {
                _EditEnded(false);
            }
            _canceledByGrid = false;
        }
        /// <summary>
        /// If edited item has driver/vehicle, which names are the same as others
        /// routes names - raises property changed event for such routes.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">DataGridItemCancelEventArgs.</param>
        private void _DataGridCollectionViewSourceCommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            Route editedRoute = e.Item as Route;

            foreach (Route route in DataKeeper.Routes)
            {
                // If drivers name are the same - raise driver property changed.
                if (route.Driver.Name == editedRoute.Driver.Name)
                {
                    (route as IForceNotifyPropertyChanged).RaisePropertyChangedEvent(Route.PropertyNameDriver);
                }

                // If vehicle name are the same - raise vehicle property changed.
                if (route.Vehicle.Name == editedRoute.Vehicle.Name)
                {
                    (route as IForceNotifyPropertyChanged).RaisePropertyChangedEvent(Route.PropertyNameVehicle);
                }
            }
        }
        /// <summary>
        /// React on beginning edit.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Event args.</param>
        private void _BeginningEdit(object sender, DataGridItemCancelEventArgs e)
        {
            _ShowLocateButton();

            if (GeocodeHelpers.IsActiveAddressFieldsEmpty(CurrentItem))
            {
                ButtonsPanel.IsEnabled = false;
            }
            else
            {
                ButtonsPanel.IsEnabled = true;
            }

            _geocodablePage.OnBeginningEdit(e);
            e.Handled = true;

            CurrentItem.Address.PropertyChanged += new PropertyChangedEventHandler(_AddressPropertyChanged);
            CurrentItem.PropertyChanged         += new PropertyChangedEventHandler(_CurrentItemPropertyChanged);
        }
Beispiel #19
0
        /// <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;
        }
Beispiel #20
0
        /// <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);
        }
Beispiel #21
0
        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;
                }
            }
        }
        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)
            {
                IsEditingInProgress = true;
                _SetEditingStatus(e.Item.ToString());
            }
            else
            {
                e.Cancel = true;
            }
        }
Beispiel #23
0
        /// <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)
        {
            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((AppData.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>
        /// 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)
        {
            // Define event args from commited object.
            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)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;
            }
        }
        /// <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;
            }
        }
 /// <summary>
 /// React on editing committed in grid.
 /// </summary>
 /// <param name="sender">Ignored.</param>
 /// <param name="e">Commiting edit param args.</param>
 private void _DataGridCommittingEdit(object sender, DataGridItemCancelEventArgs e)
 {
     e.Handled = true;
 }
 /// <summary>
 /// React on editing started in grid.
 /// </summary>
 /// <param name="sender">Ignored.</param>
 /// <param name="e">Edited param args.</param>
 private void _DataGridBeginningEdit(object sender, DataGridItemCancelEventArgs e)
 {
     // We shouldn't allow renaming for current schedule and build routes snapshot.
     e.Cancel  = _WasRenamingProhibited(e.Item as Schedule);
     e.Handled = true;
 }
 private void DataGridCollectionViewSource_BeginningEdit(object sender, DataGridItemCancelEventArgs e)
 {
     e.Handled = true;
 }
Beispiel #29
0
 /// <summary>
 /// Handler for the Xceed.Wpf.DataGrid.DataGridCollectionViewSource.CommittingEdit event.
 /// </summary>
 /// <param name="sender">DataGridCollectionViewSource object.</param>
 /// <param name="e">Event arguments.</param>
 private void _DataGridCollectionViewSourceCommittingEdit(object sender, DataGridItemCancelEventArgs e)
 {
     _isEdititngInProgress = false;
 }
Beispiel #30
0
        /// <summary>
        /// Handler for the Xceed.Wpf.DataGrid.DataGridCollectionViewSource.BeginningEdit event.
        /// </summary>
        /// <param name="sender">DataGridCollectionViewSource object.</param>
        /// <param name="e">Event arguments.</param>
        private void _DataGridCollectionViewSourceBeginningEdit(object sender, DataGridItemCancelEventArgs e)
        {
            _isEdititngInProgress = true;

            _buttonDelete.IsEnabled = true;
        }