Exemple #1
0
 protected override void OnPropertyChanging(RadPropertyChangingEventArgs e)
 {
     if (this.ownerTemplate == null)
     {
         return;
     }
     if (e.Property == GridViewColumn.WidthProperty)
     {
         int newValue = (int)e.NewValue;
         int maxWidth = this.MaxWidth;
         int minWidth = this.MinWidth;
         e.Cancel = newValue <minWidth || maxWidth> minWidth && newValue > maxWidth && maxWidth > 0;
         this.OwnerTemplate.BestFitQueue.Dequeue(this);
         if (this.EventDispatcher != null)
         {
             ColumnWidthChangingEventArgs args = new ColumnWidthChangingEventArgs(this.Index, newValue);
             args.Cancel = e.Cancel;
             this.EventDispatcher.RaiseEvent <ColumnWidthChangingEventArgs>(EventDispatcher.ColumnWidthChanging, (object)this, args);
             e.Cancel = args.Cancel;
         }
     }
     else if (e.Property == GridViewColumn.IsCurrentProperty)
     {
         if (this.ownerTemplate.MasterTemplate == null || GridViewSynchronizationService.IsEventSuspended(this.ownerTemplate, KnownEvents.CurrentChanged))
         {
             return;
         }
         if ((bool)e.NewValue)
         {
             if (!this.CanBeCurrent)
             {
                 e.Cancel = true;
                 return;
             }
             this.ownerTemplate.MasterTemplate.CurrentColumn = this;
             e.Cancel = this.ownerTemplate.MasterTemplate.CurrentColumn != this;
         }
         else
         {
             this.ownerTemplate.MasterTemplate.CurrentColumn = (GridViewColumn)null;
             e.Cancel = this.ownerTemplate.MasterTemplate.CurrentRow != null;
         }
     }
     else if (e.Property == GridViewColumn.IsVisibleProperty)
     {
         bool newValue = (bool)e.NewValue;
         e.Cancel = !newValue && !this.AllowHide && this.GetVisibleColumnsCount((IEnumerable)this.OwnerTemplate.Columns) > 1;
     }
     else if (e.Property == GridViewColumn.NameProperty)
     {
         string newValue = (string)e.NewValue;
         if (this.ownerTemplate.Columns.Contains(newValue) && this != this.ownerTemplate.Columns[newValue])
         {
             throw new InvalidOperationException("A column with the same Name already exists in the collection");
         }
         this.ownerTemplate.Columns.Rename((string)e.OldValue, newValue);
     }
     base.OnPropertyChanging(e);
 }
Exemple #2
0
        private void RemoveAt(int index, bool selectCurrentRow)
        {
            if (index < 0 || index >= this.Count)
            {
                throw new IndexOutOfRangeException("Invalid Index.");
            }
            GridViewRowInfo gridViewRowInfo = this[index];
            GridViewInfo    viewInfo        = gridViewRowInfo.ViewInfo;

            if (this.OnRowsChanging(new GridViewCollectionChangingEventArgs(this.owner, NotifyCollectionChangedAction.Remove, (object)gridViewRowInfo, -1, index)))
            {
                return;
            }
            int count = this.Count;

            GridViewSynchronizationService.SuspendEvent(this.owner, KnownEvents.CurrentChanged);
            GridViewRowInfo navRow = (GridViewRowInfo)null;
            bool            flag   = selectCurrentRow && this.owner.MasterTemplate != null && gridViewRowInfo == this.owner.MasterTemplate.CurrentRow;

            if (flag)
            {
                navRow = GridViewRowCollection.NavigateAfterRemove(this.owner.MasterTemplate.CurrentRow, (List <GridViewRowInfo>)null);
            }
            this.suspendNotifications = true;
            gridViewRowInfo.ViewInfo.PinnedRows.Remove(gridViewRowInfo);
            this.owner.ListSource.RemoveAt(index);
            this.suspendNotifications = false;
            GridViewSynchronizationService.ResumeEvent(this.owner, KnownEvents.CurrentChanged);
            if (count != this.Count)
            {
                this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.Remove, (object)gridViewRowInfo));
                if (flag)
                {
                    if (navRow == null && this.Owner.AllowAddNewRow)
                    {
                        navRow = (GridViewRowInfo)viewInfo.TableAddNewRow;
                    }
                    if (navRow != null && navRow.ViewInfo != null)
                    {
                        this.ExpandRow(navRow);
                        this.owner.MasterTemplate.CurrentRow = navRow;
                    }
                    if (this.Owner.MasterTemplate.CurrentRow == null)
                    {
                        this.Owner.MasterTemplate.EventDispatcher.RaiseEvent <EventArgs>(EventDispatcher.SelectionChanged, (object)this.Owner, EventArgs.Empty);
                    }
                }
                gridViewRowInfo.Detach();
            }
            else
            {
                gridViewRowInfo.Attach();
                if (!gridViewRowInfo.IsPinned)
                {
                    return;
                }
                viewInfo.PinnedRows.Add(gridViewRowInfo);
            }
        }
