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

            //    if (mousePos.IsEmpty() == false)
            //    {
            //        float distance;
            //        DevAge.Drawing.RectanglePartType partType = sender.Selection.Border.GetPointPartType(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
		protected virtual void grid_MouseDown(GridVirtual sender, MouseEventArgs e)
		{
#warning da fare
            //if (sender.Selection.BorderRange.IsEmpty() == false)
            //{
            //    Position mousePos = sender.PositionAtPoint(new System.Drawing.Point(e.X, e.Y));

            //    if (mousePos.IsEmpty() == false)
            //    {
            //        float distance;
            //        DevAge.Drawing.RectanglePartType partType = sender.Selection.Border.GetPointPartType(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 #3
0
        public virtual System.Drawing.Bitmap Export(GridVirtual grid, Range rangeToExport)
        {
            System.Drawing.Bitmap bitmap = null;

            try
            {
                System.Drawing.Size size = grid.RangeToSize(rangeToExport);

                bitmap = new System.Drawing.Bitmap(size.Width, size.Height);

                using (System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(bitmap))
                {
                    Export(grid, graphic, rangeToExport, new System.Drawing.Point(0, 0));
                }
            }
            catch (Exception)
            {
                if (bitmap != null)
                {
                    bitmap.Dispose();
                    bitmap = null;
                }

                throw;
            }

            return bitmap;
        }
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)
            {
                CellContext focusCell = new CellContext(sender, sender.Selection.ActivePosition);
                if (focusCell.Cell != null && focusCell.IsEditing())
                {
                    if (focusCell.EndEdit(false) == false)
                    {
                        return;
                    }
                }
            }

            //scateno eventi di MouseDown
            Position position = sender.PositionAtPoint(new Point(e.X, e.Y));

            if (position.IsEmpty() == false)
            {
                Cells.ICellVirtual cellMouseDown = sender.GetCell(position);
                if (cellMouseDown != null)
                {
                    sender.ChangeMouseDownCell(position, position);

                    //Cell.OnMouseDown
                    CellContext cellContext = new CellContext(sender, position, cellMouseDown);
                    sender.Controller.OnMouseDown(cellContext, e);
                }
            }
            else
            {
                sender.ChangeMouseDownCell(Position.Empty, Position.Empty);
            }
        }
Example #5
0
        public virtual void Export(GridVirtual grid, System.Drawing.Graphics graphics, 
                                Range rangeToExport, System.Drawing.Point destinationLocation)
        {
            if (rangeToExport.IsEmpty())
                return;

            System.Drawing.Point cellPoint = destinationLocation;

            System.Drawing.Point deltaPoint = destinationLocation;

            using (DevAge.Drawing.GraphicsCache graphicsCache = new DevAge.Drawing.GraphicsCache(graphics))
            {
                for (int r = rangeToExport.Start.Row; r <= rangeToExport.End.Row; r++)
                {
                    int rowHeight = grid.Rows.GetHeight(r);

                    for (int c = rangeToExport.Start.Column; c <= rangeToExport.End.Column; c++)
                    {
                        Rectangle cellRectangle;
                        Position pos = new Position(r, c);

                        Size cellSize = new Size(grid.Columns.GetWidth(c), rowHeight);

                        Range range = grid.PositionToCellRange(pos);

                        //support for RowSpan or ColSpan
                        //Note: for now I draw only the merged cell at the first position
                        // (this can cause a problem if you export partial range that contains a partial merged cells)
                        if ( range.ColumnsCount > 1 || range.RowsCount > 1)
                        {
                            //Is the first position
                            if (range.Start == pos)
                            {
                                Size rangeSize = grid.RangeToSize(range);

                                cellRectangle = new Rectangle(cellPoint,
                                                              rangeSize);
                            }
                            else
                                cellRectangle = Rectangle.Empty;
                        }
                        else
                        {
                            cellRectangle = new Rectangle(cellPoint, cellSize);
                        }

                        if (cellRectangle.IsEmpty == false)
                        {
                            Cells.ICellVirtual cell = grid.GetCell(pos);
                            CellContext context = new CellContext(grid, pos, cell);
                            ExportCell(context, graphicsCache, cellRectangle);
                        }

                        cellPoint = new Point(cellPoint.X + cellSize.Width, cellPoint.Y);
                    }

                    cellPoint = new Point(destinationLocation.X, cellPoint.Y + rowHeight);
                }
            }
        }
Example #6
0
		/// <summary>
		/// Returns the Range struct from the specific instance
		/// </summary>
		/// <param name="p_Grid"></param>
		/// <returns></returns>
		public Range GetRange(GridVirtual p_Grid)
		{
			if (p_Grid.ColumnsCount >= p_Grid.FixedColumns)
				return new Range(0, 0, p_Grid.RowsCount-1, p_Grid.FixedColumns);
			else
				return Range.Empty;
		}
