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>
        /// 开始编辑,增加日历控件的事件绑定
        /// 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();
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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. 5
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. 6
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));
                }
            }
        }