Exemple #3
0
        private void DispatchDataViewChangedEvent(DataViewChangedEventArgs args, GridEventType type)
        {
            GridViewEventInfo eventInfo = new GridViewEventInfo(KnownEvents.ViewChanged, type, GridEventDispatchMode.Send);

            GridViewSynchronizationService.DispatchEvent(this.owner, new GridViewEvent((object)this.owner, (object)this.owner, new object[1]
            {
                (object)args
            }, eventInfo), false);
        }
        public void BeginEdit()
        {
            GridViewTemplate viewTemplate = this.row.ViewTemplate;

            if (!this.row.IsCurrent || !this.column.IsCurrent)
            {
                GridViewSynchronizationService.RaiseCurrentChanged(viewTemplate, this.row, this.column, true);
            }
            viewTemplate.OnViewChanged((object)viewTemplate, new DataViewChangedEventArgs(ViewChangedAction.BeginEdit, (IList) new object[2]
            {
                (object)this.row,
                (object)this.column
            }));
        }
        protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
        {
            base.OnCollectionChanged(args);
            if (this.Suspended)
            {
                return;
            }
            GridViewEventInfo eventInfo = new GridViewEventInfo(KnownEvents.CollectionChanged, GridEventType.Both, GridEventDispatchMode.Send);

            GridViewSynchronizationService.DispatchEvent(this.owner, new GridViewEvent((object)this, (object)null, new object[1]
            {
                (object)args
            }, eventInfo), false);
            this.owner.EventDispatcher.RaiseEvent <GridViewCollectionChangedEventArgs>(EventDispatcher.GroupByChanged, (object)this.owner, new GridViewCollectionChangedEventArgs(this.owner, args));
        }
        private bool IsGridViewEventToRemove(GridViewEvent gridEvent)
        {
            if (GridViewSynchronizationService.IsTemplatePropertyChangingEvent(gridEvent))
            {
                return((gridEvent.Arguments[0] as PropertyChangingEventArgsEx).PropertyName == "DataSource");
            }
            if (gridEvent.Info.Id != KnownEvents.ViewChanged)
            {
                return(false);
            }
            DataViewChangedEventArgs changedEventArgs = gridEvent.Arguments[0] as DataViewChangedEventArgs;
            int action = (int)changedEventArgs.Action;

            return(changedEventArgs.Action == ViewChangedAction.Reset);
        }
        protected virtual void DispatchEvent(
            KnownEvents id,
            GridEventType type,
            GridEventDispatchMode dispatchMode,
            object originator,
            object[] arguments)
        {
            if (this.ViewTemplate == null)
            {
                return;
            }
            GridViewEventInfo eventInfo = new GridViewEventInfo(id, type, dispatchMode);

            GridViewSynchronizationService.DispatchEvent(this.ViewTemplate, new GridViewEvent((object)this, originator, arguments, eventInfo), false);
        }
        private bool OnIsCurrentPropertyChanging(PropertyChangingEventArgsEx args)
        {
            if (GridViewSynchronizationService.IsEventSuspended(this.ViewTemplate, KnownEvents.CurrentChanged))
            {
                return(false);
            }
            bool newValue = (bool)args.NewValue;

            if (newValue && !this.CanBeCurrent)
            {
                return(true);
            }
            GridViewRowInfo row    = newValue ? this : (GridViewRowInfo)null;
            GridViewColumn  column = this.ViewTemplate.CurrentColumn ?? MasterGridViewTemplate.GetColumnAllowingForCurrent(this.ViewTemplate);

            GridViewSynchronizationService.RaiseCurrentChanged(this.ViewTemplate, row, column, true);
            return(this.ViewTemplate.MasterTemplate.CurrentRow != row);
        }
