DotNet 4.8.1 build of DotNetBar

This commit is contained in:
2025-02-07 10:35:23 -05:00
parent 33439b63a0
commit 6b0a5d60f4
2609 changed files with 989814 additions and 7 deletions

View File

@@ -0,0 +1,105 @@
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// EditorPanel
///</summary>
[ToolboxItem(false)]
public class EditorPanel : Control
{
#region Private variables
private Size _SizeEx;
private Point _OffsetEx;
private GridCell _GridCell;
#endregion
///<summary>
/// Constructor
///</summary>
public EditorPanel()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
#region Public properties
#region GridCell
///<summary>
/// GridCell
///</summary>
public GridCell GridCell
{
get { return (_GridCell); }
internal set { _GridCell = value; }
}
#endregion
#endregion
#region Internal properties
#region OffsetEx
internal Point OffsetEx
{
get { return (_OffsetEx); }
set { _OffsetEx = value; }
}
#endregion
#region SizeEx
internal Size SizeEx
{
get { return (_SizeEx); }
set { _SizeEx = value; }
}
#endregion
#endregion
#region OnPaintBackground
/// <summary>
/// Background painting
/// </summary>
/// <param name="e"></param>
protected override void OnPaintBackground(PaintEventArgs e)
{
Graphics g = e.Graphics;
if (_GridCell != null && _GridCell.GridColumn != null)
{
Rectangle r = new Rectangle(_OffsetEx, _SizeEx);
VisualStyle style = _GridCell.GetEffectiveStyle();
if (r.IsEmpty == false)
{
if (_GridCell.SuperGrid.DoPreRenderCellEvent(g, _GridCell, RenderParts.Background, r) == false)
{
using (Brush br = style.Background.GetBrush(r))
g.FillRectangle(br, r);
_GridCell.SuperGrid.DoPostRenderCellEvent(g, _GridCell, RenderParts.Background, r);
}
}
}
else
{
base.OnPaintBackground(e);
}
}
#endregion
}
}

View File

@@ -0,0 +1,517 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridCheckBoxEditControl
///</summary>
[ToolboxItem(false)]
public class GridBubbleBarEditControl : BubbleBar, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.Both;
#endregion
///<summary>
/// GridBubbleBarEditControl
///</summary>
public GridBubbleBarEditControl()
{
ShowTooltips = false;
ButtonClick += EditControlButtonClick;
#if !TRIAL
LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F";
#endif
}
#region Hidden properties
///<summary>
/// ShowTooltips
///</summary>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new bool ShowTooltips
{
get { return (base.ShowTooltips); }
set { base.ShowTooltips = value; }
}
#endregion
#region EditControlButtonClick
private void EditControlButtonClick(object sender, ClickEventArgs e)
{
if (_SuspendUpdate == false)
{
if (_Cell != null)
{
_Cell.Value = SelectedTab.Buttons.IndexOf((BubbleButton) sender);
_Cell.EditorValueChanged(this);
_Cell.EndEdit();
}
}
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaint
/// <summary>
/// OnPaint
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
PaintControl(e);
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public virtual bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get { return (Text); }
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set
{
if (_EditorPanel != null)
_EditorPanel.VisibleChanged -= EditorPanelVisibleChanged;
_EditorPanel = value;
if (_EditorPanel != null)
_EditorPanel.VisibleChanged += EditorPanelVisibleChanged;
}
}
void EditorPanelVisibleChanged(object sender, EventArgs e)
{
if (_EditorPanel.Visible == false)
StopBubbleEffect();
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (_Cell.Value); }
set { }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public virtual bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.None); }
}
#endregion
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
if (constraintSize.Height == 0)
size.Height = Dpi.Height50;
return (size);
}
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
_ValueChanged = false;
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns>false</returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns>false</returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
Focus();
switch (e.KeyData)
{
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,501 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridButtonXEditControl
///</summary>
[ToolboxItem(false)]
public class GridButtonEditControl : Button, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private bool _UseCellValueAsButtonText = true;
private StretchBehavior _StretchBehavior = StretchBehavior.Both;
#endregion
///<summary>
/// GridButtonEditControl
///</summary>
public GridButtonEditControl()
{
AccessibleRole = AccessibleRole.PushButton;
Click += ButtonClick;
}
#region Public properties
#region UseCellValueAsButtonText
///<summary>
/// UseCellValueAsButtonText
///</summary>
public bool UseCellValueAsButtonText
{
get { return (_UseCellValueAsButtonText); }
set { _UseCellValueAsButtonText = value; }
}
#endregion
#endregion
#region ButtonClick
private void ButtonClick(object sender, EventArgs e)
{
EditorValueChanged = true;
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual string GetValue(object value)
{
if (_UseCellValueAsButtonText == false)
return (Text);
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (_Cell.NullString);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (value.ToString());
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get { return (Text); }
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Text); }
set { Text = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public virtual bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Text = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
if (constraintSize.Height == 0)
size.Height = Dpi.Height23;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
OnKeyDown(e);
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
if (Bounds.Contains(e.Location) == true)
OnClick(EventArgs.Empty);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,610 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridButtonXEditControl
///</summary>
[ToolboxItem(false)]
public class GridButtonXEditControl : ButtonX, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private bool _UseCellValueAsButtonText = true;
private StretchBehavior _StretchBehavior = StretchBehavior.Both;
#endregion
///<summary>
/// GridButtXEditControl
///</summary>
public GridButtonXEditControl()
{
AutoCheckOnClick = false;
AutoExpandOnClick = false;
AutoSizeMode = AutoSizeMode.GrowAndShrink;
ColorTable = eButtonColor.OrangeWithBackground;
Style = eDotNetBarStyle.StyleManagerControlled;
Click += ButtonXClick;
ButtonItem.ExpandChange += ButtonXExpandChanged;
}
#region Hidden properties
///<summary>
/// AutoCheckOnClick
///</summary>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new bool AutoCheckOnClick
{
get { return (base.AutoCheckOnClick); }
set { base.AutoCheckOnClick = value; }
}
#endregion
#region Public properties
#region FocusCuesEnabled
/// <summary>
/// FocusCuesEnabled
/// </summary>
public override bool FocusCuesEnabled
{
get { return (false); }
set { base.FocusCuesEnabled = value; }
}
#endregion
#region UseCellValueAsButtonText
///<summary>
/// UseCellValueAsButtonText
///</summary>
public bool UseCellValueAsButtonText
{
get { return (_UseCellValueAsButtonText); }
set { _UseCellValueAsButtonText = value; }
}
#endregion
#endregion
#region ButtonXExpandChanged
private void ButtonXExpandChanged(object sender, EventArgs e)
{
if (Expanded == false)
{
_Cell.SuperGrid.PostInternalMouseMove();
_Cell.SuperGrid.Focus();
}
}
#endregion
#region ButtonXClick
private void ButtonXClick(object sender, EventArgs e)
{
EditorValueChanged = true;
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual string GetValue(object value)
{
if (_UseCellValueAsButtonText == false)
return (Text);
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (_Cell.NullString);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (value.ToString());
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (Expanded == false && IsMouseDown == false); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.NonModal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get { return (Text); }
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Text); }
set { Text = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public virtual bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Text = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
// Perform a little kludge work here, since getting the base.PreferredSize
// on a button with empty text seems to add height to the size of the
// button each time it is called.
string oldText = Text;
if (string.IsNullOrEmpty(Text))
Text = " ";
Size size = GetPreferredSize(constraintSize);
if (constraintSize.Width > 0)
{
ButtonItem.RecalcSize();
if (String.IsNullOrEmpty(ButtonItem.Text) == false)
{
size = ButtonItem.TextDrawRect.Size;
size.Height += Dpi.Height8;
}
}
else
{
size.Width += Dpi.Width1;
}
if (string.IsNullOrEmpty(oldText))
Text = oldText;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
Expanded = false;
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
Expanded = false;
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
OnKeyDown(e);
OnKeyUp(e);
Checked = false;
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
Point pt = _Cell.SuperGrid.PointToClient(MousePosition);
if (_Cell.Bounds.Contains(pt) == false)
StopFade();
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
if (_Cell != null)
{
Point pt = _Cell.SuperGrid.PointToClient(MousePosition);
if (_Cell.Bounds.Contains(pt) == false)
StopFade();
OnMouseLeave(e);
_Cell.GridRow.EditorDirty = false;
Refresh();
}
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
#region Dispose
/// <summary>
/// Dispose
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
Click -= ButtonXClick;
ButtonItem.ExpandChange -= ButtonXExpandChanged;
base.Dispose(disposing);
}
#endregion
}
}

View File

