//--------------------------------------------------------------------------------// #region method GetMouseInTableView /// <summary> /// Gets view what is at specified point. /// </summary> /// <param name="pt"></param> /// <returns></returns> private WGridTableView GetMouseInTableView(Point pt) { // Focused view is in edit mode, skip all mouse events // if(m_pFocusedView != null && m_pFocusedView.ActiveEditor != null){ // return null; // } for (int i = m_pActiveViews.Count - 1; i > -1; i--) { WGridTableView view = (WGridTableView)m_pActiveViews[i]; if (view.Bounds.Contains(pt)) { if (m_pMouseView != view) { // Mouse in view changed, send Exit note. if (m_pMouseView != null) { m_pMouseView.Process_mouseExited(null); } m_pMouseView = view; } return(view); } } return(m_pFocusedView); }
/// <summary> /// /// </summary> /// <param name="view"></param> /// <param name="value"></param> internal protected virtual void StartEdit(WGridTableView view, object value) { m_pGridView = view; this.Value = value; this.SelectAll(); this.Invalidate(); }
/// <summary> /// Is called when specified view minimized. /// </summary> /// <param name="view"></param> internal protected void OnViewMinimized(WGridTableView view) { // Show all grid components which was hidden for maximized view for (int i = 0; i < m_pMaximizeHiddenControls.Count; i++) { Control c = (Control)m_pMaximizeHiddenControls[i]; c.Visible = true; } m_pMaximizedView = null; }
//----------------------------------------------------------------------------// //--- Forward mouse events to view under mouse cursor ------------------------// #region override method OnMouseDown protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); WGridTableView view = this.GetMouseInTableView(new Point(e.X, e.Y)); if (view != null) { view.Process_mousePressed(e); } }
/// <summary> /// Sets specified view as focused view. /// </summary> /// <param name="view">Grid view.</param> internal void SetFocusedView(WGridTableView view) { if (m_pFocusedView != view) { m_pFocusedView = view; RaiseFocusedViewChanged(); } else { m_pFocusedView = view; } }
protected override void OnDoubleClick(EventArgs e) { base.OnDoubleClick(e); int x = this.PointToClient(Control.MousePosition).X; int y = this.PointToClient(Control.MousePosition).Y; WGridTableView view = this.GetMouseInTableView(new Point(x, y)); if (view != null) { view.Process_mouseClicked(new MouseEventArgs(MouseButtons.Left, 2, x, y, 0)); } }
/// <summary> /// Adss specified view to the collection. /// </summary> /// <param name="view">View to add.</param> /// <exception cref="ArgumentNullException">Is raised when <b>view</b> is null reference.</exception> public void Add(WGridTableView view) { if (view == null) { throw new ArgumentNullException("view"); } if (Contains(view.Name)) { throw new ArgumentException("View with the sepcified name '" + view.Name + "' already exists in the collection."); } m_pList.Add(view); }
/// <summary> /// Removes with with the specified name from the collection. /// </summary> /// <param name="name">View name.</param> /// <exception cref="ArgumentNullException">Is raised when <b>name</b> is null reference.</exception> public void Remove(string name) { if (name == null) { throw new ArgumentNullException("name"); } WGridTableView view = this[name]; if (view != null) { m_pList.Remove(view); } }
/// <summary> /// Default constructor. /// </summary> public WGridControl() { m_pFocusedView = new WGridTableView(this); m_pMainView = m_pFocusedView; m_pActiveViews = new List <WGridTableView>(); m_pActiveViews.Add(m_pFocusedView); m_pMaximizeHiddenControls = new ArrayList(); SetStyle(ControlStyles.Selectable | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); m_pDelayedPainterTimer = new Timer(); m_pDelayedPainterTimer.Interval = 40; m_pDelayedPainterTimer.Tick += new EventHandler(m_pDelayedPainterTimer_Tick); }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (m_pDragView != null) { m_pDragView.Process_mouseReleased(e); m_pDragView = null; } else { WGridTableView view = this.GetMouseInTableView(new Point(e.X, e.Y)); if (view != null) { view.Process_mouseReleased(e); } } }
/// <summary> /// Is called when specified view maximized. /// </summary> /// <param name="view"></param> internal protected void OnViewMaximized(WGridTableView view) { // Hide all grid components which owner isn't maximized view ArrayList viewC = view.Components; foreach (Control comp in this.Controls) { if (comp.Visible) { if (!viewC.Contains(comp)) { comp.Visible = false; m_pMaximizeHiddenControls.Add(comp); } } } m_pMaximizedView = view; }
/// <summary> /// Default constructor. /// </summary> public WGridControl() { m_pViews = new WGridViewCollection(); m_pActiveViews = new List <WGridTableView>(); this.ViewStyle = ViewStyle.staticViewStyle; m_pMaximizeHiddenControls = new ArrayList(); SetStyle(ControlStyles.Selectable | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); m_pDelayedPainterTimer = new Timer(); m_pDelayedPainterTimer.Interval = 40; m_pDelayedPainterTimer.Tick += new EventHandler(m_pDelayedPainterTimer_Tick); m_pDelayedPainterTimer.Enabled = false; WGridTableView mainView = new WGridTableView("main", this); m_pViews.Add(mainView); this.MainView = mainView; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (m_pDragView == null && e.Button == MouseButtons.Left) { m_pDragView = this.GetMouseInTableView(new Point(e.X, e.Y)); } if (m_pDragView != null) { m_pDragView.Process_mouseDragged(e); } else if (e.Button == MouseButtons.None) { WGridTableView view = this.GetMouseInTableView(new Point(e.X, e.Y)); if (view != null) { view.Process_mouseMoved(e); } } }
/// <summary> /// Default constructor. /// </summary> /// <param name="ownerView">View that owns this row info.</param> /// <param name="row">Row what info this row info holds.</param> public _RowInfo(WGridTableView ownerView, DataRowView row) { m_pOwnerView = ownerView; m_pRow = row; }
/// <summary> /// /// </summary> /// <param name="view"></param> /// <param name="value"></param> internal protected override void StartEdit(WGridTableView view, object value) { m_pTime.Focus(); base.StartEdit(view, value); }
/// <summary> /// Default constructor. /// </summary> /// <param name="parentView">View that owns these grid columns.</param> internal WGridColumns(WGridTableView parentView) { m_pView = parentView; m_pColumns = new List <WGridColumn>(); }
/// <summary> /// Paints default editor. This is called foreach visible cell what isn't active editor. /// </summary> /// <param name="view"></param> /// <param name="g"></param> /// <param name="value"></param> /// <param name="cellBounds"></param> /// <param name="selected"></param> /// <param name="column"></param> public virtual void PaintDefault(WGridTableView view, Graphics g, Object value, Rectangle cellBounds, bool selected, WGridColumn column) { ViewStyle m_ViewStyle = view.Grid.ViewStyle; Color textColor = selected ? Color.White : Color.Black; if (value != null && value.GetType() == typeof(Decimal)) { if ((decimal)value < 0) { textColor = Color.Red; } } if (column.CellTextFormat.Length == 0 && value != null && value.GetType() == typeof(DateTime)) { if ((DateTime)value == DateTime.MinValue) { value = ""; } else { value = ((DateTime)value).ToString("dd.MM.yyyy"); } } else if (value != null && value.GetType() == typeof(bool)) { Rectangle checkRect = new Rectangle(cellBounds.X + (int)(cellBounds.Width - 12) / 2, cellBounds.Y + (int)(cellBounds.Height - 13) / 2, 12, 12); // Fill checkrect g.FillRectangle(new SolidBrush(Color.White), checkRect); if ((bool)value) { // Draw check (Lines from up to down). g.DrawLine(new Pen(Color.Black), checkRect.X + 3, checkRect.Y + 5, checkRect.X + 3, checkRect.Y + 5 + 2); g.DrawLine(new Pen(Color.Black), checkRect.X + 4, checkRect.Y + 6, checkRect.X + 4, checkRect.Y + 6 + 2); g.DrawLine(new Pen(Color.Black), checkRect.X + 5, checkRect.Y + 7, checkRect.X + 5, checkRect.Y + 7 + 2); g.DrawLine(new Pen(Color.Black), checkRect.X + 6, checkRect.Y + 6, checkRect.X + 6, checkRect.Y + 6 + 2); g.DrawLine(new Pen(Color.Black), checkRect.X + 7, checkRect.Y + 5, checkRect.X + 7, checkRect.Y + 5 + 2); g.DrawLine(new Pen(Color.Black), checkRect.X + 8, checkRect.Y + 4, checkRect.X + 8, checkRect.Y + 4 + 2); g.DrawLine(new Pen(Color.Black), checkRect.X + 9, checkRect.Y + 3, checkRect.X + 9, checkRect.Y + 3 + 2); } // Draw rect around check g.DrawRectangle(new Pen(m_ViewStyle.GetBorderColor(false)), checkRect); value = null; // Force not to draw text } else if (value != null && column.CellTextFormat.Length > 0) { if (value is IFormattable) { value = ((IFormattable)value).ToString(column.CellTextFormat, null); } } if (value != null) { LumiSoft.UI.Controls.Paint.DrawText(g, textColor, m_ViewStyle.GridCellsFont, value.ToString(), cellBounds, column.CellsTextAlign); } }