Example #7
0
 protected override void OnDetach(GridVirtual grid)
 {
     grid.MouseDown  -= new GridMouseEventHandler(grid_MouseDown);
     grid.MouseUp    -= new GridMouseEventHandler(grid_MouseUp);
     grid.MouseMove  -= new GridMouseEventHandler(grid_MouseMove);
     grid.MouseLeave -= new GridEventHandler(grid_MouseLeave);
 }
        public override void BindToGrid(GridVirtual p_grid)
        {
            base.BindToGrid(p_grid);

            mDecorator = new Decorators.DecoratorSelection(this);
            Grid.Decorators.Add(mDecorator);
        }
Example #9
0
        /// <summary>
        /// Convert a range and an array of string into a string. Normally using a tab delimited for columns and a LineFeed for rows.
        /// </summary>
        /// <returns></returns>
        protected static string[,] DataToStringArray(GridVirtual sourceGrid, Range range)
        {
            int numberOfRows = range.End.Row - range.Start.Row + 1;
            int numberOfCols = range.End.Column - range.Start.Column + 1;

            string[,] values = new string[numberOfRows, numberOfCols];

            int arrayRow = 0;

            for (int r = range.Start.Row; r <= range.End.Row; r++, arrayRow++)
            {
                int arrayCol = 0;
                for (int c = range.Start.Column; c <= range.End.Column; c++, arrayCol++)
                {
                    String val = String.Empty;

                    Position           posCell     = new Position(r, c);
                    Cells.ICellVirtual cell        = sourceGrid.GetCell(posCell);
                    CellContext        cellContext = new CellContext(sourceGrid, posCell, cell);

                    if (cell != null && cell.Editor != null && cell.Editor.IsStringConversionSupported())
                    {
                        values[arrayRow, arrayCol] = cell.Editor.ValueToString(cell.Model.ValueModel.GetValue(cellContext));
                    }
                    else if (cell != null)
                    {
                        values[arrayRow, arrayCol] = cellContext.DisplayText;
                    }
                }
            }

            return(values);
        }
Example #10
0
		protected override void OnDetach(GridVirtual grid)
		{
			grid.MouseDown -= new GridMouseEventHandler(grid_MouseDown);
			grid.MouseUp -= new GridMouseEventHandler(grid_MouseUp);
			grid.MouseMove -= new GridMouseEventHandler(grid_MouseMove);
			grid.MouseLeave -= new GridEventHandler(grid_MouseLeave);
		}
Example #11
0
        protected virtual void grid_MouseMove(GridVirtual sender, System.Windows.Forms.MouseEventArgs e)
        {
            Position l_PointPosition = sender.PositionAtPoint(new Point(e.X, e.Y));

            Cells.ICellVirtual l_CellPosition = sender.GetCell(l_PointPosition);

            //Call MouseMove on the cell that receive tha MouseDown event
            if (sender.MouseDownPosition.IsEmpty() == false)
            {
                Cells.ICellVirtual l_MouseDownCell = sender.GetCell(sender.MouseDownPosition);
                if (l_MouseDownCell != null)
                {
                    sender.Controller.OnMouseMove(new CellContext(sender, sender.MouseDownPosition, l_MouseDownCell), e);
                }
            }
            else             //se non ho nessuna cella attualmente che ha ricevuto un mousedown, l'evento di MouseMove viene segnalato sulla cella correntemente sotto il Mouse
            {
                // se non c'รจ nessuna cella MouseDown cambio la cella corrente sotto il Mouse
#if !MINI
                sender.ChangeMouseCell(l_PointPosition);                //in ogni caso cambio la cella corrente
#endif
                if (l_PointPosition.IsEmpty() == false && l_CellPosition != null)
                {
                    // I call MouseMove on the current cell only if there aren't any cells under the mouse
                    sender.Controller.OnMouseMove(new CellContext(sender, l_PointPosition, l_CellPosition), e);
                }
            }
        }
Example #12
0
 protected override void OnDetach(GridVirtual grid)
 {
     grid.DragEnter -= new GridDragEventHandler(grid_DragEnter);
     grid.DragLeave -= new GridEventHandler(grid_DragLeave);
     grid.DragDrop  -= new GridDragEventHandler(grid_DragDrop);
     grid.DragOver  -= new GridDragEventHandler(grid_DragOver);
 }
Example #13
0
        public GridSubPanelHidden(GridVirtual gridContainer)
            : base(gridContainer, GridSubPanelType.Hidden)
        {
            SetStyle(ControlStyles.Selectable, true);

            TabStop = true;
        }
