Exemplo n.º 1
0
        private void DataGridCollectionViewSource_CreatingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCreatingNewItemEventArgs e)
        {
            e.NewItem = _CreateRouteWithDefaultValues();
            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.NewItem);

            if (CreatingNewObject != null)
            {
                CreatingNewObject(this, args);
            }

            e.Handled = true;

            if (!args.Cancel)
            {
                _isNewItemCreated = true; // set flag to true because new object was created
                _SetCreatingStatus();
                IsEditingInProgress = true;

                if (_InsertionRow.Cells["HardZones"] != null)
                {
                    _InsertionRow.Cells["HardZones"].Visibility = Visibility.Visible;
                }
            }
            else
            {
                e.Cancel          = true;
                _isNewItemCreated = false; // set flag to false because new object wasn't created

                if (_InsertionRow.Cells["HardZones"] != null)
                {
                    _InsertionRow.Cells["HardZones"].Visibility = Visibility.Hidden;
                }
            }
        }
Exemplo n.º 2
0
        private void DataGridCollectionViewSource_CreatingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCreatingNewItemEventArgs e)
        {
            e.NewItem = new Location();
            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.NewItem);

            if (CreatingNewObject != null)
            {
                CreatingNewObject(this, args);
            }

            e.Handled = true;

            if (!args.Cancel)
            {
                if (!_geocodablePage.IsGeocodingInProcess)
                {
                    _geocodablePage.OnCreatingNewItem(e);
                    _isNewItemCreated = true; // set flag to true because new object was created
                }
                else
                {
                    e.Cancel          = true;
                    _isNewItemCreated = false;  // set flag to false because new object wasn't created
                }

                _isNewItemCreated = true; //
                _SetCreatingStatus();
                IsEditingInProgress = true;
            }
            else
            {
                e.Cancel          = true;
                _isNewItemCreated = false; // set flag to false because new object wasn't created
            }
        }