Exemple #9
0
        public GridViewEventResult ProcessEvent(GridViewEvent eventData)
        {
            bool flag1 = GridViewSynchronizationService.IsTemplatePropertyChangedEvent(eventData) && (eventData.Arguments[0] as PropertyChangedEventArgs).PropertyName == "EnableGrouping";
            bool flag2 = GridViewSynchronizationService.IsTemplatePropertyChangedEvent(eventData) && (eventData.Arguments[0] as PropertyChangedEventArgs).PropertyName == "AllowDragToGroup";

            if (flag1 || GridViewSynchronizationService.IsColumnsCollectionChangedEvent(eventData))
            {
                this.UpdateVisibility();
            }
            else if (GridViewSynchronizationService.IsGroupCollectionChangedEvent(eventData) || eventData.Info.Id == KnownEvents.ViewChanged && (eventData.Arguments[0] as DataViewChangedEventArgs).Action == ViewChangedAction.Reset)
            {
                this.UpdateView();
            }
            else if (flag2 || eventData.Info.Id == KnownEvents.LocalizationProviderChanged)
            {
                this.UpdateView();
            }
            return((GridViewEventResult)null);
        }
 GridViewEventResult IGridViewEventListener.ProcessEvent(
     GridViewEvent eventData)
 {
     if (GridViewSynchronizationService.IsTemplatePropertyChangingEvent(eventData))
     {
         return(this.ProcessTemplatePropertyChanging(eventData));
     }
     if (eventData.Sender != this.template)
     {
         return((GridViewEventResult)null);
     }
     if (GridViewSynchronizationService.IsTemplatePropertyChangedEvent(eventData))
     {
         return(this.ProcessTemplatePropertyChangedEvent(eventData));
     }
     if (eventData.Info.Id == KnownEvents.ViewChanged)
     {
         return(this.ProcessViewChangedEvent(eventData));
     }
     return((GridViewEventResult)null);
 }