Example #14
0
		protected override void OnDetach(GridVirtual grid)
		{
			grid.DragEnter -= new GridDragEventHandler(grid_DragEnter);
			grid.DragLeave -= new GridEventHandler(grid_DragLeave);
			grid.DragDrop -= new GridDragEventHandler(grid_DragDrop);
            grid.DragOver -= new GridDragEventHandler(grid_DragOver);
        }
Example #15
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 #16
0
        public virtual System.Drawing.Bitmap Export(GridVirtual grid, Range rangeToExport)
        {
            System.Drawing.Bitmap bitmap = null;

            try
            {
                System.Drawing.Size size = grid.RangeToSize(rangeToExport);

                bitmap = new System.Drawing.Bitmap(size.Width, size.Height);

                using (System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(bitmap))
                {
                    Export(grid, graphic, rangeToExport, new System.Drawing.Point(0, 0));
                }
            }
            catch (Exception)
            {
                if (bitmap != null)
                {
                    bitmap.Dispose();
                    bitmap = null;
                }

                throw;
            }

            return(bitmap);
        }
        public override void BindToGrid(GridVirtual p_grid)
        {
            base.BindToGrid(p_grid);

            mDecorator = new Decorators.DecoratorSelection(this);
            Grid.Decorators.Add(mDecorator);
        }
        public override void OnMouseDown(CellContext sender, System.Windows.Forms.MouseEventArgs e)
        {
            base.OnMouseDown(sender, e);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            GridVirtual grid = sender.Grid;

            //Check the control and shift key status
            bool controlPress = ((Control.ModifierKeys & Keys.Control) == Keys.Control &&
                                 (grid.SpecialKeys & GridSpecialKeys.Control) == GridSpecialKeys.Control);

            bool shiftPress = ((Control.ModifierKeys & Keys.Shift) == Keys.Shift &&
                               (grid.SpecialKeys & GridSpecialKeys.Shift) == GridSpecialKeys.Shift);

            if (shiftPress == false ||
                grid.Selection.EnableMultiSelection == false)
            {
                //Handle Control key
                bool mantainSelection = grid.Selection.EnableMultiSelection && controlPress;

                grid.Selection.Focus(sender.Position, !mantainSelection);
            }
            else //handle shift key
            {
                grid.Selection.ResetSelection(true);

                Range rangeToSelect = new Range(grid.Selection.ActivePosition, sender.Position);
                grid.Selection.SelectRange(rangeToSelect, true);
            }
        }
Example #19
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)
			{
				CellContext focusCell = new CellContext(sender, sender.Selection.ActivePosition);
				if (focusCell.Cell != null && focusCell.IsEditing())
				{
					if (focusCell.EndEdit(false) == false)
						return;
				}
			}

			//scateno eventi di MouseDown
			Position position = sender.PositionAtPoint( new Point(e.X, e.Y) );
			if (position.IsEmpty() == false)
			{
				Cells.ICellVirtual cellMouseDown = sender.GetCell(position);
				if (cellMouseDown != null)
				{
					sender.ChangeMouseDownCell(position, position);

					//Cell.OnMouseDown
					CellContext cellContext = new CellContext(sender, position, cellMouseDown);
					sender.Controller.OnMouseDown(cellContext, e);
				}
			}
			else
				sender.ChangeMouseDownCell(Position.Empty, Position.Empty);
		}
Example #20
0
		protected override void OnDetach(GridVirtual grid)
		{
			grid.MouseMove -= new GridMouseEventHandler(grid_MouseMove);
			grid.MouseLeave -= new GridEventHandler(grid_MouseLeave);
			grid.MouseDown -= new GridMouseEventHandler(grid_MouseDown);
            grid.GiveFeedback -= new GridGiveFeedbackEventHandler(grid_GiveFeedback);
        }
 protected override void OnDetach(GridVirtual grid)
 {
     grid.MouseMove    -= new GridMouseEventHandler(grid_MouseMove);
     grid.MouseLeave   -= new GridEventHandler(grid_MouseLeave);
     grid.MouseDown    -= new GridMouseEventHandler(grid_MouseDown);
     grid.GiveFeedback -= new GridGiveFeedbackEventHandler(grid_GiveFeedback);
 }
        void grid_GiveFeedback(GridVirtual sender, GiveFeedbackEventArgs e)
        {
            //Just to test GiveFeedback event

            //e.UseDefaultCursors = false;
            //if (e.Effect == DragDropEffects.Move)
            //    Cursor.Current = Cursors.Help;
        }
Example #23
0
 public RangePaintEventArgs(GridVirtual grid,
                            DevAge.Drawing.GraphicsCache graphicsCache,
                            Range drawingRange)
 {
     mGrid          = grid;
     mGraphicsCache = graphicsCache;
     mDrawingRange  = drawingRange;
 }
