///<summary>Registers an IGridBehavior for one or more Singularity schemas.</summary> ///<param name="schemas">The schemas to apply the behavior to.</param> ///<param name="behavior">The IGridBehavior instance.</param> public static void RegisterBehavior(IEnumerable <TableSchema> schemas, IGridBehavior behavior) { if (schemas == null) { throw new ArgumentNullException("schemas"); } RegisterBehavior(t => schemas.Contains(TableSchema.GetSchema(t)), behavior); }
///<summary>Registers an IGridBehavior for a Singularity schema.</summary> ///<param name="schema">The schema to apply the behavior to.</param> ///<param name="behavior">The IGridBehavior instance.</param> public static void RegisterBehavior(TableSchema schema, IGridBehavior behavior) { if (schema == null) { throw new ArgumentNullException("schema"); } RegisterBehavior(t => TableSchema.GetSchema(t) == schema, behavior); }
public virtual void UnlockBehavior(IGridBehavior behavior) { if (this.lockedBehavior != behavior) { return; } this.lockedBehavior = (IGridBehavior)null; }
public virtual IGridBehavior GetBehavior(System.Type rowType) { IGridBehavior lockedBehavior = this.lockedBehavior; if (lockedBehavior == null) { this.rowBehaviors.TryGetValue(rowType, out lockedBehavior); } return(lockedBehavior ?? this.DefaultRowBehavior); }
public virtual void LockBehavior(IGridBehavior behavior) { if (behavior == null) { throw new ArgumentNullException(nameof(behavior)); } if (this.lockedBehavior != null && this.lockedBehavior != behavior) { throw new InvalidOperationException("There is already locked behavior of type " + this.lockedBehavior.GetType().FullName); } this.lockedBehavior = behavior; }
public virtual bool UnregisterBehavior(System.Type rowType) { IGridBehavior gridBehavior = (IGridBehavior)null; this.rowBehaviors.TryGetValue(rowType, out gridBehavior); if (gridBehavior == null) { return(false); } this.rowBehaviors.Remove(rowType); return(true); }
///<summary>Registers an IGridBehavior for matching datasources.</summary> ///<param name="selector">A delegate that determines which datasources the behavior should be applied to.</param> ///<param name="behavior">The IGridBehavior instance.</param> public static void RegisterBehavior(Func <object, bool> selector, IGridBehavior behavior) { if (selector == null) { throw new ArgumentNullException("selector"); } if (behavior == null) { throw new ArgumentNullException("behavior"); } UIThread.Verify(); behaviors.AddFirst(new KeyValuePair <Func <object, bool>, IGridBehavior>(selector, behavior)); }
public override bool OnMouseUp(MouseEventArgs e) { if (base.OnMouseUp(e)) { return(true); } if (this.scrollBarAtPoint != null) { this.scrollBarAtPoint = (RadScrollBarElement)null; return(false); } IGridBehavior rowBehaviorAtPoint = this.GetRowBehaviorAtPoint(e.Location); return(rowBehaviorAtPoint != null && rowBehaviorAtPoint.OnMouseUp(e)); }
public BaseGridBehavior() { this.rowBehaviors = (IDictionary <System.Type, IGridBehavior>) new Dictionary <System.Type, IGridBehavior>(); this.scrollReason = BaseGridBehavior.ScrollReason.MouseWheel; this.lockedBehavior = (IGridBehavior)null; this.originalCursor = (Cursor)null; this.scrollBarAtPoint = (RadScrollBarElement)null; this.defaultRowBehavior = new GridRowBehavior(); this.RegisterBehavior(typeof(GridViewDataRowInfo), (IGridBehavior) new GridDataRowBehavior()); this.RegisterBehavior(typeof(GridViewNewRowInfo), (IGridBehavior) new GridNewRowBehavior()); this.RegisterBehavior(typeof(GridViewGroupRowInfo), (IGridBehavior) new GridGroupRowBehavior()); this.RegisterBehavior(typeof(GridViewFilteringRowInfo), (IGridBehavior) new GridFilterRowBehavior()); this.RegisterBehavior(typeof(GridViewTableHeaderRowInfo), (IGridBehavior) new GridHeaderRowBehavior()); this.RegisterBehavior(typeof(GridViewSearchRowInfo), (IGridBehavior) new GridSearchRowBehavior()); this.RegisterBehavior(typeof(GridViewHierarchyRowInfo), (IGridBehavior) new GridHierarchyRowBehavior()); this.RegisterBehavior(typeof(GridViewDetailsRowInfo), (IGridBehavior) new GridDetailViewRowBehavior()); this.scrollTimer = new Timer(); this.scrollTimer.Interval = 10; this.scrollTimer.Tick += new EventHandler(this.scrollTimer_Tick); }
public override bool OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left && this.OnMouseDownLeft(e) || e.Button == MouseButtons.Right && this.OnMouseDownRight(e) || base.OnMouseDown(e)) { return(true); } this.scrollBarAtPoint = GridVisualElement.GetElementAtPoint <RadScrollBarElement>((RadElementTree)this.GridViewElement.ElementTree, e.Location); if (this.scrollBarAtPoint != null && this.scrollBarAtPoint.Parent is GridTableElement) { GridViewEditManager editorManager = this.GridControl.EditorManager; bool whenValidationFails = editorManager.CloseEditorWhenValidationFails; editorManager.CloseEditorWhenValidationFails = true; editorManager.CloseEditor(); editorManager.CloseEditorWhenValidationFails = whenValidationFails; return(false); } IGridBehavior rowBehaviorAtPoint = this.GetRowBehaviorAtPoint(e.Location); return(rowBehaviorAtPoint != null && rowBehaviorAtPoint.OnMouseDown(e)); }
public override bool OnMouseMove(MouseEventArgs e) { if (this.RowAtPoint == null && e.Button == MouseButtons.None && (Cursor.Current != Cursors.Default && this.OriginalCursor != (Cursor)null)) { this.GridControl.Cursor = this.OriginalCursor; this.OriginalCursor = (Cursor)null; } if (this.GridViewElement.ElementTree.GetElementAtPoint(e.Location) is GroupPanelSizeGripElement) { this.GridControl.Cursor = Cursors.SizeNS; return(true); } if (base.OnMouseMove(e)) { return(true); } if (this.scrollBarAtPoint != null) { return(false); } IGridBehavior rowBehaviorAtPoint = this.GetRowBehaviorAtPoint(e.Location); if (this.hoveredBehavior != null && this.hoveredBehavior != rowBehaviorAtPoint) { this.hoveredBehavior.OnMouseLeave((EventArgs)e); this.hoveredBehavior = (IGridBehavior)null; } if (rowBehaviorAtPoint != null) { if (rowBehaviorAtPoint != this.hoveredBehavior) { this.hoveredBehavior = rowBehaviorAtPoint; this.hoveredBehavior.OnMouseEnter((EventArgs)e); } if (rowBehaviorAtPoint.OnMouseMove(e)) { return(true); } } return(false); }
public virtual void RegisterBehavior(System.Type rowType, IGridBehavior rowBehavior) { IGridBehavior gridBehavior = (IGridBehavior)null; this.rowBehaviors.TryGetValue(rowType, out gridBehavior); if (gridBehavior == null) { this.rowBehaviors.Add(rowType, rowBehavior); if (this.GridViewElement == null) { return; } rowBehavior.Initialize(this.GridViewElement); } else { this.rowBehaviors[rowType] = rowBehavior; if (this.GridViewElement == null) { return; } rowBehavior.Initialize(this.GridViewElement); } }
public override bool OnDoubleClick(EventArgs e) { IGridBehavior currentRowBehavior = this.GetCurrentRowBehavior(); return(currentRowBehavior != null && currentRowBehavior.OnDoubleClick(e)); }
public override bool ProcessKey(KeyEventArgs keys) { IGridBehavior currentRowBehavior = this.GetCurrentRowBehavior(); if (currentRowBehavior != null && currentRowBehavior.ProcessKey(keys)) { return(true); } switch (keys.KeyCode) { case Keys.Prior: return(this.ProcessPageUpKey(keys)); case Keys.Next: return(this.ProcessPageDownKey(keys)); case Keys.Apps: GridCellElement currentCell = (GridCellElement)this.GridViewElement.CurrentCell; if (currentCell != null) { Point control = currentCell.PointToControl(new Point(currentCell.Size.Width, currentCell.Size.Height)); this.GridViewElement.ContextMenuManager.ShowContextMenu((IContextMenuProvider)currentCell, control); } return(true); default: if (!keys.Control) { return(false); } switch (keys.KeyCode) { case Keys.C: if (this.GridViewElement.Template.ClipboardCopyMode != GridViewClipboardCopyMode.Disable) { this.GridViewElement.Template.Copy(); break; } break; case Keys.F: if (this.GridControl.AllowSearchRow) { if (!this.GridControl.MasterTemplate.MasterViewInfo.TableSearchRow.IsVisible) { this.GridControl.MasterTemplate.MasterViewInfo.TableSearchRow.IsVisible = true; this.GridViewElement.UpdateLayout(); } this.GridViewElement.TableElement.FindDescendant <GridSearchCellElement>().SearchTextBox.Focus(); break; } break; case Keys.V: if (!this.GridViewElement.Template.GridReadOnly && !this.GridViewElement.Template.ReadOnly && (this.GridControl.CurrentColumn != null && !this.GridControl.CurrentColumn.ReadOnly)) { this.GridViewElement.Template.Paste(); break; } break; case Keys.X: if (!this.GridViewElement.Template.GridReadOnly && !this.GridViewElement.Template.ReadOnly && (this.GridControl.CurrentColumn != null && !this.GridControl.CurrentColumn.ReadOnly) && this.GridViewElement.Template.ClipboardCutMode != GridViewClipboardCutMode.Disable) { this.GridViewElement.Template.Cut(); break; } break; } return(false); } }
public override bool OnContextMenu(MouseEventArgs e) { IGridBehavior currentRowBehavior = this.GetCurrentRowBehavior(); return(currentRowBehavior != null && currentRowBehavior.OnContextMenu(e)); }
public override bool OnMouseWheel(MouseEventArgs e) { HandledMouseEventArgs handledMouseEventArgs = e as HandledMouseEventArgs; if (handledMouseEventArgs != null && handledMouseEventArgs.Handled) { return(false); } int num1 = Math.Max(1, e.Delta / SystemInformation.MouseWheelScrollDelta); int num2 = Math.Sign(e.Delta) * num1 * SystemInformation.MouseWheelScrollLines; bool flag = Control.ModifierKeys == Keys.Shift; RadElement elementAtPoint = this.GridControl.ElementTree.GetElementAtPoint(e.Location); if (elementAtPoint != null) { GroupPanelElement ancestor = elementAtPoint.FindAncestor <GroupPanelElement>(); if (ancestor != null) { RadScrollBarElement scrollBarElement = !flag ? ancestor.ScrollView.VScrollBar : ancestor.ScrollView.HScrollBar; int num3 = scrollBarElement.Value - num2 * scrollBarElement.SmallChange; if (num3 > scrollBarElement.Maximum - scrollBarElement.LargeChange + 1) { num3 = scrollBarElement.Maximum - scrollBarElement.LargeChange + 1; } if (num3 < scrollBarElement.Minimum) { num3 = scrollBarElement.Minimum; } scrollBarElement.Value = num3; return(true); } } IGridBehavior rowBehaviorAtPoint = this.GetRowBehaviorAtPoint(e.Location); if (rowBehaviorAtPoint != null && rowBehaviorAtPoint.OnMouseWheel(e)) { return(true); } this.tableElement = (GridTableElement)null; if (this.GridViewElement.UseScrollbarsInHierarchy) { this.tableElement = this.ScrollableTableElement(e.Delta < 0); } else if (this.GridViewElement.SplitMode != RadGridViewSplitMode.None) { this.tableElement = this.GetGridTableElementAtPoint(e.Location); } if (this.tableElement == null) { this.tableElement = this.GridViewElement.TableElement; } if (this.tableElement != null && (!this.GridViewElement.IsInEditMode || this.GridViewElement.EndEdit())) { RadScrollBarElement scrollBarElement = !flag ? this.tableElement.VScrollBar : this.tableElement.HScrollBar; int num3 = scrollBarElement.Value - num2 * scrollBarElement.SmallChange; if (num3 > scrollBarElement.Maximum - scrollBarElement.LargeChange + 1) { num3 = scrollBarElement.Maximum - scrollBarElement.LargeChange + 1; } if (num3 < scrollBarElement.Minimum) { num3 = 0; } else if (num3 > scrollBarElement.Maximum) { num3 = scrollBarElement.Maximum; } if (num3 != scrollBarElement.Value) { if (this.scrollDelta == 0) { this.scrollTimer.Start(); } this.scrollDelta += num3 - scrollBarElement.Value; if (handledMouseEventArgs != null) { handledMouseEventArgs.Handled = true; } } } return(false); }
public override bool OnMouseDoubleClick(MouseEventArgs e) { IGridBehavior rowBehaviorAtPoint = this.GetRowBehaviorAtPoint(e.Location); return(rowBehaviorAtPoint != null && rowBehaviorAtPoint.OnMouseDoubleClick(e)); }
public override bool ProcessKeyPress(KeyPressEventArgs keys) { IGridBehavior currentRowBehavior = this.GetCurrentRowBehavior(); return(currentRowBehavior != null && currentRowBehavior.ProcessKeyPress(keys)); }