예제 #1
0
        /// <summary>
        /// Change the value of the cell applying the rule of the current editor.
        /// Is recommend to use this method to simulate a edit operation and to validate
        /// the cell value using the current model.
        /// </summary>
        /// <param name="p_Cell">Cell to change value</param>
        /// <param name="position">Current Cell Position</param>
        /// <param name="p_NewValue">New value</param>
        /// <returns>
        /// returns true if the value passed is valid and has been applied to the cell
        /// </returns>
        public virtual bool SetCellValue(Cells.ICellVirtual p_Cell, Position position, object p_NewValue)
        {
            if (EnableEdit == false)
            {
                return(false);
            }

            CellValidatingEventArgs l_cancelEvent = new CellValidatingEventArgs(p_Cell, p_NewValue);

            OnValidating(l_cancelEvent);

            // check whether cancel == true
            if (l_cancelEvent.Cancel == false)
            {
                object l_PrevValue = p_Cell.GetValue(position);
                try
                {
                    p_Cell.SetValue(position, ObjectToValue(l_cancelEvent.NewValue));
                    OnValidated(new CellValidatedEventArgs(p_Cell));
                }
                catch (Exception ex)
                {
                    LoggerManager.Log(LogLevels.Warning, "Exception caught: " + ex.ToString());
                    p_Cell.SetValue(position, l_PrevValue);
                    l_cancelEvent.Cancel = true;
                }
            }

            return(l_cancelEvent.Cancel == false);
        }
예제 #2
0
파일: Rows.cs 프로젝트: siemens/sourcegrid
        /// <summary>
        /// Measures the current row when drawn with the specified cells.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="useColumnWidth">True to fix the column width when calculating the required height of the row.</param>
        /// <param name="StartCol">Start column to measure</param>
        /// <param name="EndCol">End column to measure</param>
        /// <returns>Returns the required height</returns>
        public int MeasureRowHeight(int row, bool useColumnWidth, int StartCol, int EndCol)
        {
            int min = Grid.MinimumHeight;

            if ((GetAutoSizeMode(row) & AutoSizeMode.MinimumSize) == AutoSizeMode.MinimumSize)
            {
                return(min);
            }

            for (int c = StartCol; c <= EndCol; c++)
            {
                Cells.ICellVirtual cell = Grid.GetCell(row, c);
                if (cell != null)
                {
                    Position cellPosition = new Position(row, c);

                    Size maxLayout = Size.Empty;
                    //Use the width of the actual cell (considering spanned cells)
                    if (useColumnWidth)
                    {
                        maxLayout.Width = Grid.RangeToSize(Grid.PositionToCellRange(cellPosition)).Width;
                    }

                    CellContext cellContext = new CellContext(Grid, cellPosition, cell);
                    Size        cellSize    = cellContext.Measure(maxLayout);
                    if (cellSize.Height > min)
                    {
                        min = cellSize.Height;
                    }
                }
            }
            return(min);
        }