@@ -0,0 +1,612 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridCheckBoxEditControl
///</summary>
[ToolboxItem(false)]
public class GridCheckBoxEditControl : CheckBox, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private object _CheckValueChecked;
private object _CheckValueUnchecked;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridCheckBoxEditControl
///</summary>
public GridCheckBoxEditControl()
{
BackColor = Color.Transparent;
CheckedChanged += ControlCheckedChanged;
}
#region Public properties
#region CheckValueChecked
///<summary>
/// CheckValueChecked
///</summary>
public object CheckValueChecked
{
get { return (_CheckValueChecked); }
set { _CheckValueChecked = value; }
}
#endregion
#region CheckValueUnchecked
///<summary>
/// CheckValueUnchecked
///</summary>
public object CheckValueUnchecked
{
get { return (_CheckValueUnchecked); }
set { _CheckValueUnchecked = value; }
}
#endregion
#endregion
#region ControlCheckedChanged
private void ControlCheckedChanged(object sender, EventArgs e)
{
if (_SuspendUpdate == false)
{
if (Checked == true)
_Cell.Value = _CheckValueChecked ?? true;
else
_Cell.Value = _CheckValueUnchecked ?? false;
_Cell.EditorValueChanged(this);
}
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
///<exception cref="Exception"></exception>
public virtual bool GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (false);
}
Type type = value.GetType();
if (CheckValueChecked != null)
{
if (value.Equals(CheckValueChecked))
return (true);
}
else
{
if (type == typeof(bool))
return ((bool)value);
if (type == typeof(string))
{
string s = (string)value;
if (_Cell.IsValueExpression == true)
s = _Cell.GetExpValue(s);
switch (s.ToLower())
{
case "y":
case "yes":
case "t":
case "true":
case "1":
return (true);
}
}
else
{
int n = Convert.ToInt32(value);
if (n == 1)
return (true);
}
}
if (CheckValueUnchecked != null)
{
if (value.Equals(CheckValueUnchecked))
return (true);
}
else
{
if (type == typeof(bool))
return ((bool)value);
if (type == typeof(string))
{
string s = (string)value;
if (_Cell.IsValueExpression == true)
s = _Cell.GetExpValue(s);
switch (s.ToLower())
{
case "n":
case "no":
case "f":
case "false":
case "0":
return (false);
}
}
else
{
int n = Convert.ToInt32(value);
if (n == 0)
return (false);
}
}
throw new Exception("Invalid checkBox cell value (" + value + ").");
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.NonModal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Checked); }
set { Checked = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Checked = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
Focus();
switch (e.KeyData)
{
case Keys.T:
if (Checked == false)
Checked = true;
break;
case Keys.F:
if (Checked == true)
Checked = false;
break;
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.T:
case Keys.F:
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,676 @@
using System;
using System.ComponentModel;
using System.Data.SqlTypes;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridCheckBoxEditControl
///</summary>
[ToolboxItem(false)]
public class GridCheckBoxXEditControl : CheckBoxX, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridCheckBoxXEditControl
///</summary>
public GridCheckBoxXEditControl()
{
CheckValueChecked = null;
CheckValueUnchecked = null;
Text = "";
CheckedChanged += ControlCheckedChanged;
}
#region ControlCheckedChanged
private void ControlCheckedChanged(object sender, EventArgs e)
{
if (_SuspendUpdate == false)
{
if (CheckState == CheckState.Checked)
{
_Cell.Value = (CheckValueChecked ?? true);
}
else if (CheckState == CheckState.Unchecked)
{
_Cell.Value = (CheckValueUnchecked ?? false);
}
else
{
_Cell.Value = CheckValueIndeterminate;
}
_Cell.EditorValueChanged(this);
}
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaint
/// <summary>
/// OnPaint
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
PaintControl(e);
}
#endregion
#region Text
/// <summary>
/// Text
/// </summary>
public override string Text
{
get { return (base.Text); }
set
{
if (string.IsNullOrEmpty(value))
{
value = "";
TextVisible = false;
}
else
{
TextVisible = true;
}
base.Text = value;
}
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
///<exception cref="Exception"></exception>
public virtual CheckState GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (ThreeState ? CheckState.Indeterminate : CheckState.Unchecked);
}
Type type = value.GetType();
if (CheckValueChecked != null)
{
if (value.Equals(CheckValueChecked))
return (CheckState.Checked);
}
if (CheckValueUnchecked != null)
{
if (value.Equals(CheckValueUnchecked))
return (CheckState.Unchecked);
}
if (type == typeof (bool))
return ((bool) value ? CheckState.Checked : CheckState.Unchecked);
if (type == typeof (string))
{
string s = (string) value;
if (_Cell.IsValueExpression == true)
s = _Cell.GetExpValue(s);
switch (s.ToLower())
{
case "y":
case "yes":
case "t":
case "true":
case "1":
return (CheckState.Checked);
case "":
case "0":
case "n":
case "no":
case "f":
case "false":
return (CheckState.Unchecked);
}
}
else if (type == typeof (SqlBoolean))
{
SqlBoolean sb = (SqlBoolean) value;
if (sb.IsNull == true)
return (ThreeState ? CheckState.Indeterminate : CheckState.Unchecked);
return (sb.IsTrue ? CheckState.Checked : CheckState.Unchecked);
}
else if (type == typeof(char))
{
char c = (char)value;
switch (Char.ToLower(c))
{
case 't':
case 'y':
case '1':
return (CheckState.Checked);
case 'f':
case 'n':
case '0':
return (CheckState.Unchecked);
}
}
else
{
int n = Convert.ToInt32(value);
return (n == 0 ? CheckState.Unchecked : CheckState.Checked);
}
throw new Exception("Invalid checkBox cell value (" + value + ").");
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (EditorValue.ToString());
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (CheckState); }
set { CheckState = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(bool)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
CheckState = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
HostItem.RecalcSize();
Size size = HostItem.Size;
if (TextVisible == false)
{
// RadioButtons are not actually 13 - they are 14, even
// though the system thinks they are 13.
if (CheckBoxStyle == eCheckBoxStyle.RadioButton)
size.Height += Dpi.Height1;
if (size.Width < size.Height)
size.Width = size.Height;
}
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.T:
case Keys.Y:
if (Checked == false)
Checked = true;
break;
case Keys.F:
case Keys.N:
if (Checked == true)
Checked = false;
break;
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.T:
case Keys.F:
case Keys.Y:
case Keys.N:
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
eCheckBoxStyle style = CheckBoxStyle;
CheckBoxStyle = eCheckBoxStyle.CheckBox;
try
{
OnMouseUp(e);
}
finally
{
CheckBoxStyle = style;
}
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
#region Dispose
/// <summary>
/// Dispose
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
CheckedChanged -= ControlCheckedChanged;
base.Dispose(disposing);
}
#endregion
}
}

View File

@@ -0,0 +1,602 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridColorPickerEditControl
///</summary>
[ToolboxItem(false)]
public class GridColorPickerEditControl : ColorPickerButton, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridColorPickerEditControl
///</summary>
public GridColorPickerEditControl()
{
AccessibleRole = AccessibleRole.PushButton;
AutoSizeMode = AutoSizeMode.GrowAndShrink;
ColorTable = eButtonColor.Flat;
InternalAutoExpandOnClick = true;
InternalFocusCuesEnabled = false;
InternalStyle = eDotNetBarStyle.StyleManagerControlled;
SetSelectedColorImageEx();
SelectedColorChanged += ControlSelectedColorChanged;
}
#region SetSelectedColorImage
/// <summary>
/// Creates and sets the Image and SelectedColorImageRectangle.
/// </summary>
protected virtual void SetSelectedColorImage()
{
SetSelectedColorImageEx();
}
private void SetSelectedColorImageEx()
{
Rectangle r = new Rectangle(0, 0, 16, 16);
Bitmap image = new Bitmap(r.Width, r.Height);
using (Graphics g = Graphics.FromImage(image))
g.FillRectangle(Brushes.Black, r);
r.Inflate(-1, -1);
Image = image;
SelectedColorImageRectangle = r;
}
#endregion
#region ControlSelectedColorChanged
private void ControlSelectedColorChanged(object sender, EventArgs e)
{
if (_SuspendUpdate == false)
{
Type dataType = _Cell.GridColumn.DataType;
if (dataType == null && _Cell.Value != null)
dataType = _Cell.Value.GetType();
if (dataType == typeof(Color))
{
_Cell.Value = SelectedColor;
}
else if (dataType == typeof(string))
{
if (SelectedColor.IsKnownColor)
_Cell.Value = SelectedColor.Name;
else
_Cell.Value = SelectedColor.ToArgb().ToString();
}
else
{
_Cell.Value = SelectedColor.ToArgb();
}
_Cell.EditorValueChanged(this);
}
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated processing.
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual int GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (0);
}
if (value.GetType() == typeof(int))
return ((int)value);
if (value.GetType() == typeof(Color))
return (((Color)value).ToArgb());
if (value is string)
{
Color color = Color.FromName((string)value);
if (color.IsKnownColor == true)
return (color.ToArgb());
int x;
if (int.TryParse((string)value, out x) == true)
return (x);
if (int.TryParse((string)value,
NumberStyles.HexNumber, CultureInfo.InvariantCulture, out x) == true)
return (x);
}
throw new Exception("Invalid cell value (" + value + ").");
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (Expanded == false && IsMouseDown == false); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.NonModal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return String.IsNullOrEmpty(SelectedColor.Name) ? "" : SelectedColor.Name;
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (SelectedColor.ToArgb()); }
set
{
Color color = Color.FromArgb(GetValue(value));
if (SelectedColor != color)
SelectedColor = color;
}
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(int)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public virtual bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
BackColor = Color.Transparent;
}
int value = GetValue(_Cell.Value);
if (value != 0)
SelectedColor = Color.FromArgb(value);
else
SelectedColor = Color.Empty;
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
OnKeyDown(e);
OnKeyUp(e);
Checked = false;
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
Refresh();
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
if (_Cell != null)
{
Refresh();
OnMouseLeave(e);
}
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
#region Dispose
/// <summary>
/// Dispose
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
Image image = Image;
if (image != null)
{
Image = null;
image.Dispose();
}
base.Dispose(disposing);
}
#endregion
}
}

View File

@@ -0,0 +1,871 @@
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridComboBoxExEditControl
///</summary>
[ToolboxItem(false)]
public class GridComboBoxExEditControl : ComboBoxEx, IGridCellEditControl
{
#region DllImports
[DllImport("kernel32.dll")]
private static extern int GetCurrentThreadId();
[DllImport("user32.dll")]
private static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll")]
private static extern void GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
[DllImport("user32.dll")]
private static extern bool EnumThreadWindows(int dwThreadId, EnumThreadDelegate lpfn, IntPtr lParam);
private delegate bool EnumThreadDelegate(IntPtr hWnd, IntPtr lParam);
#endregion
#region Static data
static bool _StaticIsOpen;
#endregion
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private bool _PanelShown;
private bool _CacheDisplayMembers = true;
private int _ValueIndex;
private string _ValueText;
private int[] _ValueIndicees;
private object[] _ValueMembers;
private CurrencyManager _CurrentDataManager;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridComboBoxExEditControl
///</summary>
public GridComboBoxExEditControl()
{
DrawMode = DrawMode.OwnerDrawFixed;
DisconnectedPopupDataSource = true;
BindingContext = new BindingContext();
}
#region OnDataSourceChanged
/// <summary>
/// OnDataSourceChanged
/// </summary>
/// <param name="e"></param>
protected override void OnDataSourceChanged(EventArgs e)
{
if (_CurrentDataManager != null)
_CurrentDataManager.ListChanged -= DataManagerListChanged;
base.OnDataSourceChanged(e);
_ValueMembers = null;
_ValueIndicees = null;
_CurrentDataManager = DataManager;
if (_CurrentDataManager != null)
_CurrentDataManager.ListChanged += DataManagerListChanged;
if (IsDisposed == false)
{
if (_Cell != null && _Cell.GridPanel != null)
InitializeContext(_Cell, null);
}
}
#endregion
#region DataManagerListChanged
/// <summary>
/// DataManager_ListChanged
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void DataManagerListChanged(object sender, ListChangedEventArgs e)
{
_ValueMembers = null;
_ValueIndicees = null;
}
#endregion
#region OnTextChanged
/// <summary>
/// OnTextChanged
/// </summary>
/// <param name="e"></param>
protected override void OnTextChanged(EventArgs e)
{
if (IsDisposed == false)
{
if (_Cell != null && _SuspendUpdate == false)
{
_Cell.EditorValueChanged(this);
_ValueIndex = -1;
}
}
base.OnTextChanged(e);
}
#endregion
#region OnSelectedIndexChanged
/// <summary>
/// OnSelectedIndexChanged
/// </summary>
/// <param name="e"></param>
protected override void OnSelectedIndexChanged(EventArgs e)
{
if (IsDisposed == false)
{
if (_Cell != null && _SuspendUpdate == false)
{
_ValueIndex = SelectedIndex;
_Cell.EditorValueChanged(this);
EditorValueChanged = true;
}
}
base.OnSelectedIndexChanged(e);
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region GetValue
/// <summary>
/// GetValue
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public virtual object GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return ("");
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (value);
}
#endregion
#region SetValue
private void SetValue(object o, bool initEdit)
{
_ValueText = "";
_ValueIndex = -1;
bool oldSuspend = SuspendUpdate;
SuspendUpdate = true;
SelectedIndex = -1;
SuspendUpdate = oldSuspend;
if (o != null)
{
_ValueText = o.ToString();
if (string.IsNullOrEmpty(_ValueText) == false &&
string.IsNullOrEmpty(ValueMember) == false &&
string.IsNullOrEmpty(DisplayMember) == false)
{
if (Items.Count > 0)
{
if (Items[0] is DataRowView &&
initEdit == false && _CacheDisplayMembers == true)
{
SetSelectedDrvValue(o);
}
else
{
SetSelectedValue(o);
}
}
}
else
{
Text = _ValueText;
_ValueIndex = SelectedIndex;
}
}
}
#region SetSelectedDrvValue
private void SetSelectedDrvValue(object o)
{
if (_ValueMembers == null)
{
SuspendUpdate = true;
_ValueMembers = new object[Items.Count];
_ValueIndicees = new int[Items.Count];
for (int i = 0; i < Items.Count; i++)
{
DataRowView drv = (DataRowView)Items[i];
_ValueMembers[i] = drv.Row[ValueMember];
_ValueIndicees[i] = i;
}
Array.Sort(_ValueMembers, _ValueIndicees);
SuspendUpdate = false;
}
int n = -1;
try
{
n = Array.BinarySearch(_ValueMembers, o);
}
catch { }
if (n >= 0)
{
_ValueIndex = _ValueIndicees[n];
_ValueText = GetItemText(Items[_ValueIndex]);
}
else
{
Text = _ValueText;
}
}
#endregion
#region SetSelectedValue
private void SetSelectedValue(object o)
{
try
{
SelectedValue = o;
_ValueIndex = SelectedIndex;
if (SelectedValue != null)
_ValueText = Text;
}
catch
{
Text = _ValueText;
}
}
#endregion
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CacheDisplayMembers
/// <summary>
/// Informs the control to cache DataRowView
/// ValueMember/DisplayMember information (default is true).
/// </summary>
public bool CacheDisplayMembers
{
get { return (_CacheDisplayMembers); }
set
{
_CacheDisplayMembers = value;
if (value == false)
{
_ValueMembers = null;
_ValueIndicees = null;
}
}
}
#endregion
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public virtual bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
CellEditMode _CellEditMode = CellEditMode.Modal;
/// <summary>
/// CellEditMode
/// </summary>
public virtual CellEditMode CellEditMode
{
get { return (_CellEditMode); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (_ValueText);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get
{
if (_ValueIndex >= 0)
SelectedIndex = _ValueIndex;
if (string.IsNullOrEmpty(ValueMember) == false)
return (SelectedValue ?? Text);
if (string.IsNullOrEmpty(DisplayMember) == false)
return (Text);
return (this.SelectedValue ?? this.SelectedItem ?? Text);
}
set { SetValue(GetValue(value), true); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
SetValue(GetValue(_Cell.Value), false);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
eTextFormat tf = eTextFormat.NoClipping |
eTextFormat.WordEllipsis | eTextFormat.NoPrefix;
if (style.AllowWrap == Tbool.True)
tf |= eTextFormat.WordBreak;
string s = EditorFormattedValue;
if (String.IsNullOrEmpty(s) == true)
s = " ";
Size size = (constraintSize.IsEmpty == true)
? TextHelper.MeasureText(g, s, style.Font)
: TextHelper.MeasureText(g, s, style.Font, constraintSize, tf);
if (ItemHeight > size.Height)
size.Height = ItemHeight;
size.Height += Dpi.Height(DefaultMargin.Vertical);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
// If we are caching Display/Value member info, then
// force the ComboBox to now set the correct SelectedValue.
if (CacheDisplayMembers == true)
{
object o = EditorValue;
}
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
if (IsPopupOpen == true)
IsPopupOpen = false;
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
if (IsPopupOpen == true)
IsPopupOpen = false;
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
if (_PanelShown == false)
{
_EditorPanel.Show();
_EditorPanel.Hide();
_PanelShown = true;
}
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
Focus();
switch (e.KeyData)
{
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Space:
case Keys.Up:
case Keys.Down:
return (true);
case Keys.Enter:
if (DroppedDown == true || IsPopupOpen == true)
return (true);
if (AutoCompleteMode != AutoCompleteMode.None)
{
if (string.IsNullOrEmpty(DropDownColumns) == true)
{
if (IsAutoSuggestOpen() == true)
return (true);
}
}
break;
}
return (gridWantsKey == false);
}
#region IsAutoSuggestOpen
private bool IsAutoSuggestOpen()
{
_StaticIsOpen = false;
EnumThreadWindows(GetCurrentThreadId(), EnumThreadWindowCallback, IntPtr.Zero);
return (_StaticIsOpen);
}
#region EnumThreadWindowCallback
private static bool EnumThreadWindowCallback(IntPtr hWnd, IntPtr lParam)
{
if (IsWindowVisible(hWnd) == true)
{
if ((GetClassName(hWnd) == "Auto-Suggest Dropdown"))
{
_StaticIsOpen = true;
return (false);
}
}
return true;
}
#region GetClassName
private static string GetClassName(IntPtr hRef)
{
StringBuilder lpClassName = new StringBuilder(256);
GetClassName(hRef, lpClassName, 256);
return (lpClassName.ToString());
}
#endregion
#endregion
#endregion
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
#region Dispose
/// <summary>
/// Dispose
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
if (_CurrentDataManager != null)
_CurrentDataManager.ListChanged -= DataManagerListChanged;
BindingContext = null;
base.Dispose(disposing);
}
#endregion
}
}