Example #24
0
        public HighlightedRange(GridVirtual grid)
        {
            mGrid = grid;

            Grid.RangePaint += new RangePaintEventHandler(Grid_RangePaint);

            Region = new RangeRegion();
        }
Example #25
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gridContainer"></param>
        /// <param name="containerType"></param>
        public GridSubPanelBase(GridVirtual gridContainer, GridSubPanelType containerType)
        {
            ContainerType = containerType;
            toolTip       = new System.Windows.Forms.ToolTip();

            ToolTipText     = "";
            m_GridContainer = gridContainer;
        }
Example #26
0
        protected virtual void grid_GiveFeedback(GridVirtual sender, System.Windows.Forms.GiveFeedbackEventArgs e)
        {
            Position dragPosition = sender.DragCellPosition;

            Cells.ICellVirtual cellPosition = sender.GetCell(dragPosition);

            sender.Controller.OnGiveFeedback(new CellContext(sender, dragPosition, cellPosition), e);
        }
Example #27
0
        protected virtual void grid_DragEnter(GridVirtual sender, System.Windows.Forms.DragEventArgs e)
        {
            Position pointPosition = sender.PositionAtPoint(sender.PointToClient(new Point(e.X, e.Y)));

            Cells.ICellVirtual cellPosition = sender.GetCell(pointPosition);

            sender.ChangeDragCell(new CellContext(sender, pointPosition, cellPosition), e);
        }
Example #28
0
        /// <summary>
        /// Remove the link of the cell from the previous grid.
        /// </summary>
        public virtual void UnBindToGrid()
        {
            if (m_Grid != null)           //tolgo la cella dalla griglia precedentemente selezionata
            {
                OnRemoveToGrid(EventArgs.Empty);
            }

            m_Grid = null;
        }
Example #29
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 #30
0
        /// <summary>
        /// Loads the setting.
        /// </summary>
        /// <param name="grid">The parent grid.</param>
        /// <param name="column">The column.</param>
        /// <param name="row">The row.</param>
        /// <param name="mode">The cell size mode.</param>
        public void LoadSetting(GridVirtual grid, int column, int row, CellSizeMode mode)
        {
            this.ownerGrid    = grid;
            this.columnId     = column;
            this.rowId        = row;
            this.cellSizeMode = mode;

            RefreshSetting();
        }
Example #31
0
        /// <summary>
        /// Remove the link of the cell from the previous grid.
        /// </summary>
        public virtual void UnBindToGrid()
        {
            if (this.ownerGrid != null)
            { // remove the cell from the grid previously selected
                OnRemoveToGrid(EventArgs.Empty);
            }

            this.ownerGrid = null;
        }
Example #32
0
		/// <summary>
		/// Add the Control to the specified grid. Consider that a Control can only be a child of one Container.
		/// </summary>
		private void AttachControl(GridVirtual grid)
		{
			mGrid = grid;
			mLinkedControl = new LinkedControlValue(Control, Position.Empty);
			Control.Hide();
			grid.LinkedControls.Add(mLinkedControl);
			Control.Validated += new EventHandler(InnerControl_Validated);
			Control.KeyPress += new KeyPressEventHandler(InnerControl_KeyPress);
		}
Example #33
0
        public void LoadSetting(GridVirtual p_Grid, int p_Col, int p_Row, CellSizeMode p_Mode)
        {
            m_Grid = p_Grid;
            m_Col  = p_Col;
            m_Mode = p_Mode;
            m_Row  = p_Row;

            RefreshSetting();
        }
Example #34
0
        /// <summary>
        /// Load the data from a Tab delimited string of data. Each column is separated by a Tab and each row by a LineFeed character.
        /// </summary>
        public void LoadData(string data)
        {
            mSourceGrid = null;
            StringToData(data, out mSourceRange, out mSourceValues);

            mClipboardDataObject = new System.Windows.Forms.DataObject();
            mClipboardDataObject.SetData(RANGEDATA_FORMAT, this);
            mClipboardDataObject.SetData(typeof(string), StringArrayToString(mSourceValues as string[, ]));
        }
 /// <summary>
 /// Add the Control to the specified grid. Consider that a Control can only be a child of one Container.
 /// </summary>
 private void AttachControl(GridVirtual grid)
 {
     mGrid          = grid;
     mLinkedControl = new LinkedControlValue(Control, Position.Empty);
     Control.Hide();
     grid.LinkedControls.Add(mLinkedControl);
     Control.Validated += new EventHandler(InnerControl_Validated);
     Control.KeyPress  += new KeyPressEventHandler(InnerControl_KeyPress);
 }
