Ejemplo n.º 1
0
 public override AccessibleObject GetChild(int index)
 {
     if (this.owner.IsInEditMode && this.owner.CurrentRow == this.row && this.owner.CurrentColumn == this.column)
     {
         BaseGridEditor activeEditor = this.owner.ActiveEditor as BaseGridEditor;
         if (activeEditor != null)
         {
             RadElement           editorElement = activeEditor.EditorElement;
             RadSpinEditorElement editor        = editorElement as RadSpinEditorElement;
             if (editor != null)
             {
                 return((AccessibleObject) new RadGridSpinEditorElementAccessibleObject(this.owner, editor, this, editor.ControlBoundingRectangle.Size, new Point(editor.ControlBoundingRectangle.X, editor.ControlBoundingRectangle.Y), editor.Name));
             }
             RadDropDownListEditorElement listEditorElement = editorElement as RadDropDownListEditorElement;
             if (listEditorElement != null)
             {
                 if (this.dropDownListAccessibleObject != null)
                 {
                     this.dropDownListAccessibleObject.UnwireEvents();
                 }
                 this.dropDownListAccessibleObject = new GridDropDownAccessibilityObject((RadDropDownListElement)listEditorElement, this, listEditorElement.Name);
                 return((AccessibleObject)this.dropDownListAccessibleObject);
             }
         }
     }
     return(base.GetChild(index));
 }
Ejemplo n.º 2
0
 public void Dispose()
 {
     this.gridViewElement.Template.SynchronizationService.RemoveListener((IGridViewEventListener)this);
     this.permanentEditors.Clear();
     foreach (KeyValuePair <Type, IInputEditor> cachedEditor in this.cachedEditors)
     {
         IInputEditor   inputEditor    = cachedEditor.Value;
         BaseGridEditor baseGridEditor = inputEditor as BaseGridEditor;
         (baseGridEditor == null ? inputEditor as IDisposable : (IDisposable)baseGridEditor.EditorElement)?.Dispose();
     }
     this.cachedEditors.Clear();
 }
        protected override void RemoveElement(int position)
        {
            RadGridViewElement gridViewElement = ((RowsContainerElement)this.Parent).TableElement.GridViewElement;
            BaseGridEditor     activeEditor    = gridViewElement.ActiveEditor as BaseGridEditor;

            if (gridViewElement.IsInEditMode && (activeEditor == null || !activeEditor.IsInBeginEditMode))
            {
                GridViewRowInfo        gridViewRowInfo    = ((GridRowElement)this.Children[position]).RowInfo;
                GridViewDetailsRowInfo viewDetailsRowInfo = gridViewRowInfo as GridViewDetailsRowInfo;
                if (viewDetailsRowInfo != null)
                {
                    gridViewRowInfo = (GridViewRowInfo)viewDetailsRowInfo.Owner;
                }
                if (gridViewRowInfo == gridViewElement.CurrentRow || gridViewElement.CurrentRow != null && gridViewElement.CurrentRow.ViewInfo != null && (gridViewElement.CurrentRow.ViewInfo.ParentRow != null && !gridViewElement.CurrentRow.ViewInfo.ParentRow.IsPinned) && gridViewElement.CurrentRow.ViewInfo.ParentRow.ViewInfo == gridViewRowInfo.ViewInfo)
                {
                    gridViewElement.CloseEditor();
                }
            }
            base.RemoveElement(position);
        }
Ejemplo n.º 4
0
        public virtual void AddEditor(IInputEditor editor)
        {
            GridViewEditManager editorManager = this.GridViewElement.EditorManager;

            if (editor != null && this.editor != editor && !editorManager.IsPermanentEditor(editor.GetType()))
            {
                this.editor = editor;
                RadItem editorElement = this.GetEditorElement(this.editor);
                if (editorElement != null && !this.Children.Contains((RadElement)editorElement))
                {
                    int num = (int)editorElement.SetDefaultValueOverride(VisualElement.ForeColorProperty, (object)Color.FromKnownColor(KnownColor.ControlText));
                    this.Children.Add((RadElement)editorElement);
                    BaseGridEditor baseGridEditor = editor as BaseGridEditor;
                    if (baseGridEditor != null && baseGridEditor.ClearCellText)
                    {
                        this.Text = string.Empty;
                    }
                }
            }
            int num1 = (int)this.SetValue(GridDataCellElement.IsInEditModeProperty, (object)true);
        }
Ejemplo n.º 5
0
        public RadItem GetEditorElement(IInputEditor editor)
        {
            RadItem radItem = editor as RadItem;

            if (radItem == null)
            {
                BaseGridEditor baseGridEditor = editor as BaseGridEditor;
                if (baseGridEditor != null)
                {
                    radItem = baseGridEditor.EditorElement as RadItem;
                }
                else
                {
                    BaseInputEditor baseInputEditor = editor as BaseInputEditor;
                    if (baseInputEditor != null)
                    {
                        radItem = baseInputEditor.EditorElement as RadItem;
                    }
                }
            }
            return(radItem);
        }