View File

@@ -0,0 +1,622 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.AdvTree;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.DotNetBar.Controls;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridComboTreeEditControl
///</summary>
[ToolboxItem(false)]
public class GridComboTreeEditControl : ComboTree, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private bool _PanelShown;
private string _ValueText;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridComboTreeEditControl
///</summary>
public GridComboTreeEditControl()
{
BindingContext = new BindingContext();
ButtonDropDown.Visible = true;
}
#region Dispose
/// <summary>
/// Dispose
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
BindingContext = null;
base.Dispose(disposing);
}
#endregion
#region OnTextChanged
/// <summary>
/// OnTextChanged
/// </summary>
/// <param name="e"></param>
protected override void OnTextChanged(EventArgs e)
{
if (IsDisposed == false)
{
if (_Cell != null && _SuspendUpdate == false)
_Cell.EditorValueChanged(this);
}
base.OnTextChanged(e);
}
#endregion
#region OnSelectedIndexChanged
/// <summary>
/// OnSelectedIndexChanged
/// </summary>
/// <param name="e"></param>
protected override void OnSelectedIndexChanged(EventArgs e)
{
if (IsDisposed == false)
{
if (_Cell != null && _SuspendUpdate == false)
{
_Cell.EditorValueChanged(this);
EditorValueChanged = true;
}
}
base.OnSelectedIndexChanged(e);
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region GetValue
/// <summary>
/// GetValue
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public virtual object GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return ("");
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (value);
}
#endregion
#region SetValue
private void SetValue(object o)
{
if (o == null)
{
_ValueText = "";
SelectedIndex = -1;
}
else
{
_ValueText = o.ToString();
if (string.IsNullOrEmpty(ValueMember) == false)
{
try
{
SelectedValue = o;
if (SelectedValue != null)
_ValueText = Text;
}
catch
{
Text = "";
}
}
else
{
SelectedIndex = -1;
string s = o.ToString();
if (string.IsNullOrEmpty(s) == false)
{
Node node = AdvTree.FindNodeByCellText(s);
if (node != null)
{
SelectedNode = node;
if (string.IsNullOrEmpty(SelectedDisplayMember) == false)
_ValueText = GetSelectedDisplayMemberText(node);
}
else
{
Text = s;
}
}
}
}
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (_ValueText);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get
{
if (string.IsNullOrEmpty(ValueMember) == false)
return (SelectedValue);
return (Text);
}
set { SetValue(GetValue(value)); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
SetValue(GetValue(_Cell.Value));
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
eTextFormat tf = eTextFormat.NoPadding | eTextFormat.NoClipping |
eTextFormat.WordEllipsis | eTextFormat.NoPrefix;
if (style.AllowWrap == Tbool.True)
tf |= eTextFormat.WordBreak;
string s = String.IsNullOrEmpty(Text) ? " " : Text;
Size size = (constraintSize.IsEmpty == true)
? TextHelper.MeasureText(g, s, style.Font, new Size(10000, 0), tf)
: TextHelper.MeasureText(g, s, style.Font, constraintSize, tf);
if (size.Height < Dpi.Height22)
size.Height = Dpi.Height22;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
UpdateTreeSize();
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
if (_PanelShown == false)
{
_EditorPanel.Show();
_EditorPanel.Hide();
_PanelShown = true;
}
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
Focus();
switch (e.KeyData)
{
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Space:
case Keys.Up:
case Keys.Down:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,506 @@
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlTypes;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.Editors.DateTimeAdv;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridTextBoxEditControl
///</summary>
[ToolboxItem(false)]
public class GridDateTimeInputEditControl : DateTimeInput, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private DateTime _OrigValue;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridDateTimeInputEditControl
///</summary>
public GridDateTimeInputEditControl()
{
ShowUpDown = true;
}
#region OnValueChanged
/// <summary>
/// OnValueChanged
/// </summary>
/// <param name="e"></param>
protected override void OnValueChanged(EventArgs e)
{
if (_Cell != null && _SuspendUpdate == false)
{
if (_OrigValue.Year != Value.Year || _OrigValue.Month != Value.Month ||
_OrigValue.Day != Value.Day || _OrigValue.Hour != Value.Hour ||
_OrigValue.Minute != Value.Minute || _OrigValue.Second != Value.Second)
{
_Cell.EditorValueChanged(this);
}
}
base.OnValueChanged(e);
}
#endregion
#region GetValue
/// <summary>
/// GetValue
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public virtual DateTime GetValue(object value)
{
if (value == null || value == Convert.DBNull ||
(value is string && String.IsNullOrEmpty((string)value) == true))
{
return (DateTime.MinValue);
}
if (value is DateTime)
return (Convert.ToDateTime(value));
if (value is SqlDateTime)
{
SqlDateTime sdt = (SqlDateTime)value;
if (sdt.IsNull == true)
return (DateTime.MinValue);
return (sdt.Value);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
if (value is string && CurrentCulture != null)
{
DateTime d;
if (DateTime.TryParse(value.ToString(), GetActiveCulture().DateTimeFormat,
System.Globalization.DateTimeStyles.None, out d))
{
return (d);
}
}
return (Convert.ToDateTime(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (Text);
}
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Value); }
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(DateTime)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
ForeColor = style.TextColor;
Font = style.Font;
}
_OrigValue = GetValue(cell.Value);
Value = _OrigValue;
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
Show();
Focus();
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Home:
case Keys.End:
case Keys.Up:
case Keys.Down:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,490 @@
using System;
using System.ComponentModel;
using System.Data.SqlTypes;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridDateTimePickerEditControl
///</summary>
[ToolboxItem(false)]
public class GridDateTimePickerEditControl : DateTimePicker, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
///GridDateTimePickerEditControl
///</summary>
public GridDateTimePickerEditControl()
{
Format = DateTimePickerFormat.Short;
}
#region OnValueChanged
/// <summary>
/// OnValueChanged
/// </summary>
/// <param name="e"></param>
protected override void OnValueChanged(EventArgs e)
{
if (_Cell != null && _SuspendUpdate == false)
_Cell.EditorValueChanged(this);
base.OnValueChanged(e);
}
#endregion
#region GetValue
/// <summary>
/// GetValue
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public virtual DateTime GetValue(object value)
{
if (value == null || value == Convert.DBNull ||
(value is string && String.IsNullOrEmpty((string)value) == true))
{
return (MinDate);
}
if (value is DateTime)
return ((DateTime)value);
if (value is SqlDateTime)
{
SqlDateTime sdt = (SqlDateTime)value;
if (sdt.IsNull == true)
return (DateTime.MinValue);
return (sdt.Value);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToDateTime(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Value); }
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(DateTime)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
// Control colors are tied to Windows System Colors
// therefore there is not an easy way to pass along color settings.
Enabled = (_Cell.ReadOnly == false);
Font = style.Font;
}
Value = GetValue(cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
// We seem to have to recreate the control to override it's
// internal client area offsetting when previously sized too
// small for the given constraintSize
//RecreateHandle();
Show();
Focus();
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Home:
case Keys.End:
case Keys.Up:
case Keys.Down:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,621 @@
using System;
using System.ComponentModel;
using System.Data.SqlTypes;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.Editors;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridDoubleInputEditControl
///</summary>
[ToolboxItem(false)]
public class GridDoubleInputEditControl : DoubleInput, IGridCellEditControl, IGridCellEditorFocus
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridIntegerInputEditControl
///</summary>
public GridDoubleInputEditControl()
{
InitInputControl(false);
}
#region InitInputControl
/// <summary>
/// InitInputControl
/// </summary>
/// <param name="isIntegral"></param>
protected void InitInputControl(bool isIntegral)
{
ShowUpDown = true;
if (isIntegral == true)
DisplayFormat = "G";
}
#endregion
#region OnValueChanged
/// <summary>
/// OnValueChanged
/// </summary>
/// <param name="e"></param>
protected override void OnValueChanged(EventArgs e)
{
if (_Cell != null && _SuspendUpdate == false)
_Cell.EditorValueChanged(this);
base.OnValueChanged(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual double GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (0);
}
if (value is SqlSingle)
{
SqlSingle sdt = (SqlSingle)value;
if (sdt.IsNull == true)
return (0);
return (sdt.Value);
}
if (value is SqlDouble)
{
SqlDouble sdt = (SqlDouble)value;
if (sdt.IsNull == true)
return (0);
return (sdt.Value);
}
if (value is SqlDecimal)
{
SqlDecimal sdt = (SqlDecimal)value;
if (sdt.IsNull == true)
return (0);
return (Convert.ToDouble(sdt.Value));
}
if (value is SqlInt64)
{
SqlDecimal sdt = (SqlInt64)value;
if (sdt.IsNull == true)
return (0);
return (Convert.ToDouble(sdt.Value));
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToDouble(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Value); }
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(double)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Value = GetValue(cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
if (FreeTextEntryMode == true)
{
TextBox box = GetFreeTextBox() as TextBox;
if (box != null)
{
if (selectAll == true)
box.SelectAll();
}
}
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
CloseDropDown();
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
CloseDropDown();
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
if ((key & Keys.KeyCode) == Keys.Tab)
{
ApplyFreeTextValue();
return (false);
}
if (IsCalculatorDisplayed == true)
return (true);
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Home:
case Keys.End:
case Keys.Up:
case Keys.Down:
return (true);
case Keys.Enter:
ApplyFreeTextValue();
return (gridWantsKey == false);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
#region IGridCellEditorFocus members
#region FocusEditor
/// <summary>
/// Gives focus to the editor
/// </summary>
public void FocusEditor()
{
if (IsEditorFocused == false)
{
if (FreeTextEntryMode == true)
{
TextBox box = GetFreeTextBox() as TextBox;
if (box != null)
box.Focus();
}
else
{
Focus();
}
}
}
#endregion
#region IsEditorFocused
/// <summary>
/// Gets whether editor has the focus
/// </summary>
public bool IsEditorFocused
{
get
{
if (FreeTextEntryMode == true)
{
TextBox box = GetFreeTextBox() as TextBox;
if (box != null)
return (box.Focused);
}
return (Focused);
}
}
#endregion
#endregion
}
///<summary>
/// GridDoubleIntInputEditControl
///</summary>
[ToolboxItem(false)]
public class GridDoubleIntInputEditControl : GridDoubleInputEditControl
{
///<summary>
/// GridDoubleIntInputEditControl
///</summary>
public GridDoubleIntInputEditControl()
{
InitInputControl(true);
}
}
}

View File

@@ -0,0 +1,548 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.Instrumentation;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridGaugeEditControl
///</summary>
[ToolboxItem(false)]
public class GridGaugeEditControl : GaugeControl, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private string _PointerName = "Pointer1";
private StretchBehavior _StretchBehavior = StretchBehavior.Both;
#endregion
///<summary>
/// GridGaugeEditControl
///</summary>
public GridGaugeEditControl()
{
PointerValueChanged += OnValueChanged;
#if !TRIAL
LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F";
#endif
}
#region Public properties
///<summary>
/// PointerName
///</summary>
public string PointerName
{
get { return (_PointerName); }
set { _PointerName = value; }
}
#endregion
#region OnValueChanged
/// <summary>
/// Pointer Value changed
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void OnValueChanged(object sender, PointerChangedEventArgs e)
{
if (_Cell != null && _SuspendUpdate == false)
{
_Cell.Value = e.NewValue;
_Cell.EditorValueChanged(this);
}
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaintBackground
/// <summary>
/// OnPaintBackground
/// </summary>
/// <param name="e"></param>
protected override void OnPaintBackground(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual double GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (0);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToDouble(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get { return (Text); }
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (GetPointerValue(_PointerName)); }
set { SetPointerValue(_PointerName, GetValue(value), false); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
SetPointerValue(_PointerName, GetValue(_Cell.Value), false);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = constraintSize;
size.Height = size.Width;
if (size.Width == 0)
size.Width = cell.Size.Width - Dpi.Width2;
size.Height = Dpi.Height50;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.T:
break;
case Keys.F:
break;
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.T:
case Keys.F:
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
_Cell.SuperGrid.GridCursor = Cursor;
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
#region Dispose
/// <summary>
/// Dispose
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
PointerValueChanged -= OnValueChanged;
base.Dispose(disposing);
}
#endregion
}
}

View File

@@ -0,0 +1,900 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridImageEditControl
///</summary>
[ToolboxItem(false)]
public class GridImageEditControl : Control, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private int _ImageIndex = -1;
private ImageList _ImageList;
private string _ImageKey;
private Image _Image;
private string _ImageLocation;
private Image _LocationImage;
private ImageSizeMode _ImageSizeMode = ImageSizeMode.Normal;
private Image _StreamImage;
private MemoryStream _ImageMemoryStream;
private byte[] _ImageData;
private StretchBehavior _StretchBehavior = StretchBehavior.Both;
#endregion
#region Public properties
#region Image
///<summary>
/// Image
///</summary>
public Image Image
{
get { return (_Image); }
set { _Image = value; }
}
#endregion
#region ImageData
///<summary>
/// ImageData
///</summary>
public byte[] ImageData
{
get { return (_ImageData); }
set
{
_ImageData = value;
StreamImage = null;
}
}
#endregion
#region ImageIndex
///<summary>
/// ImageKey
///</summary>
public int ImageIndex
{
get { return (_ImageIndex); }
set { _ImageIndex = value; }
}
#endregion
#region ImageKey
///<summary>
/// ImageKey
///</summary>
public string ImageKey
{
get { return (_ImageKey); }
set { _ImageKey = value; }
}
#endregion
#region ImageList
///<summary>
/// ImageList
///</summary>
public ImageList ImageList
{
get { return (_ImageList); }
set { _ImageList = value; }
}
#endregion
#region ImageLocation
///<summary>
/// ImageLocation
///</summary>
public string ImageLocation
{
get { return (_ImageLocation); }
set
{
_ImageLocation = value;
LocationImage = null;
}
}
#endregion
#region ImageSizeMode
///<summary>
/// ImageSizeMode
///</summary>
public ImageSizeMode ImageSizeMode
{
get { return (_ImageSizeMode); }
set { _ImageSizeMode = value; }
}
#endregion
#endregion
#region Private properties
#region EffectiveImage
private Image EffectiveImage
{
get
{
if (_Image != null)
return (_Image);
if (StreamImage != null)
return (StreamImage);
if (_ImageList != null)
{
_ImageList.TransparentColor = Color.Magenta;
if ((uint)_ImageIndex < _ImageList.Images.Count)
return (_ImageList.Images[_ImageIndex]);
if (_ImageKey != null)
return (_ImageList.Images[_ImageKey]);
}
return (LocationImage);
}
}
#endregion
#region ImageMemoryStream
private MemoryStream ImageMemoryStream
{
get
{
if (_ImageMemoryStream == null)
_ImageMemoryStream = new MemoryStream();
return (_ImageMemoryStream);
}
set
{
if (_ImageMemoryStream != null)
_ImageMemoryStream.Dispose();
_ImageMemoryStream = value;
}
}
#endregion
#region LocationImage
private Image LocationImage
{
get { return (_LocationImage); }
set
{
if (_LocationImage != null)
_LocationImage.Dispose();
_LocationImage = value;
if (string.IsNullOrEmpty(_ImageLocation) == false)
{
using (FileStream fs = new FileStream(_ImageLocation, FileMode.Open))
_LocationImage = Image.FromStream(fs);
}
}
}
#endregion
#region StreamImage
private Image StreamImage
{
get
{
if (_StreamImage == null)
{
if (_ImageData != null)
{
MemoryStream ms = ImageMemoryStream;
if (ms != null)
{
ms.SetLength(0);
ms.Write(_ImageData, 0, _ImageData.Length);
StreamImage = Image.FromStream(ms);
}
}
}
return (_StreamImage);
}
set
{
if (_StreamImage != null)
_StreamImage.Dispose();
_StreamImage = value;
}
}
#endregion
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaintBackground
/// <summary>
/// OnPaintBackground
/// </summary>
/// <param name="e"></param>
protected override void OnPaintBackground(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
}
#endregion
#region Dispose
/// <summary>
/// Dispose
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
ResetImageInfo();
ImageMemoryStream = null;
base.Dispose(disposing);
}
#endregion
#region SetValue
///<summary>
/// SetValue
///</summary>
///<param name="value"></param>
public virtual void SetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (panel.IsDesignerHosted == false)
{
ResetImageInfo();
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
}
else if (value is Image)
{
Image = (Image)value;
}
else if (value is string)
{
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
if (SetImageKey((string)value) == false)
{
int index;
if (int.TryParse((string)value, out index) == true)
SetImageIndex(index);
else
ImageLocation = (string)value;
}
}
else if (value is byte[])
{
ImageData = (byte[])value;
}
else
{
int index = Convert.ToInt32(value);
SetImageIndex(index);
}
}
}
#region ResetImageInfo
private void ResetImageInfo()
{
Image = null;
ImageKey = null;
ImageIndex = -1;
ImageLocation = null;
ImageData = null;
}
#endregion
#region SetImageKey
private bool SetImageKey(string key)
{
if (_ImageList != null)
{
if (_ImageList.Images.ContainsKey(key))
{
_ImageKey = key;
return (true);
}
}
return (false);
}
#endregion
#region SetImageIndex
private void SetImageIndex(int index)
{
if (_ImageList != null && index < _ImageList.Images.Count)
ImageIndex = index;
}
#endregion
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.Value != null)
return (_Cell.Value.ToString());
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get
{
if (String.IsNullOrEmpty(ImageLocation) == false)
return (ImageLocation);
if (String.IsNullOrEmpty(_ImageKey) == false)
return (_ImageKey);
return (_ImageIndex);
}
set { SetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
Enabled = (_Cell.IsReadOnly == false);
SetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Image image = EffectiveImage;
Size size = (image != null)
? image.Size : Dpi.Size(20, 20);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
Image image = EffectiveImage;
if (image != null)
{
Rectangle r = _Cell.GetCellEditBounds(this);
switch (_ImageSizeMode)
{
case ImageSizeMode.Normal:
Rectangle sr = r;
sr.Location = Point.Empty;
g.DrawImage(image, r, sr, GraphicsUnit.Pixel);
break;
case ImageSizeMode.CenterImage:
RenderImageCentered(g, image, r);
break;
case ImageSizeMode.StretchImage:
g.DrawImage(image, r);
break;
case ImageSizeMode.Zoom:
RenderImageScaled(g, image, r);
break;
}
}
}
#region RenderImageCentered
private void RenderImageCentered(Graphics g, Image image, Rectangle r)
{
Rectangle sr = r;
sr.Location = Point.Empty;
if (image.Width > r.Width)
sr.X += (image.Width - r.Width) / 2;
else
r.X += (r.Width - image.Width) / 2;
if (image.Height > r.Height)
sr.Y += (image.Height - r.Height) / 2;
else
r.Y += (r.Height - image.Height) / 2;
g.DrawImage(image, r, sr, GraphicsUnit.Pixel);
}
#endregion
#region RenderImageScaled
private void RenderImageScaled(Graphics g, Image image, Rectangle r)
{
SizeF size = new SizeF(image.Width / image.HorizontalResolution,
image.Height / image.VerticalResolution);
float scale = Math.Min(r.Width / size.Width, r.Height / size.Height);
size.Width *= scale;
size.Height *= scale;
g.DrawImage(image, r.X + (r.Width - size.Width) / 2,
r.Y + (r.Height - size.Height) / 2,
size.Width, size.Height);
}
#endregion
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
OnKeyDown(e);
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
return (gridWantsKey == false);
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
#region ImageSizeMode
///<summary>
/// ImageSizeMode
///</summary>
public enum ImageSizeMode
{
///<summary>
/// The image is placed in the upper-left
/// corner of the cell and is clipped if needed to fit.
///</summary>
Normal,
///<summary>
/// The image is stretched or shrunk to fit the cell.
///</summary>
StretchImage,
///<summary>
/// The image is displayed in the center of the cell if
/// the cell is larger than the image. If the image is larger
/// than the cell, the image is placed in the center of the
/// cell and the outside edges are clipped.
///</summary>
CenterImage,
///<summary>
/// The size of the image is increased or decreased to fit the
/// cell, maintaining the size ratio.
///</summary>
Zoom
}
#endregion
}