Example #36
0
        /// <summary>
        /// Write the current loaded array string in the specified grid range. This method use the cell editor to set the value.
        /// </summary>
        public void WriteData(GridVirtual sourceGrid, Position destinationPosition)
        {
            int sourceRow    = this.SourceValues.GetUpperBound(0);
            int sourceColumn = this.SourceValues.GetUpperBound(1);
            var dataRow      = 0;

            for (int r = destinationPosition.Row; r <= destinationPosition.Row + sourceRow; r++)
            {
                int dataColumn = 0;
                for (int c = destinationPosition.Column; c <= destinationPosition.Column + sourceColumn; c++)
                {
                    Position           posCell     = new Position(r, c);
                    Cells.ICellVirtual cell        = sourceGrid.GetCell(posCell);
                    CellContext        cellContext = new CellContext(sourceGrid, posCell, cell);

                    //[email protected] : WriteData method is changed to support paste activity.
                    if (cell != null && (cell.ClipboardModes & ClipboardMode.Paste) == ClipboardMode.Paste &&
                        cell.Editor != null && mSourceValues[dataRow, dataColumn] != null)
                    {
                        cell.Editor.SetCellValue(cellContext, mSourceValues[dataRow, dataColumn]);
                    }
                    dataColumn++;
                }
                dataRow++;
            }


            /*int sourceRow = this.SourceValues.Length - 1;
             * int sourceColumn = this.SourceValues.Rank - 1;
             * //Calculate the destination Range merging the source range
             * var destinationRange = new Range(destinationPosition,
             *                               new Position(destinationPosition.Row + sourceRow, destinationPosition.Column + sourceColumn));
             * Range newRange = mSourceRange;
             * newRange.MoveTo(destinationRange.Start);
             * if (newRange.End.Column > destinationRange.End.Column)
             *      newRange.End = new Position(newRange.End.Row, destinationRange.End.Column);
             * if (newRange.End.Row > destinationRange.End.Row)
             *      newRange.End.Row = destinationRange.End.Row;
             *
             * for (int r = newRange.Start.Row; r <= newRange.End.Row; r++)
             * {
             *      int dataColumn = 0;
             *      for (int c = newRange.Start.Column; c <= newRange.End.Column ; c++)
             *      {
             *              //if (sourceGrid.Columns.IsColumnVisible(c) == false)
             *              //	continue;
             *              Position posCell = new Position(r, c);
             *              Cells.ICellVirtual cell = sourceGrid.GetCell(posCell);
             *              CellContext cellContext = new CellContext(sourceGrid, posCell, cell);
             *
             *              if (cell != null && cell.Editor != null && mSourceValues[r - newRange.Start.Row, dataColumn] != null)
             *                      cell.Editor.SetCellValue(cellContext, mSourceValues[r - newRange.Start.Row, dataColumn] );
             *              dataColumn++;
             *      }
             * }*/
        }
Example #37
0
        private void SetWidth(GridVirtual grid, Position position, int width)
        {
            Range range       = grid.PositionToCellRange(position);
            int   widthForCol = width / range.ColumnsCount;

            for (int c = range.Start.Column; c <= range.End.Column; c++)
            {
                grid.Columns.SetWidth(c, widthForCol);
            }
        }
Example #38
0
        private void SetHeight(GridVirtual grid, Position position, int height)
        {
            Range range        = grid.PositionToCellRange(position);
            int   heightForCol = height / range.RowsCount;

            for (int r = range.Start.Row; r <= range.End.Row; r++)
            {
                grid.Rows.SetHeight(r, heightForCol);
            }
        }
Example #39
0
        public override void OnMouseDown(CellContext sender, System.Windows.Forms.MouseEventArgs e)
        {
            base.OnMouseDown(sender, e);

            var pressed = e.Button & MouseButtons;

            if (pressed == MouseButtons.None)
            {
                return;
            }

            GridVirtual grid = sender.Grid;

            //Check the control and shift key status
            bool controlPress = ((Control.ModifierKeys & Keys.Control) == Keys.Control &&
                                 (grid.SpecialKeys & GridSpecialKeys.Control) == GridSpecialKeys.Control);

            bool shiftPress = ((Control.ModifierKeys & Keys.Shift) == Keys.Shift &&
                               (grid.SpecialKeys & GridSpecialKeys.Shift) == GridSpecialKeys.Shift);

            //Default click handler
            if (shiftPress == false ||
                grid.Selection.EnableMultiSelection == false)
            {
                //Handle Control key
                bool mantainSelection = grid.Selection.EnableMultiSelection && controlPress;

                //If the cell is already selected and the user has the ctrl key pressed then deselect the cell
                // AlanP: Sep 2013.  Changed the equality test for the active row to be row based rather than actual position
                if (controlPress && grid.Selection.IsSelectedCell(sender.Position) && grid.Selection.ActivePosition.Row != sender.Position.Row)
                {
                    grid.Selection.SelectCell(sender.Position, false);
                }
                else
                {
                    grid.Selection.Focus(sender.Position, !mantainSelection);
                }
            }
            else             //handle shift key
            {
                grid.Selection.ResetSelection(true);

                Range rangeToSelect = new Range(grid.Selection.ActivePosition, sender.Position);
                grid.Selection.SelectRange(rangeToSelect, true);
            }

            // begin scroll tracking only if mouse was clicked
            // in scrollable area
            Rectangle scrollRect = grid.GetScrollableArea();

            if (scrollRect.Contains(e.Location))
            {
                BeginScrollTracking(grid);
            }
        }