예제 #3
0
        protected override void DrawCell_Background(Cells.ICellVirtual p_Cell,
                                                    Position p_CellPosition,
                                                    PaintEventArgs e,
                                                    Rectangle p_ClientRectangle,
                                                    DrawCellStatus p_Status)
        {
            Color l_BackColor = BackColor;

            if (p_Status == DrawCellStatus.Focus)
            {
                l_BackColor = FocusBackColor;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_BackColor = SelectionBackColor;
            }

            using (SolidBrush br = new SolidBrush(l_BackColor))
            {
                if (p_Status == DrawCellStatus.Normal)
                {
                    e.Graphics.FillRectangle(br, p_ClientRectangle);
                }
                else
                {
                    br.Color = _selectionBackColor;//p_Cell.VisualModel.BackColor;
                    e.Graphics.FillRectangle(br, p_ClientRectangle);

                    Rectangle rect = new Rectangle(p_ClientRectangle.Left, p_ClientRectangle.Top, p_ClientRectangle.Width - 1, p_ClientRectangle.Height - 1);
                    e.Graphics.DrawRectangle(new Pen(Brushes.Black, 2), rect);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Draw the borders of the specified cell.
        /// </summary>
        /// <param name="p_Cell"></param>
        /// <param name="p_CellPosition"></param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status"></param>
        protected override void DrawCell_Border(Cells.ICellVirtual p_Cell,
                                                Position p_CellPosition,
                                                PaintEventArgs e,
                                                Rectangle p_ClientRectangle,
                                                DrawCellStatus p_Status)
        {
            RectangleBorder l_Border = Border;

            l_Border.SetColor(BorderColor);
            if (p_Status == DrawCellStatus.Focus)
            {
                l_Border = FocusBorder;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_Border = SelectionBorder;
            }

            ControlPaint.DrawBorder(e.Graphics, p_ClientRectangle,
                                    l_Border.Left.Color,
                                    l_Border.Left.Width,
                                    ButtonBorderStyle.Solid,
                                    l_Border.Top.Color,
                                    l_Border.Top.Width,
                                    ButtonBorderStyle.Solid,
                                    l_Border.Right.Color,
                                    l_Border.Right.Width,
                                    ButtonBorderStyle.Solid,
                                    l_Border.Bottom.Color,
                                    l_Border.Bottom.Width,
                                    ButtonBorderStyle.Solid);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PositionKeyPressEventArgs"/> class.
 /// </summary>
 /// <param name="position">The position.</param>
 /// <param name="p_Cell">The cell.</param>
 /// <param name="p_KeyPressArge">The <see cref="System.Windows.Forms.KeyPressEventArgs"/> instance containing the event data.</param>
 public PositionKeyPressEventArgs(Position position, Cells.ICellVirtual p_Cell, System.Windows.Forms.KeyPressEventArgs p_KeyPressArge)
     : base(position, p_Cell)
 {
     this.keyPressArgs     = p_KeyPressArge;
     this.isControlPressed = Control.ModifierKeys == Keys.Control;
     this.isShiftPressed   = Control.ModifierKeys == Keys.Shift;
 }
예제 #6
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);
            }
        }
예제 #7
0
        /// <summary>
        /// Write the content of the tag specified
        /// </summary>
        /// <param name="p_Cell"></param>
        /// <param name="p_Position"></param>
        /// <param name="p_Export"></param>
        /// <param name="p_Writer"></param>
        /// <param name="p_ElementTagName"></param>
        protected override void ExportHTML_Element(Cells.ICellVirtual p_Cell, Position p_Position, IHTMLExport p_Export, System.Xml.XmlTextWriter p_Writer, string p_ElementTagName)
        {
            ICellCheckBox  l_CheckBox = (ICellCheckBox)p_Cell;
            CheckBoxStatus l_Status   = l_CheckBox.GetCheckBoxStatus(p_Position);

            if (p_ElementTagName == "td")
            {
                if (l_Status.Checked == true)
                {
                    p_Writer.WriteRaw("<input type=\"checkbox\" checked>");
                }
                else
                {
                    p_Writer.WriteRaw("<input type=\"checkbox\">");
                }

                base.ExportHTML_Element(p_Cell, p_Position, p_Export, p_Writer, p_ElementTagName);
            }
            else if (p_ElementTagName == "font")
            {
                Utility.ExportHTML_Element_Font(p_Writer, l_Status.Caption, GetCellFont());

                //do not call base ExportHTML_Element because we use the caption not the display text
                //base.ExportHTML_Element(p_Cell, p_Position, p_Export, p_Writer, p_ElementTagName);
            }
            else
            {
                base.ExportHTML_Element(p_Cell, p_Position, p_Export, p_Writer, p_ElementTagName);
            }
        }
예제 #8
0
 /// <summary>
 /// Returns true if the specified position can receive the focus.
 /// </summary>
 /// <param name="position"></param>
 /// <returns></returns>
 public bool CanReceiveFocus(Position position)
 {
     if (Grid.CompleteRange.Contains(position))
     {
         Cells.ICellVirtual cell = Grid.GetCell(position);
         if (cell != null)
         {
             CellContext context = new CellContext(Grid, position, cell);
             if (Grid.Controller.CanReceiveFocus(context, EventArgs.Empty))
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
예제 #9
0
        /// <summary>
        /// Measures the current column when drawn with the specified cells.
        /// </summary>
        /// <param name="column"></param>
        /// <param name="useRowHeight">True to fix the row height when measure the column width.</param>
        /// <param name="StartRow">Start row to measure</param>
        /// <param name="EndRow">End row to measure</param>
        /// <returns>Returns the required width</returns>
        public int MeasureColumnWidth(int column, bool useRowHeight, int StartRow, int EndRow)
        {
            int min = Grid.MinimumWidth;

            if ((GetAutoSizeMode(column) & AutoSizeMode.MinimumSize) == AutoSizeMode.MinimumSize)
            {
                return(min);
            }

            for (int r = StartRow; r <= EndRow; r++)
            {
                Cells.ICellVirtual cell = Grid.GetCell(r, column);
                if (cell != null)
                {
                    Size maxLayout = Size.Empty;
                    if (useRowHeight)
                    {
                        maxLayout.Height = Grid.Rows.GetHeight(r);
                    }

                    CellContext cellContext = new CellContext(Grid, new Position(r, column), cell);

                    Size l_size = cellContext.Measure(maxLayout);
                    if (l_size.Width > min)
                    {
                        min = l_size.Width;
                    }
                }
            }
            return(min);
        }
예제 #10
0
        /// <summary>
        /// Draw the image and the display string of the specified cell.
        /// </summary>
        /// <param name="p_Cell">The cell.</param>
        /// <param name="p_CellPosition">The cell position.</param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status">Cell status</param>
        protected override void DrawCell_ImageAndText(Cells.ICellVirtual p_Cell, Position p_CellPosition, PaintEventArgs e, Rectangle p_ClientRectangle, DrawCellStatus p_Status)
        {
            if (p_ClientRectangle.Width == 0 || p_ClientRectangle.Height == 0)
            {
                return;
            }

            RectangleBorder l_Border    = Border;
            Color           l_ForeColor = ForeColor;

            IExpandCell l_Cell   = (IExpandCell)p_Cell;
            bool        l_Status = l_Cell.GetStateValue(p_CellPosition);

            Image l_StateImage = GetImageForState(l_Status);

            Font l_CurrentFont = GetCellFont();

            // Image and Text
            VisualModelBase.PaintImageAndText(e.Graphics,
                                              p_ClientRectangle,
                                              l_StateImage,
                                              ContentAlignment.MiddleCenter,
                                              false, // unused
                                              null,  // unused
                                              StringFormat,
                                              false, // unused
                                              l_Border,
                                              l_ForeColor,
                                              l_CurrentFont,
                                              false,
                                              false);
        }
예제 #11
0
        /// <summary>
        /// Change the value of the cell applying the rule of the current editor. Is recommend to use this method to simulate a edit operation and to validate the cell value using the current model.
        /// </summary>
        /// <param name="p_Cell">Cell to change value</param>
        /// <param name="p_Position">Current Cell Position</param>
        /// <param name="p_NewValue"></param>
        /// <returns>returns true if the value passed is valid and has been applied to the cell</returns>
        public virtual bool SetCellValue(Cells.ICellVirtual p_Cell, Position p_Position, object p_NewValue)
        {
            if (EnableEdit)
            {
                ValidatingCellEventArgs l_cancelEvent = new ValidatingCellEventArgs(p_Cell, p_NewValue);
                OnValidating(l_cancelEvent);

                //check if cancel == true
                if (l_cancelEvent.Cancel == false)
                {
                    object l_PrevValue = p_Cell.GetValue(p_Position);
                    try
                    {
                        p_Cell.SetValue(p_Position, ObjectToValue(l_cancelEvent.NewValue));
                        OnValidated(new CellEventArgs(p_Cell));
                    }
                    catch (Exception)
                    {
                        p_Cell.SetValue(p_Position, l_PrevValue);
                        //throw err;
                        l_cancelEvent.Cancel = true;                        //di fatto � fallita la validazione del dato
                    }
                }

                return(l_cancelEvent.Cancel == false);
            }
            else
            {
                return(false);
            }
        }
예제 #12
0
        /// <summary>
        /// Draw the image and the displaystring of the specified cell.
        /// </summary>
        /// <param name="p_Cell"></param>
        /// <param name="p_CellPosition"></param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status"></param>
        protected override void DrawCell_ImageAndText(Cells.ICellVirtual p_Cell,
                                                      Position p_CellPosition,
                                                      PaintEventArgs e,
                                                      Rectangle p_ClientRectangle,
                                                      DrawCellStatus p_Status)
        {
            RectangleBorder l_Border    = Border;
            Color           l_ForeColor = ForeColor;

            if (p_Status == DrawCellStatus.Focus)
            {
                l_Border    = FocusBorder;
                l_ForeColor = FocusForeColor;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_Border    = SelectionBorder;
                l_ForeColor = SelectionForeColor;
            }

            Font l_CurrentFont = GetCellFont();

            //Image and Text
            Utility.PaintImageAndText(e.Graphics,
                                      p_ClientRectangle,
                                      Image,
                                      ImageAlignment,
                                      ImageStretch,
                                      p_Cell.GetDisplayText(p_CellPosition),
                                      StringFormat,
                                      AlignTextToImage,
                                      l_Border,
                                      l_ForeColor,
                                      l_CurrentFont);
        }
예제 #13
0
        /// <summary>
        /// Measures the current column when drawn with the specified cells.
        /// </summary>
        /// <param name="column"></param>
        /// <param name="useRowHeight">True to fix the row height when measure the column width.</param>
        /// <param name="StartRow">Start row to measure</param>
        /// <param name="EndRow">End row to measure</param>
        /// <returns>Returns the required width</returns>
        public int MeasureColumnWidth(int column, bool useRowHeight, int StartRow, int EndRow)
        {
            int min = Grid.MinimumWidth;

            if ((GetAutoSizeMode(column) & AutoSizeMode.MinimumSize) == AutoSizeMode.MinimumSize)
            {
                return(min);
            }

            for (int r = StartRow; r <= EndRow; r++)
            {
                Cells.ICellVirtual cell = Grid.GetCell(r, column);
                if (cell != null)
                {
                    Position cellPosition = new Position(r, column);

                    Size maxLayout = Size.Empty;
                    //Use the width of the actual cell (considering spanned cells)
                    if (useRowHeight)
                    {
                        maxLayout.Height = Grid.RangeToSize(Grid.PositionToCellRange(cellPosition)).Height;
                    }

                    CellContext cellContext = new CellContext(Grid, cellPosition, cell);
                    Size        cellSize    = cellContext.Measure(maxLayout);
                    if (cellSize.Width > min)
                    {
                        min = cellSize.Width;
                    }
                }
            }
            return(min);
        }
예제 #14
0
파일: CheckBox.cs 프로젝트: Crimso44/Avia45
 private void AutoChangeValues(CellContext sender, bool newVal)
 {
     foreach (Position pos in sender.Grid.Selection.GetSelectionRegion().GetCellsPositions())
     {
         Cells.ICellVirtual c = sender.Grid.GetCell(pos);
         Models.ICheckBox   check;
         if (c != this && c != null &&
             (check = (Models.ICheckBox)c.Model.FindModel(typeof(Models.ICheckBox))) != null)
         {
             CellContext context = new CellContext(sender.Grid, pos, c);
             if (context.StartEdit())
             {
                 try
                 {
                     check.SetCheckedValue(context, newVal);
                     context.EndEdit(false);
                 }
                 catch (Exception)
                 {
                     context.EndEdit(true);
                     throw;
                 }
             }
         }
     }
 }
예제 #15
0
        /// <summary>
        /// Draw the background of the specified cell. Background
        /// </summary>
        /// <param name="p_Cell">The cell.</param>
        /// <param name="p_CellPosition">The cell position.</param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status">Cell status</param>
        protected override void DrawCell_Background(Cells.ICellVirtual p_Cell,
                                                    Position p_CellPosition,
                                                    PaintEventArgs e,
                                                    Rectangle p_ClientRectangle,
                                                    DrawCellStatus p_Status)
        {
            if (p_ClientRectangle.Width == 0 || p_ClientRectangle.Height == 0)
            {
                return;
            }

            Color l_BackColor;

            if (p_Status == DrawCellStatus.Focus)
            {
                l_BackColor = FocusBackColor;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_BackColor = SelectionBackColor;
            }
            else
            {
                l_BackColor = BackColor;
            }

            SolidBrush br = new SolidBrush(l_BackColor);

            e.Graphics.FillRectangle(br, p_ClientRectangle);
        }
예제 #16
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);
        }
예제 #17
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);
                }
            }
        }
