Esempio n. 1
0
        /// <summary>
        /// Handler for the PropertyGrid's SelectedObjectsChanged event
        /// </summary>
        /// <param name="sender">The object that raised the event</param>
        /// <param name="e">An EventArgs that contains the event data</param>
        protected void PropertyGrid_SelectedObjectsChanged(object sender, EventArgs e)
        {
            object[] objects = ((PropertyGrid)sender).SelectedObjects;

            this.previewColumnModel.Columns.Clear();

            if (objects.Length == 1)
            {
                I3Column column = (I3Column)objects[0];
                I3Cell   cell   = this.previewTableModel[0, 0];

                SetCellData(cell, column);

                I3Column       newColumn  = (I3Column)Activator.CreateInstance(column.GetType());
                PropertyInfo[] properties = column.GetType().GetProperties();
                foreach (PropertyInfo property in properties)
                {
                    if (property.GetGetMethod() != null && property.GetSetMethod() != null)
                    {
                        object value = property.GetValue(column, null);
                        property.SetValue(newColumn, value, null);
                    }
                }
                newColumn.Tag              = column;
                newColumn.PropertyChanged += new I3ColumnEventHandler(newColumn_PropertyChanged);
                this.previewColumnModel.Columns.Add(newColumn);
            }

            this.previewTable.Invalidate();
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the ColumnEventArgs class with
 /// the specified Column source, column index and event type
 /// </summary>
 /// <param name="source">The Column that Raised the event</param>
 /// <param name="index">The index of the Column</param>
 /// <param name="eventType">The type of event</param>
 /// <param name="oldValue">The old value of the changed property</param>
 public I3ColumnEventArgs(I3Column source, int index, I3ColumnEventType eventType, object oldValue) : base()
 {
     this.source    = source;
     this.index     = index;
     this.eventType = eventType;
     this.oldValue  = oldValue;
 }
 /// <summary>
 /// Initializes a new instance of the ColumnModelEventArgs class with
 /// the specified ColumnModel source, start index, end index and affected Column
 /// </summary>
 /// <param name="source">The ColumnModel that originated the event</param>
 /// <param name="column">The affected Column</param>
 /// <param name="fromIndex">The start index of the affected Column(s)</param>
 /// <param name="toIndex">The end index of the affected Column(s)</param>
 public I3ColumnModelEventArgs(I3ColumnModel source, I3Column column, int fromIndex, int toIndex) : base()
 {
     this.source    = source;
     this.column    = column;
     this.fromIndex = fromIndex;
     this.toIndex   = toIndex;
 }
Esempio n. 4
0
        /// <summary>
        /// 开始编辑,增加日历控件的事件绑定
        /// Starts editing the Cell
        /// </summary>
        public override void StartEditing()
        {
            this.dateTimePicker.CloseUp += new EventHandler(dateTimePicker_CloseUp);

            I3Column column = this.EditingTable.ColumnModel.Columns[this.EditingCellPos.Column];

            if (column.GetType() == typeof(I3DateTimeColumn))
            {
                I3DateTimeColumn dateTimeColumn = column as I3DateTimeColumn;
                if (dateTimeColumn.DateTimeColumnType == I3DateTimeColumnType.Date)
                {
                    this.dateTimePicker.Format     = DateTimePickerFormat.Short;
                    this.dateTimePicker.ShowUpDown = false;
                }
                else
                {
                    this.dateTimePicker.Format     = DateTimePickerFormat.Time;
                    this.dateTimePicker.ShowUpDown = true;
                }
                this.dateTimePicker.CustomFormat = dateTimeColumn.Format;
            }

            this.TextBox.SelectionLength = 0;

            base.StartEditing();
        }
 /// <summary>
 /// Initializes a new instance of the HeaderMouseEventArgs class with
 /// the specified source Column, Table, column index and column header bounds
 /// </summary>
 /// <param name="column">The Column that Raised the event</param>
 /// <param name="table">The Table the Column belongs to</param>
 /// <param name="index">The index of the Column</param>
 /// <param name="headerRect">The column header's bounding rectangle</param>
 public I3ColumnHeaderMouseEventArgs(I3Column column, I3Table table, int index, Rectangle headerRect)
     : base(MouseButtons.None, 0, -1, -1, 0)
 {
     this.column     = column;
     this.table      = table;
     this.index      = index;
     this.headerRect = headerRect;
 }
 /// <summary>
 /// Initializes a new instance of the HeaderMouseEventArgs class with
 /// the specified source Column, Table, column index, column header bounds
 /// and MouseEventArgs
 /// </summary>
 /// <param name="column">The Column that Raised the event</param>
 /// <param name="table">The Table the Column belongs to</param>
 /// <param name="index">The index of the Column</param>
 /// <param name="headerRect">The column header's bounding rectangle</param>
 /// <param name="mea">The MouseEventArgs that contains data about the
 /// mouse event</param>
 public I3ColumnHeaderMouseEventArgs(I3Column column, I3Table table, int index, Rectangle headerRect, MouseEventArgs mea)
     : base(mea.Button, mea.Clicks, mea.X, mea.Y, mea.Delta)
 {
     this.column     = column;
     this.table      = table;
     this.index      = index;
     this.headerRect = headerRect;
 }
Esempio n. 7
0
        void PopupCellEditor_BeginEdit(object sender, I3CellEditEventArgs e)
        {
            I3Column column = e.Table.ColumnModel.Columns[e.Column];

            if (column.GetType() == typeof(I3PopupColumn))
            {
                I3PopupColumn popupColumn = (I3PopupColumn)column;
                popupColumn.OnBeforePopup(e);
            }
        }
 /// <summary>
 /// Initializes a new instance of the PaintHeaderEventArgs class with
 /// the specified graphics, column, table, column index, header style
 /// and clipping rectangle
 /// </summary>
 /// <param name="g">The Graphics used to paint the Column header</param>
 /// <param name="column">The Column to be painted</param>
 /// <param name="table">The Table the Column's ColumnModel belongs to</param>
 /// <param name="columnIndex">The index of the Column in the Table's ColumnModel</param>
 /// <param name="headerStyle">The style of the Column's header</param>
 /// <param name="headerRect">The Rectangle that represents the rectangle
 /// in which to paint</param>
 public I3PaintColumnHeaderEventArgs(Graphics g, I3Column column, I3Table table, int columnIndex, ColumnHeaderStyle headerStyle, Rectangle headerRect)
     : base(g, headerRect)
 {
     this._column      = column;
     this._table       = table;
     this._columnIndex = columnIndex;
     this._column      = column;
     this._headerStyle = headerStyle;
     this._headerRect  = headerRect;
     this._handled     = false;
 }
Esempio n. 9
0
        void ExtendCellEditor_BeginEdit(object sender, I3CellEditEventArgs e)
        {
            I3Column column = e.Table.ColumnModel.Columns[e.Column];

            if (column.GetType() == typeof(I3ExtendColumn))
            {
                I3ExtendColumn extendColumn = (I3ExtendColumn)column;
                extendColumn.OnExtendEdit(e);
            }
            e.Cancel = true;
        }
Esempio n. 10
0
 /// <summary>
 /// 计算将ColumnHeader绘制完全时需要的大小
 /// </summary>
 /// <param name="g"></param>
 /// <param name="column"></param>
 /// <param name="text"></param>
 /// <param name="font"></param>
 /// <param name="sf"></param>
 /// <param name="imageWidth"></param>
 public virtual void CalColumnHeaderNeedWidth(Graphics g, I3Column column, string text, Font font, StringFormat sf, int imageWidth)
 {
     if (text != null && text.Length != 0)
     {
         SizeF sizeF = g.MeasureString(text, font, I3ColumnModel.MaxAutoColumnWidth_Const, sf);
         column.NeedWidth = sizeF.Width + imageWidth + 6;
     }
     else
     {
         column.NeedWidth = I3ColumnModel.MinColumnWidth_Const;
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Raises the MouseUp event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseUp(I3CellMouseEventArgs e)
        {
            base.OnMouseUp(e);

            // get the button renderer data
            I3ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell);

            // check for the left mouse button
            if (e.Button == MouseButtons.Left)
            {
                Rectangle buttonRect = this.CalcButtonBounds();

                // if the mouse pointer is over the button, make sure
                // the button is "hot"
                if (buttonRect.Contains(e.X, e.Y))
                {
                    rendererData.ButtonState = I3PushButtonStates.Hot;

                    e.Table.Invalidate(e.CellRect);

                    // check if the click started inside the button.  if
                    // it did, Raise the tables CellButtonClicked event
                    if (buttonRect.Contains(rendererData.ClickPoint))
                    {
                        I3Column column = e.Table.ColumnModel.Columns[e.Column];
                        if (column.GetType() == typeof(I3ButtonColumn))
                        {
                            I3ButtonColumn buttonColumn = (I3ButtonColumn)column;
                            buttonColumn.OnButtonClicked(new I3CellButtonEventArgs(e.Cell, e.Column, e.Row));
                        }
                        //e.Table.OnCellButtonClicked(new CellButtonEventArgs(e.Cell, e.Column, e.Row));
                    }
                }
                else
                {
                    // the mouse was released somewhere outside of the button,
                    // so make set the button back to its normal state
                    if (rendererData.ButtonState != I3PushButtonStates.Normal)
                    {
                        rendererData.ButtonState = I3PushButtonStates.Normal;

                        e.Table.Invalidate(e.CellRect);
                    }
                }
            }

            // reset the click point
            rendererData.ClickPoint = Point.Empty;
        }
Esempio n. 12
0
        /// <summary>
        /// Destroys the specified instance of the object
        /// </summary>
        /// <param name="instance">The object to destroy</param>
        protected override void DestroyInstance(object instance)
        {
            if (instance != null && instance is I3Column)
            {
                I3Column column = (I3Column)instance;

                // the specified column is about to be destroyed
                // so we need to remove it from the ColumnCollection first
                this.columns.Remove(column);
                column.PropertyChanged -= new IE310.Table.Events.I3ColumnEventHandler(column_PropertyChanged);
            }

            base.DestroyInstance(instance);
            this.CheckCells();
        }
Esempio n. 13
0
 private void SetCellData(I3Cell cell, I3Column column)
 {
     if (column is I3ButtonColumn)
     {
         cell.Data = null;
         cell.Data = "Button";
     }
     else if (column is I3CheckBoxColumn)
     {
         cell.Data    = null;
         cell.Data    = "Checkbox";
         cell.Checked = true;
     }
     else if (column is I3ColorColumn)
     {
         cell.Data = null;
         cell.Data = Color.Red;
     }
     else if (column is I3ComboBoxColumn)
     {
         cell.Data = null;
         cell.Data = "ComboBox";
     }
     else if (column is I3DateTimeColumn)
     {
         cell.Data = null;
         cell.Data = DateTime.Now;
     }
     else if (column is I3ImageColumn)
     {
         cell.Data = null;
         cell.Data = "Image";
     }
     else if (column is I3NumberColumn || column is I3ProgressBarColumn)
     {
         cell.Data = null;
         cell.Data = 50;
     }
     else if (column is I3TextColumn)
     {
         cell.Data = null;
         cell.Data = "Text";
     }
     else
     {
         cell.Data = null;
     }
 }
Esempio n. 14
0
 void newColumn_PropertyChanged(object sender, I3ColumnEventArgs e)
 {
     if (e.EventType == I3ColumnEventType.WidthChanged)
     {
         I3Column newColumn = sender as I3Column;
         if (newColumn == null || newColumn.Tag == null)
         {
             return;
         }
         I3Column column = newColumn.Tag as I3Column;
         if (column == null)
         {
             return;
         }
         column.Width = newColumn.Width;
     }
 }
Esempio n. 15
0
        /// <summary>
        /// Creates a new instance of the specified collection item type
        /// </summary>
        /// <param name="itemType">The type of item to create</param>
        /// <returns>A new instance of the specified object</returns>
        protected override object CreateInstance(Type itemType)
        {
            I3Column column = (I3Column)base.CreateInstance(itemType);

            // newly created items aren't added to the collection
            // until editing has finished.  we'd like the newly
            // created column to show up in the table immediately
            // so we'll add it to the ColumnCollection now
            this.columns.Add(column);

            // for some reason (might be beacause Column is an
            // abstract class) the table doesn't get redrawn
            // when a columns property changes, but we can get
            // around that by subscribing to the columns
            // PropertyChange event and passing the message on
            // to the table ourselves
            column.PropertyChanged += new IE310.Table.Events.I3ColumnEventHandler(column_PropertyChanged);

            this.CheckCells();
            return(column);
        }
Esempio n. 16
0
        /// <summary>
        /// Raises the KeyUp event
        /// </summary>
        /// <param name="e">A CellKeyEventArgs that contains the event data</param>
        public override void OnKeyUp(I3CellKeyEventArgs e)
        {
            base.OnKeyUp(e);

            // get the button renderer data
            I3ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell);

            //
            if (e.KeyData == Keys.Enter || e.KeyData == Keys.Space)
            {
                rendererData.ButtonState = I3PushButtonStates.Normal;

                e.Table.Invalidate(e.CellRect);
                I3Column column = e.Table.ColumnModel.Columns[e.Column];
                if (column.GetType() == typeof(I3ButtonColumn))
                {
                    I3ButtonColumn buttonColumn = (I3ButtonColumn)column;
                    buttonColumn.OnButtonClicked(new I3CellButtonEventArgs(e.Cell, e.Column, e.Row));
                }
            }
        }
Esempio n. 17
0
 /// <summary>
 /// 设置引发事件的列
 /// </summary>
 /// <param name="column"></param>
 internal void SetColumn(I3Column column)
 {
     this.source = column;
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the ColumnEventArgs class with
 /// the specified Column source, column index and event type
 /// </summary>
 /// <param name="source">The Column that Raised the event</param>
 /// <param name="eventType">The type of event</param>
 /// <param name="oldValue">The old value of the changed property</param>
 public I3ColumnEventArgs(I3Column source, I3ColumnEventType eventType, object oldValue) : this(source, -1, eventType, oldValue)
 {
 }
 /// <summary>
 /// 设置绘制的列
 /// </summary>
 /// <param name="column"></param>
 internal void SetColumn(I3Column column)
 {
     this._column = column;
 }