Ejemplo n.º 6
0
        protected virtual bool EndEditCore(bool validate, bool cancel)
        {
            if (this.endEditCore || !this.IsInEditMode)
            {
                this.RestoreValidationFlag();
                return(false);
            }
            this.endEditCore = true;
            GridCellElement currentCell = this.gridViewElement.CurrentView.CurrentCell;

            if (currentCell == null)
            {
                this.RestoreValidationFlag();
                return(false);
            }
            GridViewDataColumn columnInfo      = currentCell.ColumnInfo as GridViewDataColumn;
            RadItem            activeEditor1   = this.activeEditor as RadItem;
            GridCellElement    gridCellElement = (GridCellElement)null;

            if (activeEditor1 != null)
            {
                gridCellElement = activeEditor1.FindAncestor <GridCellElement>();
            }
            else
            {
                BaseGridEditor activeEditor2 = this.activeEditor as BaseGridEditor;
                if (activeEditor2 != null)
                {
                    gridCellElement = activeEditor2.EditorElement.FindAncestor <GridCellElement>();
                }
            }
            if (gridCellElement != null && gridCellElement.ColumnInfo != null && gridCellElement.ColumnInfo != currentCell.ColumnInfo)
            {
                cancel   = true;
                validate = false;
            }
            object result = this.activeEditor.Value;

            if (columnInfo is GridViewDecimalColumn && !RadDataConverter.Instance.EqualsNullValue(result, (IDataConversionInfoProvider)columnInfo) && (result != null && (object)result.GetType() != (object)columnInfo.DataType))
            {
                RadDataConverter.Instance.TryFormat(result, columnInfo.DataType, (IDataConversionInfoProvider)columnInfo, out result);
            }
            if (object.Equals(result, (object)string.Empty))
            {
                result = (object)null;
            }
            bool   flag1      = this.activeEditor.IsModified && this.editModeInitialized;
            bool   flag2      = true;
            object dataSource = this.GridViewElement.Template.DataSource;

            if (validate)
            {
                GridTableElement tableElement = currentCell.TableElement;
                tableElement.BeginUpdate();
                flag2 = !this.RaiseCellValidatingEvent(currentCell.RowInfo, currentCell.ColumnInfo, result, currentCell.Value);
                tableElement.EndUpdate(false);
            }
            if (!flag2 && !this.CloseEditorWhenValidationFails)
            {
                this.endEditCore = false;
                this.RestoreValidationFlag();
                BaseGridEditor activeEditor2 = this.activeEditor as BaseGridEditor;
                (activeEditor2 != null ? activeEditor2.EditorElement : this.activeEditor as RadElement)?.FindDescendant <RadTextBoxItem>()?.HostedControl.Focus();
                return(flag2);
            }
            if (cancel || !flag2)
            {
                object         obj           = currentCell.Value;
                BaseGridEditor activeEditor2 = this.activeEditor as BaseGridEditor;
                if (activeEditor2 != null)
                {
                    obj = RadDataConverter.Instance.Format(obj, activeEditor2.DataType, (IDataConversionInfoProvider)columnInfo);
                }
                this.activeEditor.Value = obj;
            }
            else if (!flag1 && columnInfo.DataSourceNullValue != null && RadDataConverter.Instance.EqualsNullValue(result, (IDataConversionInfoProvider)columnInfo))
            {
                flag1 = true;
            }
            this.activeEditor.EndEdit();
            if (this.gridViewElement.AutoSizeRows)
            {
                GridViewRowInfo rowInfo = currentCell.RowElement.RowInfo;
                rowInfo.SuspendPropertyNotifications();
                rowInfo.Height = this.oldRowHeight;
                rowInfo.ResumePropertyNotifications();
                this.oldRowHeight = -1;
            }
            if (currentCell != null)
            {
                ((IEditableCell)currentCell).RemoveEditor(this.activeEditor);
                if (!this.isValidating && currentCell.ElementTree != null && currentCell.ElementTree.Control.ContainsFocus)
                {
                    currentCell.GridViewElement.Focus();
                }
            }
            if (currentCell.RowInfo is GridViewNewRowInfo && currentCell.Value == null && result == DBNull.Value)
            {
                flag1 = false;
            }
            int num1 = 0;

            if (currentCell.ViewTemplate != null && currentCell.ViewTemplate.DataSource != null)
            {
                num1 = currentCell.ViewTemplate.DataSource.GetHashCode();
            }
            if (flag1 && !cancel && flag2)
            {
                this.gridViewElement.SuspendLayout(true);
                currentCell.Value = result;
                validate          = currentCell.ViewTemplate != null && (currentCell.ViewTemplate.DataSource != null && num1 == currentCell.ViewTemplate.DataSource.GetHashCode() || currentCell.RowInfo is GridViewNewRowInfo || flag1);
                if (currentCell != null && currentCell.RowInfo != null)
                {
                    currentCell.RowInfo.IsModified = true;
                }
                else
                {
                    this.ActiveEditor = (IInputEditor)null;
                    this.endEditCore  = false;
                    this.RestoreValidationFlag();
                    this.gridViewElement.ResumeLayout(true, true);
                    return(true);
                }
            }
            int num2 = 0;

            if (currentCell.ViewTemplate != null && currentCell.ViewTemplate.DataSource != null)
            {
                num2 = currentCell.ViewTemplate.DataSource.GetHashCode();
            }
            if (validate && num1 == num2)
            {
                this.RaiseCellValidatedEvent(currentCell.RowInfo, currentCell.ColumnInfo, currentCell.MasterTemplate.VirtualMode ? result : currentCell.Value);
            }
            IInputEditor activeEditor3 = this.ActiveEditor;

            this.ActiveEditor = (IInputEditor)null;
            if (currentCell.RowElement != null)
            {
                currentCell.RowElement.UpdateInfo();
            }
            this.endEditCore = false;
            if (flag1 && !cancel && flag2)
            {
                this.gridViewElement.ResumeLayout(true, true);
            }
            if (this.GridViewElement.Template.DataSource != dataSource)
            {
                this.GridViewElement.TableElement.Update(GridUINotifyAction.Reset);
            }
            GridViewCellEventArgs args = new GridViewCellEventArgs(currentCell.RowInfo, currentCell.ColumnInfo, activeEditor3);

            this.gridViewElement.Template.EventDispatcher.RaiseEvent <GridViewCellEventArgs>(EventDispatcher.CellEndEdit, (object)this, args);
            this.RestoreValidationFlag();
            return(true);
        }