Exemplo n.º 3
0
 internal void OnCreatingNewItem(DataGridCreatingNewItemEventArgs e)
 {
     if (this.CreatingNewItem != null)
     {
         this.CreatingNewItem(this, e);
     }
 }
        private void DataGridCollectionViewSource_CreatingNewItem(object sender, Xceed.Wpf.DataGrid.DataGridCreatingNewItemEventArgs e)
        {
            // Create new vehicle with default fuel type.
            var vehicle = new Vehicle(App.Current.Project.CapacitiesInfo);

            if (App.Current.Project.FuelTypes != null && App.Current.Project.FuelTypes.Count > 0)
            {
                vehicle.FuelType = _GetDefaultFuelType();
            }
            e.NewItem = vehicle;

            if (App.Current.Project.FuelTypes.Count == 1)
            {
                ((Vehicle)e.NewItem).FuelType = App.Current.Project.FuelTypes[0];
            }

            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.NewItem);

            if (CreatingNewObject != null)
            {
                CreatingNewObject(this, args);
            }

            e.Handled = true;

            if (!args.Cancel)
            {
                _isNewItemCreated = true; // set flag to true because new object was created
                _SetCreatingStatus();
                IsEditingInProgress = true;
            }
            else
            {
                e.Cancel          = true;
                _isNewItemCreated = false; // set flag to false because new object wasn't created
            }
        }
 /// <summary>
 /// Creates new item 
 /// </summary>
 protected abstract void _CreateNewItem(DataGridCreatingNewItemEventArgs e);
        /// <summary>
        /// Handler for the Xceed.Wpf.DataGrid.DataGridCollectionViewSource.CreatingNewItem event.
        /// </summary>
        /// <param name="sender">DataGridCollectionViewSource object.</param>
        /// <param name="e">Event arguments.</param>
        private void _DataGridCollectionViewSourceCreatingNewItem(object sender, DataGridCreatingNewItemEventArgs e)
        {
            // Create new custom order property.
            e.NewItem = new CustomOrderProperty();

            // Set flag indicating that new object is being edited now.
            _isEdititngInProgress = true;

            // Make the "Delete" button enabled.
            _buttonDelete.IsEnabled = true;

            // Set flag indicating that event was handled.
            e.Handled = true;
        }
        /// <summary>
        /// Creates new object.
        /// </summary>
        public void CreateNewItem(DataGridCreatingNewItemEventArgs e)
        {
            Project project = App.Current.Project;

            if (!_geocodablePage.IsGeocodingInProcess)
            {
                e.NewItem = new Order(project.CapacitiesInfo, project.OrderCustomPropertiesInfo);
                _geocodablePage.OnCreatingNewItem(e);
            }
            else
            {
                e.Cancel = true;
            }
            e.Handled = true;

            _statusBuilder.FillCreatingStatus((string)App.Current.FindResource("Order"), _parentPage);
        }
        /// <summary>
        /// Handler begin creating new item.
        /// </summary>
        /// <param name="sender">Data grid control sender.</param>
        /// <param name="e">Item event args.</param>
        private void _DataGridCollectionViewSourceCreatingNewItem(object sender, DataGridCreatingNewItemEventArgs e)
        {
            // If current visible collection is routes.
            e.NewItem = App.Current.Project.CreateRoute();

            // NOTE : workaround - used to show drop-downs cell editors in routes insertion row.
            _routesInsertionRow.CellEditorDisplayConditions = CellEditorDisplayConditions.CellIsCurrent;

            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.NewItem);

            // Raise event about creating new object was started.
            if (CreatingNewObject != null)
                CreatingNewObject(this, args);
            e.Handled = true;

            if (!args.Cancel) // If action was not cancelled - begin creating new item.
            {
                _handler.CreateNewItem(e);
                _isNewItemCreated = true; // Set flag to true because new object was created.

                if (_routesInsertionRow.Cells[HARD_ZONES_PROPERTY_NAME] != null)
                    _routesInsertionRow.Cells[HARD_ZONES_PROPERTY_NAME].Visibility = Visibility.Visible;
            }
            else
            {
                _isNewItemCreated = false; // Set flag to false because new object wasn't created.
                e.Cancel = true;
            }
        }
        /// <summary>
        /// Handler begin creating new item.
        /// </summary>
        /// <param name="sender">Data grid control sender.</param>
        /// <param name="e">Item event args.</param>
        private void _DataGridCollectionViewSourceCreatingNewItem(object sender, DataGridCreatingNewItemEventArgs e)
        {
            e.NewItem = new Order(App.Current.Project.CapacitiesInfo, App.Current.Project.OrderCustomPropertiesInfo);

            // NOTE : workaround - used to show drop-downs cell editors in orders insertion row.
            _ordersInsertionRow.CellEditorDisplayConditions = CellEditorDisplayConditions.CellIsCurrent;

            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((ESRI.ArcLogistics.Data.DataObject)e.NewItem);

            // Raise event about creating new object was started.
            if (CreatingNewObject != null)
                CreatingNewObject(this, args);
            e.Handled = true;

            if (!args.Cancel) // If action was not cancelled - begin creating new item.
            {
                _handler.CreateNewItem(e);
                _isNewItemCreated = true; // Set flag to true because new object was created.
            }
            else
            {
                _isNewItemCreated = false; // Set flag to false because new object wasn't created.
                e.Cancel = true;
            }

            // Reset new item if adding of new item was canceled.
            if (e.Cancel)
                e.NewItem = null;
        }
        /// <summary>
        /// Occurs when set focus to inits insertion row.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGridCollectionViewSource_CreatingNewItem(object sender, DataGridCreatingNewItemEventArgs e)
        {
            e.NewItem = new ProjectDataWrapper(true, string.Empty, string.Empty);
            e.Handled = true;

            DeleteButton.IsEnabled = true;

            // If user clicks into "IsCurrent" cell in insertion row - move focus to "Name" cell and start edit it.
            if (_InsertionRow.Cells[IS_CURRENT_COLUMN_CAPTION].IsCurrent)
                Dispatcher.BeginInvoke(new ZeroParamsDelegate(_BeginEditNameCell), System.Windows.Threading.DispatcherPriority.SystemIdle);

            _statusBuilder.FillCreatingStatus(PROJECT_TYPE_NAME, this);
            _needToUpdateStatus = false;
        }
 internal void OnCreatingNewItem( DataGridCreatingNewItemEventArgs e )
 {
   if( this.CreatingNewItem != null )
     this.CreatingNewItem( this, e );
 }
    internal void OnCreatingNewItem( DataGridCreatingNewItemEventArgs e )
    {
      if( this.CreatingNewItem != null )
        this.CreatingNewItem( this, e );

      if( m_parentCollectionViewSourceBase != null )
        m_parentCollectionViewSourceBase.OnCreatingNewItem( e );
    }
 /// <summary>
 /// Creates new item
 /// </summary>
 /// <param name="e"></param>
 protected override void _CreateNewItem(DataGridCreatingNewItemEventArgs e)
 {
     e.NewItem = new DriverSpecialty();
 }
