コード例 #1
0
        public bool ChooseCellValue(CellValueEvaluator evaluator,
                                    CellValueChooser chooser, string text)
        {
            if (chooser == null || !grid.EditedCell.IsValid)
            {
                return(false);
            }

            chooser(evaluator(grid.EditedCell.Row, text) ? string.Empty : text);
            return(true);
        }
コード例 #2
0
 private void ContinueEditingIfValid(CellKeyPressEventArgs args, CellValueEvaluator evaluator,
                                     CellValueChooser chooser, string filter, CellValueContiueEdit contiueEdit)
 {
     if (evaluator(grid.EditedCell.Row, args.Entry.Text))
     {
         contiueEdit(grid.EditedCell.Row, args.GdkKey);
     }
     else if (chooser != null)
     {
         chooser(filter);
     }
 }
コード例 #3
0
        public bool ColumnKeyPress(CellKeyPressEventArgs args, int colIndex, CellValueChooser chooser,
                                   CellValueEvaluator evaluator, CellValueContiueEdit editPrev, CellValueContiueEdit editNext)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            string filter = args.Editing ? args.Entry.Text : string.Empty;

            if (KeyShortcuts.Equal(args.EventKey, KeyShortcuts.ChooseKey))
            {
                args.MarkAsHandled();
                return(ChooseCellValue(evaluator, chooser, filter));
            }

            switch (args.GdkKey)
            {
            case Key.Tab:
            case Key.Return:
            case Key.KP_Enter:
                if (args.Editing)
                {
                    ContinueEditingIfValid(args, evaluator, chooser, filter, editNext);
                }
                break;

            case Key.Right:
                if (args.Editing)
                {
                    // If the cursor is at the end of the text
                    if (args.Entry.CursorPosition == args.Entry.Text.Length)
                    {
                        ContinueEditingIfValid(args, evaluator, chooser, filter, editNext);
                    }
                }
                break;

            case Key.Left:
            case Key.ISO_Left_Tab:
                if (args.Editing)
                {
                    // If the cursor is at the end of the text
                    if (args.Entry.CursorPosition == args.Entry.Text.Length ||
                        args.Entry.CursorPosition == 0 ||
                        args.GdkKey == Key.ISO_Left_Tab)
                    {
                        ContinueEditingIfValid(args, evaluator, chooser, filter, editPrev);
                    }
                }
                break;

            case Key.Up:
            case Key.KP_Up:
                if (args.Editing)
                {
                    evaluator(grid.EditedCell.Row, args.Entry.Text);
                    cellUpEditor(colIndex);
                }
                break;

            case Key.Down:
            case Key.KP_Down:
                if (args.Editing)
                {
                    evaluator(grid.EditedCell.Row, args.Entry.Text);
                    cellDownEditor(colIndex);
                }
                break;

            case Key.BackSpace:
                if (args.Editing)
                {
                    if (args.Entry.Text.Length == 0)
                    {
                        evaluator(grid.EditedCell.Row, args.Entry.Text);
                        editPrev(grid.EditedCell.Row, args.GdkKey);
                    }
                }
                break;

            default:
                return(false);
            }

            return(true);
        }