Example #1
0
        protected virtual void grid_MouseDown(GridVirtual sender, MouseEventArgs e)
        {
            if (sender.Selection.BorderRange.IsEmpty() == false)
            {
                Position mousePos = sender.PositionAtPoint(new System.Drawing.Point(e.X, e.Y));

                if (mousePos.IsEmpty() == false)
                {
                    int distance;
                    DevAge.Drawing.RectanglePartType partType = sender.Selection.Border.PointToPartType(sender.Selection.GetDrawingRectangle(),
                                                                                                        new System.Drawing.Point(e.X, e.Y), out distance);
                    if (partType == DevAge.Drawing.RectanglePartType.BottomBorder ||
                        partType == DevAge.Drawing.RectanglePartType.TopBorder ||
                        partType == DevAge.Drawing.RectanglePartType.RightBorder ||
                        partType == DevAge.Drawing.RectanglePartType.LeftBorder)
                    {
                        RangeData data = new RangeData();
                        data.LoadData(sender, sender.Selection.BorderRange, mousePos, mCutMode);
                        if (mCutMode == CutMode.None)
                        {
                            sender.DoDragDrop(data, DragDropEffects.Copy);
                        }
                        else
                        {
                            sender.DoDragDrop(data, DragDropEffects.Move);
                        }
                    }
                }
            }
        }
Example #2
0
        public override void OnMouseUp(CellContext sender, MouseEventArgs e)
        {
            base.OnMouseUp(sender, e);

            //Note: I can't use the click event because I don't have Button information (Control.MouseButtons returns always None inside the Click event)

            Point     currentPoint = sender.Grid.PointToClient(System.Windows.Forms.Control.MousePosition);
            Rectangle cellRect     = sender.Grid.PositionToRectangle(sender.Position);
            float     distance;

            DevAge.Drawing.RectanglePartType partType = LogicalBorder.GetPointPartType(cellRect, currentPoint, out distance);

            //eseguo il sort solo se non sono attualmente in resize
            if (IsSortEnable(sender) &&
                partType == DevAge.Drawing.RectanglePartType.ContentArea &&
                e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                Models.ISortableHeader sortHeader = (Models.ISortableHeader)sender.Cell.Model.FindModel(typeof(Models.ISortableHeader));
                Models.SortStatus      l_Status   = sortHeader.GetSortStatus(sender);
                if (l_Status.Style == DevAge.Drawing.HeaderSortStyle.Ascending)
                {
                    SortColumn(sender, false, l_Status.Comparer);
                }
                else
                {
                    SortColumn(sender, true, l_Status.Comparer);
                }
            }
        }
Example #3
0
        public override void OnMouseDown(CellContext sender, MouseEventArgs e)
        {
            base.OnMouseDown(sender, e);

            // AlanP: Dec 2013.  Added code to set the value of m_MouseDownStartedWidthResize
            m_IsHeightResize = false;
            m_IsWidthResize  = false;
            m_MouseDownStartedWidthResize = false;

            Rectangle l_CellRect = sender.Grid.PositionToRectangle(sender.Position);
            Point     mousePoint = new Point(e.X, e.Y);

            DevAge.Drawing.RectanglePartType partType = LogicalBorder.GetPointPartType(l_CellRect, mousePoint, out mDistanceFromBorder);

            if (((ResizeMode & CellResizeMode.Width) == CellResizeMode.Width) &&
                partType == DevAge.Drawing.RectanglePartType.RightBorder)
            {
                m_IsWidthResize = true;
                m_MouseDownStartedWidthResize = true;
            }
            else if (((ResizeMode & CellResizeMode.Height) == CellResizeMode.Height) &&
                     partType == DevAge.Drawing.RectanglePartType.BottomBorder)
            {
                m_IsHeightResize = true;
            }
        }