Exemple #11
0
        protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
        {
            base.OnCollectionChanged(args);
            if (this.Suspended || this.owner == null)
            {
                return;
            }
            this.ApplyFilter();
            GridViewEventInfo eventInfo = new GridViewEventInfo(KnownEvents.CollectionChanged, GridEventType.Both, GridEventDispatchMode.Send);

            GridViewSynchronizationService.DispatchEvent(this.owner, new GridViewEvent((object)this, (object)null, new object[1]
            {
                (object)args
            }, eventInfo), false);
            this.owner.EventDispatcher.RaiseEvent <GridViewCollectionChangedEventArgs>(EventDispatcher.FilterChangedEvent, (object)this.owner, new GridViewCollectionChangedEventArgs(this.owner, args));
            if (!this.owner.IsSelfReference || !this.owner.EnableHierarchyFiltering)
            {
                return;
            }
            this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.GroupingChanged));
        }
        public static void DispatchEvent(
            GridViewTemplate template,
            GridViewEvent eventData,
            bool postUI)
        {
            if (template == null)
            {
                throw new ArgumentNullException("Template");
            }
            MasterGridViewTemplate masterTemplate = template.MasterTemplate;

            if (masterTemplate == null)
            {
                return;
            }
            GridViewSynchronizationService synchronizationService = masterTemplate.SynchronizationService;

            if (synchronizationService == null)
            {
                return;
            }
            if (eventData.Info.Type == GridEventType.Both && postUI)
            {
                KnownEvents       id         = eventData.Info.Id;
                bool              critical   = eventData.Info.Critical;
                object[]          arguments  = eventData.Arguments;
                object            sender     = eventData.Sender;
                object            originator = eventData.Originator;
                GridViewEventInfo eventInfo1 = new GridViewEventInfo(id, GridEventType.Data, GridEventDispatchMode.Send, critical);
                GridViewEvent     gridEvent1 = new GridViewEvent(sender, originator, arguments, eventInfo1);
                GridViewEventInfo eventInfo2 = new GridViewEventInfo(id, GridEventType.UI, GridEventDispatchMode.Post, critical);
                GridViewEvent     gridEvent2 = new GridViewEvent(sender, originator, arguments, eventInfo2);
                synchronizationService.DispatchEvent(gridEvent1);
                synchronizationService.DispatchEvent(gridEvent2);
            }
            else
            {
                synchronizationService.DispatchEvent(eventData);
            }
        }
Exemple #13
0
        public bool AnalyzeQueue(List <GridViewEvent> events)
        {
            bool          flag1          = false;
            GridViewEvent gridViewEvent1 = (GridViewEvent)null;

            for (int index = events.Count - 1; index >= 0; --index)
            {
                GridViewEvent gridViewEvent2 = events[index];
                bool          flag2          = GridViewSynchronizationService.IsGroupCollectionChangedEvent(gridViewEvent2);
                if (flag2)
                {
                    if (gridViewEvent1 == null || gridViewEvent1 == gridViewEvent2)
                    {
                        gridViewEvent1 = gridViewEvent2;
                    }
                    else if (flag2)
                    {
                        events.Remove(gridViewEvent2);
                        flag1 = true;
                    }
                }
            }
            return(flag1);
        }