View File

@@ -0,0 +1,570 @@
using System;
using System.ComponentModel;
using System.Data.SqlTypes;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.Editors;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridIntegerInputEditControl
///</summary>
[ToolboxItem(false)]
public class GridIntegerInputEditControl : IntegerInput, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridIntegerInputEditControl
///</summary>
public GridIntegerInputEditControl()
{
ShowUpDown = true;
}
#region OnValueChanged
/// <summary>
/// OnValueChanged
/// </summary>
/// <param name="e"></param>
protected override void OnValueChanged(EventArgs e)
{
if (_Cell != null && _SuspendUpdate == false)
_Cell.EditorValueChanged(this);
base.OnValueChanged(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual int GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (0);
}
if (value is SqlInt16)
{
SqlInt16 sdt = (SqlInt16) value;
if (sdt.IsNull == true)
return (0);
return (sdt.Value);
}
if (value is SqlInt32)
{
SqlInt32 sdt = (SqlInt32)value;
if (sdt.IsNull == true)
return (0);
return (sdt.Value);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToInt32(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Value); }
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(int)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Value = GetValue(cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
if (FreeTextEntryMode == true)
{
TextBox box = GetFreeTextBox() as TextBox;
if (box != null)
{
if (selectAll == true)
box.SelectAll();
}
}
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
CloseDropDown();
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
CloseDropDown();
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
if ((key & Keys.KeyCode) == Keys.Tab)
{
ApplyFreeTextValue();
return (false);
}
if (IsCalculatorDisplayed == true)
return (true);
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Home:
case Keys.End:
case Keys.Up:
case Keys.Down:
return (true);
case Keys.Enter:
ApplyFreeTextValue();
return (gridWantsKey == false);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
#region IGridCellEditorFocus members
#region FocusEditor
/// <summary>
/// Gives focus to the editor
/// </summary>
public void FocusEditor()
{
if (IsEditorFocused == false)
{
if (FreeTextEntryMode == true)
{
TextBox box = GetFreeTextBox() as TextBox;
if (box != null)
box.Focus();
}
else
{
Focus();
}
}
}
#endregion
#region IsEditorFocused
/// <summary>
/// Gets whether editor has the focus
/// </summary>
public bool IsEditorFocused
{
get
{
if (FreeTextEntryMode == true)
{
TextBox box = GetFreeTextBox() as TextBox;
if (box != null)
return (box.Focused);
}
return (Focused);
}
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,463 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.Editors;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridIpAddressInputEditControl
///</summary>
[ToolboxItem(false)]
public class GridIpAddressInputEditControl : IpAddressInput, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
#region OnValueChanged
/// <summary>
/// OnValueChanged
/// </summary>
/// <param name="e"></param>
protected override void OnValueChanged(EventArgs e)
{
if (_SuspendUpdate == false)
_Cell.EditorValueChanged(this);
base.OnValueChanged(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual string GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return ("");
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToString(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Value); }
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(int)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Value = GetValue(cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
Show();
Focus();
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Home:
case Keys.End:
case Keys.Up:
case Keys.Down:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,513 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridLabelEditControl
///</summary>
[ToolboxItem(false)]
public class GridLabelEditControl : Label, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaintBackground
/// <summary>
/// OnPaintBackground
/// </summary>
/// <param name="e"></param>
protected override void OnPaintBackground(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual string GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return ("");
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToString(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Text); }
set { Text = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
SetTextAlign(style);
}
Text = GetValue(_Cell.Value);
_ValueChanged = false;
}
#region SetTextAlign
private void SetTextAlign(CellVisualStyle style)
{
switch (style.Alignment)
{
case Alignment.TopLeft:
TextAlign = ContentAlignment.TopLeft;
break;
case Alignment.TopCenter:
TextAlign = ContentAlignment.TopCenter;
break;
case Alignment.TopRight:
TextAlign = ContentAlignment.TopRight;
break;
case Alignment.MiddleLeft:
TextAlign = ContentAlignment.MiddleLeft;
break;
case Alignment.MiddleCenter:
TextAlign = ContentAlignment.MiddleCenter;
break;
case Alignment.MiddleRight:
TextAlign = ContentAlignment.MiddleRight;
break;
case Alignment.BottomLeft:
TextAlign = ContentAlignment.BottomLeft;
break;
case Alignment.BottomCenter:
TextAlign = ContentAlignment.BottomCenter;
break;
case Alignment.BottomRight:
TextAlign = ContentAlignment.BottomRight;
break;
}
}
#endregion
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
return (gridWantsKey == false);
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,555 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridLabelEditControl
///</summary>
[ToolboxItem(false)]
public class GridLabelXEditControl : LabelX, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaint
/// <summary>
/// OnPaint
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
PaintControl(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual string GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (" ");
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
string s = Convert.ToString(value);
if (string.IsNullOrEmpty(s) == true)
s = " ";
return (s);
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (PlainText);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Text); }
set { Text = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateLayout); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Font = style.Font;
WordWrap = (style.AllowWrap == Tbool.True);
Enabled = (_Cell.IsReadOnly == false);
SetTextAlign(style);
ForeColor = style.TextColor;
BackColor = Color.Transparent;
}
EnableMarkup = !EnableMarkup;
EnableMarkup = !EnableMarkup;
Text = GetValue(_Cell.Value);
_ValueChanged = false;
}
#region SetTextAlign
private void SetTextAlign(CellVisualStyle style)
{
switch (style.Alignment)
{
case Alignment.TopLeft:
TextLineAlignment = StringAlignment.Near;
TextAlignment = StringAlignment.Near;
break;
case Alignment.TopCenter:
TextLineAlignment = StringAlignment.Near;
TextAlignment = StringAlignment.Center;
break;
case Alignment.TopRight:
TextLineAlignment = StringAlignment.Near;
TextAlignment = StringAlignment.Far;
break;
case Alignment.MiddleLeft:
TextLineAlignment = StringAlignment.Center;
TextAlignment = StringAlignment.Near;
break;
case Alignment.MiddleCenter:
TextLineAlignment = StringAlignment.Center;
TextAlignment = StringAlignment.Center;
break;
case Alignment.MiddleRight:
TextLineAlignment = StringAlignment.Center;
TextAlignment = StringAlignment.Far;
break;
case Alignment.BottomLeft:
TextLineAlignment = StringAlignment.Far;
TextAlignment = StringAlignment.Near;
break;
case Alignment.BottomCenter:
TextLineAlignment = StringAlignment.Far;
TextAlignment = StringAlignment.Center;
break;
case Alignment.BottomRight:
TextLineAlignment = StringAlignment.Far;
TextAlignment = StringAlignment.Far;
break;
}
}
#endregion
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size maxSize = MaximumSize;
MaximumSize = constraintSize;
InvalidateAutoSize();
Size size = GetPreferredSize(constraintSize);
MaximumSize = maxSize;
if (constraintSize.Width > 0 && EnableMarkup == true)
size.Width = constraintSize.Width;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
// Force a resize (LabelX seems to need this)
Bounds = new Rectangle();
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
return (gridWantsKey == false);
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
_Cell.SuperGrid.GridCursor = Cursor;
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
OnClick(EventArgs.Empty);
Cursor = Cursors.Default;
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,526 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridMaskedTextBoxEditControl
///</summary>
[ToolboxItem(false)]
public class GridMaskedTextBoxEditControl : MaskedTextBox, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
#region OnTextChanged
/// <summary>
/// OnTextChanged
/// </summary>
/// <param name="e"></param>
protected override void OnTextChanged(EventArgs e)
{
if (_Cell != null && _SuspendUpdate == false)
_Cell.EditorValueChanged(this);
base.OnTextChanged(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual string GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return ("");
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToString(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return ((PasswordChar == '\0')
? Text : PasswordText());
}
}
#region PasswordText
private string PasswordText()
{
if (string.IsNullOrEmpty(Mask))
return (new string(PasswordChar, TextLength));
string text = Mask;
char[] c = new char[text.Length];
int n = 0;
for (int i = 0; i < text.Length; i++)
{
if ("09#L?&CAa".IndexOf(text[i]) >= 0)
c[n++] = PasswordChar;
else if ("<>|".IndexOf(text[i]) < 0)
c[n++] = text[i];
}
return (new string(c));
}
#endregion
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Text); }
set { Text = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
ForeColor = style.TextColor;
Font = style.Font;
SetTextAlign(style);
}
Text = GetValue(_Cell.Value);
_ValueChanged = false;
}
#region SetTextAlign
private void SetTextAlign(CellVisualStyle style)
{
switch (style.Alignment)
{
case Alignment.TopLeft:
case Alignment.MiddleLeft:
case Alignment.BottomLeft:
TextAlign = HorizontalAlignment.Left;
break;
case Alignment.TopCenter:
case Alignment.MiddleCenter:
case Alignment.BottomCenter:
TextAlign = HorizontalAlignment.Center;
break;
case Alignment.TopRight:
case Alignment.MiddleRight:
case Alignment.BottomRight:
TextAlign = HorizontalAlignment.Right;
break;
}
}
#endregion
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
Show();
Focus();
if (selectAll == true)
SelectAll();
else
Select(Text.Length, 1);
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
// Let the TextBox handle the following keys
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Home:
case Keys.End:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,488 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridMicroChartEditControl
///</summary>
[ToolboxItem(false)]
public class GridMicroChartEditControl : MicroChart, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.Both;
#endregion
///<summary>
/// GridMicroChartEditControl
///</summary>
public GridMicroChartEditControl()
{
FocusCuesEnabled = false;
AnimationEnabled = false;
}
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaint
/// <summary>
/// OnPaint
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
PaintControl(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual List<double> GetValue(object value)
{
List<double> dps = new List<double>();
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
string s = value as string;
if (s != null)
{
string[] values = s.Split(new char[] { ',', ' ', '\t', '|' });
foreach (string t in values)
{
double d;
if (double.TryParse(t, out d) == true)
dps.Add(d);
}
}
return (dps);
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.Value == null)
return (_Cell.NullString);
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (null); }
set { DataPoints = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
Enabled = (_Cell.IsReadOnly == false);
DataPoints = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
size.Width += Dpi.Width1;
if (constraintSize.Height == 0)
size.Height = Dpi.Height24;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
OnKeyDown(e);
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
return (gridWantsKey == false);
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,549 @@
using System;
using System.ComponentModel;
using System.Data.SqlTypes;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridNumericUpDownEditControl
///</summary>
[ToolboxItem(false)]
public class GridNumericUpDownEditControl : NumericUpDown, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridNumericUpDownEditControl
///</summary>
public GridNumericUpDownEditControl()
{
DecimalPlaces = 4;
}
#region OnTextChanged
/// <summary>
/// OnTextChanged
/// </summary>
/// <param name="e"></param>
protected override void OnTextChanged(EventArgs e)
{
if (_Cell != null && _SuspendUpdate == false)
_Cell.EditorValueChanged(this);
base.OnTextChanged(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual decimal GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (0);
}
if (value is SqlDecimal)
{
SqlDecimal sdt = (SqlDecimal)value;
if (sdt.IsNull == true)
return (0);
return (sdt.Value);
}
if (value is SqlSingle)
{
SqlSingle sdt = (SqlSingle)value;
if (sdt.IsNull == true)
return (0);
return (Convert.ToDecimal(sdt.Value));
}
if (value is SqlDouble)
{
SqlDouble sdt = (SqlDouble)value;
if (sdt.IsNull == true)
return (0);
return (Convert.ToDecimal(sdt.Value));
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToDecimal(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (Value.ToString());
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get
{
if (string.IsNullOrEmpty(Text) == true)
return (0);
return (Value);
}
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(decimal)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
ForeColor = style.TextColor;
Font = style.Font;
SetTextAlign(style);
}
Value = GetValue(cell.Value);
Text = Value.ToString();
_ValueChanged = false;
}
#region SetTextAlign
private void SetTextAlign(CellVisualStyle style)
{
switch (style.Alignment)
{
case Alignment.TopLeft:
case Alignment.MiddleLeft:
case Alignment.BottomLeft:
TextAlign = HorizontalAlignment.Left;
break;
case Alignment.TopCenter:
case Alignment.MiddleCenter:
case Alignment.BottomCenter:
TextAlign = HorizontalAlignment.Center;
break;
case Alignment.TopRight:
case Alignment.MiddleRight:
case Alignment.BottomRight:
TextAlign = HorizontalAlignment.Right;
break;
}
}
#endregion
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
AutoSize = true;
Size size = GetPreferredSize(constraintSize);
AutoSize = false;
if (constraintSize.Width > 0)
size.Width = constraintSize.Width;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
if (selectAll == true)
Select(0, 100);
else
Select(Text.Length, 1);
Show();
Focus();
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Home:
case Keys.End:
case Keys.Up:
case Keys.Down:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,481 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.DotNetBar.Controls;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridProgressBarXEditControl
///</summary>
[ToolboxItem(false)]
public class GridProgressBarXEditControl : ProgressBarX, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.Both;
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaint
/// <summary>
/// OnPaint
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
PaintControl(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual int GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (0);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToInt32(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get { return (Text); }
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Value); }
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
Value = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
if (constraintSize.Height == 0)
size.Height = Dpi.Height23;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Add:
Value += Step;
break;
case Keys.Subtract:
Value -= Step;
break;
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Add:
case Keys.Subtract:
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,575 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridButtonXEditControl
///</summary>
[ToolboxItem(false)]
public class GridRadialMenuEditControl : RadialMenu, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
///<summary>
/// GridRadialMenuEditControl
///</summary>
public GridRadialMenuEditControl()
{
this.SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.Opaque |
ControlStyles.ResizeRedraw |
DisplayHelp.DoubleBufferFlag |
ControlStyles.SupportsTransparentBackColor, true);
BackColor = Color.Transparent;
Colors.RadialMenuButtonBackground = Color.Transparent;
ItemClick += GridRadialMenuEditControl_ItemClick;
}
#region GridRadialMenuEditControl_ItemClick
/// <summary>
/// RadialMenu item click handler
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void GridRadialMenuEditControl_ItemClick(object sender, EventArgs e)
{
if (_SuspendUpdate == false)
{
RadialMenuItem item = sender as RadialMenuItem;
if (item != null)
OnGridRadialMenuEditControl_ItemClick(item);
}
}
#region OnGridRadialMenuEditControl_ItemClick
/// <summary>
/// RadialMenu item click handler
/// </summary>
/// <param name="item"></param>
public virtual void OnGridRadialMenuEditControl_ItemClick(RadialMenuItem item)
{
if ((item.Text != null && item.Text.Equals(_Cell.Value) == false) ||
(item.Text == null && _Cell.Value != null))
{
_Cell.Value = item.Text;
_Cell.EditorValueChanged(this);
}
}
#endregion
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual string GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (_Cell.NullString);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (value.ToString());
}
#endregion
#region FindItemByText
/// <summary>
/// Finds the RadialMenuItem based upon the given item Text.
/// </summary>
/// <param name="items"></param>
/// <param name="text"></param>
/// <returns>RadialMenuItem or null</returns>
public RadialMenuItem FindItemByText(SubItemsCollection items, string text)
{
if (string.IsNullOrEmpty(text))
return (null);
foreach (RadialMenuItem item in items)
{
if (item.Text.Equals(text))
return (item);
if (item.SubItems.Count > 0)
{
RadialMenuItem item2 = FindItemByText(item.SubItems, text);
if (item2 != null)
return (item2);
}
}
return (null);
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.NonModal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get { return (Text); }
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Text); }
set { Text = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public virtual bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Text = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(Size.Empty);
int n = Dpi.Width(CenterButtonDiameter);
if (n > size.Width)
size.Width = n;
n = Dpi.Height(CenterButtonDiameter);
if (n > size.Height)
size.Height = n;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
OnKeyDown(e);
OnKeyUp(e);
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
Point pt = _Cell.SuperGrid.PointToClient(MousePosition);
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
if (_Cell != null)
{
Refresh();
OnMouseLeave(e);
}
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
#region Dispose
/// <summary>
/// Dispose
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
#endregion
}
}