Example #4
0
        protected virtual void grid_MouseDown(GridVirtual sender, System.Windows.Forms.MouseEventArgs e)
        {
            //verifico che l'eventuale edit sia terminato altrimenti esco
            if (sender.Selection.ActivePosition.IsEmpty() == false)
            {
                //Se la cella coincide esco
                if (sender.MouseDownPosition == sender.Selection.ActivePosition)
                {
                    return;
                }

                //Altrimenti provo a terminare l'edit
                CellContext focusCell = new CellContext(sender, sender.Selection.ActivePosition);
                if (focusCell.Cell != null && focusCell.IsEditing())
                {
                    if (focusCell.EndEdit(false) == false)
                    {
                        return;
                    }
                }
            }

            //scateno eventi di MouseDown e seleziono la cella
            if (sender.MouseDownPosition.IsEmpty() == false)
            {
                Cells.ICellVirtual cellMouseDown = sender.GetCell(sender.MouseDownPosition);
                if (cellMouseDown != null)
                {
                    int distance;
                    DevAge.Drawing.RectanglePartType partType = sender.Selection.Border.PointToPartType(sender.Selection.GetDrawingRectangle(),
                                                                                                        new System.Drawing.Point(e.X, e.Y), out distance);
                    if (partType == DevAge.Drawing.RectanglePartType.ContentArea ||
                        partType == DevAge.Drawing.RectanglePartType.None)
                    {
                        bool l_bShiftPress = ((Control.ModifierKeys & Keys.Shift) == Keys.Shift &&
                                              (sender.SpecialKeys & GridSpecialKeys.Shift) == GridSpecialKeys.Shift);

                        if (l_bShiftPress == false ||
                            sender.Selection.EnableMultiSelection == false ||
                            sender.Selection.ActivePosition.IsEmpty())
                        {
                            //Standard focus on the cell on MouseDown
                            if (sender.Selection.Contains(sender.MouseDownPosition) == false || e.Button == MouseButtons.Left)                             //solo se non รจ stata ancora selezionata
                            {
                                sender.Selection.Focus(sender.MouseDownPosition);
                            }
                        }
                        else                         //gestione speciale caso shift
                        {
                            sender.Selection.Clear();
                            Range rangeToSelect = new Range(sender.Selection.ActivePosition, sender.MouseDownPosition);
                            sender.Selection.Add(rangeToSelect);
                        }
                    }
                }
            }
        }
Example #5
0
        //Non uso questo evento altrimenti non verrebbero applicate le regole di selezione del tasto Shift
//		public override void OnClick(PositionEventArgs e)
//		{
//			base.OnClick (e);
//
//			sender.Grid.Rows[sender.Position.Row].Focus();
//		}

        public override void OnMouseMove(CellContext sender, MouseEventArgs e)
        {
            base.OnMouseMove(sender, e);

            Rectangle l_CellRect   = sender.Grid.PositionToRectangle(sender.Position);
            Point     l_MousePoint = new Point(e.X, e.Y);

            float distance;

            DevAge.Drawing.RectanglePartType partType = LogicalBorder.GetPointPartType(l_CellRect, l_MousePoint, out distance);

            if (partType == DevAge.Drawing.RectanglePartType.ContentArea)
            {
                mSelectionCursor.ApplyCursor(sender, e);
            }
        }
Example #6
0
 protected virtual void grid_MouseMove(GridVirtual sender, MouseEventArgs e)
 {
     if (sender.Selection.BorderRange.IsEmpty() == false)
     {
         int distance;
         DevAge.Drawing.RectanglePartType partType = sender.Selection.Border.PointToPartType(sender.Selection.GetDrawingRectangle(),
                                                                                             new System.Drawing.Point(e.X, e.Y), out distance);
         if (partType == DevAge.Drawing.RectanglePartType.BottomBorder ||
             partType == DevAge.Drawing.RectanglePartType.TopBorder ||
             partType == DevAge.Drawing.RectanglePartType.RightBorder ||
             partType == DevAge.Drawing.RectanglePartType.LeftBorder)
         {
             mDragCursor.ApplyCursor(sender);
         }
         else
         {
             mDragCursor.ResetCursor();
         }
     }
 }