예제 #18
0
파일: StyleGrid.cs 프로젝트: unixcrh/Motion
 public void ApplyStyle(Cells.ICellVirtual cell)
 {
     for (int i = 0; i < m_StyleCells.Count; i++)
     {
         m_StyleCells[i].ApplyToCell(cell);
     }
 }
예제 #19
0
        /// <summary>
        /// Start editing the cell passed. Do not call this method for start editing a cell, you must use Cell.StartEdit.
        /// </summary>
        /// <param name="p_Cell">Cell to start edit</param>
        /// <param name="position">Editing position(Row/Col)</param>
        /// <param name="p_StartEditValue">Can be null(in this case use the p_cell.Value</param>
        public override void InternalStartEdit(Cells.ICellVirtual p_Cell, Position position, object p_StartEditValue)
        {
            base.InternalStartEdit(p_Cell, position, p_StartEditValue);

            if (EnableEdit == false)
            {
                return;
            }

            ComboBoxTyped l_Combo = GetEditorComboBox(p_Cell.Grid);

            l_Combo.Validator              = this;
            l_Combo.EnableEscapeKeyUndo    = false;
            l_Combo.EnableEnterKeyValidate = false;
            l_Combo.EnableLastValidValue   = false;
            l_Combo.EnableAutoValidation   = false;

            if (p_StartEditValue is string && IsStringConversionSupported())
            {
                l_Combo.TextBox.Text = TextBoxTyped.ValidateCharactersString((string)p_StartEditValue, l_Combo.TextBox.ValidCharacters, l_Combo.TextBox.InvalidCharacters);
                if (l_Combo.TextBox.Text != null)
                {
                    l_Combo.TextBox.SelectionStart = l_Combo.TextBox.Text.Length;
                }
                else
                {
                    l_Combo.TextBox.SelectionStart = 0;
                }
            }
            else
            {
                l_Combo.Value = p_Cell.GetValue(position);
                l_Combo.SelectAllTextBox();
            }
        }