View File

@@ -0,0 +1,506 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.DotNetBar.Controls;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridRatingStarEditControl
///</summary>
[ToolboxItem(false)]
public class GridRatingStarEditControl : RatingStar, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
#region OnRatingChanged
/// <summary>
/// OnRatingChanged
/// </summary>
/// <param name="eventArgs"></param>
protected override void OnRatingChanged(EventArgs eventArgs)
{
if (_SuspendUpdate == false)
{
_Cell.Value = Rating;
_Cell.EditorValueChanged(this);
}
base.OnRatingChanged(eventArgs);
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaint
/// <summary>
/// OnPaint
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
PaintControl(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual int GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (0);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToInt32(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get { return (Text); }
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Rating); }
set { Rating = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Rating = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
GetPreferredSize(constraintSize);
return (CalcSize);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Add:
Rating += 1;
break;
case Keys.Subtract:
Rating -= 1;
break;
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Add:
case Keys.Subtract:
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
OnClick(EventArgs.Empty);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,510 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.DotNetBar.Controls;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridSliderEditControl
///</summary>
[ToolboxItem(false)]
public class GridSliderEditControl : Slider, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.HorizontalOnly;
#endregion
#region OnValueChanged
/// <summary>
/// OnValueChanged
/// </summary>
/// <param name="e"></param>
protected override void OnValueChanged(EventArgs e)
{
if (_SuspendUpdate == false)
{
_Cell.Value = Value;
_Cell.EditorValueChanged(this);
}
base.OnValueChanged(e);
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region OnPaint
/// <summary>
/// OnPaint
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
PaintControl(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual int GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (0);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToInt32(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get { return (Text); }
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Value); }
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Value = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
if (constraintSize.Width == 0)
size.Width = Dpi.Width80;
if (constraintSize.Height == 0)
size.Height = Dpi.Height20;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Add:
Value += Step;
break;
case Keys.Subtract:
Value -= Step;
break;
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Add:
case Keys.Subtract:
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,593 @@
using System;
using System.ComponentModel;
using System.Data.SqlTypes;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.DotNetBar.Controls;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridSwitchButtonEditControl
///</summary>
[ToolboxItem(false)]
public class GridSwitchButtonEditControl : SwitchButton, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private object _OnValue;
private object _OffValue;
private StretchBehavior _StretchBehavior = StretchBehavior.Both;
#endregion
///<summary>
/// GridSwitchButtonEditControl
///</summary>
public GridSwitchButtonEditControl()
{
FocusCuesEnabled = false;
Style = eDotNetBarStyle.StyleManagerControlled;
}
#region Public properties
#region OnValue
///<summary>
/// OnValue
///</summary>
public object OnValue
{
get { return (_OnValue); }
set { _OnValue = value; }
}
#endregion
#region OffValue
///<summary>
/// OffValue
///</summary>
public object OffValue
{
get { return (_OffValue); }
set { _OffValue = value; }
}
#endregion
#endregion
#region OnValueChanged
/// <summary>
/// OnValueChanged
/// </summary>
/// <param name="e"></param>
protected override void OnValueChanged(EventArgs e)
{
if (_SuspendUpdate == false)
{
_Cell.UpdateCellValue(this);
_Cell.EditorValueChanged(this);
}
base.OnValueChanged(e);
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_Cell != null && _SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
///<exception cref="Exception"></exception>
public virtual bool GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (false);
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
Type type = value.GetType();
if (_OnValue != null)
{
if (value.Equals(_OnValue))
return (true);
}
if (_OffValue != null)
{
if (value.Equals(_OffValue))
return (false);
}
if (type == typeof(bool))
return ((bool)value);
if (type == typeof(string))
{
string s = ((string)value).ToLower();
if (s.Equals("true") || s.Equals("yes") || s.Equals("1"))
return (true);
if (s.Equals("false") || s.Equals("no") || s.Equals("0"))
return (false);
}
else if (type == typeof(SqlBoolean))
{
SqlBoolean sb = (SqlBoolean)value;
if (sb.IsNull == true)
return (false);
return (sb.IsTrue);
}
else if (type == typeof(char))
{
char c = (char)value;
switch (Char.ToLower(c))
{
case 't':
case 'y':
case '1':
return (true);
case 'f':
case 'n':
case '0':
return (false);
}
}
else
{
int n = Convert.ToInt32(value);
return (n == 0 ? false : true);
}
throw new Exception("Invalid checkBox cell value (" + value + ").");
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.InPlace); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null)
{
if (_Cell.Value == null || _Cell.IsValueNull == true)
return (_Cell.NullString);
return (_Cell.Value.ToString());
}
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Value); }
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(bool)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.IsReadOnly == false);
Font = style.Font;
ForeColor = style.TextColor;
}
Value = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
size.Width += Dpi.Width4;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
OnKeyDown(e);
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
OnMouseEnter(e);
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
CancelAnimation();
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,577 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
using DevComponents.DotNetBar.Controls;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridTextBoxDropDownControl
///</summary>
[ToolboxItem(false)]
public class GridTextBoxDropDownEditControl : TextBoxDropDown, IGridCellEditControl
{
#region DllImports / delegates
private delegate bool EnumThreadWndProc(IntPtr hWnd, IntPtr lp);
[DllImport("user32.dll")]
private static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll")]
private static extern bool EnumThreadWindows(int tid, EnumThreadWndProc callback, IntPtr lp);
[DllImport("user32.dll")]
private static extern int GetClassName(IntPtr hWnd, StringBuilder buffer, int buflen);
[DllImport("kernel32.dll")]
private static extern int GetCurrentThreadId();
#endregion
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
private bool _AutoSuggestDropdownOpen;
#endregion
///<summary>
/// GridTextBoxDropDownEditControl
///</summary>
public GridTextBoxDropDownEditControl()
{
BackgroundStyle.Class = "TextBoxBorder";
Style = eDotNetBarStyle.StyleManagerControlled;
}
#region OnTextChanged
/// <summary>
/// OnTextChanged
/// </summary>
/// <param name="e"></param>
protected override void OnTextChanged(EventArgs e)
{
if (_SuspendUpdate == false)
_Cell.EditorValueChanged(this);
base.OnTextChanged(e);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual string GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return ("");
}
if (_Cell.IsValueExpression == true)
value = _Cell.GetExpValue((string)value);
return (Convert.ToString(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return (Text);
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Text); }
set { Text = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
ForeColor = style.TextColor;
Font = style.Font;
SetTextAlign(style);
}
Text = GetValue(_Cell.Value);
_ValueChanged = false;
}
#region SetTextAlign
private void SetTextAlign(CellVisualStyle style)
{
switch (style.Alignment)
{
case Alignment.TopLeft:
case Alignment.MiddleLeft:
case Alignment.BottomLeft:
TextAlign = HorizontalAlignment.Left;
break;
case Alignment.TopCenter:
case Alignment.MiddleCenter:
case Alignment.BottomCenter:
TextAlign = HorizontalAlignment.Center;
break;
case Alignment.TopRight:
case Alignment.MiddleRight:
case Alignment.BottomRight:
TextAlign = HorizontalAlignment.Right;
break;
}
}
#endregion
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
Size size = GetPreferredSize(constraintSize);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
Show();
Focus();
if (selectAll == true)
SelectAll();
else
Select(Text.Length, 1);
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
CloseDropDown();
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
CloseDropDown();
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
// Let the TextBox handle the following keys
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Home:
case Keys.End:
return (true);
case Keys.Down:
case Keys.Up:
if (IsAutoSuggestDropdownOpen())
return (true);
return (gridWantsKey == false);
default:
return (gridWantsKey == false);
}
}
#region IsAutoSuggestDropdownOpen
private bool IsAutoSuggestDropdownOpen()
{
_AutoSuggestDropdownOpen = false;
if (AutoCompleteMode == AutoCompleteMode.Suggest ||
AutoCompleteMode == AutoCompleteMode.SuggestAppend)
{
EnumThreadWndProc callback = CheckWindow;
EnumThreadWindows(GetCurrentThreadId(), callback, IntPtr.Zero);
}
return (_AutoSuggestDropdownOpen);
}
#region CheckWindow
private bool CheckWindow(IntPtr hWnd, IntPtr lp)
{
StringBuilder sb = new StringBuilder(260);
GetClassName(hWnd, sb, sb.Capacity);
if (sb.ToString() == "Auto-Suggest Dropdown")
{
_AutoSuggestDropdownOpen = IsWindowVisible(hWnd);
return (false);
}
return (true);
}
#endregion
#endregion
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,587 @@
using System;
using System.ComponentModel;
using System.Data.SqlTypes;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridTextBoxEditControl
///</summary>
[ToolboxItem(false)]
public class GridTextBoxXEditControl : TextBoxX, IGridCellEditControl
{
///<summary>
/// GridTextBoxXEditControl
///</summary>
public GridTextBoxXEditControl()
{
Multiline = true;
}
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.None;
#endregion
#region OnTextChanged
/// <summary>
/// OnTextChanged
/// </summary>
/// <param name="e"></param>
protected override void OnTextChanged(EventArgs e)
{
if (_SuspendUpdate == false)
_Cell.EditorValueChanged(this);
base.OnTextChanged(e);
}
#endregion
#region OnPaintBackground
/// <summary>
/// OnPaintBackground
/// </summary>
/// <param name="e"></param>
protected override void OnPaintBackground(PaintEventArgs e)
{
_Cell.PaintEditorBackground(e, this);
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual string GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return ("");
}
if (value is SqlString)
{
SqlString sdt = (SqlString) value;
if (sdt.IsNull == true)
return ("");
return (sdt.Value);
}
return (Convert.ToString(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.Modal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get
{
if (_Cell != null && _Cell.IsValueNull == true)
return (_Cell.NullString);
return ((PasswordChar == '\0')
? Text : new string(PasswordChar, TextLength));
}
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (Text); }
set { Text = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get
{
return ((Multiline == true)
? StretchBehavior.VerticalOnly : StretchBehavior.None );
}
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateLayout); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
{
Enabled = (_Cell.ReadOnly == false);
WordWrap = (style.AllowWrap == Tbool.True);
ForeColor = style.TextColor;
Font = style.Font;
Multiline = WordWrap;
}
Text = GetValue(_Cell.Value);
_ValueChanged = false;
}
#region SetTextAlign
private void SetTextAlign(CellVisualStyle style)
{
switch (style.Alignment)
{
case Alignment.TopLeft:
case Alignment.MiddleLeft:
case Alignment.BottomLeft:
TextAlign = HorizontalAlignment.Left;
break;
case Alignment.TopCenter:
case Alignment.MiddleCenter:
case Alignment.BottomCenter:
TextAlign = HorizontalAlignment.Center;
break;
case Alignment.TopRight:
case Alignment.MiddleRight:
case Alignment.BottomRight:
TextAlign = HorizontalAlignment.Right;
break;
}
}
#endregion
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
eTextFormat tf = style.GetTextFormatFlags();
string s = String.IsNullOrEmpty(Text) ? " " : Text;
SetTextAlign(style);
Size size = (constraintSize.IsEmpty == true)
? TextHelper.MeasureText(g, s, style.Font, new Size(10000, 0), tf)
: TextHelper.MeasureText(g, s, style.Font, constraintSize, tf);
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
if (selectAll == true)
SelectAll();
else
Select(Text.Length, 1);
Show();
Focus();
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
// Let the TextBox handle the following keys
if (Multiline == true)
{
switch (key & Keys.KeyCode)
{
case Keys.Up:
if (GetLineFromCharIndex(SelectionStart) != 0)
return (true);
break;
case Keys.Down:
int lastLine = GetLineFromCharIndex(int.MaxValue);
if (GetLineFromCharIndex(SelectionStart) < lastLine)
return (true);
break;
case Keys.Enter:
if (AcceptsReturn == true)
return (true);
break;
}
}
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Home:
case Keys.End:
return (true);
case Keys.Tab:
if (AcceptsTab == true)
return (true);
break;
}
return (gridWantsKey == false);
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
}
#endregion
#endregion
#endregion
#region Dispose
/// <summary>
/// Dispose
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
try
{
base.Dispose(disposing);
}
catch
{
}
}
#endregion
}
}

