Exemplo n.º 1
0
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            PointF point = new PointF(e.X / _zoom, e.Y / _zoom);

            if (Cursor == Cursors.VSplit)
            {
                Graphics graphics = Graphics.FromHwnd(this.Handle);
                InitGraphics(graphics);
                _resizeColumnCommand = new ResizeColumnCommand(Program.Document, (Column)_glyph);
                _resizeColumnCommand.Resize(_glyph.GetFillWidth(graphics));
                Program.Document.Add(_resizeColumnCommand);
                _resizeColumnCommand = null;
                _control.Refresh( );
            }
            else
            {
                _glyph = Find(point);
                if (_glyph is Cell && (_glyph as Cell).IsEdit || (_glyph is Row && (_glyph as Row).IsEditName))
                {
                    _timer.Stop( );
                    Capture = false;
                    ShowEdit(_glyph);
                }
            }
            base.OnMouseDoubleClick(e);
        }
Exemplo n.º 2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            PointF point = new PointF(e.X / _zoom, e.Y / _zoom);

            if (state == eState.None)
            {
                if (_isHeader && (_glyph = header.GetSplitter(point, _zoom)) != null)
                {
                    Cursor = Cursors.VSplit;
                }
                else
                {
                    _glyph = Find(point);
                    if (_glyph is Column && _glyph.StateGlyph != eStateGlyph.Select)
                    {
                        Cursor = cursorSelectColumn;
                    }
                    else if (_glyph is Row)
                    {
                        if (_glyph.StateGlyph == eStateGlyph.Select)
                        {
                            if ((_glyph as Row).IsMove)
                            {
                                Cursor = cursorMoveRow;
                            }
                            else
                            {
                                Cursor = Cursors.Arrow;
                            }
                        }
                        else
                        {
                            Cursor = cursorSelectRow;
                        }
                    }
                    else
                    {
                        Cursor = Cursors.Arrow;
                    }
                    if (_glyph is Cell)
                    {
                        if (_glyphToolTip != _glyph)
                        {
                            _toolTip.RemoveAll( );
                            _toolTip.SetToolTip(this, _glyph.ToolTip);
                        }
                        _glyphToolTip = _glyph;
                    }
                    else
                    {
                        _toolTip.SetToolTip(this, null);
                    }
                }
            }
            else if (state == eState.ResizeColumn)
            {
                _resizeColumnCommand.Resize((int)(point.X - ((RectangleF)_glyphHash[_glyph]).Left));
                _control.Refresh();
            }
            else if (state == eState.MoveRow)
            {
                int index = (int)((_indexRow + 1) + (point.Y - (_isHeader ? header.Size.Height : 0)) / heightRow);
                if (index < IndexRow)
                {
                    index = IndexRow;
                }
                if (index > IndexRow + _showRow - 1)
                {
                    index = IndexRow + _showRow - 1;
                }
                Row rowMove = null;
                foreach (Row row in _control.Rows)
                {
                    if (!row.IsVisible)
                    {
                        continue;
                    }
                    if (index == 0)
                    {
                        rowMove = row;
                        break;
                    }
                    index--;
                }

                if (rowMove != null && rowMove.IsMove && rowMove != glyphSelect && glyphSelect is Row &&
                    rowMove.ObjectCollection.TypeCollection == (glyphSelect as Row).ObjectCollection.TypeCollection)
                {
                    _moveRowCommand.MoveTo(rowMove);
                    _control.Refresh();
                }
            }
        }