예제 #20
0
        /// <summary>
        /// Draw the borders of the specified cell using DrawGradient3DBorder
        /// </summary>
        /// <param name="p_Cell">The cell.</param>
        /// <param name="p_CellPosition">The cell position.</param>
        /// <param name="e">Paint arguments</param>
        /// <param name="p_ClientRectangle">Rectangle position where draw the current cell, relative to the current view,</param>
        /// <param name="p_Status">Cell status</param>
        protected override void DrawCell_Border(Cells.ICellVirtual p_Cell, Position p_CellPosition, PaintEventArgs e, Rectangle p_ClientRectangle, DrawCellStatus p_Status)
        {
            Color l_BackColor;

            if (p_Status == DrawCellStatus.Focus)
            {
                l_BackColor = FocusBackColor;
            }
            else if (p_Status == DrawCellStatus.Selected)
            {
                l_BackColor = SelectionBackColor;
            }
            else
            {
                l_BackColor = BackColor;
            }

            if (p_CellPosition == p_Cell.Grid.MouseDownPosition)
            {
                DrawGradient3DBorder(e.Graphics, p_ClientRectangle, l_BackColor, HeaderShadowColor, HeaderLightColor, HeaderShadowBorderWidth, HeaderLightBorderWidth, Gradient3DBorderStyle.Sunken);
            }
            else
            {
                DrawGradient3DBorder(e.Graphics, p_ClientRectangle, l_BackColor, HeaderShadowColor, HeaderLightColor, HeaderShadowBorderWidth, HeaderLightBorderWidth, Gradient3DBorderStyle.Raised);
            }
        }