Ejemplo n.º 7
0
        public virtual bool BeginEdit()
        {
            GridCellElement currentCell  = this.gridViewElement.CurrentView.CurrentCell;
            IEditableCell   editableCell = currentCell as IEditableCell;

            if (this.IsInEditMode || editableCell == null || (!editableCell.IsEditable || currentCell == null) || (currentCell.RowInfo == null || currentCell.ViewInfo.ChildRows.Count == 0 && currentCell.RowInfo is GridViewDataRowInfo))
            {
                return(false);
            }
            bool flag = this.IsPermanentEditor(currentCell.ColumnInfo.GetDefaultEditorType());

            this.editModeInitialized = false;
            IInputEditor inputEditor1 = flag ? editableCell.Editor : this.GetDefaultEditor((IEditorProvider)currentCell.ColumnInfo);

            if (inputEditor1 == null)
            {
                return(false);
            }
            this.ActiveEditor = inputEditor1;
            GridViewCellCancelEventArgs args = new GridViewCellCancelEventArgs(currentCell, this.activeEditor);

            this.gridViewElement.Template.EventDispatcher.RaiseEvent <GridViewCellCancelEventArgs>(EventDispatcher.CellBeginEdit, (object)this, args);
            if (args.Cancel)
            {
                this.ActiveEditor = (IInputEditor)null;
                return(false);
            }
            this.gridViewElement.CurrentView.EnsureCellVisible(currentCell.RowInfo, currentCell.ColumnInfo);
            this.gridViewElement.UpdateLayout();
            if (this.gridViewElement.CurrentCell == null || this.gridViewElement.CurrentCell.RowInfo == null)
            {
                return(false);
            }
            if (currentCell != this.gridViewElement.CurrentCell || this.ActiveEditor == null)
            {
                currentCell  = (GridCellElement)this.gridViewElement.CurrentCell;
                editableCell = currentCell as IEditableCell;
                IInputEditor inputEditor2 = this.IsPermanentEditor(currentCell.ColumnInfo.GetDefaultEditorType()) ? editableCell.Editor : this.GetDefaultEditor((IEditorProvider)currentCell.ColumnInfo);
                if (inputEditor2 == null)
                {
                    return(false);
                }
                this.ActiveEditor = inputEditor2;
            }
            if (currentCell.RowInfo is GridViewNewRowInfo)
            {
                currentCell.RowInfo.CallOnBeginEdit();
            }
            editableCell.AddEditor(this.activeEditor);
            BaseGridEditor activeEditor = this.ActiveEditor as BaseGridEditor;

            activeEditor?.SetIsInBeginEditMode(true);
            currentCell.UpdateLayout();
            if (this.gridViewElement.AutoSizeRows)
            {
                GridViewRowInfo rowInfo = currentCell.RowInfo;
                this.oldRowHeight = currentCell.RowInfo.Height;
                rowInfo.SuspendPropertyNotifications();
                rowInfo.Height = (int)currentCell.RowElement.DesiredSize.Height;
                rowInfo.ResumePropertyNotifications();
                currentCell.TableElement.ViewElement.UpdateRows();
            }
            this.InitializeEditor(this.activeEditor);
            activeEditor?.SetIsInBeginEditMode(false);
            this.activeEditor.BeginEdit();
            currentCell.RowElement.UpdateInfo();
            this.editModeInitialized = true;
            return(true);
        }