| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System;
- using System.Reflection;
- using System.Windows.Forms;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- namespace Core.Mes.Client.Comm.Control
- {
- public class ExtendedCheckBoxUIElement : CheckBoxUIElement
- {
- public ExtendedCheckBoxUIElement(UIElement parent)
- : base(parent)
- {
- this.ThreeState = false;
- }
- public override CheckState CheckState
- {
- get
- {
- return base.CheckState;
- }
- set
- {
- //CheckState checkState = this.CheckState;
- base.CheckState = value;
- //if (checkState != value)
- //{
- // this.OnCheckStateChange();
- //}
- }
- }
- protected override void OnCheckStateChange()
- {
- base.OnCheckStateChange();
- ExtendedUltraGrid ultraGrid = this.Control as ExtendedUltraGrid;
- HeaderUIElement headerUIElement = this.GetAncestor(typeof(HeaderUIElement))as HeaderUIElement;
- UltraGridRow ultraGridRow = headerUIElement.GetContext(typeof(UltraGridRow))as UltraGridRow;
- UltraGridGroupByRow parentRow = ultraGridRow.ParentRow as UltraGridGroupByRow;
- if (null != parentRow)
- {
- parentRow.Tag = this.CheckState;
- this.SetAllGridRowSelected(parentRow.Rows, this.CheckState);
- }
- else
- {
- this.SetAllGridRowSelected((this.Control as UltraGrid).Rows, this.CheckState);
- }
- if (!ultraGrid.IsGroupMode)
- {
- ultraGrid.CheckState = this.CheckState;
- }
- }
- private void SetAllGridRowSelected(RowsCollection rows, CheckState state)
- {
- foreach (var row in rows)
- {
- if (row.IsGroupByRow)
- {
- row.Tag = this.CheckState;
- SetAllGridRowSelected(((UltraGridGroupByRow)row).Rows, state);
- }
- else
- {
- string selectAllColumnName = (this.Control as ExtendedUltraGrid).SelectAllColumnName;
- if (row.Activation == Activation.Disabled) continue;
- if (!row.Band.Columns.Exists(selectAllColumnName)) continue;
- if (row.Band.Columns[selectAllColumnName].CellActivation == Activation.Disabled) continue;
- if (null == row.Cells) continue;
- if (Convert.ToBoolean(row.Cells[selectAllColumnName].Value) != Convert.ToBoolean(state))
- {
- row.Cells[selectAllColumnName].Value = state;
- (this.Control as ExtendedUltraGrid).ChangeCell(row.Cells[selectAllColumnName]);
- }
- row.Update();
- }
- }
- }
- }
- }
|