예제 #21
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);
        }
예제 #22
0
 /// <summary>
 /// Export the specified cell to HTML
 /// </summary>
 /// <param name="p_CurrentPosition"></param>
 /// <param name="p_Cell"></param>
 /// <param name="p_Export"></param>
 /// <param name="p_Writer"></param>
 protected override void ExportHTMLCell(Position p_CurrentPosition, Cells.ICellVirtual p_Cell, IHTMLExport p_Export, System.Xml.XmlTextWriter p_Writer)
 {
     //export only real cell (not position occupied by rowspan or colspan
     if (p_Cell != null && ((ICell)p_Cell).Range.Start == p_CurrentPosition)
     {
         p_Cell.VisualModel.ExportHTML(p_Cell, p_CurrentPosition, p_Export, p_Writer);
     }
 }
예제 #23
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);
        }
예제 #24
0
 /// <summary>
 /// Write the attributes of the tag specified
 /// </summary>
 /// <param name="p_Cell"></param>
 /// <param name="p_Position"></param>
 /// <param name="p_Export"></param>
 /// <param name="p_Writer"></param>
 /// <param name="p_ElementTagName"></param>
 protected override void ExportHTML_Attributes(Cells.ICellVirtual p_Cell, Position p_Position, IHTMLExport p_Export, System.Xml.XmlTextWriter p_Writer, string p_ElementTagName)
 {
     base.ExportHTML_Attributes(p_Cell, p_Position, p_Export, p_Writer, p_ElementTagName);
     if (p_ElementTagName == "img")
     {
         p_Writer.WriteAttributeString("align", Utility.ContentToHorizontalAlignment(ImageAlignment).ToString().ToLower());
         p_Writer.WriteAttributeString("src", p_Export.ExportImage(Image));
     }
 }