Example #40
0
		public GridPrintDocument(GridVirtual grid)
		{
			m_Grid = grid;
			// Default to empty background
			m_CellPrintView.BackColor = Color.Empty;
			m_HeaderCellPrintView.BackColor = Color.Empty;

			m_PageHeaderFont = new Font(grid.Font, FontStyle.Regular);
			m_PageTitleFont = new Font(grid.Font, FontStyle.Bold);
			m_PageFooterFont = new Font(grid.Font, FontStyle.Regular);
		}
Example #41
0
		protected virtual void grid_MouseUp(GridVirtual sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (sender.MouseDownPosition.IsEmpty() == false)
			{
				Cells.ICellVirtual l_MouseDownCell = sender.GetCell(sender.MouseDownPosition);
				if (l_MouseDownCell!=null)
					sender.Controller.OnMouseUp(new CellContext(sender, sender.MouseDownPosition, l_MouseDownCell), e );

				sender.ChangeMouseDownCell(Position.Empty, sender.PositionAtPoint(new Point(e.X, e.Y)));
			}
		}
Example #42
0
		protected virtual void grid_MouseDown(GridVirtual sender, System.Windows.Forms.MouseEventArgs e)
		{
			//Check if the cell is valid
			if (sender.Selection.ActivePosition.IsEmpty() == false)
			{
				//If the cell is still active exit
				if (sender.MouseDownPosition == sender.Selection.ActivePosition)
					return;

				//If the cell is still in editing then exit and stop the multi selection
				CellContext focusCell = new CellContext(sender, sender.Selection.ActivePosition);
				if (focusCell.Cell != null && focusCell.IsEditing())
					return;
			}

#warning Da fare
            ////Select the cell
            //if (sender.MouseDownPosition.IsEmpty() == false)
            //{
            //    Cells.ICellVirtual cellMouseDown = sender.GetCell(sender.MouseDownPosition);
            //    if (cellMouseDown != null)
            //    {
            //        //Only select the cell if click inside or ourside the selection area (if click inside the border is not considered)
            //        float distance;
            //        DevAge.Drawing.RectanglePartType partType = sender.Selection.Border.GetPointPartType(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 //handle shift key
            //            {
            //                sender.Selection.Clear();
            //                Range rangeToSelect = new Range(sender.Selection.ActivePosition, sender.MouseDownPosition);
            //                sender.Selection.Add(rangeToSelect);
            //            }
            //        }
            //    }
            //}
		}
		private void grid_KeyDown(GridVirtual sender, KeyEventArgs e)
		{
			if (e.Handled)
				return;

			if (sender.Selection.IsEmpty())
				return;

			if (e.KeyCode == Keys.Delete)
			{
				sender.ClearValues(sender.Selection.GetSelectionRegion());
				e.Handled = true;
			}
		}
		private void grid_KeyDown(GridVirtual sender, KeyEventArgs e)
		{
			if (e.Handled)
				return;

#warning da fare

            //Range rng = sender.Selection.BorderRange;
            //if (rng.IsEmpty())
            //    return;

            ////Paste
            //if (e.Control && e.KeyCode == Keys.V && PasteEnabled)
            //{
            //    RangeData rngData = RangeData.ClipboardGetData();
			
            //    if (rngData != null)
            //    {
            //        Range destinationRange = rngData.FindDestinationRange(sender, rng.Start);
            //        if (ExpandSelection == false)
            //            destinationRange = destinationRange.Intersect(rng);

            //        rngData.WriteData(sender, destinationRange);
            //        e.Handled = true;
            //        sender.Selection.Clear();
            //        sender.Selection.Add(destinationRange);
            //    }
            //}
            ////Copy
            //else if (e.Control && e.KeyCode == Keys.C && CopyEnabled)
            //{
            //    RangeData data = new RangeData();
            //    data.LoadData(sender, rng, rng.Start, CutMode.None);
            //    RangeData.ClipboardSetData(data);

            //    e.Handled = true;
            //}
            ////Cut
            //else if (e.Control && e.KeyCode == Keys.X && CutEnabled)
            //{
            //    RangeData data = new RangeData();
            //    data.LoadData(sender, rng, rng.Start, CutMode.CutImmediately);
            //    RangeData.ClipboardSetData(data);
				
            //    e.Handled = true;
            //}
		}