Example #7
0
        public override void OnMouseUp(CellContext sender, MouseEventArgs e)
        {
            base.OnMouseUp(sender, e);

            //Note: I can't use the click event because I don't have Button information (Control.MouseButtons returns always None inside the Click event)

            Point     currentPoint = sender.Grid.PointToClient(System.Windows.Forms.Control.MousePosition);
            Rectangle cellRect     = sender.Grid.PositionToRectangle(sender.Position);
            float     distance;

            DevAge.Drawing.RectanglePartType partType = LogicalBorder.GetPointPartType(cellRect, currentPoint, out distance);

            //eseguo il sort solo se non sono attualmente in resize
            if (IsSortEnable(sender) &&
                partType == DevAge.Drawing.RectanglePartType.ContentArea &&
                e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // AlanP: Dec 2013.  Do not do a sort if the MouseUp is after a coulmnWidthResize
                Resizable resizableHeader = (Resizable)sender.Cell.Controller.FindController(typeof(Resizable));
                if (resizableHeader != null)
                {
                    // If the mouse down initiated a resize of the header on this cell we don't want to do a sort
                    if (resizableHeader.MouseDownStartedWidthResize)
                    {
                        return;
                    }
                }

                Models.ISortableHeader sortHeader = (Models.ISortableHeader)sender.Cell.Model.FindModel(typeof(Models.ISortableHeader));
                Models.SortStatus      l_Status   = sortHeader.GetSortStatus(sender);
                if (l_Status.Style == DevAge.Drawing.HeaderSortStyle.Ascending)
                {
                    SortColumn(sender, false, l_Status.Comparer);
                }
                else
                {
                    SortColumn(sender, true, l_Status.Comparer);
                }
            }
        }
Example #8
0
        public override void OnDoubleClick(CellContext sender, EventArgs e)
        {
            base.OnDoubleClick(sender, e);

            Point     currentPoint = sender.Grid.PointToClient(System.Windows.Forms.Control.MousePosition);
            Rectangle cellRect     = sender.Grid.PositionToRectangle(sender.Position);

            float distance;

            DevAge.Drawing.RectanglePartType partType = LogicalBorder.GetPointPartType(cellRect, currentPoint, out distance);

            if ((ResizeMode & CellResizeMode.Width) == CellResizeMode.Width &&
                partType == DevAge.Drawing.RectanglePartType.RightBorder)
            {
                sender.Grid.Columns.AutoSizeColumn(sender.Position.Column);
            }
            else if ((ResizeMode & CellResizeMode.Height) == CellResizeMode.Height &&
                     partType == DevAge.Drawing.RectanglePartType.BottomBorder)
            {
                sender.Grid.Rows.AutoSizeRow(sender.Position.Row);
            }
        }
Example #9
0
        public override void OnMouseMove(CellContext sender, MouseEventArgs e)
        {
            base.OnMouseMove(sender, e);

            Rectangle cellRect = sender.Grid.PositionToRectangle(sender.Position);

            if (cellRect.IsEmpty)
            {
                return;
            }

            Point mousePoint = new Point(e.X, e.Y);

            float dummy;

            DevAge.Drawing.RectanglePartType partType = LogicalBorder.GetPointPartType(cellRect, mousePoint, out dummy);

            //sono gi?in fase di resizing
            if (sender.Grid.MouseDownPosition == sender.Position)
            {
                if (m_IsWidthResize)
                {
                    int newWidth = mousePoint.X - cellRect.Left;

                    if (newWidth > 0)
                    {
                        SetWidth(sender.Grid, sender.Position, (int)(newWidth + mDistanceFromBorder));
                    }

                    mWidthCursor.ApplyCursor(sender, e);
                    mHeightCursor.ResetCursor(sender, e);
                }
                else if (m_IsHeightResize)
                {
                    int newHeight = mousePoint.Y - cellRect.Top;

                    if (newHeight > 0)
                    {
                        SetHeight(sender.Grid, sender.Position, (int)(newHeight + mDistanceFromBorder));
                    }

                    mHeightCursor.ApplyCursor(sender, e);
                    mWidthCursor.ResetCursor(sender, e);
                }
            }
            else
            {
                if (partType == DevAge.Drawing.RectanglePartType.RightBorder && (ResizeMode & CellResizeMode.Width) == CellResizeMode.Width)
                {
                    mWidthCursor.ApplyCursor(sender, e);
                }
                else if (partType == DevAge.Drawing.RectanglePartType.BottomBorder && (ResizeMode & CellResizeMode.Height) == CellResizeMode.Height)
                {
                    mHeightCursor.ApplyCursor(sender, e);
                }
                else
                {
                    mWidthCursor.ResetCursor(sender, e);
                    mHeightCursor.ResetCursor(sender, e);
                }
            }
        }