Exemple #14
0
        private void ListSource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                this.AttachRows(e.NewItems);
                if (!this.suspendNotifications)
                {
                    if (this.Count <= 1)
                    {
                        this.owner.DataView.EnsureDescriptors();
                    }
                    this.UpdateChildRowViewInfo((GridViewRowInfo)e.NewItems[0]);
                    if (((GridViewRowInfo)e.NewItems[0]).Parent is MasterGridViewTemplate)
                    {
                        ++((GridViewRowInfo)e.NewItems[0]).ViewInfo.Version;
                    }
                    this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.Add, e.NewItems));
                    if (this.owner.SelectLastAddedRow && e.NewItems.Count > 0)
                    {
                        GridViewSynchronizationService.RaiseCurrentChanged(this.owner, this.owner.DataView.CurrentItem, this.owner.CurrentColumn, this.owner.DataView == null);
                        if (!this.addingThroughUI)
                        {
                            if (this.prevSelectedRow != null)
                            {
                                GridViewSynchronizationService.SuspendEvent(this.owner, KnownEvents.CurrentChanged);
                                this.prevSelectedRow.IsCurrent  = false;
                                this.prevSelectedRow.IsSelected = false;
                                GridViewSynchronizationService.ResumeEvent(this.owner, KnownEvents.CurrentChanged);
                            }
                            GridViewRowInfo newItem = (GridViewRowInfo)e.NewItems[0];
                            newItem.IsCurrent    = true;
                            newItem.IsSelected   = true;
                            this.prevSelectedRow = newItem;
                            newItem.EnsureVisible();
                        }
                    }
                    if (this.owner.IsSelfReference)
                    {
                        this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.SortingChanged));
                    }
                }
            }
            GridViewInfo    gridViewInfo    = (GridViewInfo)null;
            GridViewRowInfo gridViewRowInfo = (GridViewRowInfo)null;
            bool            flag1           = false;

            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                GridViewRowInfo newItem = e.NewItems[0] as GridViewRowInfo;
                flag1 = newItem.IsPinned;
                if (newItem != null && newItem.ViewTemplate != null && newItem.ViewTemplate.HierarchyDataProvider != null)
                {
                    int val1 = this.owner.MasterTemplate.Owner.TableElement.RowScroller.Scrollbar.Value;
                    newItem.ViewTemplate.HierarchyDataProvider.Refresh();
                    newItem.ViewTemplate.Refresh();
                    RadScrollBarElement scrollbar = this.owner.MasterTemplate.Owner.TableElement.RowScroller.Scrollbar;
                    scrollbar.Value = Math.Min(val1, scrollbar.Maximum - scrollbar.LargeChange + 1);
                }
                if (newItem != null && newItem.IsCurrent && (this.owner.Parent != null && !this.suspendNotifications))
                {
                    gridViewInfo    = newItem.ViewInfo;
                    gridViewRowInfo = GridViewRowCollection.NavigateAfterRemove(newItem, (List <GridViewRowInfo>)null);
                }
                if (!this.suspendNotifications)
                {
                    this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.Remove, e.NewItems));
                }
            }
            this.OnCollectionChanged(e);
            if (gridViewInfo != null)
            {
                GridViewRelationDataProvider hierarchyDataProvider = gridViewInfo.ViewTemplate.HierarchyDataProvider as GridViewRelationDataProvider;
                if (hierarchyDataProvider != null && this.owner.MasterTemplate.SynchronizationService.IsDispatchSuspended)
                {
                    hierarchyDataProvider.Refresh();
                }
                gridViewInfo.Refresh();
            }
            GridViewCollectionChangedEventArgs args = new GridViewCollectionChangedEventArgs(this.owner, e.Action, e.NewItems, e.OldItems, e.NewStartingIndex, e.OldStartingIndex, e.PropertyName);
            bool flag2 = true;

            if (e.Action == NotifyCollectionChangedAction.ItemChanging || e.Action == NotifyCollectionChangedAction.ItemChanged)
            {
                flag2 = !this.owner.ListSource.IsDataBound || e.Action == NotifyCollectionChangedAction.ItemChanged && !string.IsNullOrEmpty(e.PropertyName);
            }
            if (flag2)
            {
                this.owner.EventDispatcher.RaiseEvent <GridViewCollectionChangedEventArgs>(EventDispatcher.RowsChanged, (object)this, args);
                this.UpdateHierarchyView(e.NewItems, e.PropertyName);
            }
            if (flag1)
            {
                this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.Remove), GridEventType.UI);
            }
            if (gridViewInfo == null || this.owner.MasterTemplate == null)
            {
                return;
            }
            if (this.owner.MasterTemplate.SynchronizationService.IsDispatchSuspended)
            {
                if (gridViewRowInfo == null)
                {
                    return;
                }
                this.owner.MasterTemplate.CurrentRowToSetOnEndUpdate = gridViewRowInfo;
            }
            else
            {
                if (!flag1)
                {
                    this.DispatchDataViewChangedEvent(new DataViewChangedEventArgs(ViewChangedAction.Remove), GridEventType.UI);
                }
                if (gridViewRowInfo == null)
                {
                    return;
                }
                this.owner.MasterTemplate.CurrentRow = gridViewRowInfo;
            }
        }