Example #45
0
		protected virtual void grid_MouseMove(GridVirtual sender, MouseEventArgs e)
		{
#warning da fare
            //if (sender.Selection.BorderRange.IsEmpty() == false)
            //{
            //    float distance;
            //    DevAge.Drawing.RectanglePartType partType = sender.Selection.Border.GetPointPartType(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 #46
0
        public virtual void Export(GridVirtual grid, System.IO.TextWriter stream)
        {
            for (int r = 0; r < grid.Rows.Count; r++)
            {
                for (int c = 0; c < grid.Columns.Count; c++)
                {
                    if (c > 0)
                        stream.Write(mFieldSeparator);

                    Cells.ICellVirtual cell = grid.GetCell(r, c);
                    Position pos = new Position(r, c);
                    CellContext context = new CellContext(grid, pos, cell);
                    ExportCSVCell(context, stream);
                }
                stream.Write(mLineSeparator);
            }
        }
Example #47
0
		protected override void OnDetach(GridVirtual grid)
		{
			grid.MouseDown -= new GridMouseEventHandler(grid_MouseDown);
			grid.MouseUp -= new GridMouseEventHandler(grid_MouseUp);
			grid.MouseMove -= new GridMouseEventHandler(grid_MouseMove);
			grid.MouseWheel -= new GridMouseEventHandler(grid_MouseWheel);
			grid.MouseLeave -= new GridEventHandler(grid_MouseLeave);
			grid.DragDrop -= new GridDragEventHandler(grid_DragDrop);
			grid.DragEnter -= new GridDragEventHandler(grid_DragEnter);
			grid.DragLeave -= new GridEventHandler(grid_DragLeave);
			grid.DragOver -= new GridDragEventHandler(grid_DragOver);
			grid.GiveFeedback -= new GridGiveFeedbackEventHandler(grid_GiveFeedback);
			grid.Click -= new GridEventHandler(grid_Click);
			grid.DoubleClick -= new GridEventHandler(grid_DoubleClick);
			grid.KeyDown -= new GridKeyEventHandler(grid_KeyDown);
			grid.KeyUp -= new GridKeyEventHandler(grid_KeyUp);
			grid.KeyPress -= new GridKeyPressEventHandler(grid_KeyPress);
		}
Example #48
0
		protected virtual void grid_DragDrop(GridVirtual sender, DragEventArgs e)
		{
#warning da fare

            //if (mRangeData != null)
            //{
            //    Range destination = mHighlightedRange.Range;

            //    //Solo se il range sorgente รจ diverso dal range di destinazione
            //    if (mRangeData.SourceGrid != sender || mRangeData.SourceRange != destination)
            //    {
            //        mRangeData.WriteData(sender, destination);
            //        sender.Selection.Focus(destination.Start);
            //        sender.Selection.SelectRange(destination, true);
            //    }
            //}

            //ResetTempData();
		}
Example #49
0
		private void grid_DragOver(GridVirtual sender, DragEventArgs e)
        {
#warning da fare
            //if (e.Data.GetDataPresent(typeof(RangeData)))
            //{
            //    ResetTempData();

            //    mRangeData = (RangeData)e.Data.GetData(typeof(RangeData));
            //    if (mRangeData.CutMode == CutMode.None)
            //        e.Effect = DragDropEffects.Copy;
            //    else
            //        e.Effect = DragDropEffects.Move;

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

            //    //Unfortunately for now I can't use this method because this event is not called if I move the mouse outside the scrollable area, and this method use the mouse external position to calculate the scroll direction
            //    ////Scroll if necessary
            //    //sender.ScrollOnPoint(mousePoint);

            //    Position mousePos = sender.PositionAtPoint(sender.PointToClient( mousePoint ));

            //    if (mousePos.IsEmpty() == false)
            //    {
            //        Range rngDest = mRangeData.FindDestinationRange(sender, mousePos);
            //        if (rngDest.IsEmpty() == false)
            //        {
            //            mHighlightedRange = new HighlightedRange(sender);
            //            mHighlightedRange.Range = rngDest;
            //            mHighlightedRange.Border = mHighlightedRange.Border.SetDashStyle(System.Drawing.Drawing2D.DashStyle.DashDotDot);
            //            sender.HighlightedRanges.Add(mHighlightedRange);
            //        }
            //    }
            //}
            //else
            //{
            //    e.Effect = DragDropEffects.None;
            //    ResetTempData();
            //}
		}
Example #50
0
 private void SetHeight(GridVirtual grid, Position position, int height)
 {
     Range range = grid.PositionToCellRange(position);
     int heightForCol = height / range.RowsCount;
     for (int r = range.Start.Row; r <= range.End.Row; r++)
         grid.Rows.SetHeight(r, heightForCol);
 }
Example #51
0
		/// <summary>
		/// Start the timer to scroll the visible area
		/// </summary>
		/// <param name="grid"></param>
		private void BeginScrollTracking(GridVirtual grid)
		{
			//grid.Capture = true;
			mCapturedGrid = grid;

			if (mScrollTimer == null)
			{
				mScrollTimer = new Timer();
				mScrollTimer.Interval = 100;
				mScrollTimer.Tick += this.mScrollTimer_Tick;
			}
			mScrollTimer.Enabled = true;
		}
Example #52
0
		/// <summary>
		/// Stop the timer
		/// </summary>
		private void EndScrollTracking()
		{
			//grid.Capture = false;
			if (mScrollTimer != null)
				mScrollTimer.Enabled = false;
			mCapturedGrid = null;
			mCapturedMouseMoveEventArgs = null;
			mCapturedMouseMoveSender = CellContext.Empty;
		}
 public virtual System.Windows.Forms.DateTimePicker GetEditorDateTimePicker(GridVirtual p_Grid)
 {
     return (System.Windows.Forms.DateTimePicker)GetEditorControl(p_Grid);
 }
Example #54
0
		public void Export(GridVirtual grid)
		{
			System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Stream, 
				System.Text.Encoding.UTF8);
			
			//write HTML and BODY
			if ( (Mode & ExportHTMLMode.HTMLAndBody) == ExportHTMLMode.HTMLAndBody)
			{
				writer.WriteStartElement("html");
				writer.WriteStartElement("body");
			}

			writer.WriteStartElement("table");

			writer.WriteAttributeString("cellspacing","0");
			writer.WriteAttributeString("cellpadding","0");

			for (int r = 0; r < grid.Rows.Count; r++)
			{
				writer.WriteStartElement("tr");

				for (int c = 0; c < grid.Columns.Count; c++)
				{
					Cells.ICellVirtual cell = grid.GetCell(r,c);
					Position pos = new Position(r,c);
					CellContext context = new CellContext(grid, pos, cell);
					ExportHTMLCell(context, writer);
				}

				//tr
				writer.WriteEndElement();
			}

			//table
			writer.WriteEndElement();

			//write end HTML and BODY
			if ( (Mode & ExportHTMLMode.HTMLAndBody) == ExportHTMLMode.HTMLAndBody)
			{
				//body
				writer.WriteEndElement();
				//html
				writer.WriteEndElement();
			}

			writer.Flush();
		}