예제 #25
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);
                        }
                    }
                }
            }
        }
예제 #26
0
        /// <summary>
        /// Returns the minimum required size of the current cell, calculating using the
        /// current DisplayString, Image and Borders information.
        /// </summary>
        /// <param name="p_Graphics">GDI+ drawing surface</param>
        /// <param name="p_Cell">The cell.</param>
        /// <param name="p_CellPosition">The cell position.</param>
        /// <returns></returns>
        public override SizeF GetRequiredSize(Graphics p_Graphics,
                                              Cells.ICellVirtual p_Cell,
                                              Position p_CellPosition)
        {
            SizeF s = base.GetRequiredSize(p_Graphics, p_Cell, p_CellPosition);

            s.Width += IconUtility.SortUp.Width; // add the width of the sort image
            return(s);
        }
예제 #27
0
        /// <summary>
        /// Sort the current column
        /// </summary>
        /// <param name="e"></param>
        /// <param name="p_bAscending"></param>
        /// <param name="p_Comparer"></param>
        public void SortColumn(PositionEventArgs e, bool p_bAscending, System.Collections.IComparer p_Comparer)
        {
            //verifico che il sort sia abilitato e che ci sia almeno una riga da ordinare oltra a quella corrente
            if (IsSortEnable(e) && e.Position.Row < (e.Grid.RowsCount) && e.Grid.ColumnsCount > 0)
            {
                Range l_RangeToSort;
                Range l_RangeHeader;
                if (m_RangeToSort != null)
                {
                    l_RangeToSort = m_RangeToSort.GetRange(e.Grid);
                }
                else
                {
                    //the range to sort is all the grid range without the rows < of the current row
                    l_RangeToSort = new Range(e.Position.Row + 1, 0, e.Grid.RowsCount - 1, e.Grid.ColumnsCount - 1);
                }

                if (m_HeaderRange != null)
                {
                    l_RangeHeader = m_HeaderRange.GetRange(e.Grid);
                }
                else
                {
                    //the range header is all the grid range with the rows <= of the current row
                    l_RangeHeader = new Range(0, 0, e.Position.Row, e.Grid.ColumnsCount - 1);
                }

                ICellSortableHeader l_CellSortable = (ICellSortableHeader)e.Cell;
                if (e.Grid.RowsCount > (e.Position.Row + 1) && e.Grid.ColumnsCount > e.Grid.FixedColumns)
                {
                    e.Grid.SortRangeRows(l_RangeToSort, e.Position.Column, p_bAscending, p_Comparer);
                    if (p_bAscending)
                    {
                        l_CellSortable.SetSortMode(e.Position, GridSortMode.Ascending);
                    }
                    else
                    {
                        l_CellSortable.SetSortMode(e.Position, GridSortMode.Descending);
                    }

                    //Remove the image from others ColHeaderSort
                    for (int r = l_RangeHeader.Start.Row; r <= l_RangeHeader.End.Row; r++)
                    {
                        for (int c = l_RangeHeader.Start.Column; c <= l_RangeHeader.End.Column; c++)
                        {
                            Cells.ICellVirtual l_tmp = e.Grid.GetCell(r, c);
                            if (l_tmp != l_CellSortable &&
                                l_tmp != null &&
                                l_tmp is ICellSortableHeader)
                            {
                                ((ICellSortableHeader)l_tmp).SetSortMode(new Position(r, c), GridSortMode.None);
                            }
                        }
                    }
                }
            }
        }