View File

@@ -0,0 +1,500 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// GridButtXEditControl
///</summary>
[ToolboxItem(false)]
public class GridTrackBarEditControl : TrackBar, IGridCellEditControl
{
#region Private variables
private GridCell _Cell;
private EditorPanel _EditorPanel;
private Bitmap _EditorCellBitmap;
private bool _ValueChanged;
private bool _SuspendUpdate;
private StretchBehavior _StretchBehavior = StretchBehavior.Both;
#endregion
///<summary>
/// GridTrackBarEditControl
///</summary>
public GridTrackBarEditControl()
{
AutoSize = false;
Maximum = 100;
TickFrequency = 10;
}
#region OnValueChanged
/// <summary>
/// OnValueChanged
/// </summary>
/// <param name="e"></param>
protected override void OnValueChanged(EventArgs e)
{
if (_Cell != null && _SuspendUpdate == false)
{
_Cell.Value = Value;
_Cell.EditorValueChanged(this);
}
base.OnValueChanged(e);
}
#endregion
#region OnInvalidated
/// <summary>
/// OnInvalidated
/// </summary>
/// <param name="e"></param>
protected override void OnInvalidated(InvalidateEventArgs e)
{
base.OnInvalidated(e);
if (_SuspendUpdate == false)
_Cell.InvalidateRender();
}
#endregion
#region GetValue
///<summary>
/// GetValue
///</summary>
///<param name="value"></param>
///<returns></returns>
public virtual int GetValue(object value)
{
GridPanel panel = _Cell.GridPanel;
if (value == null ||
(panel.NullValue == NullValue.DBNull && value == DBNull.Value))
{
return (0);
}
return (Convert.ToInt32(value));
}
#endregion
#region IGridCellEditControl Members
#region Public properties
#region CanInterrupt
/// <summary>
/// CanInterrupt
/// </summary>
public bool CanInterrupt
{
get { return (true); }
}
#endregion
#region CellEditMode
/// <summary>
/// CellEditMode
/// </summary>
public CellEditMode CellEditMode
{
get { return (CellEditMode.NonModal); }
}
#endregion
#region EditorCell
/// <summary>
/// EditorCell
/// </summary>
public GridCell EditorCell
{
get { return (_Cell); }
set { _Cell = value; }
}
#endregion
#region EditorCellBitmap
///<summary>
/// EditorCellBitmap
///</summary>
public Bitmap EditorCellBitmap
{
get { return (_EditorCellBitmap); }
set
{
if (_EditorCellBitmap != null)
_EditorCellBitmap.Dispose();
_EditorCellBitmap = value;
}
}
#endregion
#region EditorFormattedValue
///<summary>
/// EditorFormattedValue
///</summary>
public virtual string EditorFormattedValue
{
get { return (Text); }
}
#endregion
#region EditorPanel
/// <summary>
/// EditorPanel
/// </summary>
public EditorPanel EditorPanel
{
get { return (_EditorPanel); }
set { _EditorPanel = value; }
}
#endregion
#region EditorValue
/// <summary>
/// EditorValue
/// </summary>
public virtual object EditorValue
{
get { return (_Cell.Value); }
set { Value = GetValue(value); }
}
#endregion
#region EditorValueChanged
/// <summary>
/// EditorValueChanged
/// </summary>
public virtual bool EditorValueChanged
{
get { return (_ValueChanged); }
set
{
if (_ValueChanged != value)
{
_ValueChanged = value;
if (value == true)
_Cell.SetEditorDirty(this);
}
}
}
#endregion
#region EditorValueType
///<summary>
/// EditorValueType
///</summary>
public virtual Type EditorValueType
{
get { return (typeof(string)); }
}
#endregion
#region StretchBehavior
/// <summary>
/// StretchBehavior
/// </summary>
public virtual StretchBehavior StretchBehavior
{
get { return (_StretchBehavior); }
set { _StretchBehavior = value; }
}
#endregion
#region SuspendUpdate
/// <summary>
/// SuspendUpdate
/// </summary>
public bool SuspendUpdate
{
get { return (_SuspendUpdate); }
set { _SuspendUpdate = value; }
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// ValueChangeBehavior
/// </summary>
public virtual ValueChangeBehavior ValueChangeBehavior
{
get { return (ValueChangeBehavior.InvalidateRender); }
}
#endregion
#endregion
#region InitializeContext
///<summary>
/// InitializeContext
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
public virtual void InitializeContext(GridCell cell, CellVisualStyle style)
{
_Cell = cell;
if (style != null)
Enabled = (_Cell.IsReadOnly == false);
Value = GetValue(_Cell.Value);
_ValueChanged = false;
}
#endregion
#region GetProposedSize
///<summary>
/// GetProposedSize
///</summary>
///<param name="g"></param>
///<param name="cell"></param>
///<param name="style"></param>
///<param name="constraintSize"></param>
///<returns></returns>
public virtual Size GetProposedSize(Graphics g,
GridCell cell, CellVisualStyle style, Size constraintSize)
{
_SuspendUpdate = true;
Rectangle r = Bounds;
AutoSize = true;
Size size = GetPreferredSize(constraintSize);
AutoSize = false;
Bounds = r;
_SuspendUpdate = false;
return (size);
}
#endregion
#region Edit support
#region BeginEdit
/// <summary>
/// BeginEdit
/// </summary>
/// <param name="selectAll"></param>
/// <returns></returns>
public virtual bool BeginEdit(bool selectAll)
{
return (false);
}
#endregion
#region EndEdit
/// <summary>
/// EndEdit
/// </summary>
/// <returns></returns>
public virtual bool EndEdit()
{
return (false);
}
#endregion
#region CancelEdit
/// <summary>
/// CancelEdit
/// </summary>
/// <returns></returns>
public virtual bool CancelEdit()
{
return (false);
}
#endregion
#endregion
#region CellRender
/// <summary>
/// CellRender
/// </summary>
/// <param name="g"></param>
public virtual void CellRender(Graphics g)
{
_Cell.CellRender(this, g);
}
#endregion
#region Keyboard support
#region CellKeyDown
///<summary>
/// CellKeyDown
///</summary>
public virtual void CellKeyDown(KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Add:
Value += SmallChange;
break;
case Keys.Subtract:
Value -= SmallChange;
break;
default:
OnKeyDown(e);
break;
}
}
#endregion
#region WantsInputKey
/// <summary>
/// WantsInputKey
/// </summary>
/// <param name="key"></param>
/// <param name="gridWantsKey"></param>
/// <returns></returns>
public virtual bool WantsInputKey(Keys key, bool gridWantsKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Add:
case Keys.Subtract:
case Keys.Space:
return (true);
default:
return (gridWantsKey == false);
}
}
#endregion
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// OnCellMouseMove
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseMove(MouseEventArgs e)
{
OnMouseMove(e);
}
#endregion
#region OnCellMouseEnter
///<summary>
/// OnCellMouseEnter
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseEnter(EventArgs e)
{
}
#endregion
#region OnCellMouseLeave
///<summary>
/// OnCellMouseLeave
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseLeave(EventArgs e)
{
OnMouseLeave(e);
}
#endregion
#region OnCellMouseUp
///<summary>
/// OnCellMouseUp
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseUp(MouseEventArgs e)
{
OnMouseUp(e);
}
#endregion
#region OnCellMouseDown
///<summary>
/// OnCellMouseDown
///</summary>
///<param name="e"></param>
public virtual void OnCellMouseDown(MouseEventArgs e)
{
OnMouseDown(e);
}
#endregion
#endregion
#endregion
}
}