Exemplo n.º 14
0
        /// <summary>
        /// React on creating new item.
        /// </summary>
        /// <param name="args">New item creating args.</param>
        public void OnCreatingNewItem(DataGridCreatingNewItemEventArgs args)
        {
            Debug.Assert(_parentLayer != null);
            Debug.Assert(args != null);

            _currentItem = (IGeocodable)args.NewItem;
            _currentItem.Address.PropertyChanged += new PropertyChangedEventHandler(_AddressPropertyChanged);

            Graphic graphic = _parentLayer.CreateGraphic(_currentItem);
            _parentLayer.MapLayer.Graphics.Add(graphic);

            _editStartedByGrid = true;
            _StartEdit(_currentItem);
            _editStartedByGrid = false;

            _SetAddressByPointToolEnabled(true);
        }
        private void CollectionView_CreatingNewItem(object sender, DataGridCreatingNewItemEventArgs e)
        {
            DeleteButton.IsEnabled = false;
            if (SymbologyManager.SymbologyType == SymbologyType.CategorySymbology)
                e.NewItem = new OrderCategory(false);
            else
                e.NewItem = new OrderQuantity(false);

            e.Handled = true;
            _StartEdit((SymbologyRecord)e.NewItem);
        }
        /// <summary>
        /// Handler begin creating new item.
        /// </summary>
        /// <param name="sender">Data grid control sender.</param>
        /// <param name="e">Item event args.</param>
        private void _DataGridCollectionViewSourceCreatingNewItem(object sender,
                                                                  DataGridCreatingNewItemEventArgs e)
        {
            // since barrier's start and end dates should be created in code we should also create
            // string fields there too.
            DateTime date = App.Current.CurrentDate.Date;
            Barrier barrier = CommonHelpers.CreateBarrier(date);

            e.NewItem = barrier;

            DataObjectCanceledEventArgs args = new DataObjectCanceledEventArgs((AppData.DataObject)e.NewItem);
            if (CreatingNewObject != null)
                CreatingNewObject(this, args);

            e.Handled = true;

            if (!args.Cancel)
            {
                e.Handled = true;
                _regionsPage.OnCreatingNewItem(e);

                _isNewItemCreated = true; // set flag to true because new object was created
                _SetCreatingStatus();
                IsEditingInProgress = true;
            }
            else
            {
                e.Cancel = true;
                _isNewItemCreated = false; // set flag to false because new object wasn't created
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// New item creating.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _DataGridCollectionViewSourceCreatingNewItem(object sender,
            DataGridCreatingNewItemEventArgs e)
        {
            // Add new break of specific type.
            if (App.Current.Project.BreaksSettings.DefaultBreaks.Count < Breaks.MaximumBreakCount)
            {
                if (App.Current.Project.BreaksSettings.BreaksType == BreakType.TimeWindow)
                    e.NewItem = new TimeWindowBreak();
                else if (App.Current.Project.BreaksSettings.BreaksType == BreakType.DriveTime)
                    e.NewItem = new DriveTimeBreak();
                else if (App.Current.Project.BreaksSettings.BreaksType == BreakType.WorkTime)
                    e.NewItem = new WorkTimeBreak();
                else
                    // Unknown type of break.
                    Debug.Assert(false);

                // Set flags.
                _isNewItemCreated = true;
                IsEditingInProgress = true;
                e.Handled = true;
            }
            else
            {
                IsEditingInProgress = false;
                e.Cancel = true;
                _isNewItemCreated = false;
            }
        }
        /// <summary>
        /// Creates new object.
        /// </summary>
        public void CreateNewItem(DataGridCreatingNewItemEventArgs e)
        {
            Debug.Assert(e.NewItem is Route);

            if (_mapControl.IsInEditedMode)
                e.Cancel = true;
            else
            {
                e.NewItem = _CreateRouteWithDefaultValues();
                _addedRoute = (Route)e.NewItem;
                e.Handled = true;
                _mapControl.StartEdit(e.NewItem);
                _statusBuilder.FillCreatingStatus((string)App.Current.FindResource("Route"), _parentPage);
            }
        }
    public virtual object AddNew()
    {
      if( !this.CanAddNew )
        throw new InvalidOperationException( "An attempt was made to add an item to a source that does not support addition." );

      // If a current AddNew has not been committed, commit it.
      this.CommitNew();
      this.CommitEdit();

      this.QueueOperationForAddNew = true;

      try
      {
        DataGridCreatingNewItemEventArgs creatingNewItemEventArgs = new DataGridCreatingNewItemEventArgs( this, null, false );

        this.RootDataGridCollectionViewBase.OnCreatingNewItem( creatingNewItemEventArgs );

        this.SetCurrentAddNew( creatingNewItemEventArgs.NewItem, -1 );

        if( creatingNewItemEventArgs.Cancel )
          throw new DataGridException( "AddNew was canceled." );

        this.CreatingNewItemIsManuallyHandled = creatingNewItemEventArgs.Handled;

        if( this.CreatingNewItemIsManuallyHandled )
        {
          if( m_currentAddItem == null )
            throw new InvalidOperationException( "An attempt was made to handle the CreatingNewItem event without providing a new item." );
        }
        else
        {
          if( !this.HasSource )
            throw new InvalidOperationException( "The CreatingNewItem event must be handled when not using an underlying data source." );

          int newItemIndex;
          object newItem = ItemsSourceHelper.AddNewDataItem( this.Enumeration, null, out newItemIndex );

          this.SetCurrentAddNew(
            newItem,
            newItemIndex );
        }

        DataGridItemEventArgs initializingNewItemEventArgs = new DataGridItemEventArgs( this, m_currentAddItem );
        this.RootDataGridCollectionViewBase.OnInitializingNewItem( initializingNewItemEventArgs );
      }
      catch
      {
        // QueueOperationForAddNew must be off when calling CancelNew
        this.QueueOperationForAddNew = false;

        if( m_currentAddItem != null )
          this.CancelNew();

        throw;
      }
      finally
      {
        this.QueueOperationForAddNew = false;
      }

      DataGridItemEventArgs itemCreatedEventArgs = new DataGridItemEventArgs( this, m_currentAddItem );
      m_rootDataGridCollectionViewBase.OnNewItemCreated( itemCreatedEventArgs );

      return m_currentAddItem;
    }
Exemplo n.º 20
0
        /// <summary>
        /// React on creating new item.
        /// </summary>
        /// <param name="e">Creating item event args.</param>
        public void OnCreatingNewItem(DataGridCreatingNewItemEventArgs e)
        {
            _mapCtrl.CurrentTool = null;

            _currentItem = (object)e.NewItem;

            // Graphic, which created to show not yet committed new item.
            Graphic graphic = _parentLayer.CreateGraphic(_currentItem);

            DataGraphicObject dataGraphicObject = graphic as DataGraphicObject;
            if (dataGraphicObject != null && _parentLayer.LayerContext != null)
                dataGraphicObject.ObjectContext = _parentLayer.LayerContext;

            _parentLayer.MapLayer.Graphics.Add(graphic);

            _EditStarted(_currentItem);
            _SetToolsEnabled(true);
        }