예제 #28
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++;
             *      }
             * }*/
        }
예제 #29
0
        /// <summary>
        /// Toggle the value of the current cell and if AutoChangeValueOfSelectedCells is true of all the selected cells.
        /// Simulate an edit operation.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UIChangeChecked(CellContext sender, EventArgs e)
        {
            Models.ICheckBox checkModel = (Models.ICheckBox)sender.Cell.Model.FindModel(typeof(Models.ICheckBox));;
            if (checkModel == null)
            {
                throw new SourceGrid.SourceGridException("Models.ICheckBox not found");
            }

            Models.CheckBoxStatus checkStatus = checkModel.GetCheckBoxStatus(sender);
            if (checkStatus.CheckEnable)
            {
                bool newVal = true;
                if (checkStatus.Checked != null)
                {
                    newVal = !checkStatus.Checked.Value;
                }

                sender.StartEdit();
                try
                {
                    checkModel.SetCheckedValue(sender, newVal);
                    sender.EndEdit(false);
                }
                catch (Exception)
                {
                    sender.EndEdit(true);
                    throw;
                }

                //change the status of all selected control
                if (AutoChangeValueOfSelectedCells)
                {
                    foreach (Position pos in sender.Grid.Selection.GetSelectionRegion().GetCellsPositions())
                    {
                        Cells.ICellVirtual c = sender.Grid.GetCell(pos);
                        Models.ICheckBox   check;
                        if (c != this && c != null &&
                            (check = (Models.ICheckBox)c.Model.FindModel(typeof(Models.ICheckBox))) != null)
                        {
                            CellContext context = new CellContext(sender.Grid, pos, c);
                            context.StartEdit();
                            try
                            {
                                check.SetCheckedValue(context, newVal);
                                context.EndEdit(false);
                            }
                            catch (Exception)
                            {
                                context.EndEdit(true);
                                throw;
                            }
                        }
                    }
                }
            }
        }