View File

@@ -0,0 +1,466 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
///<summary>
/// IGridCellEditControl
///</summary>
public interface IGridCellEditControl
{
#region Properties
#region CanInterrupt
///<summary>
/// Specifies whether the Grid can automatically interrupt the
/// current NonModal cell edit operation when the mouse leaves the cell.
///
/// This is utilized in cases, such as the ButtonX editor, where multilevel
/// controls may be involved. In the ButtonX case this specifically enables
/// the mouse to to leave the main cell window and not be interrupted by the
/// grid until the current operation is complete by the editor itself.
///
///</summary>
bool CanInterrupt { get; }
#endregion
#region CellEditMode
///<summary>
/// Specifies the cell editor activation mode. There are three modes
/// available for choice, and their usage depends upon the desired
/// editor presentation, as well as how well the given underlying
/// control interacts with the grid control.
///
/// The modes are as follows:
///
/// InPlace:
/// Edit operations occur 'in place', always live, always
/// in a state of interaction with the user. The CheckBoxEx,
/// and ButtonX editors are examples of this.
///
/// Modal:
/// Edit operations will be performed as a modal, widowed edit
/// controlled via calls to BeginEdit, EndEdit, and CancelEdit.
/// The TextBoxEx and IntegerInput editors are examples of this.
///
/// NonModal:
/// Edit operation will be performed as a nonNodal, windowed edit
/// automatically invoked upon entry to the cell. The ButtonEx,
/// BubbleBar, and TrackBar are examples of this.
///
///</summary>
CellEditMode CellEditMode { get; }
#endregion
#region EditorCell
///<summary>
/// Specifies the editor's current associated grid cell
///</summary>
GridCell EditorCell { get; set; }
#endregion
#region EditorCellBitmap
///<summary>
/// Called to get or set the editor's
/// associated cell bitmap (internal use only)
///</summary>
Bitmap EditorCellBitmap { get; set; }
#endregion
#region EditorFormattedValue
///<summary>
/// Called to get the formatted editor value
///</summary>
string EditorFormattedValue { get; }
#endregion
#region EditorPanel
///<summary>
/// Called to get or set the editor's
/// associated cell panel (internal use only)
///</summary>
EditorPanel EditorPanel { get; set; }
#endregion
#region EditorValue
///<summary>
/// Called to get or set the editor value
///</summary>
object EditorValue { get; set;}
#endregion
#region EditorValueChanged
///<summary>
/// Called to get or set whether the editor value has changed
///</summary>
bool EditorValueChanged { get; set;}
#endregion
#region EditorValueType
///<summary>
/// Called to get the editor's default value data type
///</summary>
Type EditorValueType { get; }
#endregion
#region StretchBehavior
///<summary>
/// Called to get the editor's desired 'stretch' behavior.
///
/// The StretchBehavior defines whether the editor wants to
/// automatically have it's size stretched to fill the given cell.
///
/// Editors, such as ButtonX, want to fill the cell horizontally and
/// vertically, whereas other editors, such as the Slider, may only
/// want to stretch horizontally (or potentially not at all).
///</summary>
StretchBehavior StretchBehavior { get; }
#endregion
#region SuspendUpdate
///<summary>
/// Called to get or set whether updates to the grid
/// state is suspended
///</summary>
bool SuspendUpdate { get; set; }
#endregion
#region ValueChangeBehavior
///<summary>
/// Called to get the behavior
/// needed when a value changes in the editor.
///
/// For instance, CheckBoxEx value changes result in only requiring
/// the cell to be redisplayed with the new state, whereas editors such
/// as the TextBoxEx editor, may result in a new layout when the text changes.
///
///</summary>
ValueChangeBehavior ValueChangeBehavior { get; }
#endregion
#endregion
#region CellRender
///<summary>
/// Called to initiate the actual rendering of the editor
/// value into the grid cell. In most cases this can be (and is)
/// handled by a simple call to EditorCell.CellRender(this, graphics).
/// If additional rendering is required by the editor, then the editor
/// can completely render the cell contents itself (and never even call
/// Editor.CellRender) or optionally perform additional rendering before
/// or after the default cell rendering.
///</summary>
///<param name="g"></param>
void CellRender(Graphics g);
#endregion
#region CellKeyDown
///<summary>
/// Called when a KeyDown occurs and the
/// CellEditMode is InPlace (otherwise the key event is
/// automatically directed straight to the editor control).
///
///</summary>
void CellKeyDown(KeyEventArgs e);
#endregion
#region Edit support
#region BeginEdit
///<summary>
/// Called when a Modal cell edit is about to be initiated.
///</summary>
///<param name="selectAll">Signifies whether to select all editable content</param>
///<returns>true to cancel the edit operation</returns>
bool BeginEdit(bool selectAll);
#endregion
#region EndEdit
///<summary>
/// Called when the edit operation is about to end.
///</summary>
///<returns>true to cancel the operation.</returns>
bool EndEdit();
#endregion
#region CancelEdit
///<summary>
/// Called when the edit operation is being cancelled.
///</summary>
///<returns>true to cancel the operation.</returns>
bool CancelEdit();
#endregion
#endregion
#region GetProposedSize
///<summary>
/// Called to retrieve the editors proposed size
/// for the given cell, using the provided effective
/// style and size constraint.
///</summary>
///<param name="g">Graphics object</param>
///<param name="cell">Associated grid cell</param>
///<param name="style">Cell's effective style</param>
///<param name="constraintSize">The constraining cell size</param>
///<returns></returns>
Size GetProposedSize(Graphics g, GridCell cell, CellVisualStyle style, Size constraintSize);
#endregion
#region InitializeContext
///<summary>
/// Called to initialize the editor's context
/// environment (value, properties, style, etc)
///</summary>
///<param name="cell"></param>
///<param name="style"></param>
void InitializeContext(GridCell cell, CellVisualStyle style);
#endregion
#region Mouse support
#region OnCellMouseMove
///<summary>
/// Called when a MouseMove event occurs and the
/// CellEditMode is InPlace (otherwise the event is
/// automatically directed straight to the editor control).
///</summary>
///<param name="e"></param>
void OnCellMouseMove(MouseEventArgs e);
#endregion
#region OnCellMouseEnter
/// <summary>
/// Called when a MouseEnter event occurs and the
/// CellEditMode is InPlace (otherwise the event is
/// automatically directed straight to the editor control).
/// </summary>
/// <param name="e"></param>
void OnCellMouseEnter(EventArgs e);
#endregion
#region OnCellMouseLeave
///<summary>
/// Called when a MouseLeave event occurs and the
/// CellEditMode is InPlace (otherwise the event is
/// automatically directed straight to the editor control).
///</summary>
///<param name="e"></param>
void OnCellMouseLeave(EventArgs e);
#endregion
#region OnCellMouseUp
/// <summary>
/// Called when a MouseUp event occurs and the
/// CellEditMode is InPlace (otherwise the event is
/// automatically directed straight to the editor control).
/// </summary>
/// <param name="e"></param>
void OnCellMouseUp(MouseEventArgs e);
#endregion
#region OnCellMouseDown
/// <summary>
/// Called when a MouseDown event occurs and the
/// CellEditMode is InPlace (otherwise the event is
/// automatically directed straight to the editor control).
/// </summary>
/// <param name="e"></param>
void OnCellMouseDown(MouseEventArgs e);
#endregion
#endregion
#region WantsInputKey
///<summary>
/// Called to determine if the editor wants to process and
/// handle the given key
///</summary>
///<param name="key">Key in question</param>
///<param name="gridWantsKey">Whether the grid, by default, wants the key</param>
///<returns>true is the control wants the key</returns>
bool WantsInputKey(Keys key, bool gridWantsKey);
#endregion
}
#region IGridCellConvertTo
///<summary>
///IGridCellConvertTo
///</summary>
public interface IGridCellConvertTo
{
///<summary>
///TryConvertTo
///</summary>
///<param name="value">Value to convert</param>
///<param name="dataType">Data type to convert to</param>
///<param name="result">Converted value</param>
///<returns></returns>
bool TryConvertTo(object value, Type dataType, out object result);
}
#endregion
#region IGridCellEditorFocus
///<summary>
///IGridCellEditorFocus
///</summary>
public interface IGridCellEditorFocus
{
///<summary>
///Indicates whether the editor has the input focus
///</summary>
///<returns></returns>
bool IsEditorFocused { get; }
///<summary>
///Gives the editor the input focus
///</summary>
void FocusEditor();
}
#endregion
#region enums
#region CellEditMode
///<summary>
/// Specifies the mode of cell editor activation
///</summary>
public enum CellEditMode
{
///<summary>
/// Edit operation will be performed as a modal, widowed
/// edit controlled via BeginEdit, EndEdit, and CancelEdit.
///</summary>
Modal,
///<summary>
/// Edit operation will be performed as a nonNodal, windowed
/// edit automatically invoked upon entry to the cell.
///</summary>
NonModal,
///<summary>
/// Edit operation will be performed in-place, as a non-windowed
/// edit automatically invoked upon entry to the cell.
///</summary>
InPlace,
}
#endregion
#region StretchBehavior
/// <summary>
/// Defines how the editor is stretched to
/// have it's size fill the given cell.
/// </summary>
public enum StretchBehavior
{
///<summary>
/// No stretching to fill the cell
///</summary>
None,
///<summary>
/// Auto stretch horizontally only
///</summary>
HorizontalOnly,
///<summary>
/// Auto stretch vertically only
///</summary>
VerticalOnly,
///<summary>
/// Auto stretch both horizontally and vertically
///</summary>
Both,
}
#endregion
#region ValueChangeBehavior
/// <summary>
/// Defines how the grid should respond to
/// editor content / value changes
/// </summary>
public enum ValueChangeBehavior
{
///<summary>
/// No action needed
///</summary>
None,
///<summary>
/// Grid layout needs invalidated
///</summary>
InvalidateLayout,
///<summary>
/// Cell needs rendered
///</summary>
InvalidateRender,
}
#endregion
#endregion
}