Наследование: IDisposable
Пример #1
0
 private void ListAdd(ChangeLogItem log)
 {
     Table table = this.tableList;       // The Table control on a form - already initialised
     Cell c = new Cell();
     switch (log.T)
     {
         case ChangeLogLevel.ADD:
             c = new Cell(Translator.Instance.T("新增"), global::ZForge.Controls.Logs.Properties.Resources.add_16);
             break;
         case ChangeLogLevel.BUGFIX:
             c = new Cell(Translator.Instance.T("BUGFIX"), global::ZForge.Controls.Logs.Properties.Resources.bug_yellow_16);
             break;
         case ChangeLogLevel.REMOVE:
             c = new Cell(Translator.Instance.T("移除"), global::ZForge.Controls.Logs.Properties.Resources.delete_16);
             break;
         default:
             c = new Cell(Translator.Instance.T("更改"), global::ZForge.Controls.Logs.Properties.Resources.document_into_16);
             break;
     }
     Row row = new Row(
         new Cell[] {
             new Cell(log.Version),
             c,
             new Cell(log.Message)
         }
     );
     row.Tag = log;
     table.TableModel.Rows.Add(row);
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the CellEventArgs class with 
 /// the specified Cell source, column index and row index
 /// </summary>
 /// <param name="source">The Cell that Raised the event</param>
 /// <param name="column">The Column index of the Cell</param>
 /// <param name="row">The Row index of the Cell</param>
 public CellEventArgsBase(Cell source, int column, int row)
     : base()
 {
     this.source = source;
     this.column = column;
     this.row = row;
 }
Пример #3
0
        /// <summary>
        /// Compares two cells and returns a value indicating whether one is less 
        /// than, equal to or greater than the other.
        /// </summary>
        /// <param name="cell1"></param>
        /// <param name="cell2"></param>
        /// <returns></returns>
        protected override int CompareCells(Cell cell1, Cell cell2)
        {
            int retVal = 0;

            if (cell1.Checked && !cell2.Checked)
            {
                retVal = -1;
            }
            else if (!cell1.Checked && cell2.Checked)
            {
                retVal = 1;
            }

            // if the cells have the same checked value and the CheckBoxColumn
            // they belong to allows text drawing, compare the text properties
            // to determine order
            if (retVal == 0 && ((CheckBoxColumn)this.TableModel.Table.ColumnModel.Columns[this.SortColumn]).DrawText)
            {
                // check for null data
                if (cell1.Text == null && cell2.Text == null)
                {
                    return 0;
                }
                else if (cell1.Text == null)
                {
                    return -1;
                }

                retVal = cell1.Text.CompareTo(cell2.Text);
            }

            return retVal;
        }
Пример #4
0
 /// <summary>
 /// Returns the height that is required to render this cell. If zero is returned then the default row height is used.
 /// </summary>
 /// <param name="graphics"></param>
 /// <param name="cell"></param>
 /// <returns></returns>
 public override int GetCellHeight(Graphics graphics, Cell cell)
 {
     if (cell != null)
     {
         this.Font = cell.Font;
         // Need to set this.Bounds before we access Client rectangle
         SizeF size = graphics.MeasureString(cell.Text, this.Font, this.ClientRectangle.Width, this.StringFormat);
         return (int)Math.Ceiling(size.Height);
     }
     else
         return 0;
 }
Пример #5
0
        /// <summary>
        /// Compares two cells and returns a value indicating whether one is less 
        /// than, equal to or greater than the other.
        /// </summary>
        /// <param name="cell1"></param>
        /// <param name="cell2"></param>
        /// <returns></returns>
        protected override int CompareCells(Cell cell1, Cell cell2)
        {
            // check for null data
            if (cell1.Data == null && cell2.Data == null)
            {
                return 0;
            }
            else if (cell1.Data == null)
            {
                return -1;
            }
            else if (cell2.Data == null)
            {
                return 1;
            }

            Color color1 = (Color) cell1.Data;
            Color color2 = (Color) cell2.Data;

            if (color1.GetHue() < color2.GetHue())
            {
                return -1;
            }
            else if (color1.GetHue() > color2.GetHue())
            {
                return 1;
            }
            else
            {
                if (color1.GetSaturation() < color2.GetSaturation())
                {
                    return -1;
                }
                else if (color1.GetSaturation() > color2.GetSaturation())
                {
                    return 1;
                }
                else
                {
                    if (color1.GetBrightness() < color2.GetBrightness())
                    {
                        return -1;
                    }
                    else if (color1.GetBrightness() > color2.GetBrightness())
                    {
                        return 1;
                    }

                    return 0;
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Compares two cells and returns a value indicating whether one is less 
        /// than, equal to or greater than the other.
        /// </summary>
        /// <param name="cell1"></param>
        /// <param name="cell2"></param>
        /// <returns></returns>
        protected override int CompareCells(Cell cell1, Cell cell2)
        {
            // check for null data
            if (cell1.Data == null && cell2.Data == null)
            {
                return 0;
            }
            else if (cell1.Data == null)
            {
                return -1;
            }
            else if (cell2.Data == null)
            {
                return 1;
            }

            return Convert.ToDateTime(cell1.Data).CompareTo(Convert.ToDateTime(cell2.Data));
        }
Пример #7
0
        /// <summary>
        /// Compares two cells and returns a value indicating whether one is less 
        /// than, equal to or greater than the other.
        /// </summary>
        /// <param name="cell1"></param>
        /// <param name="cell2"></param>
        /// <returns></returns>
        protected override int CompareCells(Cell cell1, Cell cell2)
        {
            int retVal = 0;

            // check for null data
            if (cell1.Data == null && cell2.Data == null)
            {
                retVal = 0;
            }
            else if (cell1.Data == null)
            {
                retVal = -1;
            }
            else if (cell2.Data == null)
            {
                retVal = 1;
            }

            // since images aren't comparable, if retVal = 0 and the ImageColumn
            // they belong to allows text drawing, compare the text properties
            // to determine order
            if (retVal == 0 && ((ImageColumn) this.TableModel.Table.ColumnModel.Columns[this.SortColumn]).DrawText)
            {
                // check for null data
                if (cell1.Text == null && cell2.Text == null)
                {
                    return 0;
                }
                else if (cell1.Text == null)
                {
                    return -1;
                }

                retVal = cell1.Text.CompareTo(cell2.Text);
            }

            return retVal;
        }
Пример #8
0
        /// <summary>
        /// Compares two cells and returns a value indicating whether one is less 
        /// than, equal to or greater than the other.
        /// </summary>
        /// <param name="cell1"></param>
        /// <param name="cell2"></param>
        /// <returns></returns>
        protected override int CompareCells(Cell cell1, Cell cell2)
        {
            string s1 = cell1.Text;
            string s2 = cell2.Text;

            // check for null cells
            if (s1 == null && s2 == null)
            {
                return 0;
            }
            else if (s1 == null)
            {
                return -1;
            }
            else if (s2 == null)
            {
                return 1;
            }
            else
            {
                return s1.CompareTo(s2);
            }
        }
Пример #9
0
        /// <summary>
        /// Returns the cell to add to a row for the given value, depending on the type of column it will be 
        /// shown in.
        /// If the column is a TextColumn then just the Text property is set. For all other
        /// column types just the Data value is set.
        /// </summary>
        /// <param name="column"></param>
        /// <param name="val"></param>
        /// <returns></returns>
        public virtual Cell GetCell(Column column, object val)
        {
            Cell cell = null;

            switch (column.GetType().Name)
            {
                case "TextColumn":
                    cell = new Cell(val.ToString());
                    break;

                case "CheckBoxColumn":
                    bool check = false;
                    if (val is Boolean)
                        check = (bool)val;
                    cell = new Cell("", check);
                    break;

                default:
                    cell = new Cell(val);
                    break;
            }

            return cell;
        }
Пример #10
0
        /// <summary>
        /// Prepares the CellEditor to edit the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to be edited</param>
        /// <param name="table">The Table that contains the Cell</param>
        /// <param name="cellPos">A CellPos representing the position of the Cell</param>
        /// <param name="cellRect">The Rectangle that represents the Cells location and size</param>
        /// <param name="userSetEditorValues">Specifies whether the ICellEditors 
        /// starting value has already been set by the user</param>
        /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns>
        public override bool PrepareForEditing(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, bool userSetEditorValues)
        {
            //
            if (!(table.ColumnModel.Columns[cellPos.Column] is NumberColumn))
            {
                throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn");
            }

            if (!(table.ColumnModel.GetCellRenderer(cellPos.Column) is NumberCellRenderer))
            {
                throw new InvalidOperationException("Cannot edit Cell as NumberCellEditor can only be used with a NumberColumn that uses a NumberCellRenderer");
            }

            this.Minimum = ((NumberColumn) table.ColumnModel.Columns[cellPos.Column]).Minimum;
            this.Maximum = ((NumberColumn) table.ColumnModel.Columns[cellPos.Column]).Maximum;
            this.Increment = ((NumberColumn) table.ColumnModel.Columns[cellPos.Column]).Increment;

            return base.PrepareForEditing (cell, table, cellPos, cellRect, userSetEditorValues);
        }
Пример #11
0
        /// <summary>
        /// Initializes a new instance of the Row class with an array of Cell objects and 
        /// the foreground color, background color, and font of the Row
        /// </summary>
        /// <param name="cells">An array of Cell objects that represent the Cells of the Row</param>
        /// <param name="foreColor">The foreground Color of the Row</param>
        /// <param name="backColor">The background Color of the Row</param>
        /// <param name="font">The Font used to draw the text in the Row's Cells</param>
        public Row(Cell[] cells, Color foreColor, Color backColor, Font font)
        {
            if (cells == null)
            {
                throw new ArgumentNullException("cells", "Cell[] cannot be null");
            }

            this.Init();

            this.ForeColor = foreColor;
            this.BackColor = backColor;
            this.Font = font;

            if (cells.Length > 0)
            {
                this.Cells.AddRange(cells);
            }
        }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the CellEventArgs class with 
 /// the specified Cell source and event type
 /// </summary>
 /// <param name="source">The Cell that Raised the event</param>
 public CellEventArgsBase(Cell source)
     : this(source, -1, -1)
 {
 }
Пример #13
0
 /// <summary>
 /// Allows an existing control to be modified or swapped for another control.
 /// Return null if the same control is left in place, or return a control if that is to replace the current one.
 /// </summary>
 /// <param name="cell">The cell that contains the control.</param>
 /// <param name="control">The current control in that cell.</param>
 /// <returns></returns>
 public virtual Control UpdateControl(Cell cell, Control control)
 {
     return null;
 }
Пример #14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="cell"></param>
 internal void SetCell(Cell cell)
 {
     this.cell = cell;
 }
Пример #15
0
        /// <summary>
        /// Gets the CheckBoxCellRenderer specific data used by the Renderer from 
        /// the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to get the CheckBoxCellRenderer data for</param>
        /// <returns>The CheckBoxCellRenderer data for the specified Cell</returns>
        protected CheckBoxRendererData GetCheckBoxRendererData(Cell cell)
        {
            object rendererData = this.GetRendererData(cell);

            if (rendererData == null || !(rendererData is CheckBoxRendererData))
            {
                if (cell.CheckState == CheckState.Unchecked)
                {
                    rendererData = new CheckBoxRendererData(CheckBoxStates.UncheckedNormal);
                }
                else if (cell.CheckState == CheckState.Indeterminate && cell.ThreeState)
                {
                    rendererData = new CheckBoxRendererData(CheckBoxStates.MixedNormal);
                }
                else
                {
                    rendererData = new CheckBoxRendererData(CheckBoxStates.CheckedNormal);
                }

                this.SetRendererData(cell, rendererData);
            }

            this.ValidateCheckState(cell, (CheckBoxRendererData) rendererData);

            return (CheckBoxRendererData) rendererData;
        }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the CellEventArgs class with 
 /// the specified Cell source, column index, row index and event type
 /// </summary>
 /// <param name="source">The Cell that Raised the event</param>
 /// <param name="column">The Column index of the Cell</param>
 /// <param name="row">The Row index of the Cell</param>
 /// <param name="eventType">The type of event</param>
 /// <param name="oldValue">The old value of the property</param>
 public CellEventArgs(Cell source, int column, int row, CellEventType eventType, object oldValue)
     : base(source, column, row)
 {
     this.eventType = eventType;
     this.oldValue = oldValue;
 }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the RowEventArgs class with 
 /// the specified Row source, row index, start index, end index 
 /// and affected Cell
 /// </summary>
 /// <param name="source">The Row that originated the event</param>
 /// <param name="cell">The affected Cell</param>
 /// <param name="cellFromIndex">The start index of the affected Cell(s)</param>
 /// <param name="cellToIndex">The end index of the affected Cell(s)</param>
 public RowEventArgs(Row source, Cell cell, int cellFromIndex, int cellToIndex)
     : this(source, -1, cell, cellFromIndex, cellToIndex, RowEventType.Unknown)
 {
 }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the CellEventArgs class with 
        /// the specified Cell source, column index and row index
        /// </summary>
        /// <param name="source">The Cell that Raised the event</param>
        /// <param name="editor">The CellEditor used to edit the Cell</param>
        /// <param name="table">The Table that the Cell belongs to</param>
        /// <param name="row">The Column index of the Cell</param>
        /// <param name="column">The Row index of the Cell</param>
        /// <param name="cellRect"></param>
        public CellEditEventArgs(Cell source, ICellEditor editor, Table table, int row, int column, Rectangle cellRect)
            : base(source, column, row)
        {
            this.editor = editor;
            this.table = table;
            this.cellRect = cellRect;

            this.cancel = false;
        }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the CellEventArgs class with 
 /// the specified Cell source, column index and row index
 /// </summary>
 /// <param name="source">The Cell that Raised the event</param>
 /// <param name="editor">The CellEditor used to edit the Cell</param>
 /// <param name="table">The Table that the Cell belongs to</param>
 public CellEditEventArgs(Cell source, ICellEditor editor, Table table)
     : this(source, editor, table, -1, -1, Rectangle.Empty)
 {
 }
Пример #20
0
 /// <summary>
 /// Returns true if this cell is in a sub row.
 /// </summary>
 /// <param name="cell"></param>
 /// <returns></returns>
 private bool IsSubRow(Cell cell)
 {
     return cell.Row.Parent != null;
 }
Пример #21
0
 /// <summary>
 /// Returns true if this cell is in the last subrow.
 /// </summary>
 /// <param name="cell"></param>
 /// <returns></returns>
 private bool IsLastRow(Cell cell)
 {
     if (cell.Row.Parent != null)
     {
         Row parent = cell.Row.Parent;
         if (parent.SubRows.IndexOf(cell.Row) == parent.SubRows.Count-1)
             return true;
         else
             return false;
     }
     else
         return false;
 }
Пример #22
0
        /// <summary>
        /// Gets the GroupRendererData specific data used by the Renderer from 
        /// the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to get the GroupRendererData data for</param>
        /// <returns>The GroupRendererData data for the specified Cell</returns>
        protected GroupRendererData GetGroupRendererData(Cell cell)
        {
            object rendererData = this.GetRendererData(cell);

            if (rendererData == null || !(rendererData is GroupRendererData))
            {
                rendererData = new GroupRendererData();

                this.SetRendererData(cell, rendererData);
            }

            return (GroupRendererData) rendererData;
        }
Пример #23
0
 /// <summary>
 /// Initializes a new instance of the CellButtonEventArgs class with 
 /// the specified Cell source, row index and column index
 /// </summary>
 /// <param name="source">The Cell that Raised the event</param>
 /// <param name="column">The Column index of the Cell</param>
 /// <param name="row">The Row index of the Cell</param>
 public CellCheckBoxEventArgs(Cell source, int column, int row)
     : base(source, column, row)
 {
 }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the RowEventArgs class with 
 /// the specified Row source, row index, start index, end index 
 /// and affected Cell
 /// </summary>
 /// <param name="source">The Row that originated the event</param>
 /// <param name="rowIndex">The index of the Row</param>
 /// <param name="cell">The affected Cell</param>
 /// <param name="cellFromIndex">The start index of the affected Cell(s)</param>
 /// <param name="cellToIndex">The end index of the affected Cell(s)</param>
 /// <param name="eventType">The type of event</param>
 public RowEventArgs(Row source, int rowIndex, Cell cell, int cellFromIndex, int cellToIndex, RowEventType eventType)
     : base()
 {
     this.source = source;
     this.rowIndex = rowIndex;
     this.cell = cell;
     this.cellFromIndex = cellFromIndex;
     this.cellToIndex = cellToIndex;
     this.eventType = eventType;
 }
Пример #25
0
 /// <summary>
 /// Initializes a new instance of the CellEventArgs class with 
 /// the specified Cell source and event type
 /// </summary>
 /// <param name="source">The Cell that Raised the event</param>
 /// <param name="eventType">The type of event</param>
 /// <param name="oldValue">The old value of the property</param>
 public CellEventArgs(Cell source, CellEventType eventType, object oldValue)
     : this(source, -1, -1, eventType, oldValue)
 {
 }
Пример #26
0
        /// <summary>
        /// Gets the DropDownRendererData specific data used by the Renderer from 
        /// the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to get the DropDownRendererData data for</param>
        /// <returns>The DropDownRendererData data for the specified Cell</returns>
        protected DropDownRendererData GetDropDownRendererData(Cell cell)
        {
            object rendererData = this.GetRendererData(cell);

            if (rendererData == null || !(rendererData is DropDownRendererData))
            {
                rendererData = new DropDownRendererData();

                this.SetRendererData(cell, rendererData);
            }

            return (DropDownRendererData) rendererData;
        }
Пример #27
0
 /// <summary>
 /// Compares two cells and returns a value indicating whether one is less 
 /// than, equal to or greater than the other.
 /// Both cells are non-null;
 /// </summary>
 /// <param name="cell1"></param>
 /// <param name="cell2"></param>
 /// <returns></returns>
 protected abstract int CompareCells(Cell cell1, Cell cell2);
Пример #28
0
 /// <summary>
 /// Creates the control to show for the given cell.
 /// Use Cell.Data to store any state object for the cell.
 /// </summary>
 /// <param name="cell">The cell that the control will be added to.</param>
 /// <returns></returns>
 public abstract Control GetControl(Cell cell);
Пример #29
0
        /// <summary>
        /// Corrects any differences between the check state of the specified Cell 
        /// and the check state in its rendererData
        /// </summary>
        /// <param name="cell">The Cell to chech</param>
        /// <param name="rendererData">The CheckBoxRendererData to check</param>
        private void ValidateCheckState(Cell cell, CheckBoxRendererData rendererData)
        {
            switch (cell.CheckState)
            {
                case CheckState.Checked:
                {
                    if (rendererData.CheckState <= CheckBoxStates.UncheckedDisabled)
                    {
                        rendererData.CheckState |= (CheckBoxStates) 4;
                    }
                    else if (rendererData.CheckState >= CheckBoxStates.MixedNormal)
                    {
                        rendererData.CheckState -= (CheckBoxStates) 4;
                    }

                    break;
                }

                case CheckState.Indeterminate:
                {
                    if (rendererData.CheckState <= CheckBoxStates.UncheckedDisabled)
                    {
                        rendererData.CheckState |= (CheckBoxStates) 8;
                    }
                    else if (rendererData.CheckState <= CheckBoxStates.CheckedDisabled)
                    {
                        rendererData.CheckState |= (CheckBoxStates) 4;
                    }

                    break;
                }

                default:
                {
                    if (rendererData.CheckState >= CheckBoxStates.MixedNormal)
                    {
                        rendererData.CheckState -= (CheckBoxStates) 8;
                    }
                    else if (rendererData.CheckState >= CheckBoxStates.CheckedNormal)
                    {
                        rendererData.CheckState -= (CheckBoxStates) 4;
                    }

                    break;
                }
            }
        }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the PaintCellEventArgs class with 
 /// the specified graphics, table, row index, column index, selected value,  
 /// focused value, mouse value and clipping rectangle
 /// </summary>
 /// <param name="g">The Graphics used to paint the Cell</param>
 /// <param name="cell">The Cell to be painted</param>
 /// <param name="table">The Table the Cell belongs to</param>
 /// <param name="row">The Row index of the Cell</param>
 /// <param name="column">The Column index of the Cell</param>
 /// <param name="selected">Specifies whether the Cell is selected</param>
 /// <param name="focused">Specifies whether the Cell has focus</param>
 /// <param name="sorted">Specifies whether the Cell's Column is sorted</param>
 /// <param name="editable">Specifies whether the Cell is able to be edited</param>
 /// <param name="enabled">Specifies whether the Cell is enabled</param>
 /// <param name="cellRect">The rectangle in which to paint the Cell</param>
 public PaintCellEventArgs(Graphics g, Cell cell, Table table, int row, int column, bool selected, bool focused, bool sorted, bool editable, bool enabled, Rectangle cellRect)
     : base(g, cellRect)
 {
     this.cell = cell;
     this.table = table;
     this.row = row;
     this.column = column;
     this.selected = selected;
     this.focused = focused;
     this.sorted = sorted;
     this.editable = editable;
     this.enabled = enabled;
     this.cellRect = cellRect;
     this.handled = false;
 }