Exemple #15
0
        public GridViewRowInfo EndAddNewRow()
        {
            if (!this.newRowInitialized || !this.IsModified)
            {
                return((GridViewRowInfo)null);
            }
            GridViewCollectionChangingEventArgs args1 = new GridViewCollectionChangingEventArgs(this.ViewTemplate, Telerik.WinControls.Data.NotifyCollectionChangedAction.Add, (object)null, this.ViewTemplate.Rows.Count, -1);

            this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.RowsChanging, (object)this.ViewTemplate, args1);
            if (args1.Cancel)
            {
                return((GridViewRowInfo)null);
            }
            GridViewRowCancelEventArgs args2 = new GridViewRowCancelEventArgs(new GridViewRowInfo[1]
            {
                (GridViewRowInfo)this
            });

            this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewRowCancelEventArgs>(EventDispatcher.UserAddingRow, (object)this.ViewTemplate, args2);
            if (args2.Cancel)
            {
                return((GridViewRowInfo)null);
            }
            if (this.ViewTemplate.IsVirtualRows)
            {
                GridViewObjectRelationalDataProvider hierarchyDataProvider = this.ViewTemplate.HierarchyDataProvider as GridViewObjectRelationalDataProvider;
                GridViewRowInfo rowInfo = (GridViewRowInfo)this;
                if (hierarchyDataProvider != null && this.ViewTemplate.AutoUpdateObjectRelationalSource)
                {
                    rowInfo = hierarchyDataProvider.AddNewRow(this) ?? (GridViewRowInfo)this;
                    this.ViewInfo.Refresh();
                    if (rowInfo != this)
                    {
                        if (!this.deferUserAddedRow)
                        {
                            GridViewRowEventArgs args3 = new GridViewRowEventArgs(rowInfo);
                            this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewRowEventArgs>(EventDispatcher.UserAddedRow, (object)this.ViewTemplate, args3);
                        }
                        else
                        {
                            this.addedRow          = rowInfo;
                            this.deferUserAddedRow = false;
                        }
                        if (this.moveToLastRow)
                        {
                            rowInfo.IsCurrent  = true;
                            this.moveToLastRow = false;
                        }
                        else
                        {
                            this.ViewTemplate.MasterTemplate.CurrentRow = (GridViewRowInfo)this.ViewInfo.TableAddNewRow;
                        }
                    }
                }
                else
                {
                    GridViewRowEventArgs args3 = new GridViewRowEventArgs((GridViewRowInfo)this);
                    this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewRowEventArgs>(EventDispatcher.UserAddedRow, (object)this.ViewTemplate, args3);
                }
                GridViewSynchronizationService.DispatchEvent(this.ViewTemplate, new GridViewEvent((object)this.ViewTemplate, (object)this.ViewTemplate, new object[1]
                {
                    (object)new DataViewChangedEventArgs(ViewChangedAction.Add, (object)this)
                }, new GridViewEventInfo(KnownEvents.ViewChanged, GridEventType.Both, GridEventDispatchMode.Send)), false);
                return(rowInfo);
            }
            int             count    = this.ViewTemplate.ListSource.Count;
            GridViewRowInfo rowInfo1 = this.boundRow;

            try
            {
                this.ViewTemplate.Rows.addingThroughUI = true;
                this.ViewTemplate.BeginUpdate();
                IEditableObject editableObject = rowInfo1 != null ? rowInfo1.DataBoundItem as IEditableObject : (IEditableObject)null;
                if (rowInfo1 == null)
                {
                    rowInfo1       = this.ViewTemplate.ListSource.AddNew();
                    editableObject = rowInfo1.DataBoundItem as IEditableObject;
                    editableObject?.BeginEdit();
                }
                else
                {
                    this.boundRow.IsVisible = true;
                }
                rowInfo1.AddingNewDataRow = true;
                bool flag = false;
                for (int index = 0; index < this.ViewTemplate.Columns.Count; ++index)
                {
                    GridViewColumn column = (GridViewColumn)this.ViewTemplate.Columns[index];
                    object         obj    = this[column];
                    if (obj == null)
                    {
                        GridViewCheckBoxColumn viewCheckBoxColumn = column as GridViewCheckBoxColumn;
                        if (viewCheckBoxColumn != null && viewCheckBoxColumn.DataType.IsValueType)
                        {
                            object instance = Activator.CreateInstance(viewCheckBoxColumn.DataType);
                            rowInfo1[column] = instance;
                        }
                    }
                    else if (this.changedColumns.Contains((object)column))
                    {
                        flag             = true;
                        rowInfo1[column] = obj;
                    }
                }
                if (flag)
                {
                    editableObject?.EndEdit();
                    this.ViewTemplate.EndUpdate(false);
                    GridViewSynchronizationService.SuspendEvent(this.ViewTemplate, KnownEvents.CurrentChanged);
                    ((ICancelAddNew)this.ViewTemplate.ListSource).EndNew(this.ViewTemplate.ListSource.Count - 1);
                    GridViewSynchronizationService.ResumeEvent(this.ViewTemplate, KnownEvents.CurrentChanged);
                    if (!this.deferUserAddedRow)
                    {
                        GridViewRowEventArgs args3 = new GridViewRowEventArgs(rowInfo1);
                        this.ViewTemplate.EventDispatcher.RaiseEvent <GridViewRowEventArgs>(EventDispatcher.UserAddedRow, (object)this.ViewTemplate, args3);
                        this.addedRow = (GridViewRowInfo)null;
                    }
                    else
                    {
                        this.addedRow = rowInfo1;
                    }
                    this.deferUserAddedRow = false;
                    if (this.moveToLastRow)
                    {
                        rowInfo1.IsCurrent = true;
                        this.moveToLastRow = false;
                    }
                    else
                    {
                        this.ViewTemplate.MasterTemplate.CurrentRow = (GridViewRowInfo)this.ViewInfo.TableAddNewRow;
                    }
                }
                else
                {
                    if (this.boundRow != null || this.ViewTemplate.ListSource.Count > count)
                    {
                        ((ICancelAddNew)this.ViewTemplate.ListSource).CancelNew(this.ViewTemplate.ListSource.Count - 1);
                    }
                    this.ViewTemplate.EndUpdate(false);
                }
            }
            catch (Exception ex)
            {
                if (this.boundRow != null || this.ViewTemplate.ListSource.Count > count)
                {
                    ((ICancelAddNew)this.ViewTemplate.ListSource).CancelNew(this.ViewTemplate.ListSource.Count - 1);
                }
                this.ViewTemplate.EndUpdate(false);
                this.ViewTemplate.SetError(new GridViewCellCancelEventArgs((GridCellElement)null, (IInputEditor)null), ex);
                return((GridViewRowInfo)null);
            }
            finally
            {
                this.boundRow          = (GridViewRowInfo)null;
                this.newRowInitialized = false;
                this.IsModified        = false;
                this.ClearCache();
                this.changedColumns.Clear();
                this.InvalidateRow();
                this.ViewTemplate.Rows.addingThroughUI = false;
                if (this.ViewTemplate != null && this.ViewTemplate.ListSource != null)
                {
                    this.ViewTemplate.ListSource.CreateATransactionForEveryValueSetting = true;
                }
                if (rowInfo1 != null)
                {
                    rowInfo1.AddingNewDataRow = false;
                }
                if (this.ViewInfo.ParentRow != null && this.ViewInfo.SummaryRows.Count > 0)
                {
                    ++this.ViewInfo.summaryValueVersion;
                    this.ViewTemplate.MasterTemplate.SynchronizationService.DispatchEvent(new GridViewEvent((object)this.ViewTemplate, (object)this, new object[1]
                    {
                        (object)new DataViewChangedEventArgs(ViewChangedAction.DataChanged, (IList)null)
                    }, new GridViewEventInfo(KnownEvents.ViewChanged, GridEventType.Both, GridEventDispatchMode.Send)));
                }
            }
            return(rowInfo1);
        }