Example #55
0
 private void SetWidth(GridVirtual grid, Position position, int width)
 {
     Range range = grid.PositionToCellRange(position);
     int widthForCol = width / range.ColumnsCount;
     for (int c = range.Start.Column; c <= range.End.Column; c++)
         grid.Columns.SetWidth(c, widthForCol);
 }
Example #56
0
		protected virtual void grid_MouseLeave(GridVirtual sender, EventArgs e)
		{
			mDragCursor.ResetCursor();
		}
Example #57
0
        void grid_GiveFeedback(GridVirtual sender, GiveFeedbackEventArgs e)
        {
            //Just to test GiveFeedback event

            //e.UseDefaultCursors = false;
            //if (e.Effect == DragDropEffects.Move)
            //    Cursor.Current = Cursors.Help;
        }
Example #58
0
 /// <summary>
 /// Link the cell at the specified grid.
 /// For internal use only.
 /// </summary>
 /// <param name="p_grid"></param>
 public virtual void BindToGrid(GridVirtual p_grid)
 {
     mGrid = p_grid;
 }
Example #59
0
 /// <summary>
 /// Remove the link of the cell from the grid.
 /// For internal use only.
 /// </summary>
 public virtual void UnBindToGrid()
 {
     mGrid = null;
 }
        /// <summary>
        /// Loads the setting.
        /// </summary>
        /// <param name="grid">The parent grid.</param>
        /// <param name="column">The column.</param>
        /// <param name="row">The row.</param>
        /// <param name="mode">The cell size mode.</param>
        public void LoadSetting(GridVirtual grid, int column, int row, CellSizeMode mode)
        {
            this.ownerGrid = grid;
              this.columnId = column;
              this.rowId = row;
              this.cellSizeMode = mode;

              RefreshSetting();
        }