예제 #30
0
 /// <summary>
 /// Constructor. Create a DataGridColumn class.
 /// </summary>
 public DataGridColumn(DataGrid grid,
                       Cells.ICellVirtual headerCell,
                       Cells.ICellVirtual dataCell,
                       string propertyName)
     : base(grid)
 {
     mPropertyName = propertyName;
     mHeaderCell   = headerCell;
     mDataCell     = dataCell;
 }
예제 #31
0
 /// <summary>
 /// Set the current editing cell, for an editor only one cell can be in editing state
 /// </summary>
 /// <param name="cell">The cell.</param>
 /// <param name="position">The position.</param>
 protected void SetEditCell(Cells.ICellVirtual cell, Position position)
 {
     this.editCell = cell;
       this.editPosition = position;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CellValidatingEventArgs"/> class.
 /// </summary>
 /// <param name="cell">The cell.</param>
 /// <param name="newValue">The new value.</param>
 public CellValidatingEventArgs(Cells.ICellVirtual cell, object newValue)
     : base(false)
 {
     this.cell = cell;
       this.newValue = newValue;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CellValidatedEventArgs"/> class.
 /// </summary>
 /// <param name="cell">The cell.</param>
 public CellValidatedEventArgs(Cells.ICellVirtual cell)
 {
     this.cell = cell;
 }
예제 #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PositionEventArgs"/> class.
 /// </summary>
 /// <param name="position">The position.</param>
 /// <param name="p_Cell">The cell.</param>
 public PositionEventArgs(Position position, Cells.ICellVirtual p_Cell)
 {
     this.position = position;
       this.cell = p_Cell;
 }
예제 #35
0
		/// <summary>
		/// Returns all the cells at specified row position
		/// </summary>
		/// <param name="p_RowIndex"></param>
		/// <returns></returns>
		public virtual Cells.ICellVirtual[] GetCellsAtRow(int p_RowIndex)
		{
			Cells.ICellVirtual[] l_Cells = new Cells.ICellVirtual[Columns.Count];
			for (int c = 0; c < Columns.Count; c++)
				l_Cells[c] = GetCell(p_RowIndex, c);

			return l_Cells;
		}
예제 #36
0
		/// <summary>
		/// Returns all the cells at specified column position
		/// </summary>
		/// <param name="p_ColumnIndex"></param>
		/// <returns></returns>
		public virtual Cells.ICellVirtual[] GetCellsAtColumn(int p_ColumnIndex)
		{
			Cells.ICellVirtual[] l_Cells = new Cells.ICellVirtual[Rows.Count];
			for (int r = 0; r < Rows.Count; r++)
				l_Cells[r] = GetCell(r, p_ColumnIndex);

			return l_Cells;
		}
예제 #37
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="pGridVirtual"></param>
		/// <param name="pPosition"></param>
		public CellContext(GridVirtual pGridVirtual, Position pPosition)
		{
			Position = pPosition;
			Grid = pGridVirtual;
			Cell = Grid.GetCell(Position);
		}
예제 #38
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="pGridVirtual"></param>
		/// <param name="pPosition"></param>
		/// <param name="pCell"></param>
		public CellContext(GridVirtual pGridVirtual, Position pPosition, Cells.ICellVirtual pCell)
		{
			Position = pPosition;
			Cell = pCell;
			Grid = pGridVirtual;
		}