DotNet 4.8.1 build of DotNetBar
This commit is contained in:
+105
@@ -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
|
||||
}
|
||||
}
|
||||
+517
@@ -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
|
||||
}
|
||||
}
|
||||
+501
@@ -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
|
||||
}
|
||||
}
|
||||
+610
@@ -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
|
||||
}
|
||||
}
|
||||
+612
@@ -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
|
||||
}
|
||||
}
|
||||
+676
@@ -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
|
||||
}
|
||||
}
|
||||
+602
@@ -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
|
||||
}
|
||||
}
|
||||
+871
@@ -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
|
||||
}
|
||||
}
|
||||
+622
@@ -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
|
||||
}
|
||||
}
|
||||
+506
@@ -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
|
||||
}
|
||||
}
|
||||
+490
@@ -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
|
||||
}
|
||||
}
|
||||
+621
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+548
@@ -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
|
||||
}
|
||||
}
|
||||
+900
@@ -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
|
||||
}
|
||||
+570
@@ -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
|
||||
}
|
||||
}
|
||||
+463
@@ -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
|
||||
}
|
||||
}
|
||||
+513
@@ -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
|
||||
}
|
||||
}
|
||||
+555
@@ -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
|
||||
}
|
||||
}
|
||||
+526
@@ -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
|
||||
}
|
||||
}
|
||||
+488
@@ -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
|
||||
}
|
||||
}
|
||||
+549
@@ -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
|
||||
}
|
||||
}
|
||||
+481
@@ -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
|
||||
}
|
||||
}
|
||||
+575
@@ -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
|
||||
}
|
||||
}
|
||||
+506
@@ -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
|
||||
}
|
||||
}
|
||||
+510
@@ -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
|
||||
}
|
||||
}
|
||||
+593
@@ -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
|
||||
}
|
||||
}
|
||||
+577
@@ -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
|
||||
}
|
||||
}
|
||||
+587
@@ -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
|
||||
}
|
||||
}
|
||||
+500
@@ -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
|
||||
}
|
||||
}
|
||||
+466
@@ -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
|
||||
}
|
||||
Generated
+43
@@ -0,0 +1,43 @@
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
partial class CellInfoWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// CellInfoWindow
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(16, 16);
|
||||
this.Name = "CellInfoWindow";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
public partial class CellInfoWindow : FloatWindow
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private SuperGridControl _SuperGrid;
|
||||
private GridCell _Cell;
|
||||
|
||||
private System.Windows.Forms.ToolTip _ToolTip;
|
||||
|
||||
#endregion
|
||||
|
||||
public CellInfoWindow(SuperGridControl superGrid, GridCell cell)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Image image = cell.GetInfoImage();
|
||||
|
||||
if (image != null)
|
||||
Size = image.Size;
|
||||
|
||||
TopLevel = false;
|
||||
|
||||
_SuperGrid = superGrid;
|
||||
_Cell = cell;
|
||||
|
||||
_ToolTip = new System.Windows.Forms.ToolTip();
|
||||
|
||||
using (GraphicsPath path = GetImageGraphicsPath())
|
||||
Region = new Region(path);
|
||||
|
||||
Paint += CellInfoWindowPaint;
|
||||
MouseClick += CellInfoWindowMouseClick;
|
||||
MouseDoubleClick += CellInfoWindowMouseDoubleClick;
|
||||
|
||||
MouseEnter += CellInfoWindowMouseEnter;
|
||||
MouseLeave += CellInfoWindowMouseLeave;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region ToolTip
|
||||
|
||||
public System.Windows.Forms.ToolTip ToolTip
|
||||
{
|
||||
get { return (_ToolTip); }
|
||||
internal set { _ToolTip = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellInfoWindowMouseEnter
|
||||
|
||||
void CellInfoWindowMouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
if (_SuperGrid.DoCellInfoEnterEvent(_Cell, this, _ToolTip, MousePosition) == false)
|
||||
_ToolTip.SetToolTip(this, _Cell.InfoText);
|
||||
else
|
||||
_ToolTip.SetToolTip(this, "");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellInfoWindowMouseLeave
|
||||
|
||||
void CellInfoWindowMouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
_SuperGrid.DoCellInfoLeaveEvent(_Cell, this, _ToolTip);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetImageGraphicsPath
|
||||
|
||||
private GraphicsPath GetImageGraphicsPath()
|
||||
{
|
||||
Bitmap bitmap = new Bitmap(_Cell.GetInfoImage());
|
||||
GraphicsPath graphicsPath = new GraphicsPath();
|
||||
|
||||
Color colorTransparent = bitmap.GetPixel(0, 0);
|
||||
|
||||
for (int row = 0; row < bitmap.Height; row++)
|
||||
{
|
||||
for (int col = 0; col < bitmap.Width; col++)
|
||||
{
|
||||
if (bitmap.GetPixel(col, row) != colorTransparent)
|
||||
{
|
||||
int colOpaquePixel = col;
|
||||
int colNext;
|
||||
|
||||
for (colNext = colOpaquePixel; colNext < bitmap.Width; colNext++)
|
||||
{
|
||||
if (bitmap.GetPixel(colNext, row) == colorTransparent)
|
||||
break;
|
||||
}
|
||||
|
||||
graphicsPath.AddRectangle(new Rectangle(colOpaquePixel,
|
||||
row, colNext - colOpaquePixel, 1));
|
||||
|
||||
col = colNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (graphicsPath);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellInfoWindowPaint
|
||||
|
||||
void CellInfoWindowPaint(object sender, PaintEventArgs e)
|
||||
{
|
||||
Image image = _Cell.GetInfoImage();
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
Rectangle r = Bounds;
|
||||
r.Location = Point.Empty;
|
||||
|
||||
e.Graphics.DrawImageUnscaledAndClipped(image, r);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellInfoWindowMouseClick
|
||||
|
||||
void CellInfoWindowMouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
_SuperGrid.DoCellInfoClickEvent(_Cell, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellInfoWindowMouseDoubleClick
|
||||
|
||||
void CellInfoWindowMouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
_SuperGrid.DoCellInfoDoubleClickEvent(_Cell, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// CheckDisplay
|
||||
///</summary>
|
||||
static public class CheckDisplay
|
||||
{
|
||||
///<summary>
|
||||
/// RenderCheckbox
|
||||
///</summary>
|
||||
///<param name="g"></param>
|
||||
///<param name="bounds"></param>
|
||||
///<param name="cstate"></param>
|
||||
///<param name="bstate"></param>
|
||||
static public void RenderCheckbox(
|
||||
Graphics g, Rectangle bounds, CheckBoxState cstate, ButtonState bstate)
|
||||
{
|
||||
Size csize = CheckBoxRenderer.GetGlyphSize(g, cstate);
|
||||
|
||||
if (Application.RenderWithVisualStyles == true)
|
||||
{
|
||||
Point pt = bounds.Location;
|
||||
pt.Y += (bounds.Height - csize.Height) / 2;
|
||||
|
||||
CheckBoxRenderer.DrawCheckBox(g, pt, cstate);
|
||||
}
|
||||
else
|
||||
{
|
||||
ControlPaint.DrawCheckBox(g, bounds, bstate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3203
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+54
@@ -0,0 +1,54 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// CheckDisplay
|
||||
///</summary>
|
||||
static public class ExpandDisplay
|
||||
{
|
||||
#region RenderButton
|
||||
|
||||
///<summary>
|
||||
/// RenderButton
|
||||
///</summary>
|
||||
///<param name="g"></param>
|
||||
///<param name="image"></param>
|
||||
///<param name="buttonBounds"></param>
|
||||
///<param name="clipBounds"></param>
|
||||
static public Size RenderButton(Graphics g,
|
||||
Image image, Rectangle buttonBounds, Rectangle clipBounds)
|
||||
{
|
||||
if (image != null && buttonBounds.IsEmpty == false)
|
||||
{
|
||||
Rectangle r = buttonBounds;
|
||||
r.Width++;
|
||||
r.Height++;
|
||||
|
||||
Size isize = Dpi.Size(image.Size);
|
||||
|
||||
if (r.Width > isize.Width)
|
||||
{
|
||||
r.X += (r.Width - isize.Width) / 2;
|
||||
r.Width = isize.Width;
|
||||
}
|
||||
|
||||
if (r.Height > isize.Height)
|
||||
{
|
||||
r.Y += (r.Height - isize.Height) / 2;
|
||||
r.Height = isize.Height;
|
||||
}
|
||||
|
||||
r.Intersect(clipBounds);
|
||||
|
||||
g.DrawImageUnscaledAndClipped(image, r);
|
||||
|
||||
return (r.Size);
|
||||
}
|
||||
|
||||
return (Size.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Generated
+51
@@ -0,0 +1,51 @@
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
partial class FloatWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// FloatWindow
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.CausesValidation = false;
|
||||
this.ClientSize = new System.Drawing.Size(90, 23);
|
||||
this.ControlBox = false;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FloatWindow";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// FloatWindow
|
||||
///</summary>
|
||||
public partial class FloatWindow : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public FloatWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
SetStyle(ControlStyles.UserPaint, true);
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||
SetStyle(ControlStyles.Selectable, false);
|
||||
}
|
||||
|
||||
const int WS_EX_NOACTIVATE = 0x08000000;
|
||||
|
||||
/// <summary>
|
||||
/// CreateParams
|
||||
/// </summary>
|
||||
protected override CreateParams CreateParams
|
||||
{
|
||||
get
|
||||
{
|
||||
CreateParams cp = base.CreateParams;
|
||||
|
||||
cp.ExStyle |= WS_EX_NOACTIVATE;
|
||||
|
||||
return (cp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ShowWithoutActivation
|
||||
/// </summary>
|
||||
protected override bool ShowWithoutActivation
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.SuperGrid.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// GridCaption
|
||||
///</summary>
|
||||
public class GridCaption : GridTextRow
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
///<summary>
|
||||
/// GridCaption
|
||||
///</summary>
|
||||
public GridCaption()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// GridCaption
|
||||
///</summary>
|
||||
///<param name="text"></param>
|
||||
public GridCaption(string text)
|
||||
: base(text)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hidden properties
|
||||
|
||||
#region RowHeaderVisibility
|
||||
|
||||
/// <summary>
|
||||
/// RowHeaderVisibility
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new RowHeaderVisibility RowHeaderVisibility
|
||||
{
|
||||
get { return (base.RowHeaderVisibility); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderBorder
|
||||
|
||||
/// <summary>
|
||||
/// RenderBorder
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="panel"></param>
|
||||
/// <param name="pstyle"></param>
|
||||
/// <param name="r"></param>
|
||||
protected override void RenderBorder(Graphics g,
|
||||
GridPanel panel, GridPanelVisualStyle pstyle, Rectangle r)
|
||||
{
|
||||
using (Pen pen = new Pen(pstyle.HeaderLineColor))
|
||||
{
|
||||
r.Height--;
|
||||
g.DrawLine(pen, r.X, r.Bottom, r.Right - 1, r.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CanShowRowHeader
|
||||
|
||||
/// <summary>
|
||||
/// CanShowRowHeader
|
||||
/// </summary>
|
||||
/// <param name="panel"></param>
|
||||
/// <returns></returns>
|
||||
protected override bool CanShowRowHeader(GridPanel panel)
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style support
|
||||
|
||||
/// <summary>
|
||||
/// ApplyStyleEx
|
||||
/// </summary>
|
||||
/// <param name="style"></param>
|
||||
/// <param name="css"></param>
|
||||
protected override void ApplyStyleEx(TextRowVisualStyle style, StyleType[] css)
|
||||
{
|
||||
foreach (StyleType cs in css)
|
||||
{
|
||||
style.ApplyStyle(SuperGrid.BaseVisualStyles.CaptionStyles[cs]);
|
||||
style.ApplyStyle(SuperGrid.DefaultVisualStyles.CaptionStyles[cs]);
|
||||
style.ApplyStyle(GridPanel.DefaultVisualStyles.CaptionStyles[cs]);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+82
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
using DevComponents.DotNetBar.SuperGrid.Primitives;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the collection of grid cells.
|
||||
/// </summary>
|
||||
[Editor("DevComponents.SuperGrid.Design.GridCellCollectionEditor, DevComponents.SuperGrid.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=26d81176cfa2b486", typeof(UITypeEditor))]
|
||||
public class GridCellCollection : CustomCollection<GridCell>
|
||||
{
|
||||
#region Indexer (string)
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets item at ColumnName index
|
||||
/// </summary>
|
||||
/// <param name="columnName">Name of Column containing the cell</param>
|
||||
public GridCell this[string columnName]
|
||||
{
|
||||
get
|
||||
{
|
||||
GridCell cell = FindCellItem(columnName);
|
||||
|
||||
if (cell != null)
|
||||
return (Items[cell.ColumnIndex]);
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
GridCell cell = FindCellItem(columnName);
|
||||
|
||||
if (cell == null)
|
||||
throw new Exception("Column \"" + columnName + "\" not found.");
|
||||
|
||||
Items[cell.ColumnIndex] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Indexer (Column)
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets item at Column index
|
||||
/// </summary>
|
||||
/// <param name="column">Column containing the cell</param>
|
||||
public GridCell this[GridColumn column]
|
||||
{
|
||||
get { return (Items[column.ColumnIndex]); }
|
||||
set { Items[column.ColumnIndex] = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FindCellItem
|
||||
|
||||
private GridCell FindCellItem(string columnName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(columnName) == true)
|
||||
throw new Exception("Invalid Column Name.");
|
||||
|
||||
foreach (GridCell cell in Items)
|
||||
{
|
||||
GridColumn col = cell.GridColumn;
|
||||
|
||||
if (col == null)
|
||||
break;
|
||||
|
||||
if (columnName.Equals(col.Name) == true)
|
||||
return (cell);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+3910
File diff suppressed because it is too large
Load Diff
+787
@@ -0,0 +1,787 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the collection of grid columns
|
||||
/// </summary>
|
||||
[Editor("DevComponents.SuperGrid.Design.GridColumnCollectionEditor, DevComponents.SuperGrid.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=26d81176cfa2b486", typeof(UITypeEditor))]
|
||||
public class GridColumnCollection : CollectionBase
|
||||
{
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the collection has changed
|
||||
/// </summary>
|
||||
[Description("Occurs when collection has changed.")]
|
||||
public CollectionChangeEventHandler CollectionChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Variables
|
||||
|
||||
private GridElement _ParentItem;
|
||||
private int[] _DisplayIndexMap;
|
||||
private bool _IsDisplayIndexValid;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region FirstSelectableColumn
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to first selectable column
|
||||
/// or null if there is no first selectable column.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public GridColumn FirstSelectableColumn
|
||||
{
|
||||
get
|
||||
{
|
||||
int[] displayMap = DisplayIndexMap;
|
||||
|
||||
for (int i = 0; i < displayMap.Length; i++)
|
||||
{
|
||||
GridColumn column = this[displayMap[i]];
|
||||
|
||||
if (column.Visible == true && column.AllowSelection == true)
|
||||
return (column);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FirstVisibleColumn
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to first visible column
|
||||
/// or null if there is no first visible column.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public GridColumn FirstVisibleColumn
|
||||
{
|
||||
get
|
||||
{
|
||||
int[] displayMap = DisplayIndexMap;
|
||||
|
||||
for (int i = 0; i < displayMap.Length; i++)
|
||||
{
|
||||
if (this[displayMap[i]].Visible)
|
||||
return (this[displayMap[i]]);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Index indexer
|
||||
|
||||
/// <summary>
|
||||
/// Returns reference to the object in collection based on it's index.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public GridColumn this[int index]
|
||||
{
|
||||
get { return (GridColumn)(List[index]); }
|
||||
set { List[index] = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Name indexer
|
||||
|
||||
///<summary>
|
||||
/// Name indexer
|
||||
///</summary>
|
||||
///<param name="name"></param>
|
||||
///<exception cref="Exception"></exception>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public GridColumn this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
int index = FindIndexByName(name);
|
||||
|
||||
return (index >= 0 ? this[index] : null);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
int index = FindIndexByName(name);
|
||||
|
||||
if (index < 0)
|
||||
throw new Exception("Column Name not defined (" + name + ").");
|
||||
|
||||
List[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#region FindIndexByName
|
||||
|
||||
private int FindIndexByName(string name)
|
||||
{
|
||||
for (int i=0; i<List.Count; i++)
|
||||
{
|
||||
GridColumn item = (GridColumn)List[i];
|
||||
|
||||
if (name != null)
|
||||
name = name.ToUpper();
|
||||
|
||||
if (item.Name != null && item.Name.ToUpper().Equals(name))
|
||||
return (i);
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region LastSelectableColumn
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to last selectable column
|
||||
/// or null if there is no last selectable column.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public GridColumn LastSelectableColumn
|
||||
{
|
||||
get
|
||||
{
|
||||
int[] displayMap = DisplayIndexMap;
|
||||
|
||||
for (int i = displayMap.Length - 1; i >= 0; i--)
|
||||
{
|
||||
GridColumn column = this[displayMap[i]];
|
||||
|
||||
if (column.Visible == true && column.AllowSelection == true)
|
||||
return (column);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LastVisibleColumn
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to last visible column
|
||||
/// or null if there is no last visible column.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public GridColumn LastVisibleColumn
|
||||
{
|
||||
get
|
||||
{
|
||||
int[] displayMap = DisplayIndexMap;
|
||||
|
||||
for (int i = displayMap.Length - 1; i >= 0; i--)
|
||||
{
|
||||
if (this[displayMap[i]].Visible)
|
||||
return (this[displayMap[i]]);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ParentItem
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the node this collection is associated with.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public GridElement ParentItem
|
||||
{
|
||||
get { return _ParentItem; }
|
||||
|
||||
internal set
|
||||
{
|
||||
_ParentItem = value;
|
||||
|
||||
OnParentItemChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnParentItemChanged()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add
|
||||
|
||||
/// <summary>
|
||||
/// Adds new object to the collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Object to add.</param>
|
||||
/// <returns>Index of newly added object.</returns>
|
||||
public int Add(GridColumn value)
|
||||
{
|
||||
value.ColumnIndex = List.Add(value);
|
||||
|
||||
return (value.ColumnIndex);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Insert
|
||||
|
||||
/// <summary>
|
||||
/// Inserts new object into the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">Position of the object.</param>
|
||||
/// <param name="value">Object to insert.</param>
|
||||
public void Insert(int index, GridColumn value)
|
||||
{
|
||||
List.Insert(index, value);
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
((GridColumn)List[i]).ColumnIndex = i;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IndexOf
|
||||
|
||||
/// <summary>
|
||||
/// Returns index of the object inside of the collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Reference to the object.</param>
|
||||
/// <returns>Index of the object.</returns>
|
||||
public int IndexOf(GridColumn value)
|
||||
{
|
||||
return (List.IndexOf(value));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Contains
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether collection contains specified object.
|
||||
/// </summary>
|
||||
/// <param name="value">Object to look for.</param>
|
||||
/// <returns>true if object is part of the collection, otherwise false.</returns>
|
||||
public bool Contains(GridColumn value)
|
||||
{
|
||||
return (List.Contains(value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether collection contains specified object.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the object to look for.</param>
|
||||
/// <returns>true if object is part of the collection, otherwise false.</returns>
|
||||
public bool Contains(string name)
|
||||
{
|
||||
foreach (GridColumn column in List)
|
||||
{
|
||||
if (column.Name.Equals(name) == true)
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Remove
|
||||
|
||||
/// <summary>
|
||||
/// Removes specified object from the collection.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void Remove(GridColumn value)
|
||||
{
|
||||
List.Remove(value);
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
((GridColumn)List[i]).ColumnIndex = i;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnRemoveComplete
|
||||
|
||||
/// <summary>
|
||||
/// Called when remove of an item is completed.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of removed item</param>
|
||||
/// <param name="value">Removed item.</param>
|
||||
protected override void OnRemoveComplete(int index, object value)
|
||||
{
|
||||
if (value is GridColumn)
|
||||
{
|
||||
GridColumn column = (GridColumn)value;
|
||||
GridPanel panel = column.GridPanel;
|
||||
|
||||
ResetColumn(panel, column);
|
||||
}
|
||||
|
||||
OnCollectionChanged(CollectionChangeAction.Remove, value);
|
||||
|
||||
base.OnRemoveComplete(index, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clear
|
||||
|
||||
/// <summary>
|
||||
/// Clears all objects from the collection.
|
||||
/// </summary>
|
||||
public new void Clear()
|
||||
{
|
||||
foreach (GridColumn column in this)
|
||||
ResetColumn(column.GridPanel, column);
|
||||
|
||||
List.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnClearComplete
|
||||
|
||||
/// <summary>
|
||||
/// OnClearComplete
|
||||
/// </summary>
|
||||
protected override void OnClearComplete()
|
||||
{
|
||||
InvalidateDisplayIndexes();
|
||||
InvalidateLayout();
|
||||
|
||||
base.OnClearComplete();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ResetColumn
|
||||
|
||||
private void ResetColumn(GridPanel panel, GridColumn column)
|
||||
{
|
||||
column.DisplayIndexChanged -= ColumnDisplayIndexChanged;
|
||||
|
||||
if (panel.DataSource != null)
|
||||
panel.DataBinder.DataResetCount++;
|
||||
|
||||
GridCell cell = column.SuperGrid.ActiveElement as GridCell;
|
||||
|
||||
if (cell != null)
|
||||
{
|
||||
if (cell.ColumnIndex == column.ColumnIndex)
|
||||
column.SuperGrid.ActiveElement = null;
|
||||
}
|
||||
|
||||
if (panel.SortColumns.Contains(column))
|
||||
panel.SortColumns.Remove(column);
|
||||
|
||||
if (panel.GroupColumns.Contains(column))
|
||||
panel.GroupColumns.Remove(column);
|
||||
|
||||
FilterPanel fp = column.SuperGrid.ActiveFilterPanel;
|
||||
|
||||
if (fp != null && fp.GridColumn == column)
|
||||
fp.EndEdit();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnInsertComplete
|
||||
|
||||
/// <summary>
|
||||
/// Called when insertion of an item is completed.
|
||||
/// </summary>
|
||||
/// <param name="index">Insert index.</param>
|
||||
/// <param name="value">Inserted item.</param>
|
||||
protected override void OnInsertComplete(int index, object value)
|
||||
{
|
||||
if (value is GridColumn)
|
||||
{
|
||||
GridColumn column = (GridColumn)value;
|
||||
|
||||
if (column.Parent != null && column.Parent != _ParentItem)
|
||||
throw new Exception("Column is already a member of another Column collection.");
|
||||
|
||||
column.DisplayIndexChanged += ColumnDisplayIndexChanged;
|
||||
|
||||
column.Parent = _ParentItem;
|
||||
}
|
||||
|
||||
OnCollectionChanged(CollectionChangeAction.Add, value);
|
||||
|
||||
base.OnInsertComplete(index, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnCollectionChanged
|
||||
|
||||
private void OnCollectionChanged(
|
||||
CollectionChangeAction action, object value)
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
((GridColumn)List[i]).ColumnIndex = i;
|
||||
|
||||
if (action == CollectionChangeAction.Remove)
|
||||
{
|
||||
GridColumn rcol = (GridColumn)value;
|
||||
GridPanel panel = rcol.GridPanel;
|
||||
|
||||
if (rcol.DisplayIndex >= 0)
|
||||
{
|
||||
foreach (GridColumn col in panel.Columns)
|
||||
{
|
||||
if (col.DisplayIndex > rcol.DisplayIndex)
|
||||
col.DisplayIndex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InvalidateDisplayIndexes();
|
||||
InvalidateLayout();
|
||||
|
||||
if (CollectionChanged != null)
|
||||
{
|
||||
CollectionChangeEventArgs e = new
|
||||
CollectionChangeEventArgs(action, value);
|
||||
|
||||
CollectionChanged(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ColumnDisplayIndexChanged
|
||||
|
||||
private void ColumnDisplayIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
InvalidateDisplayIndexes();
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateDisplayIndexes
|
||||
|
||||
/// <summary>
|
||||
/// Invalidates the display indexes and
|
||||
/// causes them to be re-evaluated on next layout.
|
||||
/// </summary>
|
||||
public void InvalidateDisplayIndexes()
|
||||
{
|
||||
_IsDisplayIndexValid = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateLayout
|
||||
|
||||
private void InvalidateLayout()
|
||||
{
|
||||
if (_ParentItem != null)
|
||||
{
|
||||
_ParentItem.InvalidateLayout();
|
||||
|
||||
if (_ParentItem.SuperGrid != null)
|
||||
{
|
||||
_ParentItem.SuperGrid.NeedMergeLayout = true;
|
||||
_ParentItem.SuperGrid.DisplayedMergeLayoutCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Copies collection into the specified array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to copy collection to.</param>
|
||||
/// <param name="index">Starting index.</param>
|
||||
public void CopyTo(GridColumn[] array, int index)
|
||||
{
|
||||
List.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies contained items to the ColumnHeader array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to copy to.</param>
|
||||
internal void CopyTo(GridColumn[] array)
|
||||
{
|
||||
List.CopyTo(array, 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnClear
|
||||
|
||||
/// <summary>
|
||||
/// Called when collection is cleared.
|
||||
/// </summary>
|
||||
protected override void OnClear()
|
||||
{
|
||||
if (Count > 0)
|
||||
{
|
||||
GridPanel panel = this[0].Parent as GridPanel;
|
||||
|
||||
if (panel != null)
|
||||
{
|
||||
panel.SuperGrid.ActiveElement = null;
|
||||
|
||||
foreach (GridElement item in panel.Rows)
|
||||
{
|
||||
GridRow row = item as GridRow;
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
foreach (GridCell cell in row.Cells)
|
||||
{
|
||||
cell.EditControl = null;
|
||||
cell.RenderControl = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GridColumn item in this)
|
||||
{
|
||||
item.EditControl = null;
|
||||
item.RenderControl = null;
|
||||
}
|
||||
|
||||
base.OnClear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DisplayIndexMap
|
||||
|
||||
/// <summary>
|
||||
/// A map of display index (key) to index in the column collection
|
||||
/// (value). Used to quickly find a column from its display index.
|
||||
/// </summary>
|
||||
internal int[] DisplayIndexMap
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_IsDisplayIndexValid)
|
||||
UpdateDisplayIndexMap();
|
||||
|
||||
return (_DisplayIndexMap);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDisplayIndex
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display index for specified column.
|
||||
/// </summary>
|
||||
/// <param name="column">Column that is part of ColumnHeaderCollection</param>
|
||||
/// <returns>Display index or -1 column is not part of this collection.</returns>
|
||||
public int GetDisplayIndex(GridColumn column)
|
||||
{
|
||||
return (GetDisplayIndex(IndexOf(column)));
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Gets the display index for specified column.
|
||||
///</summary>
|
||||
///<param name="index">Column index</param>
|
||||
///<returns>Display index or -1 column is not part of this collection.</returns>
|
||||
public int GetDisplayIndex(int index)
|
||||
{
|
||||
UpdateDisplayIndexMap();
|
||||
|
||||
for (int i = 0; i < _DisplayIndexMap.Length; i++)
|
||||
{
|
||||
if (_DisplayIndexMap[i] == index)
|
||||
return (i);
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ColumnAtDisplayIndex
|
||||
|
||||
/// <summary>
|
||||
/// Returns the column that is displayed at specified display index.
|
||||
/// </summary>
|
||||
/// <param name="displayIndex">0 based display index.</param>
|
||||
/// <returns>ColumnHeader</returns>
|
||||
public GridColumn ColumnAtDisplayIndex(int displayIndex)
|
||||
{
|
||||
UpdateDisplayIndexMap();
|
||||
|
||||
return (this[_DisplayIndexMap[displayIndex]]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateDisplayIndexMap
|
||||
|
||||
private void UpdateDisplayIndexMap()
|
||||
{
|
||||
if (_IsDisplayIndexValid == false)
|
||||
{
|
||||
_IsDisplayIndexValid = true;
|
||||
|
||||
_DisplayIndexMap = new int[Count];
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
_DisplayIndexMap[i] = -1;
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
int di = this[i].DisplayIndex;
|
||||
|
||||
if (di != -1)
|
||||
AddIndexToMap(i, di);
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
int di = this[i].DisplayIndex;
|
||||
|
||||
if (di == -1)
|
||||
AddIndexToMap(i, n++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddIndexToMap(int i, int di)
|
||||
{
|
||||
for (int j = 0; j < Count; j++)
|
||||
{
|
||||
int n = (di + j) % Count;
|
||||
|
||||
if (_DisplayIndexMap[n] == -1)
|
||||
{
|
||||
_DisplayIndexMap[n] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetNextVisibleColumn
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to next visible column
|
||||
/// or null if there is no next visible column
|
||||
/// </summary>
|
||||
public GridColumn GetNextVisibleColumn(GridColumn column)
|
||||
{
|
||||
return (GetNextVisibleColumn(GetDisplayIndex(column)));
|
||||
}
|
||||
|
||||
internal GridColumn GetNextVisibleColumn(int displayIndex)
|
||||
{
|
||||
int[] displayMap = DisplayIndexMap;
|
||||
|
||||
while (++displayIndex < Count)
|
||||
{
|
||||
if (this[displayMap[displayIndex]].Visible)
|
||||
return (this[displayMap[displayIndex]]);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPrevVisibleColumn
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to previous visible column
|
||||
/// or null if there is no last visible previous column
|
||||
/// </summary>
|
||||
public GridColumn GetPrevVisibleColumn(GridColumn column)
|
||||
{
|
||||
return (GetPrevVisibleColumn(GetDisplayIndex(column)));
|
||||
}
|
||||
|
||||
internal GridColumn GetPrevVisibleColumn(int displayIndex)
|
||||
{
|
||||
int[] displayMap = DisplayIndexMap;
|
||||
|
||||
while (--displayIndex >= 0)
|
||||
{
|
||||
if (this[displayMap[displayIndex]].Visible)
|
||||
return (this[displayMap[displayIndex]]);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetLastVisibleFrozenColumn
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to the last visible frozen column
|
||||
/// or null if there is none
|
||||
/// </summary>
|
||||
public GridColumn GetLastVisibleFrozenColumn()
|
||||
{
|
||||
int[] displayMap = DisplayIndexMap;
|
||||
|
||||
if (displayMap.Length > 0)
|
||||
{
|
||||
GridPanel panel = this[displayMap[0]].GridPanel;
|
||||
|
||||
if (panel != null &&
|
||||
panel.FrozenColumnCount > 0 && panel.IsSubPanel == false)
|
||||
{
|
||||
for (int i = displayMap.Length - 1; i >= 0; i--)
|
||||
{
|
||||
GridColumn column = this[displayMap[i]];
|
||||
|
||||
if (column.Visible == true)
|
||||
{
|
||||
if (column.IsHFrozen == true)
|
||||
return (column);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+1121
File diff suppressed because it is too large
Load Diff
+6532
File diff suppressed because it is too large
Load Diff
+4018
File diff suppressed because it is too large
Load Diff
+1126
File diff suppressed because it is too large
Load Diff
+128
@@ -0,0 +1,128 @@
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
partial class CustomFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomFilter));
|
||||
this.btnCancel = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnOk = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnApply = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnClear = new DevComponents.DotNetBar.ButtonX();
|
||||
this.lblEnterText = new DevComponents.DotNetBar.LabelX();
|
||||
this.filterExprEdit1 = new DevComponents.DotNetBar.SuperGrid.FilterExprEdit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnCancel, "btnCancel");
|
||||
this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnCancel.Click += new System.EventHandler(this.BtnCancelClick);
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnOk, "btnOk");
|
||||
this.btnOk.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnOk.Click += new System.EventHandler(this.BtnOkClick);
|
||||
//
|
||||
// btnApply
|
||||
//
|
||||
this.btnApply.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnApply, "btnApply");
|
||||
this.btnApply.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnApply.Click += new System.EventHandler(this.BtnApplyClick);
|
||||
//
|
||||
// btnClear
|
||||
//
|
||||
this.btnClear.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnClear, "btnClear");
|
||||
this.btnClear.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnClear.Name = "btnClear";
|
||||
this.btnClear.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnClear.Click += new System.EventHandler(this.BtnClearClick);
|
||||
//
|
||||
// lblEnterText
|
||||
//
|
||||
resources.ApplyResources(this.lblEnterText, "lblEnterText");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.lblEnterText.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.lblEnterText.Name = "lblEnterText";
|
||||
//
|
||||
// filterExprEdit1
|
||||
//
|
||||
resources.ApplyResources(this.filterExprEdit1, "filterExprEdit1");
|
||||
this.filterExprEdit1.Name = "filterExprEdit1";
|
||||
//
|
||||
// CustomFilter
|
||||
//
|
||||
this.AcceptButton = this.btnApply;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.CancelButton = this.btnCancel;
|
||||
this.Controls.Add(this.filterExprEdit1);
|
||||
this.Controls.Add(this.lblEnterText);
|
||||
this.Controls.Add(this.btnClear);
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.btnOk);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.DoubleBuffered = true;
|
||||
this.EnableGlass = false;
|
||||
this.HelpButton = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "CustomFilter";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.TitleText = "Custom Filter";
|
||||
this.HelpButtonClicked += new System.ComponentModel.CancelEventHandler(this.CustomFilterHelpButtonClicked);
|
||||
this.Shown += new System.EventHandler(this.CustomFilterShown);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DevComponents.DotNetBar.ButtonX btnCancel;
|
||||
private DevComponents.DotNetBar.ButtonX btnOk;
|
||||
private ButtonX btnApply;
|
||||
private ButtonX btnClear;
|
||||
private LabelX lblEnterText;
|
||||
private FilterExprEdit filterExprEdit1;
|
||||
}
|
||||
}
|
||||
+393
@@ -0,0 +1,393 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// CustomFilter
|
||||
///</summary>
|
||||
public partial class CustomFilter : Office2007Form
|
||||
{
|
||||
#region Static data
|
||||
|
||||
private static bool _localizedStringsLoaded;
|
||||
|
||||
private static string _filterClearString = "Clear";
|
||||
private static string _filterCustomFilterString = "Custom Filter";
|
||||
private static string _filterEnterExprString = "Enter custom filter expression";
|
||||
private static string _filterHelpString = "Click the Title Bar help button for syntax help";
|
||||
private static string _filterHelpTitle = "SampleExpr";
|
||||
|
||||
private static Point _offset = Point.Empty;
|
||||
private static Size _size = Size.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private GridPanel _GridPanel;
|
||||
private GridColumn _GridColumn;
|
||||
|
||||
private string _FilterExpr;
|
||||
private object _FilterValue;
|
||||
private object _FilterDisplayValue;
|
||||
|
||||
private bool _LockedResize = true;
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
/// CustomFilter
|
||||
///</summary>
|
||||
public CustomFilter(GridPanel gridPanel, GridColumn gridColumn)
|
||||
: this(gridPanel, gridColumn, gridColumn != null ? gridColumn.FilterExpr : gridPanel.FilterExpr)
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// CustomFilter
|
||||
///</summary>
|
||||
public CustomFilter(GridPanel gridPanel, GridColumn gridColumn, string filterText)
|
||||
{
|
||||
_GridPanel = gridPanel;
|
||||
_GridColumn = gridColumn;
|
||||
|
||||
InitializeComponent();
|
||||
InitializeText();
|
||||
InitializeFilter(filterText);
|
||||
|
||||
PositionWindow(_GridPanel.SuperGrid);
|
||||
|
||||
StyleManager.UpdateAmbientColors(filterExprEdit1);
|
||||
|
||||
filterExprEdit1.RtbOutput.BackColorRichTextBox = Color.White;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region FilterExpr
|
||||
|
||||
/// <summary>
|
||||
/// FilterExpr
|
||||
/// </summary>
|
||||
public string FilterExpr
|
||||
{
|
||||
get { return (filterExprEdit1.InputText); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialization
|
||||
|
||||
#region InitializeText
|
||||
|
||||
private void InitializeText()
|
||||
{
|
||||
SuperGridControl superGrid = _GridPanel.SuperGrid;
|
||||
|
||||
LoadLocalizedStrings(superGrid);
|
||||
|
||||
TitleText = _filterCustomFilterString;
|
||||
|
||||
lblEnterText.Text = _filterEnterExprString;
|
||||
|
||||
btnClear.Text = _filterClearString;
|
||||
btnApply.Text = superGrid.FilterApplyString;
|
||||
btnOk.Text = superGrid.FilterOkString;
|
||||
btnCancel.Text = superGrid.FilterCancelString;
|
||||
|
||||
if (superGrid.ShowCustomFilterHelp == true)
|
||||
filterExprEdit1.WaterMarkText = _filterHelpString;
|
||||
else
|
||||
HelpButton = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InitializeFilter
|
||||
|
||||
private void InitializeFilter(string filterText)
|
||||
{
|
||||
if (_GridColumn != null)
|
||||
{
|
||||
_FilterExpr = _GridColumn.FilterExpr;
|
||||
_FilterValue = _GridColumn.FilterValue;
|
||||
_FilterDisplayValue = _GridColumn.FilterDisplayValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
_FilterExpr = _GridPanel.FilterExpr;
|
||||
_FilterValue = null;
|
||||
_FilterDisplayValue = null;
|
||||
}
|
||||
|
||||
filterExprEdit1.GridPanel = _GridPanel;
|
||||
filterExprEdit1.GridColumn = _GridColumn;
|
||||
filterExprEdit1.InputText = filterText;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PositionWindow
|
||||
|
||||
private void PositionWindow(SuperGridControl superGrid)
|
||||
{
|
||||
if (_size != Size.Empty)
|
||||
Size = _size;
|
||||
|
||||
Form form = superGrid.FindForm();
|
||||
|
||||
if (form != null)
|
||||
{
|
||||
Point pt = form.Location;
|
||||
|
||||
if (_offset != Point.Empty)
|
||||
{
|
||||
pt.Offset(_offset);
|
||||
|
||||
Location = pt;
|
||||
}
|
||||
else
|
||||
{
|
||||
Screen screen = Screen.FromControl(form);
|
||||
|
||||
int boundWidth = screen.Bounds.Width;
|
||||
int boundHeight = screen.Bounds.Height;
|
||||
|
||||
int x = boundWidth - Width;
|
||||
int y = boundHeight - Height;
|
||||
|
||||
Location = new Point(screen.Bounds.X + x / 2, screen.Bounds.Y + y / 2);
|
||||
}
|
||||
}
|
||||
|
||||
_LockedResize = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event processong
|
||||
|
||||
#region CustomFilterShown
|
||||
|
||||
private void CustomFilterShown(object sender, EventArgs e)
|
||||
{
|
||||
filterExprEdit1.SetFocus();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnResize
|
||||
|
||||
/// <summary>
|
||||
/// Handles filter resize
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
if (_LockedResize == false)
|
||||
_size = Size;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnLocationChanged
|
||||
|
||||
/// <summary>
|
||||
/// LocationChanged processing
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnLocationChanged(EventArgs e)
|
||||
{
|
||||
base.OnLocationChanged(e);
|
||||
|
||||
if (_LockedResize == false)
|
||||
{
|
||||
Form form = _GridPanel.SuperGrid.FindForm();
|
||||
|
||||
if (form != null)
|
||||
{
|
||||
Point pt = Location;
|
||||
|
||||
pt.Offset(-form.Location.X, -form.Location.Y);
|
||||
|
||||
_offset = pt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Button processing
|
||||
|
||||
#region BtnApplyClick
|
||||
|
||||
private void BtnApplyClick(object sender, EventArgs e)
|
||||
{
|
||||
ApplyFilter();
|
||||
}
|
||||
|
||||
#region ApplyFilter
|
||||
|
||||
private void ApplyFilter()
|
||||
{
|
||||
string text = filterExprEdit1.InputText;
|
||||
|
||||
object filterValue = null;
|
||||
object filterDisplayValue = text;
|
||||
string filterExpr = text;
|
||||
|
||||
if (_GridColumn != null)
|
||||
{
|
||||
if (_GridColumn.SuperGrid.DoFilterEditValueChangedEvent(_GridPanel, _GridColumn, null,
|
||||
_GridColumn.FilterValue, ref filterValue, ref filterDisplayValue, ref filterExpr) == false)
|
||||
{
|
||||
_GridColumn.FilterExpr = text;
|
||||
_GridColumn.FilterValue = null;
|
||||
_GridColumn.FilterDisplayValue = text;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_GridPanel.SuperGrid.DoFilterEditValueChangedEvent(_GridPanel, null, null,
|
||||
_GridPanel.FilterExpr, ref filterValue, ref filterDisplayValue, ref filterExpr) == false)
|
||||
{
|
||||
_GridPanel.FilterExpr = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnOkClick
|
||||
|
||||
private void BtnOkClick(object sender, EventArgs e)
|
||||
{
|
||||
ApplyFilter();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnCancelClick
|
||||
|
||||
private void BtnCancelClick(object sender, EventArgs e)
|
||||
{
|
||||
CancelFilter();
|
||||
}
|
||||
|
||||
private void CancelFilter()
|
||||
{
|
||||
if (_GridColumn != null)
|
||||
{
|
||||
_GridColumn.FilterExpr = _FilterExpr;
|
||||
_GridColumn.FilterValue = _FilterValue;
|
||||
_GridColumn.FilterDisplayValue = _FilterDisplayValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
_GridPanel.FilterExpr = _FilterExpr;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnClearClick
|
||||
|
||||
private void BtnClearClick(object sender, EventArgs e)
|
||||
{
|
||||
filterExprEdit1.InputText = "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CustomFilterHelpButtonClicked
|
||||
|
||||
/// <summary>
|
||||
/// Sample Expr variable
|
||||
/// </summary>
|
||||
static protected SampleExpr Se;
|
||||
|
||||
private void CustomFilterHelpButtonClicked(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (Se == null)
|
||||
{
|
||||
Se = new SampleExpr(_GridPanel.SuperGrid);
|
||||
Se.TitleText = _filterHelpTitle;
|
||||
|
||||
Se.FormClosed += SeFormClosed;
|
||||
}
|
||||
|
||||
if (_GridPanel.SuperGrid.DoFilterHelpOpeningEvent(_GridPanel, _GridColumn, Se) == true)
|
||||
{
|
||||
Se.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
Se.Show();
|
||||
|
||||
if (Se.WindowState == FormWindowState.Minimized)
|
||||
Se.WindowState = FormWindowState.Normal;
|
||||
|
||||
Se.BringToFront();
|
||||
}
|
||||
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
void SeFormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
_GridPanel.SuperGrid.DoFilterHelpClosingEvent(_GridPanel, _GridColumn, Se);
|
||||
|
||||
Se.FormClosed -= SeFormClosed;
|
||||
Se = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadLocalizedStrings
|
||||
|
||||
private void LoadLocalizedStrings(SuperGridControl sg)
|
||||
{
|
||||
if (_localizedStringsLoaded == false)
|
||||
{
|
||||
using (LocalizationManager lm = new LocalizationManager(sg))
|
||||
{
|
||||
string s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterCustomHelp)) != "")
|
||||
_filterHelpString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterEnterExpr)) != "")
|
||||
_filterEnterExprString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterClear)) != "")
|
||||
_filterClearString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterCustomFilter)) != "")
|
||||
_filterCustomFilterString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterHelpTitle)) != "")
|
||||
_filterHelpTitle = s;
|
||||
}
|
||||
|
||||
_localizedStringsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="btnCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="btnCancel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>315, 157</value>
|
||||
</data>
|
||||
<data name="btnCancel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="btnCancel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="btnCancel.Text" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.Name" xml:space="preserve">
|
||||
<value>btnCancel</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="btnOk.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="btnOk.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>244, 157</value>
|
||||
</data>
|
||||
<data name="btnOk.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="btnOk.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="btnOk.Text" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
<data name=">>btnOk.Name" xml:space="preserve">
|
||||
<value>btnOk</value>
|
||||
</data>
|
||||
<data name=">>btnOk.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnOk.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnOk.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="btnApply.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="btnApply.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>164, 157</value>
|
||||
</data>
|
||||
<data name="btnApply.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="btnApply.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="btnApply.Text" xml:space="preserve">
|
||||
<value>Apply</value>
|
||||
</data>
|
||||
<data name=">>btnApply.Name" xml:space="preserve">
|
||||
<value>btnApply</value>
|
||||
</data>
|
||||
<data name=">>btnApply.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnApply.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnApply.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="btnClear.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="btnClear.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 157</value>
|
||||
</data>
|
||||
<data name="btnClear.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="btnClear.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="btnClear.Text" xml:space="preserve">
|
||||
<value>Clear</value>
|
||||
</data>
|
||||
<data name=">>btnClear.Name" xml:space="preserve">
|
||||
<value>btnClear</value>
|
||||
</data>
|
||||
<data name=">>btnClear.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnClear.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnClear.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="lblEnterText.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="lblEnterText.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>10, 4</value>
|
||||
</data>
|
||||
<data name="lblEnterText.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>370, 26</value>
|
||||
</data>
|
||||
<data name="lblEnterText.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="lblEnterText.Text" xml:space="preserve">
|
||||
<value>labelX1</value>
|
||||
</data>
|
||||
<data name=">>lblEnterText.Name" xml:space="preserve">
|
||||
<value>lblEnterText</value>
|
||||
</data>
|
||||
<data name=">>lblEnterText.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.LabelX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>lblEnterText.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>lblEnterText.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="filterExprEdit1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left, Right</value>
|
||||
</data>
|
||||
<data name="filterExprEdit1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 34</value>
|
||||
</data>
|
||||
<data name="filterExprEdit1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>370, 112</value>
|
||||
</data>
|
||||
<data name="filterExprEdit1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name=">>filterExprEdit1.Name" xml:space="preserve">
|
||||
<value>filterExprEdit1</value>
|
||||
</data>
|
||||
<data name=">>filterExprEdit1.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.SuperGrid.FilterExprEdit, DevComponents.DotNetBar.SuperGrid, Version=2.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>filterExprEdit1.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>filterExprEdit1.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||
<value>96, 96</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>394, 192</value>
|
||||
</data>
|
||||
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>410, 230</value>
|
||||
</data>
|
||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||
<value>Manual</value>
|
||||
</data>
|
||||
<data name=">>$this.Name" xml:space="preserve">
|
||||
<value>CustomFilter</value>
|
||||
</data>
|
||||
<data name=">>$this.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Office2007Form, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
</root>
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
partial class CustomFilterEx
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomFilterEx));
|
||||
this.btnCancel = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnOk = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnApply = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnReset = new DevComponents.DotNetBar.ButtonX();
|
||||
this.lblFilterName = new DevComponents.DotNetBar.LabelX();
|
||||
this.tbxDesc = new DevComponents.DotNetBar.Controls.TextBoxX();
|
||||
this.lblDesc = new DevComponents.DotNetBar.LabelX();
|
||||
this.cbFilterName = new DevComponents.DotNetBar.Controls.ComboBoxEx();
|
||||
this.btnNewFilter = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnDeleteFilter = new DevComponents.DotNetBar.ButtonX();
|
||||
this.lblEnterText = new DevComponents.DotNetBar.LabelX();
|
||||
this.cbxShowInPopup = new DevComponents.DotNetBar.Controls.CheckBoxX();
|
||||
this.btnClear = new DevComponents.DotNetBar.ButtonX();
|
||||
this.filterExprEdit1 = new DevComponents.DotNetBar.SuperGrid.FilterExprEdit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnCancel, "btnCancel");
|
||||
this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnCancel.Click += new System.EventHandler(this.BtnCancelClick);
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnOk, "btnOk");
|
||||
this.btnOk.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnOk.Click += new System.EventHandler(this.BtnOkClick);
|
||||
//
|
||||
// btnApply
|
||||
//
|
||||
this.btnApply.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnApply, "btnApply");
|
||||
this.btnApply.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnApply.Click += new System.EventHandler(this.BtnApplyClick);
|
||||
//
|
||||
// btnReset
|
||||
//
|
||||
this.btnReset.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnReset, "btnReset");
|
||||
this.btnReset.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnReset.Name = "btnReset";
|
||||
this.btnReset.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnReset.Click += new System.EventHandler(this.BtnResetClick);
|
||||
//
|
||||
// lblFilterName
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.lblFilterName.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
resources.ApplyResources(this.lblFilterName, "lblFilterName");
|
||||
this.lblFilterName.Name = "lblFilterName";
|
||||
//
|
||||
// tbxDesc
|
||||
//
|
||||
resources.ApplyResources(this.tbxDesc, "tbxDesc");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.tbxDesc.Border.Class = "TextBoxBorder";
|
||||
this.tbxDesc.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.tbxDesc.Name = "tbxDesc";
|
||||
this.tbxDesc.TextChanged += new System.EventHandler(this.TbxDescTextChanged);
|
||||
//
|
||||
// lblDesc
|
||||
//
|
||||
resources.ApplyResources(this.lblDesc, "lblDesc");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.lblDesc.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.lblDesc.Name = "lblDesc";
|
||||
//
|
||||
// cbFilterName
|
||||
//
|
||||
resources.ApplyResources(this.cbFilterName, "cbFilterName");
|
||||
this.cbFilterName.DisplayMember = "Text";
|
||||
this.cbFilterName.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.cbFilterName.FormattingEnabled = true;
|
||||
this.cbFilterName.Name = "cbFilterName";
|
||||
this.cbFilterName.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.cbFilterName.DropDown += new System.EventHandler(this.CbFilterNameDropDown);
|
||||
this.cbFilterName.SelectedIndexChanged += new System.EventHandler(this.CbFilterNameSelectedIndexChanged);
|
||||
this.cbFilterName.TextUpdate += new System.EventHandler(this.CbFilterNameTextUpdate);
|
||||
//
|
||||
// btnNewFilter
|
||||
//
|
||||
this.btnNewFilter.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnNewFilter, "btnNewFilter");
|
||||
this.btnNewFilter.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnNewFilter.Name = "btnNewFilter";
|
||||
this.btnNewFilter.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnNewFilter.Click += new System.EventHandler(this.BtnNewFilterClick);
|
||||
//
|
||||
// btnDeleteFilter
|
||||
//
|
||||
this.btnDeleteFilter.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnDeleteFilter, "btnDeleteFilter");
|
||||
this.btnDeleteFilter.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnDeleteFilter.Name = "btnDeleteFilter";
|
||||
this.btnDeleteFilter.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnDeleteFilter.Click += new System.EventHandler(this.BtnDeleteFilterClick);
|
||||
//
|
||||
// lblEnterText
|
||||
//
|
||||
resources.ApplyResources(this.lblEnterText, "lblEnterText");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.lblEnterText.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.lblEnterText.Name = "lblEnterText";
|
||||
//
|
||||
// cbxShowInPopup
|
||||
//
|
||||
resources.ApplyResources(this.cbxShowInPopup, "cbxShowInPopup");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.cbxShowInPopup.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.cbxShowInPopup.Name = "cbxShowInPopup";
|
||||
this.cbxShowInPopup.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.cbxShowInPopup.CheckedChanged += new System.EventHandler(this.CbxShowInPopupCheckedChanged);
|
||||
//
|
||||
// btnClear
|
||||
//
|
||||
this.btnClear.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnClear, "btnClear");
|
||||
this.btnClear.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnClear.Name = "btnClear";
|
||||
this.btnClear.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnClear.Click += new System.EventHandler(this.BtnClearClick);
|
||||
//
|
||||
// filterExprEdit1
|
||||
//
|
||||
resources.ApplyResources(this.filterExprEdit1, "filterExprEdit1");
|
||||
this.filterExprEdit1.Name = "filterExprEdit1";
|
||||
//
|
||||
// CustomFilterEx
|
||||
//
|
||||
this.AcceptButton = this.btnApply;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.CancelButton = this.btnCancel;
|
||||
this.Controls.Add(this.btnClear);
|
||||
this.Controls.Add(this.filterExprEdit1);
|
||||
this.Controls.Add(this.tbxDesc);
|
||||
this.Controls.Add(this.lblEnterText);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.cbxShowInPopup);
|
||||
this.Controls.Add(this.btnOk);
|
||||
this.Controls.Add(this.btnNewFilter);
|
||||
this.Controls.Add(this.btnReset);
|
||||
this.Controls.Add(this.lblFilterName);
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.cbFilterName);
|
||||
this.Controls.Add(this.lblDesc);
|
||||
this.Controls.Add(this.btnDeleteFilter);
|
||||
this.DoubleBuffered = true;
|
||||
this.EnableGlass = false;
|
||||
this.HelpButton = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "CustomFilterEx";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.TitleText = "Custom Filter";
|
||||
this.HelpButtonClicked += new System.ComponentModel.CancelEventHandler(this.CustomFilterHelpButtonClicked);
|
||||
this.Shown += new System.EventHandler(this.CustomFilterShown);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DevComponents.DotNetBar.ButtonX btnCancel;
|
||||
private DevComponents.DotNetBar.ButtonX btnOk;
|
||||
private ButtonX btnApply;
|
||||
private ButtonX btnReset;
|
||||
private LabelX lblFilterName;
|
||||
private DevComponents.DotNetBar.Controls.TextBoxX tbxDesc;
|
||||
private LabelX lblDesc;
|
||||
private DevComponents.DotNetBar.Controls.ComboBoxEx cbFilterName;
|
||||
private ButtonX btnNewFilter;
|
||||
private ButtonX btnDeleteFilter;
|
||||
private LabelX lblEnterText;
|
||||
private DevComponents.DotNetBar.Controls.CheckBoxX cbxShowInPopup;
|
||||
private FilterExprEdit filterExprEdit1;
|
||||
private ButtonX btnClear;
|
||||
}
|
||||
}
|
||||
+700
@@ -0,0 +1,700 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// CustomFilter
|
||||
///</summary>
|
||||
internal partial class CustomFilterEx : Office2007Form
|
||||
{
|
||||
#region Static data
|
||||
|
||||
private static bool _localizedStringsLoaded;
|
||||
|
||||
private static string _filterClearString = "Clear";
|
||||
private static string _filterResetString = "Reset";
|
||||
private static string _filterCustomFilterString = "Custom Filter";
|
||||
private static string _filterEnterExprString = "Enter custom filter expression";
|
||||
private static string _filterHelpString = "Click the Title Bar help button for syntax help";
|
||||
private static string _newFilterExprString = "NewFilter";
|
||||
private static string _filterDescriptionString = "Description";
|
||||
private static string _filterNameString = "Filter Name:";
|
||||
private static string _showInFilterPopupString = "Show in FilterPopup";
|
||||
private static string _newFilterString = "New";
|
||||
private static string _deleteFilterString = "Delete";
|
||||
private static string _filterHelpTitle = "SampleExpr";
|
||||
|
||||
private static Point _offset = Point.Empty;
|
||||
private static Size _size = Size.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private GridPanel _GridPanel;
|
||||
private GridColumn _GridColumn;
|
||||
|
||||
private string _FilterExpr;
|
||||
private object _FilterValue;
|
||||
private object _FilterDisplayValue;
|
||||
|
||||
private List<UserFilterData> _FilterData;
|
||||
private UserFilterData _CurrentFilter;
|
||||
|
||||
private bool _CancelFilterEdits;
|
||||
private bool _LockedResize = true;
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
/// CustomFilter
|
||||
///</summary>
|
||||
public CustomFilterEx(GridPanel gridPanel, GridColumn gridColumn)
|
||||
: this(gridPanel, gridColumn, gridColumn != null ? gridColumn.FilterExpr : gridPanel.FilterExpr)
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// CustomFilter
|
||||
///</summary>
|
||||
public CustomFilterEx(GridPanel gridPanel,
|
||||
GridColumn gridColumn, string filterText)
|
||||
{
|
||||
_GridPanel = gridPanel;
|
||||
_GridColumn = gridColumn;
|
||||
|
||||
InitializeComponent();
|
||||
InitializeText();
|
||||
InitializeFilter(filterText);
|
||||
|
||||
PositionWindow(_GridPanel.SuperGrid);
|
||||
|
||||
FormClosing += CustomFilterExFormClosing;
|
||||
|
||||
filterExprEdit1.InputTextChanged += FilterExprEdit1InputTextChanged;
|
||||
|
||||
StyleManager.UpdateAmbientColors(filterExprEdit1);
|
||||
|
||||
filterExprEdit1.RtbOutput.BackColorRichTextBox = Color.White;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region CurrentFilter
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current UserFilterData filter
|
||||
/// </summary>
|
||||
public UserFilterData CurrentFilter
|
||||
{
|
||||
get { return (_CurrentFilter); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_CurrentFilter != value)
|
||||
{
|
||||
_CurrentFilter = value;
|
||||
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FilterData
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of UserFilterData
|
||||
/// </summary>
|
||||
public List<UserFilterData> FilterData
|
||||
{
|
||||
get { return (_FilterData); }
|
||||
set { _FilterData = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FilterExpr
|
||||
|
||||
/// <summary>
|
||||
/// FilterExpr
|
||||
/// </summary>
|
||||
public string FilterExpr
|
||||
{
|
||||
get { return (filterExprEdit1.InputText); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowInPopupVisible
|
||||
|
||||
/// <summary>
|
||||
/// ShowInPopupVisible
|
||||
/// </summary>
|
||||
public bool ShowInPopupVisible
|
||||
{
|
||||
get { return (cbxShowInPopup.Visible); }
|
||||
set { cbxShowInPopup.Visible = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialization
|
||||
|
||||
#region InitializeText
|
||||
|
||||
private void InitializeText()
|
||||
{
|
||||
SuperGridControl superGrid = _GridPanel.SuperGrid;
|
||||
|
||||
LoadLocalizedStrings(superGrid);
|
||||
|
||||
TitleText = _filterCustomFilterString;
|
||||
|
||||
lblEnterText.Text = _filterEnterExprString;
|
||||
lblDesc.Text = _filterDescriptionString;
|
||||
lblFilterName.Text = _filterNameString;
|
||||
|
||||
btnNewFilter.Text = _newFilterString;
|
||||
btnDeleteFilter.Text = _deleteFilterString;
|
||||
btnReset.Text = _filterResetString;
|
||||
btnClear.Text = _filterClearString;
|
||||
|
||||
btnApply.Text = superGrid.FilterApplyString;
|
||||
btnOk.Text = superGrid.FilterOkString;
|
||||
btnCancel.Text = superGrid.FilterCancelString;
|
||||
|
||||
cbxShowInPopup.Text = _showInFilterPopupString;
|
||||
|
||||
if (superGrid.ShowCustomFilterHelp == true)
|
||||
filterExprEdit1.WaterMarkText = _filterHelpString;
|
||||
else
|
||||
HelpButton = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InitializeFilter
|
||||
|
||||
private void InitializeFilter(string filterText)
|
||||
{
|
||||
if (_GridColumn != null)
|
||||
{
|
||||
_FilterExpr = _GridColumn.FilterExpr;
|
||||
_FilterValue = _GridColumn.FilterValue;
|
||||
_FilterDisplayValue = _GridColumn.FilterDisplayValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
_FilterExpr = _GridPanel.FilterExpr;
|
||||
_FilterValue = null;
|
||||
_FilterDisplayValue = null;
|
||||
|
||||
cbxShowInPopup.Visible = false;
|
||||
}
|
||||
|
||||
filterExprEdit1.GridPanel = _GridPanel;
|
||||
filterExprEdit1.GridColumn = _GridColumn;
|
||||
filterExprEdit1.InputText = filterText;
|
||||
|
||||
CurrentFilter = GetCurrentFilter();
|
||||
}
|
||||
|
||||
#region GetCurrentFilter
|
||||
|
||||
private UserFilterData GetCurrentFilter()
|
||||
{
|
||||
_FilterData = FilterUserData.LoadFilterData(_GridPanel);
|
||||
|
||||
foreach (UserFilterData fd in _FilterData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fd.Expression) == false)
|
||||
{
|
||||
if (fd.Expression.Equals(filterExprEdit1.InputText) == true)
|
||||
return (fd);
|
||||
}
|
||||
}
|
||||
|
||||
UserFilterData nfd = GetNewFilter();
|
||||
|
||||
nfd.Expression = filterExprEdit1.InputText;
|
||||
|
||||
return (nfd);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region PositionWindow
|
||||
|
||||
private void PositionWindow(SuperGridControl superGrid)
|
||||
{
|
||||
if (_size != Size.Empty)
|
||||
Size = _size;
|
||||
|
||||
Form form = superGrid.FindForm();
|
||||
|
||||
if (form != null)
|
||||
{
|
||||
Point pt = form.Location;
|
||||
|
||||
if (_offset != Point.Empty)
|
||||
{
|
||||
pt.Offset(_offset);
|
||||
|
||||
Location = pt;
|
||||
}
|
||||
else
|
||||
{
|
||||
Screen screen = Screen.FromControl(form);
|
||||
|
||||
int boundWidth = screen.Bounds.Width;
|
||||
int boundHeight = screen.Bounds.Height;
|
||||
|
||||
int x = boundWidth - Width;
|
||||
int y = boundHeight - Height;
|
||||
|
||||
Location = new Point(screen.Bounds.X + x / 2, screen.Bounds.Y + y / 2);
|
||||
}
|
||||
}
|
||||
|
||||
_LockedResize = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event processong
|
||||
|
||||
#region CustomFilterExFormClosing
|
||||
|
||||
void CustomFilterExFormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (_CancelFilterEdits == false)
|
||||
FilterUserData.StoreFilterData(_GridPanel, _FilterData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CustomFilterShown
|
||||
|
||||
private void CustomFilterShown(object sender, EventArgs e)
|
||||
{
|
||||
filterExprEdit1.SetFocus();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FilterExprEdit1InputTextChanged
|
||||
|
||||
void FilterExprEdit1InputTextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CurrentFilter.Expression = filterExprEdit1.InputText;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnLocationChanged
|
||||
|
||||
protected override void OnLocationChanged(EventArgs e)
|
||||
{
|
||||
base.OnLocationChanged(e);
|
||||
|
||||
if (_LockedResize == false)
|
||||
{
|
||||
Form form = _GridPanel.SuperGrid.FindForm();
|
||||
|
||||
if (form != null)
|
||||
{
|
||||
Point pt = Location;
|
||||
|
||||
pt.Offset(-form.Location.X, -form.Location.Y);
|
||||
|
||||
_offset = pt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnResize
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
if (_LockedResize == false)
|
||||
_size = Size;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateDisplay
|
||||
|
||||
private void UpdateDisplay()
|
||||
{
|
||||
cbFilterName.Text = CurrentFilter.Name;
|
||||
tbxDesc.Text = CurrentFilter.Description;
|
||||
|
||||
if (_GridColumn != null)
|
||||
cbxShowInPopup.Checked = CurrentFilter.ReferNames.Contains(_GridColumn.Name);
|
||||
|
||||
filterExprEdit1.InputText = CurrentFilter.Expression;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Button processing
|
||||
|
||||
#region BtnApplyClick
|
||||
|
||||
private void BtnApplyClick(object sender, EventArgs e)
|
||||
{
|
||||
ApplyFilter(filterExprEdit1.InputText);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnResetClick
|
||||
|
||||
private void BtnResetClick(object sender, EventArgs e)
|
||||
{
|
||||
ApplyFilter(null);
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnDeleteFilterClick
|
||||
|
||||
private void BtnDeleteFilterClick(object sender, EventArgs e)
|
||||
{
|
||||
if (CurrentFilter != null)
|
||||
{
|
||||
_FilterData.Remove(CurrentFilter);
|
||||
|
||||
UpdateFilterNameCombo();
|
||||
|
||||
CurrentFilter = (_FilterData.Count > 0)
|
||||
? _FilterData[0] : GetNewFilter();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnCancelClick
|
||||
|
||||
private void BtnCancelClick(object sender, EventArgs e)
|
||||
{
|
||||
if (_GridColumn != null)
|
||||
{
|
||||
_GridColumn.FilterExpr = _FilterExpr;
|
||||
_GridColumn.FilterValue = _FilterValue;
|
||||
_GridColumn.FilterDisplayValue = _FilterDisplayValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
_GridPanel.FilterExpr = _FilterExpr;
|
||||
}
|
||||
|
||||
_CancelFilterEdits = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnClearClick
|
||||
|
||||
private void BtnClearClick(object sender, EventArgs e)
|
||||
{
|
||||
filterExprEdit1.InputText = "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnNewFilterClick
|
||||
|
||||
private void BtnNewFilterClick(object sender, EventArgs e)
|
||||
{
|
||||
CurrentFilter = GetNewFilter();
|
||||
}
|
||||
|
||||
#region GetNewFilter
|
||||
|
||||
private UserFilterData GetNewFilter()
|
||||
{
|
||||
UserFilterData fd = new UserFilterData();
|
||||
|
||||
fd.Name = GetNewFilterName();
|
||||
fd.Description = "";
|
||||
|
||||
_FilterData.Add(fd);
|
||||
|
||||
return (fd);
|
||||
}
|
||||
|
||||
#region GetNewFilterName
|
||||
|
||||
private string GetNewFilterName()
|
||||
{
|
||||
for (int i = 1; i < 100; i++)
|
||||
{
|
||||
string s = _newFilterExprString + i;
|
||||
|
||||
if (FindFilterName(s) < 0)
|
||||
return(s);
|
||||
}
|
||||
|
||||
return (_newFilterExprString);
|
||||
}
|
||||
|
||||
#region FindFilterName
|
||||
|
||||
private int FindFilterName(string s)
|
||||
{
|
||||
for (int i = 0; i < _FilterData.Count; i++)
|
||||
{
|
||||
if (s.Equals(_FilterData[i].Name) == true)
|
||||
return (i);
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnOkClick
|
||||
|
||||
private void BtnOkClick(object sender, EventArgs e)
|
||||
{
|
||||
ApplyFilter(filterExprEdit1.InputText);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CustomFilterHelpButtonClicked
|
||||
|
||||
static protected SampleExpr Se;
|
||||
|
||||
private void CustomFilterHelpButtonClicked(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (Se == null)
|
||||
{
|
||||
Se = new SampleExpr(_GridPanel.SuperGrid);
|
||||
Se.TitleText = _filterHelpTitle;
|
||||
|
||||
Se.FormClosed += SeFormClosed;
|
||||
}
|
||||
|
||||
if (_GridPanel.SuperGrid.DoFilterHelpOpeningEvent(_GridPanel, _GridColumn, Se) == true)
|
||||
{
|
||||
Se.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
Se.Show();
|
||||
|
||||
if (Se.WindowState == FormWindowState.Minimized)
|
||||
Se.WindowState = FormWindowState.Normal;
|
||||
|
||||
Se.BringToFront();
|
||||
}
|
||||
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
void SeFormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
_GridPanel.SuperGrid.DoFilterHelpClosingEvent(_GridPanel, _GridColumn, Se);
|
||||
|
||||
Se.FormClosed -= SeFormClosed;
|
||||
Se = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyFilter
|
||||
|
||||
private void ApplyFilter(string text)
|
||||
{
|
||||
object filterValue = null;
|
||||
object filterDisplayValue = text;
|
||||
string filterExpr = text;
|
||||
|
||||
if (_GridColumn != null)
|
||||
{
|
||||
if (_GridColumn.SuperGrid.DoFilterEditValueChangedEvent(_GridPanel, _GridColumn, null,
|
||||
_GridColumn.FilterValue, ref filterValue, ref filterDisplayValue, ref filterExpr) == false)
|
||||
{
|
||||
_GridColumn.FilterExpr = text;
|
||||
_GridColumn.FilterValue = null;
|
||||
_GridColumn.FilterDisplayValue = text;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_GridPanel.SuperGrid.DoFilterEditValueChangedEvent(_GridPanel, null, null,
|
||||
_GridPanel.FilterExpr, ref filterValue, ref filterDisplayValue, ref filterExpr) == false)
|
||||
{
|
||||
_GridPanel.FilterExpr = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Checkbox processing
|
||||
|
||||
#region CbxShowInPopupCheckedChanged
|
||||
|
||||
private void CbxShowInPopupCheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_GridColumn != null)
|
||||
{
|
||||
if (cbxShowInPopup.Checked == true)
|
||||
{
|
||||
if (CurrentFilter.ReferNames.Contains(_GridColumn.Name) == false)
|
||||
CurrentFilter.ReferNames.Add(_GridColumn.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CurrentFilter.ReferNames.Contains(_GridColumn.Name) == true)
|
||||
CurrentFilter.ReferNames.Remove(_GridColumn.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Combobox processing
|
||||
|
||||
#region CbFilterNameDropDown
|
||||
|
||||
private void CbFilterNameDropDown(object sender, EventArgs e)
|
||||
{
|
||||
UpdateFilterNameCombo();
|
||||
}
|
||||
|
||||
#region UpdateFilterNameCombo
|
||||
|
||||
private void UpdateFilterNameCombo()
|
||||
{
|
||||
cbFilterName.Items.Clear();
|
||||
|
||||
foreach (UserFilterData fd in _FilterData)
|
||||
cbFilterName.Items.Add(fd.Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region CbFilterNameSelectedIndexChanged
|
||||
|
||||
private void CbFilterNameSelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (cbFilterName.SelectedIndex >= 0)
|
||||
CurrentFilter = _FilterData[cbFilterName.SelectedIndex];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CbFilterNameTextUpdate
|
||||
|
||||
private void CbFilterNameTextUpdate(object sender, EventArgs e)
|
||||
{
|
||||
CurrentFilter.Name = cbFilterName.Text;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextBox processing
|
||||
|
||||
#region TbxDescTextChanged
|
||||
|
||||
private void TbxDescTextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CurrentFilter.Description = tbxDesc.Text;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadLocalizedStrings
|
||||
|
||||
private void LoadLocalizedStrings(SuperGridControl sg)
|
||||
{
|
||||
if (_localizedStringsLoaded == false)
|
||||
{
|
||||
using (LocalizationManager lm = new LocalizationManager(sg))
|
||||
{
|
||||
string s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterCustomHelp)) != "")
|
||||
_filterHelpString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterEnterExpr)) != "")
|
||||
_filterEnterExprString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterClear)) != "")
|
||||
_filterClearString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterReset)) != "")
|
||||
_filterResetString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterCustomFilter)) != "")
|
||||
_filterCustomFilterString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridNewFilterExpr)) != "")
|
||||
_newFilterExprString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridNewFilter)) != "")
|
||||
_newFilterString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridDeleteFilter)) != "")
|
||||
_deleteFilterString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterName)) != "")
|
||||
_filterNameString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterDescription)) != "")
|
||||
_filterDescriptionString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridShowInFilterPopup)) != "")
|
||||
_showInFilterPopupString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterHelpTitle)) != "")
|
||||
_filterHelpTitle = s;
|
||||
}
|
||||
|
||||
_localizedStringsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+516
@@ -0,0 +1,516 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="btnCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="btnCancel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>256, 261</value>
|
||||
</data>
|
||||
<data name="btnCancel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="btnCancel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="btnCancel.Text" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.Name" xml:space="preserve">
|
||||
<value>btnCancel</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="btnOk.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="btnOk.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>327, 261</value>
|
||||
</data>
|
||||
<data name="btnOk.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="btnOk.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="btnOk.Text" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
<data name=">>btnOk.Name" xml:space="preserve">
|
||||
<value>btnOk</value>
|
||||
</data>
|
||||
<data name=">>btnOk.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnOk.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnOk.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="btnApply.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="btnApply.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>86, 261</value>
|
||||
</data>
|
||||
<data name="btnApply.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="btnApply.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="btnApply.Text" xml:space="preserve">
|
||||
<value>Apply</value>
|
||||
</data>
|
||||
<data name=">>btnApply.Name" xml:space="preserve">
|
||||
<value>btnApply</value>
|
||||
</data>
|
||||
<data name=">>btnApply.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnApply.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnApply.ZOrder" xml:space="preserve">
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="btnReset.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="btnReset.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>185, 261</value>
|
||||
</data>
|
||||
<data name="btnReset.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="btnReset.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="btnReset.Text" xml:space="preserve">
|
||||
<value>Reset</value>
|
||||
</data>
|
||||
<data name=">>btnReset.Name" xml:space="preserve">
|
||||
<value>btnReset</value>
|
||||
</data>
|
||||
<data name=">>btnReset.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnReset.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnReset.ZOrder" xml:space="preserve">
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="lblFilterName.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 10</value>
|
||||
</data>
|
||||
<data name="lblFilterName.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="lblFilterName.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="lblFilterName.Text" xml:space="preserve">
|
||||
<value>Filter Name:</value>
|
||||
</data>
|
||||
<data name=">>lblFilterName.Name" xml:space="preserve">
|
||||
<value>lblFilterName</value>
|
||||
</data>
|
||||
<data name=">>lblFilterName.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.LabelX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>lblFilterName.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>lblFilterName.ZOrder" xml:space="preserve">
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="tbxDesc.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="tbxDesc.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 65</value>
|
||||
</data>
|
||||
<data name="tbxDesc.Multiline" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="tbxDesc.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>232, 40</value>
|
||||
</data>
|
||||
<data name="tbxDesc.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name=">>tbxDesc.Name" xml:space="preserve">
|
||||
<value>tbxDesc</value>
|
||||
</data>
|
||||
<data name=">>tbxDesc.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.TextBoxX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>tbxDesc.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>tbxDesc.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="lblDesc.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="lblDesc.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 41</value>
|
||||
</data>
|
||||
<data name="lblDesc.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>232, 22</value>
|
||||
</data>
|
||||
<data name="lblDesc.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="lblDesc.Text" xml:space="preserve">
|
||||
<value>Description</value>
|
||||
</data>
|
||||
<data name=">>lblDesc.Name" xml:space="preserve">
|
||||
<value>lblDesc</value>
|
||||
</data>
|
||||
<data name=">>lblDesc.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.LabelX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>lblDesc.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>lblDesc.ZOrder" xml:space="preserve">
|
||||
<value>12</value>
|
||||
</data>
|
||||
<data name="cbFilterName.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="cbFilterName.ItemHeight" type="System.Int32, mscorlib">
|
||||
<value>15</value>
|
||||
</data>
|
||||
<data name="cbFilterName.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>83, 12</value>
|
||||
</data>
|
||||
<data name="cbFilterName.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>161, 21</value>
|
||||
</data>
|
||||
<data name="cbFilterName.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name=">>cbFilterName.Name" xml:space="preserve">
|
||||
<value>cbFilterName</value>
|
||||
</data>
|
||||
<data name=">>cbFilterName.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.ComboBoxEx, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cbFilterName.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbFilterName.ZOrder" xml:space="preserve">
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="btnNewFilter.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Right</value>
|
||||
</data>
|
||||
<data name="btnNewFilter.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>256, 82</value>
|
||||
</data>
|
||||
<data name="btnNewFilter.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="btnNewFilter.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="btnNewFilter.Text" xml:space="preserve">
|
||||
<value>New</value>
|
||||
</data>
|
||||
<data name=">>btnNewFilter.Name" xml:space="preserve">
|
||||
<value>btnNewFilter</value>
|
||||
</data>
|
||||
<data name=">>btnNewFilter.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnNewFilter.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnNewFilter.ZOrder" xml:space="preserve">
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="btnDeleteFilter.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Right</value>
|
||||
</data>
|
||||
<data name="btnDeleteFilter.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>327, 82</value>
|
||||
</data>
|
||||
<data name="btnDeleteFilter.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="btnDeleteFilter.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="btnDeleteFilter.Text" xml:space="preserve">
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
<data name=">>btnDeleteFilter.Name" xml:space="preserve">
|
||||
<value>btnDeleteFilter</value>
|
||||
</data>
|
||||
<data name=">>btnDeleteFilter.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnDeleteFilter.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnDeleteFilter.ZOrder" xml:space="preserve">
|
||||
<value>13</value>
|
||||
</data>
|
||||
<data name="lblEnterText.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="lblEnterText.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>12, 115</value>
|
||||
</data>
|
||||
<data name="lblEnterText.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>377, 23</value>
|
||||
</data>
|
||||
<data name="lblEnterText.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="lblEnterText.Text" xml:space="preserve">
|
||||
<value>Enter Custom Expression:</value>
|
||||
</data>
|
||||
<data name=">>lblEnterText.Name" xml:space="preserve">
|
||||
<value>lblEnterText</value>
|
||||
</data>
|
||||
<data name=">>lblEnterText.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.LabelX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>lblEnterText.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>lblEnterText.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="cbxShowInPopup.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Right</value>
|
||||
</data>
|
||||
<data name="cbxShowInPopup.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>259, 12</value>
|
||||
</data>
|
||||
<data name="cbxShowInPopup.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>133, 23</value>
|
||||
</data>
|
||||
<data name="cbxShowInPopup.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="cbxShowInPopup.Text" xml:space="preserve">
|
||||
<value>Show in FilterPopup</value>
|
||||
</data>
|
||||
<data name=">>cbxShowInPopup.Name" xml:space="preserve">
|
||||
<value>cbxShowInPopup</value>
|
||||
</data>
|
||||
<data name=">>cbxShowInPopup.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.CheckBoxX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cbxShowInPopup.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbxShowInPopup.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="btnClear.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="btnClear.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>15, 261</value>
|
||||
</data>
|
||||
<data name="btnClear.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>65, 23</value>
|
||||
</data>
|
||||
<data name="btnClear.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="btnClear.Text" xml:space="preserve">
|
||||
<value>Clear</value>
|
||||
</data>
|
||||
<data name=">>btnClear.Name" xml:space="preserve">
|
||||
<value>btnClear</value>
|
||||
</data>
|
||||
<data name=">>btnClear.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnClear.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnClear.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="filterExprEdit1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left, Right</value>
|
||||
</data>
|
||||
<data name="filterExprEdit1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>10, 136</value>
|
||||
</data>
|
||||
<data name="filterExprEdit1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>383, 114</value>
|
||||
</data>
|
||||
<data name="filterExprEdit1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name=">>filterExprEdit1.Name" xml:space="preserve">
|
||||
<value>filterExprEdit1</value>
|
||||
</data>
|
||||
<data name=">>filterExprEdit1.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.SuperGrid.FilterExprEdit, DevComponents.DotNetBar.SuperGrid, Version=2.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>filterExprEdit1.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>filterExprEdit1.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||
<value>96, 96</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>401, 292</value>
|
||||
</data>
|
||||
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>410, 330</value>
|
||||
</data>
|
||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||
<value>Manual</value>
|
||||
</data>
|
||||
<data name=">>$this.Name" xml:space="preserve">
|
||||
<value>CustomFilterEx</value>
|
||||
</data>
|
||||
<data name=">>$this.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Office2007Form, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
</root>
|
||||
+416
@@ -0,0 +1,416 @@
|
||||
using System;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// DataBinding helper class
|
||||
///</summary>
|
||||
internal static class DataFilter
|
||||
{
|
||||
#region Static data
|
||||
|
||||
private static bool _lockFilter;
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
/// FilterData
|
||||
///</summary>
|
||||
///<param name="panel"></param>
|
||||
internal static void FilterData(GridPanel panel)
|
||||
{
|
||||
if (_lockFilter == true)
|
||||
return;
|
||||
|
||||
if (panel.SuperGrid.DoDataFilteringStartEvent(panel) == false)
|
||||
{
|
||||
_lockFilter = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (panel.EnableFiltering == true &&
|
||||
panel.FilterLevel != FilterLevel.None)
|
||||
{
|
||||
bool rowFiltered = IsRowFiltered(panel);
|
||||
bool colFiltered = IsColumnFiltered(panel);
|
||||
|
||||
if (rowFiltered == true || colFiltered == true)
|
||||
{
|
||||
if (rowFiltered == true)
|
||||
rowFiltered = UpdateRowFilter(panel);
|
||||
|
||||
if (colFiltered == true)
|
||||
UpdateColumnFilter(panel);
|
||||
|
||||
UpdateFilterState(panel, rowFiltered, colFiltered);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateFilterState(panel, false, false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lockFilter = false;
|
||||
|
||||
panel.UpdateVisibleRowCount();
|
||||
panel.SuperGrid.DoDataFilteringCompleteEvent(panel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
panel.UpdateVisibleRowCount();
|
||||
}
|
||||
}
|
||||
|
||||
#region UpdateRowFilter
|
||||
|
||||
private static bool UpdateRowFilter(GridPanel panel)
|
||||
{
|
||||
if (panel.FilterEval == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
panel.FilterEval = new FilterEval(
|
||||
panel, null, panel.GetFilterMatchType(), panel.FilterExpr);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateColumnFilter
|
||||
|
||||
private static void UpdateColumnFilter(GridPanel panel)
|
||||
{
|
||||
foreach (GridColumn col in panel.Columns)
|
||||
{
|
||||
if (col.IsFiltered == true)
|
||||
{
|
||||
col.FilterError = false;
|
||||
|
||||
if (col.FilterEval == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
col.FilterEval = new FilterEval(
|
||||
panel, col, col.GetFilterMatchType(), col.FilterExpr);
|
||||
}
|
||||
catch
|
||||
{
|
||||
col.FilterError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateFilterState
|
||||
|
||||
private static void UpdateFilterState(
|
||||
GridPanel panel, bool rowFiltered, bool colFiltered)
|
||||
{
|
||||
if (IsFilteringEnabled(panel) == true)
|
||||
{
|
||||
if (panel.VirtualMode == true)
|
||||
{
|
||||
if (panel.SuperGrid.DoRefreshFilter(panel) == false)
|
||||
{
|
||||
panel.VirtualRows.Clear();
|
||||
|
||||
panel.DataBinder.UpdateFilter();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = panel.Rows.Count;
|
||||
|
||||
if (panel.ShowInsertRow == true)
|
||||
count--;
|
||||
|
||||
bool root = (panel.FilterLevel &
|
||||
(FilterLevel.Root | FilterLevel.RootConditional)) != 0;
|
||||
|
||||
UpdateFilterStateEx(panel, root,
|
||||
panel.Rows, count, rowFiltered, colFiltered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region UpdateFilterStateEx
|
||||
|
||||
private static void UpdateFilterStateEx(GridPanel panel, bool filter,
|
||||
GridItemsCollection items, int count, bool rowFiltered, bool colFiltered)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
GridRow row = items[i] as GridRow;
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
if (row.IsTempInsertRow == true)
|
||||
{
|
||||
row.IsRowFilteredOut = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool expanded = (panel.FilterLevel & FilterLevel.Expanded) != 0;
|
||||
|
||||
if (row.Rows.Count > 0)
|
||||
{
|
||||
UpdateFilterStateEx(panel, expanded,
|
||||
row.Rows, row.Rows.Count, rowFiltered, colFiltered);
|
||||
}
|
||||
|
||||
bool filteredOut = false;
|
||||
|
||||
if (filter == true)
|
||||
{
|
||||
if ((panel.FilterLevel & FilterLevel.RootConditional) != FilterLevel.RootConditional ||
|
||||
row.AnyVisibleItems() == false)
|
||||
{
|
||||
if (rowFiltered == true)
|
||||
{
|
||||
if (EvalRowFilterState(panel, row, ref filteredOut) == true)
|
||||
break;
|
||||
}
|
||||
|
||||
if (filteredOut == false && colFiltered == true)
|
||||
EvalColumnFilterState(panel, row, ref filteredOut);
|
||||
}
|
||||
}
|
||||
|
||||
row.RowFilteredOut = filteredOut;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GridContainer cont = items[i] as GridGroup;
|
||||
|
||||
if (cont != null)
|
||||
{
|
||||
UpdateFilterStateEx(panel,
|
||||
true, cont.Rows, cont.Rows.Count, rowFiltered, colFiltered);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EvalRowFilterState
|
||||
|
||||
private static bool EvalRowFilterState(
|
||||
GridPanel panel, GridRow row, ref bool filteredOut)
|
||||
{
|
||||
try
|
||||
{
|
||||
filteredOut = (panel.FilterEval.Evaluate(row) == false);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
filteredOut = false;
|
||||
|
||||
bool throwException = false;
|
||||
bool postError = true;
|
||||
|
||||
if (panel.SuperGrid.DoFilterRowErrorEvent(panel,
|
||||
row, exp, ref filteredOut, ref throwException, ref postError) == true)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (throwException == true)
|
||||
throw;
|
||||
|
||||
if (postError == true)
|
||||
MessageBoxEx.Show(exp.Message);
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EvalColumnFilterState
|
||||
|
||||
private static bool EvalColumnFilterState(
|
||||
GridPanel panel, GridRow row, ref bool filteredOut)
|
||||
{
|
||||
foreach (GridColumn col in panel.Columns)
|
||||
{
|
||||
if (col.IsFiltered == true)
|
||||
{
|
||||
if (col.FilterError == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
filteredOut = (col.FilterEval.Evaluate(row) == false);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
col.FilterError = true;
|
||||
|
||||
filteredOut = false;
|
||||
|
||||
bool throwException = false;
|
||||
bool postError = col.FilterEval.PostError;
|
||||
|
||||
if (panel.SuperGrid.DoFilterColumnErrorEvent(panel,
|
||||
row, col, exp, ref filteredOut, ref throwException, ref postError) == true)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
if (throwException == true)
|
||||
throw;
|
||||
|
||||
if (postError == true)
|
||||
MessageBoxEx.Show((col.Name ?? "[" + col.ColumnIndex + "]") + ":\n" + exp.Message);
|
||||
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filteredOut == true)
|
||||
break;
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateRowFilterState
|
||||
|
||||
internal static void UpdateRowFilterState(GridPanel panel, GridRow row)
|
||||
{
|
||||
bool isPrimary = (row.Parent is GridPanel);
|
||||
|
||||
bool root = (panel.FilterLevel &
|
||||
(FilterLevel.Root | FilterLevel.RootConditional)) != 0;
|
||||
|
||||
bool expanded = (panel.FilterLevel & FilterLevel.Expanded) != 0;
|
||||
|
||||
if ((isPrimary == true && root == true) ||
|
||||
(isPrimary == false && expanded == true))
|
||||
{
|
||||
bool filteredOut = false;
|
||||
|
||||
bool rowFiltered = IsRowFiltered(panel);
|
||||
bool colFiltered = IsColumnFiltered(panel);
|
||||
|
||||
if (rowFiltered == true || colFiltered == true)
|
||||
{
|
||||
if (rowFiltered == true)
|
||||
rowFiltered = UpdateRowFilter(panel);
|
||||
|
||||
if (colFiltered == true)
|
||||
UpdateColumnFilter(panel);
|
||||
|
||||
if (rowFiltered == true)
|
||||
{
|
||||
if (EvalRowFilterState(panel, row, ref filteredOut) == true)
|
||||
return;
|
||||
}
|
||||
|
||||
if (filteredOut == false && colFiltered == true)
|
||||
{
|
||||
if (EvalColumnFilterState(panel, row, ref filteredOut) == true)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (row.RowFilteredOut != filteredOut)
|
||||
{
|
||||
row.RowFilteredOut = filteredOut;
|
||||
|
||||
panel.SuperGrid.NeedToUpdateIndicees = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsFiltered
|
||||
|
||||
internal static bool IsFiltered(GridPanel panel)
|
||||
{
|
||||
return (IsRowFiltered(panel) || IsColumnFiltered(panel));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsRowFiltered
|
||||
|
||||
internal static bool IsRowFiltered(GridPanel panel)
|
||||
{
|
||||
return (IsRowFilteringEnabled(panel) &&
|
||||
String.IsNullOrEmpty(panel.FilterExpr) == false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsColumnFiltered
|
||||
|
||||
internal static bool IsColumnFiltered(GridPanel panel)
|
||||
{
|
||||
if (IsColumnFilteringEnabled(panel))
|
||||
{
|
||||
foreach (GridColumn col in panel.Columns)
|
||||
{
|
||||
if (col.IsFiltered == true)
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsFilteringEnabled
|
||||
|
||||
internal static bool IsFilteringEnabled(GridPanel panel)
|
||||
{
|
||||
return (IsRowFilteringEnabled(panel) || IsColumnFilteringEnabled(panel));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsRowFilteringEnabled
|
||||
|
||||
internal static bool IsRowFilteringEnabled(GridPanel panel)
|
||||
{
|
||||
return (panel.EnableFiltering == true &&
|
||||
panel.EnableRowFiltering == true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsColumnFilteringEnabled
|
||||
|
||||
internal static bool IsColumnFilteringEnabled(GridPanel panel)
|
||||
{
|
||||
return (panel.EnableFiltering == true &&
|
||||
panel.EnableColumnFiltering == true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
+366
@@ -0,0 +1,366 @@
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
partial class FilterDateTimePicker
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FilterDateTimePicker));
|
||||
this.cboDateRelative = new DevComponents.DotNetBar.Controls.ComboBoxEx();
|
||||
this.btnApply = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnCustom = new DevComponents.DotNetBar.ButtonX();
|
||||
this.cbxDateRelative = new DevComponents.DotNetBar.Controls.CheckBoxX();
|
||||
this.cbxDateRange = new DevComponents.DotNetBar.Controls.CheckBoxX();
|
||||
this.cbxShowAll = new DevComponents.DotNetBar.Controls.CheckBoxX();
|
||||
this.cbxShowNull = new DevComponents.DotNetBar.Controls.CheckBoxX();
|
||||
this.cbxShowNotNull = new DevComponents.DotNetBar.Controls.CheckBoxX();
|
||||
this.btnOk = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnCancel = new DevComponents.DotNetBar.ButtonX();
|
||||
this.dtiFromDate = new DevComponents.Editors.DateTimeAdv.DateTimeInput();
|
||||
this.dtiToDate = new DevComponents.Editors.DateTimeAdv.DateTimeInput();
|
||||
this.cbxDateSpecific = new DevComponents.DotNetBar.Controls.CheckBoxX();
|
||||
this.dtiSpecificDate = new DevComponents.Editors.DateTimeAdv.DateTimeInput();
|
||||
this.cbxCustom = new DevComponents.DotNetBar.Controls.CheckBoxX();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dtiFromDate)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dtiToDate)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dtiSpecificDate)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cboDateRelative
|
||||
//
|
||||
resources.ApplyResources(this.cboDateRelative, "cboDateRelative");
|
||||
this.cboDateRelative.DisplayMember = "Text";
|
||||
this.cboDateRelative.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.cboDateRelative.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboDateRelative.FormattingEnabled = true;
|
||||
this.cboDateRelative.Name = "cboDateRelative";
|
||||
this.cboDateRelative.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.cboDateRelative.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CboDateRelativeMouseDown);
|
||||
//
|
||||
// btnApply
|
||||
//
|
||||
this.btnApply.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnApply, "btnApply");
|
||||
this.btnApply.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnApply.Click += new System.EventHandler(this.BtnApplyClick);
|
||||
//
|
||||
// btnCustom
|
||||
//
|
||||
this.btnCustom.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnCustom, "btnCustom");
|
||||
this.btnCustom.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnCustom.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCustom.Name = "btnCustom";
|
||||
this.btnCustom.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnCustom.Click += new System.EventHandler(this.BtnCustomClick);
|
||||
//
|
||||
// cbxDateRelative
|
||||
//
|
||||
resources.ApplyResources(this.cbxDateRelative, "cbxDateRelative");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.cbxDateRelative.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.cbxDateRelative.CheckBoxStyle = DevComponents.DotNetBar.eCheckBoxStyle.RadioButton;
|
||||
this.cbxDateRelative.Name = "cbxDateRelative";
|
||||
this.cbxDateRelative.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// cbxDateRange
|
||||
//
|
||||
resources.ApplyResources(this.cbxDateRange, "cbxDateRange");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.cbxDateRange.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.cbxDateRange.CheckBoxStyle = DevComponents.DotNetBar.eCheckBoxStyle.RadioButton;
|
||||
this.cbxDateRange.Name = "cbxDateRange";
|
||||
this.cbxDateRange.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// cbxShowAll
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.cbxShowAll.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.cbxShowAll.CheckBoxStyle = DevComponents.DotNetBar.eCheckBoxStyle.RadioButton;
|
||||
this.cbxShowAll.Checked = true;
|
||||
this.cbxShowAll.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.cbxShowAll.CheckValue = "Y";
|
||||
resources.ApplyResources(this.cbxShowAll, "cbxShowAll");
|
||||
this.cbxShowAll.Name = "cbxShowAll";
|
||||
this.cbxShowAll.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// cbxShowNull
|
||||
//
|
||||
resources.ApplyResources(this.cbxShowNull, "cbxShowNull");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.cbxShowNull.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.cbxShowNull.CheckBoxStyle = DevComponents.DotNetBar.eCheckBoxStyle.RadioButton;
|
||||
this.cbxShowNull.Name = "cbxShowNull";
|
||||
this.cbxShowNull.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// cbxShowNotNull
|
||||
//
|
||||
resources.ApplyResources(this.cbxShowNotNull, "cbxShowNotNull");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.cbxShowNotNull.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.cbxShowNotNull.CheckBoxStyle = DevComponents.DotNetBar.eCheckBoxStyle.RadioButton;
|
||||
this.cbxShowNotNull.Name = "cbxShowNotNull";
|
||||
this.cbxShowNotNull.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnOk, "btnOk");
|
||||
this.btnOk.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnOk.Click += new System.EventHandler(this.BtnOkClick);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnCancel, "btnCancel");
|
||||
this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnCancel.Click += new System.EventHandler(this.BtnCancelClick);
|
||||
//
|
||||
// dtiFromDate
|
||||
//
|
||||
this.dtiFromDate.AllowEmptyState = false;
|
||||
resources.ApplyResources(this.dtiFromDate, "dtiFromDate");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiFromDate.BackgroundStyle.Class = "DateTimeInputBackground";
|
||||
this.dtiFromDate.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiFromDate.ButtonDropDown.Shortcut = DevComponents.DotNetBar.eShortcut.AltDown;
|
||||
this.dtiFromDate.ButtonDropDown.Visible = true;
|
||||
this.dtiFromDate.Format = DevComponents.Editors.eDateTimePickerFormat.Long;
|
||||
this.dtiFromDate.IsPopupCalendarOpen = false;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiFromDate.MonthCalendar.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiFromDate.MonthCalendar.CalendarDimensions = new System.Drawing.Size(1, 1);
|
||||
this.dtiFromDate.MonthCalendar.ClearButtonVisible = true;
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiFromDate.MonthCalendar.CommandsBackgroundStyle.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground2;
|
||||
this.dtiFromDate.MonthCalendar.CommandsBackgroundStyle.BackColorGradientAngle = 90;
|
||||
this.dtiFromDate.MonthCalendar.CommandsBackgroundStyle.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground;
|
||||
this.dtiFromDate.MonthCalendar.CommandsBackgroundStyle.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid;
|
||||
this.dtiFromDate.MonthCalendar.CommandsBackgroundStyle.BorderTopColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder;
|
||||
this.dtiFromDate.MonthCalendar.CommandsBackgroundStyle.BorderTopWidth = 1;
|
||||
this.dtiFromDate.MonthCalendar.CommandsBackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiFromDate.MonthCalendar.DisplayMonth = new System.DateTime(2012, 5, 1, 0, 0, 0, 0);
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiFromDate.MonthCalendar.NavigationBackgroundStyle.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
|
||||
this.dtiFromDate.MonthCalendar.NavigationBackgroundStyle.BackColorGradientAngle = 90;
|
||||
this.dtiFromDate.MonthCalendar.NavigationBackgroundStyle.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
|
||||
this.dtiFromDate.MonthCalendar.NavigationBackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiFromDate.MonthCalendar.TodayButtonVisible = true;
|
||||
this.dtiFromDate.Name = "dtiFromDate";
|
||||
this.dtiFromDate.ShowUpDown = true;
|
||||
this.dtiFromDate.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.dtiFromDate.MouseDown += new System.Windows.Forms.MouseEventHandler(this.DtiDateRangeMouseDown);
|
||||
//
|
||||
// dtiToDate
|
||||
//
|
||||
this.dtiToDate.AllowEmptyState = false;
|
||||
resources.ApplyResources(this.dtiToDate, "dtiToDate");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiToDate.BackgroundStyle.Class = "DateTimeInputBackground";
|
||||
this.dtiToDate.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiToDate.ButtonDropDown.Shortcut = DevComponents.DotNetBar.eShortcut.AltDown;
|
||||
this.dtiToDate.ButtonDropDown.Visible = true;
|
||||
this.dtiToDate.Format = DevComponents.Editors.eDateTimePickerFormat.Long;
|
||||
this.dtiToDate.IsPopupCalendarOpen = false;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiToDate.MonthCalendar.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiToDate.MonthCalendar.CalendarDimensions = new System.Drawing.Size(1, 1);
|
||||
this.dtiToDate.MonthCalendar.ClearButtonVisible = true;
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiToDate.MonthCalendar.CommandsBackgroundStyle.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground2;
|
||||
this.dtiToDate.MonthCalendar.CommandsBackgroundStyle.BackColorGradientAngle = 90;
|
||||
this.dtiToDate.MonthCalendar.CommandsBackgroundStyle.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground;
|
||||
this.dtiToDate.MonthCalendar.CommandsBackgroundStyle.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid;
|
||||
this.dtiToDate.MonthCalendar.CommandsBackgroundStyle.BorderTopColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder;
|
||||
this.dtiToDate.MonthCalendar.CommandsBackgroundStyle.BorderTopWidth = 1;
|
||||
this.dtiToDate.MonthCalendar.CommandsBackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiToDate.MonthCalendar.DisplayMonth = new System.DateTime(2012, 5, 1, 0, 0, 0, 0);
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiToDate.MonthCalendar.NavigationBackgroundStyle.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
|
||||
this.dtiToDate.MonthCalendar.NavigationBackgroundStyle.BackColorGradientAngle = 90;
|
||||
this.dtiToDate.MonthCalendar.NavigationBackgroundStyle.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
|
||||
this.dtiToDate.MonthCalendar.NavigationBackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiToDate.MonthCalendar.TodayButtonVisible = true;
|
||||
this.dtiToDate.Name = "dtiToDate";
|
||||
this.dtiToDate.ShowUpDown = true;
|
||||
this.dtiToDate.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.dtiToDate.MouseDown += new System.Windows.Forms.MouseEventHandler(this.DtiDateRangeMouseDown);
|
||||
//
|
||||
// cbxDateSpecific
|
||||
//
|
||||
resources.ApplyResources(this.cbxDateSpecific, "cbxDateSpecific");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.cbxDateSpecific.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.cbxDateSpecific.CheckBoxStyle = DevComponents.DotNetBar.eCheckBoxStyle.RadioButton;
|
||||
this.cbxDateSpecific.Name = "cbxDateSpecific";
|
||||
this.cbxDateSpecific.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// dtiSpecificDate
|
||||
//
|
||||
this.dtiSpecificDate.AllowEmptyState = false;
|
||||
resources.ApplyResources(this.dtiSpecificDate, "dtiSpecificDate");
|
||||
this.dtiSpecificDate.AutoSelectDate = true;
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiSpecificDate.BackgroundStyle.Class = "DateTimeInputBackground";
|
||||
this.dtiSpecificDate.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiSpecificDate.ButtonDropDown.Shortcut = DevComponents.DotNetBar.eShortcut.AltDown;
|
||||
this.dtiSpecificDate.ButtonDropDown.Visible = true;
|
||||
this.dtiSpecificDate.Format = DevComponents.Editors.eDateTimePickerFormat.Long;
|
||||
this.dtiSpecificDate.IsPopupCalendarOpen = false;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiSpecificDate.MonthCalendar.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiSpecificDate.MonthCalendar.CalendarDimensions = new System.Drawing.Size(1, 1);
|
||||
this.dtiSpecificDate.MonthCalendar.ClearButtonVisible = true;
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiSpecificDate.MonthCalendar.CommandsBackgroundStyle.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground2;
|
||||
this.dtiSpecificDate.MonthCalendar.CommandsBackgroundStyle.BackColorGradientAngle = 90;
|
||||
this.dtiSpecificDate.MonthCalendar.CommandsBackgroundStyle.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground;
|
||||
this.dtiSpecificDate.MonthCalendar.CommandsBackgroundStyle.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid;
|
||||
this.dtiSpecificDate.MonthCalendar.CommandsBackgroundStyle.BorderTopColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder;
|
||||
this.dtiSpecificDate.MonthCalendar.CommandsBackgroundStyle.BorderTopWidth = 1;
|
||||
this.dtiSpecificDate.MonthCalendar.CommandsBackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiSpecificDate.MonthCalendar.DisplayMonth = new System.DateTime(2012, 5, 1, 0, 0, 0, 0);
|
||||
//
|
||||
//
|
||||
//
|
||||
this.dtiSpecificDate.MonthCalendar.NavigationBackgroundStyle.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
|
||||
this.dtiSpecificDate.MonthCalendar.NavigationBackgroundStyle.BackColorGradientAngle = 90;
|
||||
this.dtiSpecificDate.MonthCalendar.NavigationBackgroundStyle.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
|
||||
this.dtiSpecificDate.MonthCalendar.NavigationBackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.dtiSpecificDate.MonthCalendar.TodayButtonVisible = true;
|
||||
this.dtiSpecificDate.Name = "dtiSpecificDate";
|
||||
this.dtiSpecificDate.ShowUpDown = true;
|
||||
this.dtiSpecificDate.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.dtiSpecificDate.MouseDown += new System.Windows.Forms.MouseEventHandler(this.DtiSpecificDateMouseDown);
|
||||
//
|
||||
// cbxCustom
|
||||
//
|
||||
resources.ApplyResources(this.cbxCustom, "cbxCustom");
|
||||
//
|
||||
//
|
||||
//
|
||||
this.cbxCustom.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.cbxCustom.CheckBoxStyle = DevComponents.DotNetBar.eCheckBoxStyle.RadioButton;
|
||||
this.cbxCustom.Name = "cbxCustom";
|
||||
this.cbxCustom.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// FilterDateTimePicker
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.Controls.Add(this.dtiToDate);
|
||||
this.Controls.Add(this.dtiFromDate);
|
||||
this.Controls.Add(this.dtiSpecificDate);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnOk);
|
||||
this.Controls.Add(this.cbxShowNotNull);
|
||||
this.Controls.Add(this.cbxShowNull);
|
||||
this.Controls.Add(this.cboDateRelative);
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.btnCustom);
|
||||
this.Controls.Add(this.cbxCustom);
|
||||
this.Controls.Add(this.cbxDateSpecific);
|
||||
this.Controls.Add(this.cbxDateRelative);
|
||||
this.Controls.Add(this.cbxDateRange);
|
||||
this.Controls.Add(this.cbxShowAll);
|
||||
this.DoubleBuffered = true;
|
||||
this.MinimumSize = new System.Drawing.Size(258, 340);
|
||||
this.Name = "FilterDateTimePicker";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dtiFromDate)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dtiToDate)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dtiSpecificDate)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DevComponents.DotNetBar.Controls.CheckBoxX cbxShowAll;
|
||||
private DevComponents.DotNetBar.Controls.CheckBoxX cbxDateRange;
|
||||
private DevComponents.DotNetBar.Controls.CheckBoxX cbxDateRelative;
|
||||
private ButtonX btnCustom;
|
||||
private DevComponents.DotNetBar.Controls.ComboBoxEx cboDateRelative;
|
||||
private DevComponents.DotNetBar.Controls.CheckBoxX cbxShowNull;
|
||||
private DevComponents.DotNetBar.Controls.CheckBoxX cbxShowNotNull;
|
||||
private ButtonX btnOk;
|
||||
private ButtonX btnCancel;
|
||||
internal ButtonX btnApply;
|
||||
private DevComponents.Editors.DateTimeAdv.DateTimeInput dtiFromDate;
|
||||
private DevComponents.Editors.DateTimeAdv.DateTimeInput dtiToDate;
|
||||
private DevComponents.DotNetBar.Controls.CheckBoxX cbxDateSpecific;
|
||||
private DevComponents.Editors.DateTimeAdv.DateTimeInput dtiSpecificDate;
|
||||
private DevComponents.DotNetBar.Controls.CheckBoxX cbxCustom;
|
||||
}
|
||||
}
|
||||
+769
@@ -0,0 +1,769 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.SuperGrid.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// FilterDateTimePicker
|
||||
///</summary>
|
||||
[ToolboxItem(false)]
|
||||
public partial class FilterDateTimePicker : UserControl
|
||||
{
|
||||
#region Events
|
||||
|
||||
#region ValueChanged
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the DateTimePicker value has changed
|
||||
/// </summary>
|
||||
[Description("Occurs when the DateTimePicker value has changed.")]
|
||||
public event EventHandler<EventArgs> ValueChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static data
|
||||
|
||||
private static bool _localizedStringsLoaded;
|
||||
|
||||
private static string _filterByRelativeDateString = "Filter by relative date";
|
||||
private static string _filterBySpecificDateString = "Filter by specific date";
|
||||
private static string _filterByDateRangeString = "Filter by date range";
|
||||
|
||||
private static string _currentMonth = "Current month";
|
||||
private static string _currentYear = "Current year";
|
||||
|
||||
private static string _lastMonthPeriod = "Last month period";
|
||||
private static string _last3MonthPeriod = "Last 3 month period";
|
||||
private static string _last6MonthPeriod = "Last 6 month period";
|
||||
private static string _last9MonthPeriod = "Last 9 month period";
|
||||
|
||||
private static string _lastYear = "Last Year";
|
||||
private static string _last5YearPeriod = "Last 5 year period";
|
||||
private static string _last10YearPeriod = "Last 10 year period";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private GridColumn _GridColumn;
|
||||
private string _CustomExpr;
|
||||
private bool _Cancel;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// FilterDateTimePicker
|
||||
/// </summary>
|
||||
/// <param name="gridColumn"></param>
|
||||
public FilterDateTimePicker(GridColumn gridColumn)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
SuperGridControl sg = gridColumn.SuperGrid;
|
||||
|
||||
LoadLocalizedStrings(sg);
|
||||
|
||||
cbxShowAll.Text = sg.FilterShowAllString;
|
||||
cbxShowNull.Text = sg.FilterShowNullString;
|
||||
cbxShowNotNull.Text = sg.FilterShowNotNullString;
|
||||
|
||||
if (string.IsNullOrEmpty(cbxShowNull.Text) == true)
|
||||
cbxShowNull.Visible = false;
|
||||
|
||||
if (string.IsNullOrEmpty(cbxShowNotNull.Text) == true)
|
||||
cbxShowNotNull.Visible = false;
|
||||
|
||||
if (cbxShowNull.Visible == false || cbxShowNotNull.Visible == false)
|
||||
{
|
||||
int y = (cbxDateRelative.Location.Y - cbxShowAll.Size.Height) / 2;
|
||||
|
||||
cbxShowAll.Location = new Point(cbxShowAll.Location.X, y);
|
||||
|
||||
if (cbxShowNull.Visible == true)
|
||||
cbxShowNull.Location = new Point(cbxShowNull.Location.X, y);
|
||||
|
||||
if (cbxShowNotNull.Visible == true)
|
||||
cbxShowNotNull.Location = new Point(cbxShowNotNull.Location.X, y);
|
||||
}
|
||||
|
||||
btnApply.Text = sg.FilterApplyString;
|
||||
|
||||
if (sg.FilterCustomString != null)
|
||||
{
|
||||
cbxCustom.Text = sg.FilterCustomString;
|
||||
btnCustom.Text = sg.FilterCustomString + "...";
|
||||
}
|
||||
else
|
||||
{
|
||||
cbxCustom.Visible = false;
|
||||
btnCustom.Visible = false;
|
||||
}
|
||||
|
||||
cbxDateRelative.Text = _filterByRelativeDateString;
|
||||
cbxDateSpecific.Text = _filterBySpecificDateString;
|
||||
cbxDateRange.Text = _filterByDateRangeString;
|
||||
|
||||
cboDateRelative.Items.Add(CurrentMonth);
|
||||
cboDateRelative.Items.Add(CurrentYear);
|
||||
cboDateRelative.Items.Add(LastMonthPeriod);
|
||||
cboDateRelative.Items.Add(Last3MonthPeriod);
|
||||
cboDateRelative.Items.Add(Last6MonthPeriod);
|
||||
cboDateRelative.Items.Add(Last9MonthPeriod);
|
||||
cboDateRelative.Items.Add(LastYear);
|
||||
cboDateRelative.Items.Add(Last5YearPeriod);
|
||||
cboDateRelative.Items.Add(Last10YearPeriod);
|
||||
|
||||
cboDateRelative.SelectedIndex = 0;
|
||||
|
||||
_GridColumn = gridColumn;
|
||||
|
||||
FilterColumnHeaderVisualStyle style = _GridColumn.GetFilterStyle(StyleType.Default);
|
||||
|
||||
Font = style.Font;
|
||||
BackColor = style.Background.Color1;
|
||||
|
||||
Cancel = false;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AcceptButton
|
||||
|
||||
///<summary>
|
||||
/// AcceptButton
|
||||
///</summary>
|
||||
public IButtonControl AcceptButton
|
||||
{
|
||||
get { return (btnApply); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cancel
|
||||
|
||||
///<summary>
|
||||
/// Cancel
|
||||
///</summary>
|
||||
public bool Cancel
|
||||
{
|
||||
get { return (_Cancel); }
|
||||
set { _Cancel = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CurrentMonth
|
||||
|
||||
///<summary>
|
||||
/// CurrentMonth
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string CurrentMonth
|
||||
{
|
||||
get { return (_currentMonth); }
|
||||
set { _currentMonth = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CurrentYear
|
||||
|
||||
///<summary>
|
||||
/// CurrentYear
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string CurrentYear
|
||||
{
|
||||
get { return (_currentYear); }
|
||||
set { _currentYear = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CustomFilter
|
||||
|
||||
///<summary>
|
||||
/// CustomFilter
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string CustomFilter
|
||||
{
|
||||
get { return ("Custom Filter"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LastMonthPeriod
|
||||
|
||||
///<summary>
|
||||
/// LastMonthPeriod
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string LastMonthPeriod
|
||||
{
|
||||
get { return (_lastMonthPeriod); }
|
||||
set { _lastMonthPeriod = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Last3MonthPeriod
|
||||
|
||||
///<summary>
|
||||
/// Last3MonthPeriod
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string Last3MonthPeriod
|
||||
{
|
||||
get { return (_last3MonthPeriod); }
|
||||
set { _last3MonthPeriod = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Last6MonthPeriod
|
||||
|
||||
///<summary>
|
||||
/// Last6MonthPeriod
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string Last6MonthPeriod
|
||||
{
|
||||
get { return (_last6MonthPeriod); }
|
||||
set { _last6MonthPeriod = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Last9MonthPeriod
|
||||
|
||||
///<summary>
|
||||
/// Last9MonthPeriod
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string Last9MonthPeriod
|
||||
{
|
||||
get { return (_last9MonthPeriod); }
|
||||
set { _last9MonthPeriod = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LastYear
|
||||
|
||||
///<summary>
|
||||
/// LastYear
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string LastYear
|
||||
{
|
||||
get { return (_lastYear); }
|
||||
set { _lastYear = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Last5YearPeriod
|
||||
|
||||
///<summary>
|
||||
/// Last5YearPeriod
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string Last5YearPeriod
|
||||
{
|
||||
get { return (_last5YearPeriod); }
|
||||
set { _last5YearPeriod = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Last10YearPeriod
|
||||
|
||||
///<summary>
|
||||
/// Last10YearPeriod
|
||||
///</summary>
|
||||
[Localizable(true)]
|
||||
public string Last10YearPeriod
|
||||
{
|
||||
get { return (_last10YearPeriod); }
|
||||
set { _last10YearPeriod = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetFilterExpr
|
||||
|
||||
/// <summary>
|
||||
/// GetFilterExpr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetFilterExpr()
|
||||
{
|
||||
if (cbxCustom.Checked == true)
|
||||
return (_CustomExpr);
|
||||
|
||||
if (cbxDateSpecific.Checked == true)
|
||||
return (DateSpecificExpr);
|
||||
|
||||
if (cbxDateRange.Checked == true)
|
||||
return (DateRangeExpr);
|
||||
|
||||
if (cbxDateRelative.Checked == true)
|
||||
return (DateRelativeExpr);
|
||||
|
||||
if (cbxShowNull.Checked == true)
|
||||
return (ShowNullExpr);
|
||||
|
||||
if (cbxShowNotNull.Checked == true)
|
||||
return (ShowNotNullExpr);
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#region ShowNullExpr
|
||||
|
||||
private string ShowNullExpr
|
||||
{
|
||||
get { return ("[" + _GridColumn.Name + "] = null"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowNotNullExpr
|
||||
|
||||
private string ShowNotNullExpr
|
||||
{
|
||||
get { return ("[" + _GridColumn.Name + "] != null"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DateSpecificExpr
|
||||
|
||||
private string DateSpecificExpr
|
||||
{
|
||||
get { return ("Date([" + _GridColumn.Name +"]) = Date(#" +
|
||||
dtiSpecificDate.Value.Date.ToShortDateString() + "#)"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DateRangeExpr
|
||||
|
||||
private string DateRangeExpr
|
||||
{
|
||||
get
|
||||
{
|
||||
return ("Date([" +
|
||||
_GridColumn.Name + "]) >= #" + dtiFromDate.Value.ToShortDateString() + "# And Date([" +
|
||||
_GridColumn.Name + "]) <= #" + dtiToDate.Value.ToShortDateString() + "#");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DateRelativeExpr
|
||||
|
||||
private string DateRelativeExpr
|
||||
{
|
||||
get
|
||||
{
|
||||
string cname = "[" + _GridColumn.Name + "]";
|
||||
|
||||
switch (cboDateRelative.SelectedIndex)
|
||||
{
|
||||
case (int)RelativeFilter.CurrentMonth:
|
||||
return (CurrentMonthExpr(cname));
|
||||
|
||||
case (int)RelativeFilter.CurrentYear:
|
||||
return (CurrentYearExpr(cname));
|
||||
|
||||
case (int)RelativeFilter.LastMonthPeriod:
|
||||
return (LastMonthExpr(cname, 1));
|
||||
|
||||
case (int)RelativeFilter.Last3MonthPeriod:
|
||||
return (LastMonthExpr(cname, 3));
|
||||
|
||||
case (int)RelativeFilter.Last6MonthPeriod:
|
||||
return (LastMonthExpr(cname, 6));
|
||||
|
||||
case (int)RelativeFilter.Last9MonthPeriod:
|
||||
return (LastMonthExpr(cname, 9));
|
||||
|
||||
case (int) RelativeFilter.LastYear:
|
||||
return (LastYearExpr(cname, 1));
|
||||
|
||||
case (int)RelativeFilter.Last5YearPeriod:
|
||||
return (LastYearExpr(cname, 5));
|
||||
|
||||
case (int)RelativeFilter.Last10YearPeriod:
|
||||
return (LastYearExpr(cname, 10));
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
|
||||
#region CurrentMonthExpr
|
||||
|
||||
private string CurrentMonthExpr(string cname)
|
||||
{
|
||||
string s = String.Format(
|
||||
"Year({0}) = Year() And Month({0}) = Month()", cname);
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LastMonthExpr
|
||||
|
||||
private string LastMonthExpr(string cname, int span)
|
||||
{
|
||||
string s = String.Format(
|
||||
"Date({0}) Is Between " +
|
||||
"FirstOfMonth(AddMonths(Date(), {1})) And " +
|
||||
"EndOfMonth(Date())", cname, -span);
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CurrentYearExpr
|
||||
|
||||
private string CurrentYearExpr(string cname)
|
||||
{
|
||||
string s = String.Format(
|
||||
"Year({0}) = Year()", cname);
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LastYearExpr
|
||||
|
||||
private string LastYearExpr(string cname, int span)
|
||||
{
|
||||
string s = String.Format(
|
||||
"Year({0}) Is Between " +
|
||||
"Year(AddYears(Date(), {1})) And " +
|
||||
"Year()", cname, -span);
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessTabKey
|
||||
|
||||
/// <summary>
|
||||
/// ProcessTabKey
|
||||
/// </summary>
|
||||
/// <param name="forward"></param>
|
||||
/// <returns></returns>
|
||||
protected override bool ProcessTabKey(bool forward)
|
||||
{
|
||||
return (SelectNextControl(ActiveControl, forward, false, false, true));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessDialogKey
|
||||
|
||||
/// <summary>
|
||||
/// ProcessDialogKey
|
||||
/// </summary>
|
||||
/// <param name="keyData"></param>
|
||||
/// <returns></returns>
|
||||
protected override bool ProcessDialogKey(Keys keyData)
|
||||
{
|
||||
if (keyData == Keys.Escape)
|
||||
Cancel = true;
|
||||
|
||||
else if (keyData == Keys.Enter)
|
||||
OnValueChanged();
|
||||
|
||||
return base.ProcessDialogKey(keyData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnCustomClick
|
||||
|
||||
private void BtnCustomClick(object sender, EventArgs e)
|
||||
{
|
||||
cbxCustom.Checked = true;
|
||||
|
||||
bool ok = LaunchCustomDialog(_CustomExpr);
|
||||
|
||||
_GridColumn.SuperGrid.Focus();
|
||||
|
||||
if (ok == true)
|
||||
OnValueChanged();
|
||||
}
|
||||
|
||||
#region LaunchCustomDialog
|
||||
|
||||
private bool LaunchCustomDialog(string filterExpr)
|
||||
{
|
||||
GridPanel panel = _GridColumn.GridPanel;
|
||||
|
||||
if (panel.SuperGrid.FilterUseExtendedCustomDialog == true)
|
||||
{
|
||||
CustomFilterEx cf = new CustomFilterEx(panel, _GridColumn, filterExpr);
|
||||
|
||||
cf.Text = "'" + _GridColumn.Name + "'" + CustomFilter;
|
||||
cf.ShowInPopupVisible = false;
|
||||
|
||||
DialogResult dr = cf.ShowDialog();
|
||||
|
||||
if (dr == DialogResult.OK)
|
||||
{
|
||||
_CustomExpr = cf.FilterExpr;
|
||||
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomFilter cf = new CustomFilter(panel, _GridColumn, filterExpr);
|
||||
|
||||
cf.Text = "'" + _GridColumn.Name + "'" + CustomFilter;
|
||||
|
||||
DialogResult dr = cf.ShowDialog();
|
||||
|
||||
if (dr == DialogResult.OK)
|
||||
{
|
||||
_CustomExpr = cf.FilterExpr;
|
||||
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnApplyClick
|
||||
|
||||
private void BtnApplyClick(object sender, EventArgs e)
|
||||
{
|
||||
OnValueChanged();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnOkClick
|
||||
|
||||
private void BtnOkClick(object sender, EventArgs e)
|
||||
{
|
||||
OnClose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnCancelClick
|
||||
|
||||
private void BtnCancelClick(object sender, EventArgs e)
|
||||
{
|
||||
OnCancel();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnValueChanged
|
||||
|
||||
private void OnValueChanged()
|
||||
{
|
||||
Parent.Invalidate();
|
||||
|
||||
if (ValueChanged != null)
|
||||
ValueChanged(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnClose
|
||||
|
||||
private void OnClose()
|
||||
{
|
||||
OnValueChanged();
|
||||
|
||||
PopupDropDown pdd = Parent as PopupDropDown;
|
||||
|
||||
if (pdd != null)
|
||||
pdd.Hide();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnCancel
|
||||
|
||||
private void OnCancel()
|
||||
{
|
||||
_Cancel = true;
|
||||
|
||||
PopupDropDown pdd = Parent as PopupDropDown;
|
||||
|
||||
if (pdd != null)
|
||||
pdd.Hide();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DtiSpecificDateMouseDown
|
||||
|
||||
private void DtiSpecificDateMouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
cbxDateSpecific.Checked = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DtiDateRangeMouseDown
|
||||
|
||||
private void DtiDateRangeMouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
cbxDateRange.Checked = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CboDateRelativeMouseDown
|
||||
|
||||
private void CboDateRelativeMouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
cbxDateRelative.Checked = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadLocalizedStrings
|
||||
|
||||
private void LoadLocalizedStrings(SuperGridControl sg)
|
||||
{
|
||||
if (_localizedStringsLoaded == false)
|
||||
{
|
||||
using (LocalizationManager lm = new LocalizationManager(sg))
|
||||
{
|
||||
string s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterByRelativeDate)) != "")
|
||||
_filterByRelativeDateString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterBySpecificDate)) != "")
|
||||
_filterBySpecificDateString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterByDateRange)) != "")
|
||||
_filterByDateRangeString = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterCurrentMonth)) != "")
|
||||
_currentMonth = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterCurrentYear)) != "")
|
||||
_currentYear = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterLastMonthPeriod)) != "")
|
||||
_lastMonthPeriod = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterLast3MonthPeriod)) != "")
|
||||
_last3MonthPeriod = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterLast6MonthPeriod)) != "")
|
||||
_last6MonthPeriod = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterLast9MonthPeriod)) != "")
|
||||
_last9MonthPeriod = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterLastYear)) != "")
|
||||
_lastYear = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterLast5YearPeriod)) != "")
|
||||
_last5YearPeriod = s;
|
||||
|
||||
if ((s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterLast10YearPeriod)) != "")
|
||||
_last10YearPeriod = s;
|
||||
}
|
||||
|
||||
_localizedStringsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region RelativeFilter
|
||||
|
||||
/// <summary>
|
||||
/// RelativeFilter
|
||||
/// </summary>
|
||||
public enum RelativeFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// CurrentMonth
|
||||
/// </summary>
|
||||
CurrentMonth,
|
||||
|
||||
/// <summary>
|
||||
/// CurrentYear
|
||||
/// </summary>
|
||||
CurrentYear,
|
||||
|
||||
/// <summary>
|
||||
/// LastMonthPeriod
|
||||
/// </summary>
|
||||
LastMonthPeriod,
|
||||
|
||||
/// <summary>
|
||||
/// Last3MonthPeriod
|
||||
/// </summary>
|
||||
Last3MonthPeriod,
|
||||
|
||||
/// <summary>
|
||||
/// Last6MonthPeriod
|
||||
/// </summary>
|
||||
Last6MonthPeriod,
|
||||
|
||||
/// <summary>
|
||||
/// Last9MonthPeriod
|
||||
/// </summary>
|
||||
Last9MonthPeriod,
|
||||
|
||||
/// <summary>
|
||||
/// LastYear,
|
||||
/// </summary>
|
||||
LastYear,
|
||||
|
||||
/// <summary>
|
||||
/// Last5YearPeriod
|
||||
/// </summary>
|
||||
Last5YearPeriod,
|
||||
|
||||
/// <summary>
|
||||
/// Last10YearPeriod
|
||||
/// </summary>
|
||||
Last10YearPeriod,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
+531
@@ -0,0 +1,531 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="cboDateRelative.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="cboDateRelative.ItemHeight" type="System.Int32, mscorlib">
|
||||
<value>15</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="cboDateRelative.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>25, 77</value>
|
||||
</data>
|
||||
<data name="cboDateRelative.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>219, 21</value>
|
||||
</data>
|
||||
<data name="cboDateRelative.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name=">>cboDateRelative.Name" xml:space="preserve">
|
||||
<value>cboDateRelative</value>
|
||||
</data>
|
||||
<data name=">>cboDateRelative.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.ComboBoxEx, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cboDateRelative.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cboDateRelative.ZOrder" xml:space="preserve">
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="btnApply.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left</value>
|
||||
</data>
|
||||
<data name="btnApply.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>9, 307</value>
|
||||
</data>
|
||||
<data name="btnApply.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>69, 21</value>
|
||||
</data>
|
||||
<data name="btnApply.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>12</value>
|
||||
</data>
|
||||
<data name="btnApply.Text" xml:space="preserve">
|
||||
<value>Apply</value>
|
||||
</data>
|
||||
<data name=">>btnApply.Name" xml:space="preserve">
|
||||
<value>btnApply</value>
|
||||
</data>
|
||||
<data name=">>btnApply.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnApply.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnApply.ZOrder" xml:space="preserve">
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="btnCustom.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Right</value>
|
||||
</data>
|
||||
<data name="btnCustom.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>176, 264</value>
|
||||
</data>
|
||||
<data name="btnCustom.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>69, 21</value>
|
||||
</data>
|
||||
<data name="btnCustom.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="btnCustom.Text" xml:space="preserve">
|
||||
<value>Custom...</value>
|
||||
</data>
|
||||
<data name=">>btnCustom.Name" xml:space="preserve">
|
||||
<value>btnCustom</value>
|
||||
</data>
|
||||
<data name=">>btnCustom.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnCustom.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnCustom.ZOrder" xml:space="preserve">
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="cbxDateRelative.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="cbxDateRelative.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>3, 52</value>
|
||||
</data>
|
||||
<data name="cbxDateRelative.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>241, 20</value>
|
||||
</data>
|
||||
<data name="cbxDateRelative.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="cbxDateRelative.Text" xml:space="preserve">
|
||||
<value>Filter by relative date:</value>
|
||||
</data>
|
||||
<data name=">>cbxDateRelative.Name" xml:space="preserve">
|
||||
<value>cbxDateRelative</value>
|
||||
</data>
|
||||
<data name=">>cbxDateRelative.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.CheckBoxX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cbxDateRelative.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbxDateRelative.ZOrder" xml:space="preserve">
|
||||
<value>12</value>
|
||||
</data>
|
||||
<data name="cbxDateRange.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="cbxDateRange.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>2, 175</value>
|
||||
</data>
|
||||
<data name="cbxDateRange.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>243, 20</value>
|
||||
</data>
|
||||
<data name="cbxDateRange.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="cbxDateRange.Text" xml:space="preserve">
|
||||
<value>Filter by date range:</value>
|
||||
</data>
|
||||
<data name=">>cbxDateRange.Name" xml:space="preserve">
|
||||
<value>cbxDateRange</value>
|
||||
</data>
|
||||
<data name=">>cbxDateRange.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.CheckBoxX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cbxDateRange.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbxDateRange.ZOrder" xml:space="preserve">
|
||||
<value>13</value>
|
||||
</data>
|
||||
<data name="cbxShowAll.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>4, 7</value>
|
||||
</data>
|
||||
<data name="cbxShowAll.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>97, 20</value>
|
||||
</data>
|
||||
<data name="cbxShowAll.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="cbxShowAll.Text" xml:space="preserve">
|
||||
<value>Show all</value>
|
||||
</data>
|
||||
<data name=">>cbxShowAll.Name" xml:space="preserve">
|
||||
<value>cbxShowAll</value>
|
||||
</data>
|
||||
<data name=">>cbxShowAll.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.CheckBoxX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cbxShowAll.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbxShowAll.ZOrder" xml:space="preserve">
|
||||
<value>14</value>
|
||||
</data>
|
||||
<data name="cbxShowNull.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="cbxShowNull.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>107, 7</value>
|
||||
</data>
|
||||
<data name="cbxShowNull.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>138, 20</value>
|
||||
</data>
|
||||
<data name="cbxShowNull.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="cbxShowNull.Text" xml:space="preserve">
|
||||
<value>Show null</value>
|
||||
</data>
|
||||
<data name=">>cbxShowNull.Name" xml:space="preserve">
|
||||
<value>cbxShowNull</value>
|
||||
</data>
|
||||
<data name=">>cbxShowNull.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.CheckBoxX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cbxShowNull.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbxShowNull.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="cbxShowNotNull.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="cbxShowNotNull.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>107, 28</value>
|
||||
</data>
|
||||
<data name="cbxShowNotNull.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>138, 20</value>
|
||||
</data>
|
||||
<data name="cbxShowNotNull.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="cbxShowNotNull.Text" xml:space="preserve">
|
||||
<value>Show not null</value>
|
||||
</data>
|
||||
<data name=">>cbxShowNotNull.Name" xml:space="preserve">
|
||||
<value>cbxShowNotNull</value>
|
||||
</data>
|
||||
<data name=">>cbxShowNotNull.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.CheckBoxX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cbxShowNotNull.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbxShowNotNull.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="btnOk.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="btnOk.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>103, 307</value>
|
||||
</data>
|
||||
<data name="btnOk.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>69, 21</value>
|
||||
</data>
|
||||
<data name="btnOk.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>106</value>
|
||||
</data>
|
||||
<data name="btnOk.Text" xml:space="preserve">
|
||||
<value>Ok</value>
|
||||
</data>
|
||||
<data name=">>btnOk.Name" xml:space="preserve">
|
||||
<value>btnOk</value>
|
||||
</data>
|
||||
<data name=">>btnOk.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnOk.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnOk.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="btnCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="btnCancel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>178, 307</value>
|
||||
</data>
|
||||
<data name="btnCancel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>69, 21</value>
|
||||
</data>
|
||||
<data name="btnCancel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>107</value>
|
||||
</data>
|
||||
<data name="btnCancel.Text" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.Name" xml:space="preserve">
|
||||
<value>btnCancel</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnCancel.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="dtiFromDate.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="dtiFromDate.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>22, 201</value>
|
||||
</data>
|
||||
<data name="dtiFromDate.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>222, 20</value>
|
||||
</data>
|
||||
<data name="dtiFromDate.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>110</value>
|
||||
</data>
|
||||
<data name=">>dtiFromDate.Name" xml:space="preserve">
|
||||
<value>dtiFromDate</value>
|
||||
</data>
|
||||
<data name=">>dtiFromDate.Type" xml:space="preserve">
|
||||
<value>DevComponents.Editors.DateTimeAdv.DateTimeInput, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>dtiFromDate.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>dtiFromDate.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="dtiToDate.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="dtiToDate.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>22, 227</value>
|
||||
</data>
|
||||
<data name="dtiToDate.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>222, 20</value>
|
||||
</data>
|
||||
<data name="dtiToDate.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>111</value>
|
||||
</data>
|
||||
<data name=">>dtiToDate.Name" xml:space="preserve">
|
||||
<value>dtiToDate</value>
|
||||
</data>
|
||||
<data name=">>dtiToDate.Type" xml:space="preserve">
|
||||
<value>DevComponents.Editors.DateTimeAdv.DateTimeInput, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>dtiToDate.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>dtiToDate.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="cbxDateSpecific.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="cbxDateSpecific.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>2, 113</value>
|
||||
</data>
|
||||
<data name="cbxDateSpecific.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>243, 20</value>
|
||||
</data>
|
||||
<data name="cbxDateSpecific.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="cbxDateSpecific.Text" xml:space="preserve">
|
||||
<value>Filter by specific date:</value>
|
||||
</data>
|
||||
<data name=">>cbxDateSpecific.Name" xml:space="preserve">
|
||||
<value>cbxDateSpecific</value>
|
||||
</data>
|
||||
<data name=">>cbxDateSpecific.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.CheckBoxX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cbxDateSpecific.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbxDateSpecific.ZOrder" xml:space="preserve">
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="dtiSpecificDate.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="dtiSpecificDate.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>23, 139</value>
|
||||
</data>
|
||||
<data name="dtiSpecificDate.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>221, 20</value>
|
||||
</data>
|
||||
<data name="dtiSpecificDate.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>109</value>
|
||||
</data>
|
||||
<data name=">>dtiSpecificDate.Name" xml:space="preserve">
|
||||
<value>dtiSpecificDate</value>
|
||||
</data>
|
||||
<data name=">>dtiSpecificDate.Type" xml:space="preserve">
|
||||
<value>DevComponents.Editors.DateTimeAdv.DateTimeInput, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>dtiSpecificDate.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>dtiSpecificDate.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="cbxCustom.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Left, Right</value>
|
||||
</data>
|
||||
<data name="cbxCustom.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>2, 264</value>
|
||||
</data>
|
||||
<data name="cbxCustom.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>170, 20</value>
|
||||
</data>
|
||||
<data name="cbxCustom.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="cbxCustom.Text" xml:space="preserve">
|
||||
<value>Custom</value>
|
||||
</data>
|
||||
<data name=">>cbxCustom.Name" xml:space="preserve">
|
||||
<value>cbxCustom</value>
|
||||
</data>
|
||||
<data name=">>cbxCustom.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.CheckBoxX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>cbxCustom.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>cbxCustom.ZOrder" xml:space="preserve">
|
||||
<value>10</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||
<value>96, 96</value>
|
||||
</data>
|
||||
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>260, 340</value>
|
||||
</data>
|
||||
<data name=">>$this.Name" xml:space="preserve">
|
||||
<value>FilterDateTimePicker</value>
|
||||
</data>
|
||||
<data name=">>$this.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
</root>
|
||||
+4106
File diff suppressed because it is too large
Load Diff
+112
@@ -0,0 +1,112 @@
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
partial class FilterExprEdit
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.rtbOutput = new DevComponents.DotNetBar.Controls.RichTextBoxEx();
|
||||
this.rtbInput = new DevComponents.DotNetBar.Controls.RichTextBoxEx();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.BackColor = System.Drawing.Color.White;
|
||||
this.tableLayoutPanel1.ColumnCount = 1;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.rtbOutput, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.rtbInput, 0, 0);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 2;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(398, 92);
|
||||
this.tableLayoutPanel1.TabIndex = 2;
|
||||
//
|
||||
// rtbOutput
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.rtbOutput.BackgroundStyle.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.rtbOutput.BackgroundStyle.Class = "RichTextBoxBorder";
|
||||
this.rtbOutput.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.rtbOutput.BackgroundStyle.PaddingBottom = 4;
|
||||
this.rtbOutput.BackgroundStyle.PaddingLeft = 4;
|
||||
this.rtbOutput.BackgroundStyle.PaddingRight = 4;
|
||||
this.rtbOutput.BackgroundStyle.PaddingTop = 4;
|
||||
this.rtbOutput.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.rtbOutput.Location = new System.Drawing.Point(3, 49);
|
||||
this.rtbOutput.Name = "rtbOutput";
|
||||
this.rtbOutput.ReadOnly = true;
|
||||
this.rtbOutput.Rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft S" +
|
||||
"ans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17\\par\r\n}\r\n";
|
||||
this.rtbOutput.Size = new System.Drawing.Size(392, 40);
|
||||
this.rtbOutput.TabIndex = 2;
|
||||
//
|
||||
// rtbInput
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.rtbInput.BackgroundStyle.Class = "RichTextBoxBorder";
|
||||
this.rtbInput.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.rtbInput.BackgroundStyle.PaddingBottom = 4;
|
||||
this.rtbInput.BackgroundStyle.PaddingLeft = 4;
|
||||
this.rtbInput.BackgroundStyle.PaddingRight = 4;
|
||||
this.rtbInput.BackgroundStyle.PaddingTop = 4;
|
||||
this.rtbInput.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.rtbInput.Location = new System.Drawing.Point(3, 3);
|
||||
this.rtbInput.Name = "rtbInput";
|
||||
this.rtbInput.Rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft S" +
|
||||
"ans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17\\par\r\n}\r\n";
|
||||
this.rtbInput.Size = new System.Drawing.Size(392, 40);
|
||||
this.rtbInput.TabIndex = 1;
|
||||
this.rtbInput.TextChanged += new System.EventHandler(this.RichTextBoxEx1TextChanged);
|
||||
//
|
||||
// FilterExprEdit
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Name = "FilterExprEdit";
|
||||
this.Size = new System.Drawing.Size(398, 92);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private DevComponents.DotNetBar.Controls.RichTextBoxEx rtbOutput;
|
||||
private DevComponents.DotNetBar.Controls.RichTextBoxEx rtbInput;
|
||||
}
|
||||
}
|
||||
+285
@@ -0,0 +1,285 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
using DevComponents.DotNetBar.SuperGrid.SuperGrid;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// FilterExprEdit
|
||||
///</summary>
|
||||
internal partial class FilterExprEdit : UserControl
|
||||
{
|
||||
#region InputTextChanged
|
||||
|
||||
public event EventHandler<EventArgs> InputTextChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private GridPanel _GridPanel;
|
||||
private GridColumn _GridColumn;
|
||||
|
||||
private string[] _Fonts;
|
||||
private int _FontSize;
|
||||
|
||||
private string _WaterMarkText;
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
/// FilterExprEdit
|
||||
///</summary>
|
||||
public FilterExprEdit()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
rtbInput.Font = SystemFonts.DialogFont;
|
||||
|
||||
_FontSize = (int)rtbInput.Font.SizeInPoints;
|
||||
_Fonts = new string[] { rtbInput.Font.Name };
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region GridColumn
|
||||
|
||||
internal GridColumn GridColumn
|
||||
{
|
||||
get { return (_GridColumn); }
|
||||
set { _GridColumn = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GridPanel
|
||||
|
||||
internal GridPanel GridPanel
|
||||
{
|
||||
get { return (_GridPanel); }
|
||||
set { _GridPanel = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InputText
|
||||
|
||||
internal string InputText
|
||||
{
|
||||
get { return (rtbInput.Text); }
|
||||
|
||||
set
|
||||
{
|
||||
rtbInput.Text = value;
|
||||
|
||||
UpdateOutput();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RtbOutput
|
||||
|
||||
internal RichTextBoxEx RtbOutput
|
||||
{
|
||||
get { return (rtbOutput); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WaterMarkText
|
||||
|
||||
internal string WaterMarkText
|
||||
{
|
||||
get { return (_WaterMarkText); }
|
||||
|
||||
set
|
||||
{
|
||||
_WaterMarkText = value;
|
||||
|
||||
UpdateOutput();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetFocus
|
||||
|
||||
public void SetFocus()
|
||||
{
|
||||
rtbInput.Focus();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RichTextBoxEx1TextChanged
|
||||
|
||||
private void RichTextBoxEx1TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (InputTextChanged != null)
|
||||
InputTextChanged(this, EventArgs.Empty);
|
||||
|
||||
UpdateOutput();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateOutput
|
||||
|
||||
private void UpdateOutput()
|
||||
{
|
||||
if (string.IsNullOrEmpty(rtbInput.Text) == true)
|
||||
{
|
||||
OutPutWaterMarkText(rtbOutput);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
FilterMatchType mtype = (_GridColumn != null)
|
||||
? _GridColumn.GetFilterMatchType()
|
||||
: _GridPanel.GetFilterMatchType();
|
||||
|
||||
FilterEval eval = new FilterEval(
|
||||
_GridPanel, _GridColumn, mtype, rtbInput.Text);
|
||||
|
||||
OutputRtf(rtbOutput,
|
||||
eval.GetInfix(_GridPanel.SuperGrid.FilterColorizeCustomExpr));
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
OutputRtfError(rtbOutput, rtbInput.Text, exp.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region OutPutWaterMarkText
|
||||
|
||||
private void OutPutWaterMarkText(RichTextBoxEx rtbOut)
|
||||
{
|
||||
if (_GridPanel != null &&
|
||||
string.IsNullOrEmpty(_WaterMarkText) == false)
|
||||
{
|
||||
Rtf myRtf = new Rtf(_Fonts,
|
||||
_GridPanel.SuperGrid.FilterExprColors.Colors);
|
||||
|
||||
myRtf.BeginGroup(true);
|
||||
|
||||
myRtf.Font = 0;
|
||||
myRtf.FontSize = _FontSize;
|
||||
myRtf.CenterAlignText();
|
||||
|
||||
myRtf.ForeColor = (int)ExprColorPart.Dim;
|
||||
|
||||
myRtf.WriteLine();
|
||||
myRtf.WriteText(_WaterMarkText);
|
||||
|
||||
myRtf.EndGroup();
|
||||
myRtf.Close();
|
||||
|
||||
rtbOut.Rtf = myRtf.RtfText;
|
||||
}
|
||||
else
|
||||
{
|
||||
rtbOut.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OutputRtf
|
||||
|
||||
private void OutputRtf(RichTextBoxEx rtb, string s)
|
||||
{
|
||||
s = s.Trim();
|
||||
|
||||
if (string.IsNullOrEmpty(s) == false)
|
||||
{
|
||||
Rtf myRtf = new Rtf(_Fonts,
|
||||
_GridPanel.SuperGrid.FilterExprColors.Colors);
|
||||
|
||||
myRtf.BeginGroup(true);
|
||||
|
||||
myRtf.Font = 0;
|
||||
myRtf.FontSize = _FontSize;
|
||||
myRtf.ForeColor = (int)ExprColorPart.Default;
|
||||
|
||||
Regex r = new Regex("(#@@#\\d)");
|
||||
MatchCollection mc = r.Matches(s);
|
||||
|
||||
if (mc.Count > 0)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
for (int i = 0; i < mc.Count; i++)
|
||||
{
|
||||
Match ma = mc[i];
|
||||
|
||||
if (ma.Index > index)
|
||||
myRtf.WriteText(s.Substring(index, ma.Index - index));
|
||||
|
||||
index = ma.Index + ma.Length;
|
||||
|
||||
myRtf.ForeColor = s[index - 1] - '0';
|
||||
}
|
||||
|
||||
if (s.Length > index)
|
||||
myRtf.WriteText(s.Substring(index, s.Length - index));
|
||||
}
|
||||
else
|
||||
{
|
||||
myRtf.WriteText(s);
|
||||
}
|
||||
|
||||
myRtf.EndGroup();
|
||||
myRtf.Close();
|
||||
|
||||
rtb.Rtf = myRtf.RtfText;
|
||||
}
|
||||
else
|
||||
{
|
||||
rtb.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OutputRtfError
|
||||
|
||||
private void OutputRtfError(
|
||||
RichTextBoxEx rtbOut, string text, string error)
|
||||
{
|
||||
Rtf myRtf = new Rtf(_Fonts,
|
||||
_GridPanel.SuperGrid.FilterExprColors.Colors);
|
||||
|
||||
myRtf.BeginGroup(true);
|
||||
|
||||
myRtf.Font = 0;
|
||||
myRtf.FontSize = _FontSize;
|
||||
myRtf.ForeColor = (int)ExprColorPart.Default;
|
||||
|
||||
myRtf.WriteText(text);
|
||||
myRtf.WriteText(" ");
|
||||
|
||||
myRtf.ForeColor = (int)ExprColorPart.Error;
|
||||
|
||||
myRtf.WriteLine();
|
||||
myRtf.WriteLine();
|
||||
myRtf.WriteText("(" + error + ")");
|
||||
|
||||
myRtf.EndGroup();
|
||||
myRtf.Close();
|
||||
|
||||
rtbOut.Rtf = myRtf.RtfText;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+1403
File diff suppressed because it is too large
Load Diff
+1207
File diff suppressed because it is too large
Load Diff
+276
@@ -0,0 +1,276 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// FilterScan
|
||||
///</summary>
|
||||
public class FilterScan
|
||||
{
|
||||
#region Events
|
||||
|
||||
///<summary>
|
||||
/// ScanComplete
|
||||
///</summary>
|
||||
public event EventHandler ScanComplete;
|
||||
|
||||
private delegate void ScanListDelegate(List<object> items);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private GridColumn _GridColumn;
|
||||
|
||||
private bool _Scanning;
|
||||
private Thread _ScanThread;
|
||||
private EventHandler _OnScanComplete;
|
||||
private ScanListDelegate _ScanListDelegate;
|
||||
private List<object> _ScanItems;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
///<summary>
|
||||
/// ScanItems
|
||||
///</summary>
|
||||
public List<object> ScanItems
|
||||
{
|
||||
get { return (GetScanItems()); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
/// FilterScan
|
||||
///</summary>
|
||||
///<param name="gridColumn"></param>
|
||||
public FilterScan(GridColumn gridColumn)
|
||||
{
|
||||
_GridColumn = gridColumn;
|
||||
|
||||
_OnScanComplete = new EventHandler(OnScanComplete);
|
||||
_ScanListDelegate = new ScanListDelegate(AddScanItems);
|
||||
}
|
||||
|
||||
#region BeginScan
|
||||
|
||||
///<summary>
|
||||
/// BeginScan
|
||||
///</summary>
|
||||
public void BeginScan()
|
||||
{
|
||||
if (_Scanning == false)
|
||||
{
|
||||
_Scanning = true;
|
||||
_ScanItems = null;
|
||||
|
||||
_ScanThread = new Thread(ScanThread);
|
||||
_ScanThread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EndScan
|
||||
|
||||
///<summary>
|
||||
/// BeginScan
|
||||
///</summary>
|
||||
public void EndScan()
|
||||
{
|
||||
if (_Scanning == true)
|
||||
{
|
||||
if (_ScanThread.IsAlive)
|
||||
{
|
||||
_ScanThread.Abort();
|
||||
_ScanThread.Join();
|
||||
}
|
||||
|
||||
_ScanThread = null;
|
||||
_ScanItems = null;
|
||||
|
||||
_Scanning = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ScanThread
|
||||
|
||||
private void ScanThread()
|
||||
{
|
||||
GridColumn gridColumn = _GridColumn;
|
||||
GridPanel panel = gridColumn.GridPanel;
|
||||
|
||||
List<object> scanItems = new List<object>();
|
||||
|
||||
try
|
||||
{
|
||||
if (panel != null)
|
||||
{
|
||||
ScanColumn(panel.Rows, gridColumn, scanItems);
|
||||
|
||||
RemoveDuplicates(scanItems);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
_Scanning = false;
|
||||
|
||||
gridColumn.SuperGrid.BeginInvoke(
|
||||
_ScanListDelegate, new object[] { scanItems });
|
||||
|
||||
gridColumn.SuperGrid.BeginInvoke(
|
||||
_OnScanComplete, new object[] { this, EventArgs.Empty });
|
||||
}
|
||||
}
|
||||
|
||||
#region ScanColumn
|
||||
|
||||
private void ScanColumn(
|
||||
GridItemsCollection rows, GridColumn gridColumn, List<object> scanItems)
|
||||
{
|
||||
if (rows != null && rows.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
GridContainer cont = rows[i] as GridContainer;
|
||||
|
||||
if (cont != null)
|
||||
{
|
||||
GridRow row = cont as GridRow;
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
GridCell cell = row.GetCell(gridColumn.ColumnIndex);
|
||||
|
||||
if (cell != null)
|
||||
{
|
||||
object value = cell.ValueEx;
|
||||
|
||||
if (value != null && value != DBNull.Value)
|
||||
{
|
||||
if (value is DateTime)
|
||||
value = ((DateTime)value).Date;
|
||||
|
||||
scanItems.Add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cont is GridGroup ||
|
||||
(gridColumn.GridPanel.FilterLevel != FilterLevel.Root && cont is GridPanel == false))
|
||||
{
|
||||
ScanColumn(cont.Rows, gridColumn, scanItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RemoveDuplicates
|
||||
|
||||
private void RemoveDuplicates(List<object> scanItems)
|
||||
{
|
||||
GridColumn gridColumn = _GridColumn;
|
||||
|
||||
if (gridColumn.DataType != null)
|
||||
{
|
||||
for (int i = scanItems.Count - 1; i >= 0; --i)
|
||||
{
|
||||
if (scanItems[i].GetType() != gridColumn.DataType)
|
||||
scanItems.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
scanItems.Sort(new ScanComparer());
|
||||
|
||||
object o = null;
|
||||
|
||||
for (int i = scanItems.Count - 1; i >= 0; --i)
|
||||
{
|
||||
if (scanItems[i].Equals(o) == true)
|
||||
scanItems.RemoveAt(i);
|
||||
else
|
||||
o = scanItems[i];
|
||||
}
|
||||
}
|
||||
|
||||
private class ScanComparer : IComparer<object>
|
||||
{
|
||||
public int Compare(object val1, object val2)
|
||||
{
|
||||
return (CompareVal.CompareTo(val1, val2));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region AddScanItems
|
||||
|
||||
private void AddScanItems(List<object> items)
|
||||
{
|
||||
_ScanItems = items;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnScanComplete
|
||||
|
||||
private void OnScanComplete(object sender, EventArgs e)
|
||||
{
|
||||
if (ScanComplete != null)
|
||||
ScanComplete(sender, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetScanItems
|
||||
|
||||
internal List<object> GetScanItems()
|
||||
{
|
||||
List<object> list = null;
|
||||
|
||||
if (_GridColumn.NeedsFilterScan == true)
|
||||
{
|
||||
_GridColumn.SuperGrid.Cursor = Cursors.AppStarting;
|
||||
|
||||
_GridColumn.NeedsFilterScan = false;
|
||||
_GridColumn.FilterScan.BeginScan();
|
||||
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
Application.DoEvents();
|
||||
System.Threading.Thread.Sleep(20);
|
||||
|
||||
list = _ScanItems;
|
||||
|
||||
if (list != null)
|
||||
break;
|
||||
}
|
||||
|
||||
_GridColumn.SuperGrid.Cursor = Cursors.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
list = _ScanItems;
|
||||
}
|
||||
|
||||
return (list);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// FilterUserData
|
||||
///</summary>
|
||||
static public class FilterUserData
|
||||
{
|
||||
#region Static data
|
||||
|
||||
private static string _filterPath;
|
||||
private static List<UserFilterData> _filterData;
|
||||
|
||||
#endregion
|
||||
|
||||
static FilterUserData()
|
||||
{
|
||||
_filterPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
|
||||
"\\DotNetBar\\UserFilterData.xml";
|
||||
}
|
||||
|
||||
#region GetFilterData
|
||||
|
||||
///<summary>
|
||||
/// GetFilterData
|
||||
///</summary>
|
||||
///<returns></returns>
|
||||
static public List<UserFilterData> GetFilterData(GridPanel gridPanel)
|
||||
{
|
||||
if (_filterData != null)
|
||||
return (_filterData);
|
||||
|
||||
return (LoadFilterData(gridPanel));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadFilterData
|
||||
|
||||
///<summary>
|
||||
/// LoadFilterData
|
||||
///</summary>
|
||||
///<returns></returns>
|
||||
static public List<UserFilterData> LoadFilterData(GridPanel gridPanel)
|
||||
{
|
||||
_filterData = new List<UserFilterData>();
|
||||
|
||||
string path = _filterPath;
|
||||
|
||||
if (gridPanel.SuperGrid.DoFilterLoadUserDataEvent(
|
||||
gridPanel, ref path, ref _filterData) == false)
|
||||
{
|
||||
if (File.Exists(path) == true)
|
||||
{
|
||||
using (XmlReader reader = XmlReader.Create(path))
|
||||
{
|
||||
UserFilterData fd = null;
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.IsStartElement())
|
||||
{
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "Filter":
|
||||
fd = new UserFilterData();
|
||||
_filterData.Add(fd);
|
||||
break;
|
||||
|
||||
case "Name":
|
||||
if (reader.Read())
|
||||
{
|
||||
if (fd != null)
|
||||
fd.Name = reader.Value.Trim();
|
||||
}
|
||||
break;
|
||||
|
||||
case "Description":
|
||||
if (reader.Read())
|
||||
{
|
||||
if (fd != null)
|
||||
fd.Description = reader.Value.Trim();
|
||||
}
|
||||
break;
|
||||
|
||||
case "Expression":
|
||||
if (reader.Read())
|
||||
{
|
||||
if (fd != null)
|
||||
fd.Expression = reader.Value.Trim();
|
||||
}
|
||||
break;
|
||||
|
||||
case "ReferNames":
|
||||
if (reader.Read())
|
||||
{
|
||||
if (fd != null)
|
||||
fd.ReferNamesString = reader.Value.Trim();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (_filterData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StoreFilterData
|
||||
|
||||
///<summary>
|
||||
/// StoreFilterData
|
||||
///</summary>
|
||||
///<param name="gridPanel"></param>
|
||||
///<param name="filterData"></param>
|
||||
static public void StoreFilterData(GridPanel gridPanel, List<UserFilterData> filterData)
|
||||
{
|
||||
for (int i = filterData.Count - 1; i >= 0; --i)
|
||||
{
|
||||
UserFilterData fd = filterData[i];
|
||||
|
||||
if (fd.Expression != null)
|
||||
{
|
||||
string expr = fd.Expression.Trim();
|
||||
|
||||
if (expr.Length <= 0)
|
||||
filterData.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
string path = _filterPath;
|
||||
|
||||
if (gridPanel.SuperGrid.DoFilterStoreUserDataEvent(
|
||||
gridPanel, ref path, ref _filterData) == false)
|
||||
{
|
||||
string dir = Path.GetDirectoryName(path);
|
||||
|
||||
if (dir != null)
|
||||
{
|
||||
if (Directory.Exists(dir) == false)
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
using (XmlWriter writer = XmlWriter.Create(path))
|
||||
{
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("FilterData");
|
||||
|
||||
foreach (UserFilterData fd in filterData)
|
||||
{
|
||||
if (String.IsNullOrEmpty(fd.Expression) == false)
|
||||
{
|
||||
if (String.IsNullOrEmpty(fd.Name) == false)
|
||||
{
|
||||
writer.WriteStartElement("Filter");
|
||||
writer.WriteElementString("Name", fd.Name);
|
||||
|
||||
if (String.IsNullOrEmpty(fd.Description) == false)
|
||||
writer.WriteElementString("Description", fd.Description);
|
||||
|
||||
writer.WriteElementString("Expression", fd.Expression);
|
||||
|
||||
if (String.IsNullOrEmpty(fd.ReferNamesString) == false)
|
||||
writer.WriteElementString("ReferNames", fd.ReferNamesString);
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
writer.WriteEndDocument();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// User Filter expression data
|
||||
///</summary>
|
||||
public class UserFilterData
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private string _Name;
|
||||
private string _Description;
|
||||
private string _Expression;
|
||||
|
||||
private List<string> _ReferNames = new List<string>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Description
|
||||
|
||||
///<summary>
|
||||
/// Description
|
||||
///</summary>
|
||||
public string Description
|
||||
{
|
||||
get { return (_Description); }
|
||||
set { _Description = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Expression
|
||||
|
||||
///<summary>
|
||||
/// Expression
|
||||
///</summary>
|
||||
public string Expression
|
||||
{
|
||||
get { return (_Expression); }
|
||||
set { _Expression = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Name
|
||||
|
||||
///<summary>
|
||||
/// Name
|
||||
///</summary>
|
||||
public string Name
|
||||
{
|
||||
get { return (_Name); }
|
||||
set { _Name = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ReferNames
|
||||
|
||||
///<summary>
|
||||
/// ReferNames
|
||||
///</summary>
|
||||
public List<string> ReferNames
|
||||
{
|
||||
get { return (_ReferNames); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ReferNamesString
|
||||
|
||||
///<summary>
|
||||
/// ReferNamesString
|
||||
///</summary>
|
||||
public string ReferNamesString
|
||||
{
|
||||
get
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
foreach (string s in _ReferNames)
|
||||
{
|
||||
sb.Append(s);
|
||||
sb.Append(",");
|
||||
}
|
||||
|
||||
if (sb.Length > 0)
|
||||
sb.Length--;
|
||||
|
||||
return (sb.ToString());
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_ReferNames.Clear();
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
string[] names = value.Split(',');
|
||||
|
||||
foreach (string s in names)
|
||||
_ReferNames.Add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
+1564
File diff suppressed because it is too large
Load Diff
+1488
File diff suppressed because it is too large
Load Diff
+800
@@ -0,0 +1,800 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// Constructor
|
||||
///</summary>
|
||||
public class Rtf
|
||||
{
|
||||
#region Private data
|
||||
|
||||
private StringBuilder _SbRtf; // Running Rtf text buffer
|
||||
private StringBuilder _SbText; // Running plain text buffer
|
||||
|
||||
private int _TextLength; // Running text length
|
||||
private int _ProLength; // Prolog length (used for Clear())
|
||||
|
||||
private Group _Group; // RTF Group
|
||||
private Stack<Group> _GStack; // Group Stack
|
||||
|
||||
private bool _Finalized; // RTF has been finalized
|
||||
private bool _KeepText; // Keep plain text
|
||||
|
||||
#endregion
|
||||
|
||||
#region Class definitions
|
||||
|
||||
private class Group : ICloneable
|
||||
{
|
||||
public int Font; // Current font index
|
||||
public int FontSize; // Current font size
|
||||
public int ForeColor; // Current ForeColor index
|
||||
public int BackColor; // Current BackColor index
|
||||
|
||||
public int LeftMargin; // Left margin
|
||||
public int FirstIndent; // First line indent
|
||||
public int LeftIndent; // Left indent
|
||||
|
||||
public bool Bold; // Bold
|
||||
public bool Italicize; // Italicize
|
||||
public bool SmallCaps; // Small Caps
|
||||
public bool Strikeout; // Strikeout
|
||||
public bool SuperScript; // Superscript
|
||||
public bool Underline; // Underline
|
||||
|
||||
public bool Paragraph; // Paragraph
|
||||
|
||||
#region ICloneable Members
|
||||
|
||||
// Routine to support the IClonable Interface
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
Group gp = new Group();
|
||||
|
||||
gp.Font = Font;
|
||||
gp.FontSize = FontSize;
|
||||
gp.ForeColor = ForeColor;
|
||||
gp.BackColor = BackColor;
|
||||
|
||||
gp.LeftMargin = LeftMargin;
|
||||
gp.FirstIndent = FirstIndent;
|
||||
gp.LeftIndent = LeftIndent;
|
||||
|
||||
gp.Bold = Bold;
|
||||
gp.Italicize = Italicize;
|
||||
gp.SmallCaps = SmallCaps;
|
||||
gp.Strikeout = Strikeout;
|
||||
gp.SuperScript = SuperScript;
|
||||
gp.Underline = Underline;
|
||||
|
||||
gp.Paragraph = Paragraph;
|
||||
|
||||
return (gp);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// This constructor accepts the Rtf font and
|
||||
/// color arrays, and initializes the Rtf buffer
|
||||
/// </summary>
|
||||
/// <param name="sFonts"></param>
|
||||
/// <param name="cColors"></param>
|
||||
public Rtf(string[] sFonts, Color[] cColors)
|
||||
{
|
||||
_Group = new Group();
|
||||
_GStack = new Stack<Group>();
|
||||
_SbRtf = new StringBuilder();
|
||||
|
||||
InitRtf(sFonts, cColors);
|
||||
}
|
||||
|
||||
#region InitRtf
|
||||
|
||||
/// <summary>
|
||||
/// Initializes our Rtf engine
|
||||
/// </summary>
|
||||
/// <param name="sFonts"></param>
|
||||
/// <param name="cColors"></param>
|
||||
private void InitRtf(string[] sFonts, Color[] cColors)
|
||||
{
|
||||
// Add the RTF prolog, font table, and
|
||||
// color table
|
||||
|
||||
_SbRtf.Append("{\\rtf1\\ansi\\deff0{\\fonttbl");
|
||||
|
||||
for (int i = 0; i < sFonts.Length; i++)
|
||||
_SbRtf.AppendFormat("{0}\\f{1} {2};{3}", '{', i, sFonts[i], '}');
|
||||
|
||||
_SbRtf.Append("}{\\colortbl;");
|
||||
|
||||
for (int i = 0; i < cColors.Length; i++)
|
||||
{
|
||||
_SbRtf.AppendFormat("\\red{0}\\green{1}\\blue{2};",
|
||||
cColors[i].R, cColors[i].G, cColors[i].B);
|
||||
}
|
||||
|
||||
_SbRtf.Append("}");
|
||||
|
||||
_ProLength = _SbRtf.Length;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Close
|
||||
|
||||
/// <summary>
|
||||
/// Closes and finalizes the Rtf document
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
if (_Finalized == false)
|
||||
{
|
||||
// Everything should be popped off the
|
||||
// stack by now
|
||||
|
||||
if (_GStack.Count > 0)
|
||||
throw new Exception();
|
||||
|
||||
_SbRtf.Append("}");
|
||||
|
||||
_Finalized = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Group support code
|
||||
|
||||
#region BeginGroup
|
||||
|
||||
/// <summary>
|
||||
/// This routine begins a new RTF group
|
||||
/// </summary>
|
||||
/// <param name="fParagraph"></param>
|
||||
/// <returns></returns>
|
||||
public int BeginGroup(bool fParagraph)
|
||||
{
|
||||
PushGroup();
|
||||
|
||||
// The paragraph flag is used when we close
|
||||
// the group, so save if for later inspection
|
||||
|
||||
_Group.Paragraph = fParagraph;
|
||||
|
||||
_SbRtf.Append("{");
|
||||
|
||||
return (_GStack.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EndGroup
|
||||
|
||||
/// <summary>
|
||||
/// This routine ends the current open group
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int EndGroup()
|
||||
{
|
||||
if (_Group.Paragraph == true)
|
||||
_SbRtf.Append("\\par");
|
||||
|
||||
_SbRtf.Append("}");
|
||||
|
||||
PopGroup();
|
||||
|
||||
return (_GStack.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PushGroup
|
||||
|
||||
/// <summary>
|
||||
/// This routine saves all the current group settings
|
||||
/// </summary>
|
||||
private void PushGroup()
|
||||
{
|
||||
Group gp = (Group)_Group.Clone();
|
||||
|
||||
_GStack.Push(gp);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PopGroup
|
||||
|
||||
/// <summary>
|
||||
/// This routine restores all the current
|
||||
/// group settings
|
||||
/// </summary>
|
||||
private void PopGroup()
|
||||
{
|
||||
if (_GStack.Count <= 0)
|
||||
throw new Exception();
|
||||
|
||||
_Group = _GStack.Pop();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GroupCount
|
||||
|
||||
/// <summary>
|
||||
/// Stack group count
|
||||
/// </summary>
|
||||
public int GroupCount
|
||||
{
|
||||
get { return (_GStack.Count); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Font support
|
||||
|
||||
#region FontSize
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level font size
|
||||
/// </summary>
|
||||
public int FontSize
|
||||
{
|
||||
get { return (_Group.FontSize); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.FontSize != value)
|
||||
{
|
||||
// The fontsize setting for an RTF document
|
||||
// is doubled (eg. if you want a 12 point font, then
|
||||
// you must specify it as size 24)
|
||||
|
||||
_SbRtf.AppendFormat("\\fs{0} ", value * 2);
|
||||
|
||||
_Group.FontSize = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Font
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level font setting
|
||||
/// </summary>
|
||||
public int Font
|
||||
{
|
||||
get { return (_Group.Font); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.Font != value)
|
||||
{
|
||||
_SbRtf.AppendFormat("\\f{0} ", value);
|
||||
|
||||
_Group.Font = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SuperScript
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level superscript setting
|
||||
/// </summary>
|
||||
public bool SuperScript
|
||||
{
|
||||
get { return (_Group.SuperScript); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.SuperScript != value)
|
||||
{
|
||||
_SbRtf.Append(value == true ? "\\super " : "\\super0 ");
|
||||
_Group.SuperScript = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SmallCaps
|
||||
|
||||
private int _ScapsFontSize;
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level smallCaps setting
|
||||
/// </summary>
|
||||
public bool SmallCaps
|
||||
{
|
||||
get { return (_Group.SmallCaps); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.SmallCaps != value)
|
||||
{
|
||||
// 'scaps' does not appear to work in the system RichTextBox
|
||||
// so we must simulate it via altering the fontsize a percentage
|
||||
// of the current size
|
||||
|
||||
if (value == true)
|
||||
{
|
||||
_ScapsFontSize = FontSize;
|
||||
|
||||
FontSize = (FontSize * 7) / 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
FontSize = _ScapsFontSize;
|
||||
}
|
||||
|
||||
_Group.SmallCaps = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bold
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level font Bold setting
|
||||
/// </summary>
|
||||
public bool Bold
|
||||
{
|
||||
get { return (_Group.Bold); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.Bold != value)
|
||||
{
|
||||
_SbRtf.Append(value == true ? "\\b " : "\\b0 ");
|
||||
_Group.Bold = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Italicize
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level font Italics setting
|
||||
/// </summary>
|
||||
public bool Italicize
|
||||
{
|
||||
get { return (_Group.Italicize); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.Italicize != value)
|
||||
{
|
||||
_SbRtf.Append(value == true ? "\\i " : "\\i0 ");
|
||||
_Group.Italicize = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Strikeout
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level font Strikeout setting
|
||||
/// </summary>
|
||||
public bool Strikeout
|
||||
{
|
||||
get { return (_Group.Strikeout); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.Strikeout != value)
|
||||
{
|
||||
_SbRtf.Append(value == true ? "\\strike " : "\\strike0 ");
|
||||
_Group.Strikeout = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Underline
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level font Underline setting
|
||||
/// </summary>
|
||||
public bool Underline
|
||||
{
|
||||
get { return (_Group.Underline); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.Underline != value)
|
||||
{
|
||||
_SbRtf.Append(value == true ? "\\ul " : "\\ul0 ");
|
||||
|
||||
_Group.Underline = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Color support
|
||||
|
||||
#region ForeColor
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level foreColor value
|
||||
/// </summary>
|
||||
public int ForeColor
|
||||
{
|
||||
get { return (_Group.ForeColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.ForeColor != value)
|
||||
{
|
||||
_SbRtf.AppendFormat("\\cf{0} ", value + 1);
|
||||
|
||||
_Group.ForeColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BackColor
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level backColor setting
|
||||
/// </summary>
|
||||
public int BackColor
|
||||
{
|
||||
get { return (_Group.BackColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.BackColor != value)
|
||||
{
|
||||
// "\\cb " does not appear to work, so we work
|
||||
// around this via using the highlight tag
|
||||
|
||||
_SbRtf.AppendFormat("\\highlight{0} ", value + 1);
|
||||
|
||||
_Group.BackColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Margin / indent support
|
||||
|
||||
#region LeftMargin
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level left margin setting
|
||||
/// </summary>
|
||||
public int LeftMargin
|
||||
{
|
||||
get { return (_Group.LeftMargin); }
|
||||
set { _Group.LeftMargin = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FirstIndent
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level first indent setting
|
||||
/// </summary>
|
||||
public int FirstIndent
|
||||
{
|
||||
get { return (_Group.FirstIndent); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.FirstIndent != value)
|
||||
{
|
||||
// Set the indent value, taking the current
|
||||
// left margin into account
|
||||
|
||||
_SbRtf.AppendFormat("\\fi{0} ", _Group.LeftMargin + value);
|
||||
|
||||
_Group.FirstIndent = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LeftIndent
|
||||
|
||||
/// <summary>
|
||||
/// This routine gets or sets the current
|
||||
/// group level left indent setting
|
||||
/// </summary>
|
||||
public int LeftIndent
|
||||
{
|
||||
get { return (_Group.LeftIndent); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Group.LeftIndent != value)
|
||||
{
|
||||
// Set the indent value, taking the current
|
||||
// left margin into account
|
||||
|
||||
_SbRtf.AppendFormat("\\li{0} ", _Group.LeftMargin + value);
|
||||
|
||||
_Group.LeftIndent = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Text output support
|
||||
|
||||
#region KeepText
|
||||
|
||||
/// <summary>
|
||||
/// This property tells the rtf code whether to
|
||||
/// keep a running accumulation of plain text
|
||||
/// </summary>
|
||||
public bool KeepText
|
||||
{
|
||||
get { return (_KeepText); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_KeepText != value)
|
||||
{
|
||||
_SbText = (value == true) ?
|
||||
new StringBuilder() : null;
|
||||
|
||||
_KeepText = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
|
||||
/// <summary>
|
||||
/// This read-only property returns the current plain
|
||||
/// text - if the 'KeepText' property was set to true
|
||||
/// </summary>
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
//if (_GStack.Count != 0 || fFinalized == false)
|
||||
// throw new Exception();
|
||||
|
||||
//if (sbText == null)
|
||||
// throw new Exception();
|
||||
|
||||
return (_SbText.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RtfText
|
||||
|
||||
/// <summary>
|
||||
/// This read-only property returns the current
|
||||
/// rtf accumulated control text
|
||||
/// </summary>
|
||||
public string RtfText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_GStack.Count != 0 || _Finalized == false)
|
||||
throw new Exception();
|
||||
|
||||
return (_SbRtf.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextLength
|
||||
|
||||
/// <summary>
|
||||
/// This property get/sets the current
|
||||
/// rtf plain text length
|
||||
/// </summary>
|
||||
public int TextLength
|
||||
{
|
||||
get { return (_TextLength); }
|
||||
set { _TextLength = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clear
|
||||
|
||||
/// <summary>
|
||||
/// This routine clears the accumulated text
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
_SbRtf.Length = _ProLength;
|
||||
|
||||
if (_SbText != null)
|
||||
_SbText.Length = 0;
|
||||
|
||||
_TextLength = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WriteText (char)
|
||||
|
||||
/// <summary>
|
||||
/// This routine writes a given char to the rtf buffer
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
public void WriteText(char c)
|
||||
{
|
||||
_SbRtf.Append(c);
|
||||
|
||||
if (_SbText != null)
|
||||
_SbText.Append(c);
|
||||
|
||||
_TextLength++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WriteText (string)
|
||||
|
||||
/// <summary>
|
||||
/// This routine writes a given string to the rtf buffer
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void WriteText(string s)
|
||||
{
|
||||
if (s.Length > 0)
|
||||
{
|
||||
_SbRtf.Append(s);
|
||||
|
||||
if (_SbText != null)
|
||||
_SbText.Append(s);
|
||||
|
||||
_TextLength += s.Length;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WriteLine
|
||||
|
||||
/// <summary>
|
||||
/// This routine writes a new line to the rtf buffer
|
||||
/// </summary>
|
||||
public void WriteLine()
|
||||
{
|
||||
_SbRtf.Append("\\line ");
|
||||
|
||||
if (_SbText != null)
|
||||
_SbText.Append('\n');
|
||||
|
||||
_TextLength++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WriteLine (string)
|
||||
|
||||
/// <summary>
|
||||
/// This routine writes a given string followed
|
||||
/// by a new line to the rtf buffer
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void WriteLine(string s)
|
||||
{
|
||||
WriteText(s);
|
||||
WriteLine();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WriteTab
|
||||
|
||||
/// <summary>
|
||||
/// This routine writes a tab to the rtf buffer
|
||||
/// </summary>
|
||||
public void WriteTab()
|
||||
{
|
||||
_SbRtf.Append("\\tab ");
|
||||
|
||||
if (_SbText != null)
|
||||
_SbText.Append('\t');
|
||||
|
||||
_TextLength++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WriteHex
|
||||
|
||||
/// <summary>
|
||||
/// This routine writes hex chars to the rtf buffer
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
public void WriteHex(uint x)
|
||||
{
|
||||
string hex =
|
||||
String.Format("{0:x2}", x);
|
||||
|
||||
_SbRtf.AppendFormat("\\'{0}", hex);
|
||||
|
||||
_TextLength++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CenterAlignText
|
||||
|
||||
/// <summary>
|
||||
/// This routine causes the test to be center aligned
|
||||
/// </summary>
|
||||
public void CenterAlignText()
|
||||
{
|
||||
_SbRtf.Append("\\qc ");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LeftAlignText
|
||||
|
||||
/// <summary>
|
||||
/// This routine causes the test to be left aligned
|
||||
/// </summary>
|
||||
public void LeftAlignText()
|
||||
{
|
||||
_SbRtf.Append("\\ql ");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
partial class SampleExpr
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SampleExpr));
|
||||
this.btnClose = new DevComponents.DotNetBar.ButtonX();
|
||||
this.richTextBoxEx1 = new DevComponents.DotNetBar.Controls.RichTextBoxEx();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
resources.ApplyResources(this.btnClose, "btnClose");
|
||||
this.btnClose.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnClose.Click += new System.EventHandler(this.BtnCloseClick);
|
||||
//
|
||||
// richTextBoxEx1
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.richTextBoxEx1.BackgroundStyle.Class = "RichTextBoxBorder";
|
||||
this.richTextBoxEx1.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.richTextBoxEx1.BackgroundStyle.PaddingLeft = 5;
|
||||
resources.ApplyResources(this.richTextBoxEx1, "richTextBoxEx1");
|
||||
this.richTextBoxEx1.Name = "richTextBoxEx1";
|
||||
this.richTextBoxEx1.Rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft S" +
|
||||
"ans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17\\par\r\n}\r\n";
|
||||
//
|
||||
// SampleExpr
|
||||
//
|
||||
this.AcceptButton = this.btnClose;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Controls.Add(this.richTextBoxEx1);
|
||||
this.DoubleBuffered = true;
|
||||
this.EnableGlass = false;
|
||||
this.Name = "SampleExpr";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ButtonX btnClose;
|
||||
private DevComponents.DotNetBar.Controls.RichTextBoxEx richTextBoxEx1;
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// SampleExpr
|
||||
/// </summary>
|
||||
public partial class SampleExpr : Office2007Form
|
||||
{
|
||||
///<summary>
|
||||
/// SampleExpr
|
||||
///</summary>
|
||||
public SampleExpr(SuperGridControl superGrid)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
btnClose.Text = superGrid.FilterCloseString;
|
||||
|
||||
string s = GetRtbText(superGrid);
|
||||
|
||||
try
|
||||
{
|
||||
richTextBoxEx1.Rtf = s;
|
||||
}
|
||||
catch
|
||||
{
|
||||
richTextBoxEx1.Text = s;
|
||||
}
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
///<summary>
|
||||
///The associated help RichTextBoxEx
|
||||
///</summary>
|
||||
public RichTextBoxEx RichTextBoxEx
|
||||
{
|
||||
get { return (richTextBoxEx1); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetRtbText
|
||||
|
||||
internal string GetRtbText(SuperGridControl superGrid)
|
||||
{
|
||||
using (LocalizationManager lm = new LocalizationManager(superGrid))
|
||||
{
|
||||
string s = lm.GetLocalizedString(LocalizationKeys.SuperGridFilterSampleExpr);
|
||||
|
||||
if (s == "")
|
||||
{
|
||||
using (Stream stream = typeof(SampleExpr).Assembly.GetManifestResourceStream(
|
||||
"DevComponents.DotNetBar.SuperGrid.SampleExpr.rtf"))
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
s = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (s);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BtnCloseClick
|
||||
|
||||
private void BtnCloseClick(object sender, System.EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="btnClose.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="btnClose.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>491, 216</value>
|
||||
</data>
|
||||
<data name="btnClose.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>82, 23</value>
|
||||
</data>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="btnClose.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="btnClose.Text" xml:space="preserve">
|
||||
<value>Close</value>
|
||||
</data>
|
||||
<data name=">>btnClose.Name" xml:space="preserve">
|
||||
<value>btnClose</value>
|
||||
</data>
|
||||
<data name=">>btnClose.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.ButtonX, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>btnClose.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>btnClose.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="richTextBoxEx1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
<data name="richTextBoxEx1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>0, 0</value>
|
||||
</data>
|
||||
<data name="richTextBoxEx1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>605, 251</value>
|
||||
</data>
|
||||
<data name="richTextBoxEx1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name=">>richTextBoxEx1.Name" xml:space="preserve">
|
||||
<value>richTextBoxEx1</value>
|
||||
</data>
|
||||
<data name=">>richTextBoxEx1.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Controls.RichTextBoxEx, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
<data name=">>richTextBoxEx1.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>richTextBoxEx1.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||
<value>96, 96</value>
|
||||
</data>
|
||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>605, 251</value>
|
||||
</data>
|
||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||
<value>CenterScreen</value>
|
||||
</data>
|
||||
<data name="$this.Text" xml:space="preserve">
|
||||
<value>SampleExpr</value>
|
||||
</data>
|
||||
<data name=">>$this.Name" xml:space="preserve">
|
||||
<value>SampleExpr</value>
|
||||
</data>
|
||||
<data name=">>$this.Type" xml:space="preserve">
|
||||
<value>DevComponents.DotNetBar.Office2007Form, DevComponents.DotNetBar2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7eb7c3a35b91de04</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,50 @@
|
||||
using DevComponents.DotNetBar.SuperGrid.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// GridFooter
|
||||
///</summary>
|
||||
public class GridFooter : GridTextRow
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
///<summary>
|
||||
/// GridFooter
|
||||
///</summary>
|
||||
public GridFooter()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// GridFooter
|
||||
///</summary>
|
||||
///<param name="text"></param>
|
||||
public GridFooter(string text)
|
||||
: base(text)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style support
|
||||
|
||||
/// <summary>
|
||||
/// ApplyStyleEx
|
||||
/// </summary>
|
||||
/// <param name="style"></param>
|
||||
/// <param name="css"></param>
|
||||
protected override void ApplyStyleEx(TextRowVisualStyle style, StyleType[] css)
|
||||
{
|
||||
foreach (StyleType cs in css)
|
||||
{
|
||||
style.ApplyStyle(SuperGrid.BaseVisualStyles.FooterStyles[cs]);
|
||||
style.ApplyStyle(SuperGrid.DefaultVisualStyles.FooterStyles[cs]);
|
||||
style.ApplyStyle(GridPanel.DefaultVisualStyles.FooterStyles[cs]);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+1731
File diff suppressed because it is too large
Load Diff
+2430
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
||||
using DevComponents.DotNetBar.SuperGrid.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the grid header
|
||||
/// </summary>
|
||||
public class GridHeader : GridTextRow
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
///<summary>
|
||||
/// GridHeader
|
||||
///</summary>
|
||||
public GridHeader()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// GridHeader
|
||||
///</summary>
|
||||
///<param name="text"></param>
|
||||
public GridHeader(string text)
|
||||
: base(text)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style support
|
||||
|
||||
/// <summary>
|
||||
/// ApplyStyleEx
|
||||
/// </summary>
|
||||
/// <param name="style"></param>
|
||||
/// <param name="css"></param>
|
||||
protected override void ApplyStyleEx(TextRowVisualStyle style, StyleType[] css)
|
||||
{
|
||||
foreach (StyleType cs in css)
|
||||
{
|
||||
style.ApplyStyle(SuperGrid.BaseVisualStyles.HeaderStyles[cs]);
|
||||
style.ApplyStyle(SuperGrid.DefaultVisualStyles.HeaderStyles[cs]);
|
||||
style.ApplyStyle(GridPanel.DefaultVisualStyles.HeaderStyles[cs]);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
using DevComponents.DotNetBar.SuperGrid.Primitives;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the collection of grid items.
|
||||
/// </summary>
|
||||
[Editor("DevComponents.SuperGrid.Design.GridRowCollectionEditor, DevComponents.SuperGrid.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=26d81176cfa2b486", typeof(UITypeEditor))]
|
||||
public class GridItemsCollection : CustomCollection<GridElement>
|
||||
{
|
||||
#region ClearItems
|
||||
|
||||
/// <summary>
|
||||
/// ClearItems
|
||||
/// </summary>
|
||||
protected override void ClearItems()
|
||||
{
|
||||
int n = Items.Count;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GridContainer item = Items[i] as GridContainer;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
GridContainer parent = item.Parent as GridContainer;
|
||||
|
||||
if (parent != null)
|
||||
parent.MergeScan = null;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (FloatLastItem == true)
|
||||
n--;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
DetachItem(Items[i] as GridContainer, true);
|
||||
|
||||
base.ClearItems();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RemoveItem
|
||||
|
||||
/// <summary>
|
||||
/// RemoveItem
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
protected override void RemoveItem(int index)
|
||||
{
|
||||
DetachItem(Items[index] as GridContainer, false);
|
||||
|
||||
base.RemoveItem(index);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DetachItem
|
||||
|
||||
private void DetachItem(GridContainer item, bool clear)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
item.DetachNestedRows(false);
|
||||
|
||||
if (clear == false)
|
||||
item.Parent = null;
|
||||
|
||||
GridPanel panel = item as GridPanel;
|
||||
|
||||
if (panel != null)
|
||||
panel.DataBinder.Clear();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.SuperGrid.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the layout information for grid layout pass
|
||||
/// </summary>
|
||||
public class GridLayoutInfo
|
||||
{
|
||||
#region Public variables
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Graphics object of the control.
|
||||
/// </summary>
|
||||
public Graphics Graphics;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether right-to-left layout is in effect.
|
||||
/// </summary>
|
||||
public bool RightToLeft;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the client bounds for the layout i.e. client bounds of SuperGridControl.
|
||||
/// </summary>
|
||||
public Rectangle ClientBounds;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default visual styles for grid elements.
|
||||
/// </summary>
|
||||
public DefaultVisualStyles DefaultVisualStyles;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the GridLayoutInfo class.
|
||||
/// </summary>
|
||||
/// <param name="graphics"></param>
|
||||
/// <param name="clientBounds"></param>
|
||||
public GridLayoutInfo(Graphics graphics, Rectangle clientBounds)
|
||||
{
|
||||
Graphics = graphics;
|
||||
ClientBounds = clientBounds;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides the layout state information for grid layout pass
|
||||
/// </summary>
|
||||
public class GridLayoutStateInfo
|
||||
{
|
||||
#region Public variables
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the layout GridPanel
|
||||
/// </summary>
|
||||
public GridPanel GridPanel;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the IndentLevel
|
||||
/// </summary>
|
||||
public int IndentLevel;
|
||||
|
||||
#endregion
|
||||
|
||||
internal int PassCount;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the GridLayoutStateInfo class
|
||||
/// </summary>
|
||||
public GridLayoutStateInfo(GridPanel gridPanel, int indentLevel)
|
||||
{
|
||||
GridPanel = gridPanel;
|
||||
IndentLevel = indentLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
+858
@@ -0,0 +1,858 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.SuperGrid.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// Defines a merged cell range, comprised
|
||||
/// of a starting and ending row,column index pair.
|
||||
///</summary>
|
||||
public class CellRange : DisplayRange
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Cs _States;
|
||||
private CellRangeData _CellRangeData;
|
||||
private object _Tag;
|
||||
private string _ToolTip;
|
||||
private ushort _StyleUpdateCount;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
///<summary>
|
||||
/// Defines a merged cell range, comprised
|
||||
/// of a starting and ending row,column index pair.
|
||||
///</summary>
|
||||
public CellRange()
|
||||
{
|
||||
AllowSuspend = true;
|
||||
AllowSelection = true;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Defines a merged cell range, comprised
|
||||
/// of a starting and ending row,column index pair.
|
||||
///</summary>
|
||||
///<param name="rowIndex">Initial start and end row index</param>
|
||||
///<param name="columnIndex">Initial start and end column index</param>
|
||||
public CellRange(int rowIndex, int columnIndex)
|
||||
: this()
|
||||
{
|
||||
RowStart = rowIndex;
|
||||
ColumnStart = columnIndex;
|
||||
|
||||
RowCount = 1;
|
||||
ColumnCount = 1;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Defines a merged cell range, comprised
|
||||
/// of a starting and ending row,column index pair.
|
||||
///</summary>
|
||||
///<param name="startRowIndex">Starting row index</param>
|
||||
///<param name="startColumnIndex">Starting column index</param>
|
||||
///<param name="rowCount">Row count</param>
|
||||
///<param name="columnCount">Column count</param>
|
||||
public CellRange(int startRowIndex, int startColumnIndex, int rowCount, int columnCount)
|
||||
: this()
|
||||
{
|
||||
RowStart = startRowIndex;
|
||||
ColumnStart = startColumnIndex;
|
||||
|
||||
RowCount = rowCount;
|
||||
ColumnCount = columnCount;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AllowSelection
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets whether the range can be selected
|
||||
///</summary>
|
||||
public bool AllowSelection
|
||||
{
|
||||
get { return (TestState(Cs.AllowSelection)); }
|
||||
set { SetState(Cs.AllowSelection, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AllowSuspend
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets whether the merged cell range can be temporarily
|
||||
/// suspended when either the user double clicks the displayed range
|
||||
/// or the application initiates a cell.SuspendMerge().
|
||||
///</summary>
|
||||
public bool AllowSuspend
|
||||
{
|
||||
get { return (TestState(Cs.AllowSuspend)); }
|
||||
set { SetState(Cs.AllowSuspend, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AlwaysDisplayFormattedValue
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets whether the 'FormattedValue' value will be
|
||||
/// displayed for all cell types when merged, or only for Modal Cells.
|
||||
///</summary>
|
||||
public bool AlwaysDisplayFormattedValue
|
||||
{
|
||||
get { return (TestState(Cs.AlwaysDisplayFormattedValue)); }
|
||||
set { SetState(Cs.AlwaysDisplayFormattedValue, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BackBounds
|
||||
|
||||
///<summary>
|
||||
/// Gets the range display bounds
|
||||
///</summary>
|
||||
public Rectangle BackBounds
|
||||
{
|
||||
get { return (RangeData.BackBounds); }
|
||||
internal set { RangeData.BackBounds = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the visual styles assigned to the cell
|
||||
/// </summary>
|
||||
public CellVisualStyles CellStyles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (RangeData.CellStyles == null)
|
||||
RangeData.CellStyles = new CellVisualStyles();
|
||||
|
||||
return (RangeData.CellStyles);
|
||||
}
|
||||
|
||||
set { RangeData.CellStyles = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FormattedValue
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the formatted value for the range display. This value will
|
||||
/// be displayed by default for all Modal Cells - all other cells will
|
||||
/// have their default cell rendering displayed when merged
|
||||
/// (unless 'AlwaysDisplayFormattedValue' is set to true).
|
||||
///</summary>
|
||||
public string FormattedValue
|
||||
{
|
||||
get { return (RangeData.FormattedValue); }
|
||||
set { RangeData.FormattedValue = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tag
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets user-defined data associated with the object
|
||||
///</summary>
|
||||
public object Tag
|
||||
{
|
||||
get { return (_Tag); }
|
||||
set { _Tag = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToolTip
|
||||
|
||||
///<summary>
|
||||
/// Gets or sets the ToolTip text for the cell range.
|
||||
///</summary>
|
||||
public string ToolTip
|
||||
{
|
||||
get { return (_ToolTip); }
|
||||
set { _ToolTip = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region Modified
|
||||
|
||||
internal bool Modified
|
||||
{
|
||||
get { return (TestState(Cs.Modified)); }
|
||||
set { SetState(Cs.Modified, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderCount
|
||||
|
||||
internal int RenderCount
|
||||
{
|
||||
get { return (RangeData.RenderCount); }
|
||||
set { RangeData.RenderCount = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectionUpdateCount
|
||||
|
||||
internal int SelectionUpdateCount
|
||||
{
|
||||
get { return (RangeData.SelectionUpdateCount); }
|
||||
set { RangeData.SelectionUpdateCount = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Suspended
|
||||
|
||||
internal bool Suspended
|
||||
{
|
||||
get { return (TestState(Cs.Suspended)); }
|
||||
set { SetState(Cs.Suspended, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private properties
|
||||
|
||||
#region EffectiveStyles
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the 'effective' visual styles assigned to the range
|
||||
/// </summary>
|
||||
private CellVisualStyles EffectiveStyles
|
||||
{
|
||||
get { return (RangeData.EffectiveStyles); }
|
||||
set { RangeData.EffectiveStyles = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RangeData
|
||||
|
||||
private CellRangeData RangeData
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CellRangeData == null)
|
||||
_CellRangeData = new CellRangeData();
|
||||
|
||||
return (_CellRangeData);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region TestState
|
||||
|
||||
private bool TestState(Cs state)
|
||||
{
|
||||
return ((_States & state) == state);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
private void SetState(Cs state, bool value)
|
||||
{
|
||||
if (value == true)
|
||||
_States |= state;
|
||||
else
|
||||
_States &= ~state;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetEffectiveStyle
|
||||
|
||||
internal CellVisualStyle GetEffectiveStyle(GridContainer cont, StyleState cellState)
|
||||
{
|
||||
switch (cellState)
|
||||
{
|
||||
case StyleState.MouseOver:
|
||||
return (GetStyle(cont, StyleType.MouseOver));
|
||||
|
||||
case StyleState.Selected:
|
||||
return (GetStyle(cont, StyleType.Selected));
|
||||
|
||||
case StyleState.Selected | StyleState.MouseOver:
|
||||
return (GetStyle(cont, StyleType.SelectedMouseOver));
|
||||
|
||||
case StyleState.ReadOnly:
|
||||
return (GetStyle(cont, StyleType.ReadOnly));
|
||||
|
||||
case StyleState.ReadOnly | StyleState.MouseOver:
|
||||
return (GetStyle(cont, StyleType.ReadOnlyMouseOver));
|
||||
|
||||
case StyleState.ReadOnly | StyleState.Selected:
|
||||
return (GetStyle(cont, StyleType.ReadOnlySelected));
|
||||
|
||||
case StyleState.ReadOnly | StyleState.MouseOver | StyleState.Selected:
|
||||
return (GetStyle(cont, StyleType.ReadOnlySelectedMouseOver));
|
||||
|
||||
default:
|
||||
return (GetStyle(cont, StyleType.Default));
|
||||
}
|
||||
}
|
||||
|
||||
#region GetStyle
|
||||
|
||||
private CellVisualStyle GetStyle(GridContainer cont, StyleType e)
|
||||
{
|
||||
GridPanel panel = cont.GridPanel;
|
||||
|
||||
ValidateStyle(panel);
|
||||
|
||||
CellVisualStyles cvs = EffectiveStyles ?? new CellVisualStyles();
|
||||
|
||||
if (cvs.IsValid(e) == false)
|
||||
{
|
||||
CellVisualStyle style = new CellVisualStyle();
|
||||
|
||||
StyleType[] css = style.GetApplyStyleTypes(e);
|
||||
|
||||
if (css != null)
|
||||
{
|
||||
int cindex = panel.Columns.DisplayIndexMap[ColumnStart];
|
||||
|
||||
GridRow row = null;
|
||||
GridColumn column = panel.Columns.ColumnAtDisplayIndex(ColumnStart);
|
||||
|
||||
if (RowCount == 1)
|
||||
{
|
||||
GridCell cell = cont.GetCell(RowStart, cindex);
|
||||
|
||||
if (cell != null)
|
||||
row = cell.GridRow;
|
||||
}
|
||||
|
||||
foreach (StyleType cs in css)
|
||||
{
|
||||
if (column != null)
|
||||
column.ApplyCellStyle(style, cs);
|
||||
|
||||
if (row != null)
|
||||
row.ApplyCellStyle(style, cs);
|
||||
|
||||
panel.ApplyMergedCellStyle(style, cs);
|
||||
|
||||
if (RangeData.CellStyles != null)
|
||||
style.ApplyStyle(RangeData.CellStyles[cs]);
|
||||
}
|
||||
}
|
||||
|
||||
panel.SuperGrid.DoGetMergedCellStyleEvent(panel, this, e, ref style);
|
||||
|
||||
if (style.Background == null || style.Background.IsEmpty == true)
|
||||
style.Background = new Background(Color.White);
|
||||
|
||||
if (style.Font == null)
|
||||
style.Font = SystemFonts.DefaultFont;
|
||||
|
||||
cvs[e] = style;
|
||||
}
|
||||
|
||||
EffectiveStyles = cvs;
|
||||
|
||||
return (EffectiveStyles[e]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ValidateStyle
|
||||
|
||||
private void ValidateStyle(GridPanel panel)
|
||||
{
|
||||
if (_StyleUpdateCount != panel.SuperGrid.StyleUpdateCount)
|
||||
ClearEffectiveStyles();
|
||||
|
||||
_StyleUpdateCount = panel.SuperGrid.StyleUpdateCount;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InvalidateStyle
|
||||
|
||||
///<summary>
|
||||
///Invalidates the cached Style
|
||||
///definition for all defined StyleTypes
|
||||
///</summary>
|
||||
public void InvalidateStyle()
|
||||
{
|
||||
ClearEffectiveStyles();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Invalidate the cached Style
|
||||
///definition for the given StyleType
|
||||
///</summary>
|
||||
///<param name="type"></param>
|
||||
public void InvalidateStyle(StyleType type)
|
||||
{
|
||||
if (EffectiveStyles != null)
|
||||
EffectiveStyles[type] = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClearEffectiveStyles
|
||||
|
||||
internal void ClearEffectiveStyles()
|
||||
{
|
||||
if (EffectiveStyles != null)
|
||||
{
|
||||
EffectiveStyles.Dispose();
|
||||
EffectiveStyles = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsSelected
|
||||
|
||||
internal bool IsSelected(GridPanel panel, GridContainer cont)
|
||||
{
|
||||
if (AllowSelection == true)
|
||||
{
|
||||
if (panel.AllowSelection == true)
|
||||
{
|
||||
if (RangeData.SelectionUpdateCount != panel.SelectionUpdateCount)
|
||||
{
|
||||
RangeData.SelectionUpdateCount = panel.SelectionUpdateCount;
|
||||
|
||||
SetState(Cs.Selected, IsMergeSelected(panel, cont));
|
||||
}
|
||||
|
||||
return (TestState(Cs.Selected));
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#region IsMergeSelected
|
||||
|
||||
private bool IsMergeSelected(GridPanel panel, GridContainer cont)
|
||||
{
|
||||
int rowCount = GetRowCount(panel, cont);
|
||||
|
||||
if (RowIsSelected(panel, cont, rowCount))
|
||||
return (true);
|
||||
|
||||
if (ColumnIsSelected(panel))
|
||||
return (true);
|
||||
|
||||
return (CellIsSelected(panel, cont, rowCount));
|
||||
}
|
||||
|
||||
#region RowIsSelected
|
||||
|
||||
private bool RowIsSelected(GridPanel panel, GridContainer cont, int rowCount)
|
||||
{
|
||||
for (int i = RowStart; i < RowEnd; i++)
|
||||
{
|
||||
if (i < rowCount)
|
||||
{
|
||||
GridContainer row = GetRow(panel, cont, i);
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
if (row.IsSelected == true)
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ColumnIsSelected
|
||||
|
||||
private bool ColumnIsSelected(GridPanel panel)
|
||||
{
|
||||
int[] map = panel.Columns.DisplayIndexMap;
|
||||
|
||||
for (int i = ColumnStart; i < ColumnEnd; i++)
|
||||
{
|
||||
if (i < panel.Columns.Count)
|
||||
{
|
||||
if (panel.Columns[map[i]].IsSelected == true)
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellIsSelected
|
||||
|
||||
private bool CellIsSelected(GridPanel panel, GridContainer cont, int rowCount)
|
||||
{
|
||||
int[] map = panel.Columns.DisplayIndexMap;
|
||||
|
||||
for (int i = RowStart; i < RowEnd; i++)
|
||||
{
|
||||
if (i < rowCount)
|
||||
{
|
||||
GridRow row = GetRow(panel, cont, i) as GridRow;
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
for (int j = ColumnStart; j < ColumnEnd; j++)
|
||||
{
|
||||
if (j < panel.Columns.Count)
|
||||
{
|
||||
GridCell cell = row.GetCell(map[j]);
|
||||
|
||||
if (cell != null)
|
||||
{
|
||||
if (panel.IsItemSelectedEx(cell) == true)
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetRowCount
|
||||
|
||||
private int GetRowCount(GridPanel panel, GridContainer cont)
|
||||
{
|
||||
if (panel.VirtualMode == true)
|
||||
return (panel.VirtualRowCount);
|
||||
|
||||
return (cont.Rows.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetRow
|
||||
|
||||
private GridContainer GetRow(GridPanel panel, GridContainer cont, int index)
|
||||
{
|
||||
return (panel.VirtualMode == true)
|
||||
? panel.VirtualRows[index]
|
||||
: cont.Rows[index] as GridContainer;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellStates
|
||||
|
||||
[Flags]
|
||||
private enum Cs
|
||||
{
|
||||
AllowSelection = (1 << 0),
|
||||
AllowSuspend = (1 << 1),
|
||||
AlwaysDisplayFormattedValue = (1 << 2),
|
||||
Modified = (1 << 3),
|
||||
Selected = (1 << 4),
|
||||
Suspended = (1 << 5),
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellRangeData
|
||||
|
||||
private class CellRangeData
|
||||
{
|
||||
#region Private data
|
||||
|
||||
private int _RenderCount;
|
||||
private int _SelectionUpdateCount;
|
||||
|
||||
private Rectangle _BackBounds;
|
||||
|
||||
private string _FormattedValue;
|
||||
|
||||
private CellVisualStyles _CellStyles;
|
||||
private CellVisualStyles _EffectiveStyles;
|
||||
|
||||
#endregion
|
||||
|
||||
#region public properties
|
||||
|
||||
#region BackBounds
|
||||
|
||||
public Rectangle BackBounds
|
||||
{
|
||||
get { return (_BackBounds); }
|
||||
set { _BackBounds = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellStyles
|
||||
|
||||
public CellVisualStyles CellStyles
|
||||
{
|
||||
get { return (_CellStyles); }
|
||||
set { _CellStyles = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EffectiveStyles
|
||||
|
||||
public CellVisualStyles EffectiveStyles
|
||||
{
|
||||
get { return (_EffectiveStyles); }
|
||||
set { _EffectiveStyles = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FormattedValue
|
||||
|
||||
public string FormattedValue
|
||||
{
|
||||
get { return (_FormattedValue); }
|
||||
set { _FormattedValue = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderCount
|
||||
|
||||
public int RenderCount
|
||||
{
|
||||
get { return (_RenderCount); }
|
||||
set { _RenderCount = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectionUpdateCount
|
||||
|
||||
public int SelectionUpdateCount
|
||||
{
|
||||
get { return (_SelectionUpdateCount); }
|
||||
set { _SelectionUpdateCount = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region DisplayRange
|
||||
|
||||
///<summary>
|
||||
///Row/Column display index range
|
||||
///</summary>
|
||||
public class DisplayRange
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private int _RowStart;
|
||||
private int _RowCount;
|
||||
|
||||
private int _ColumnStart;
|
||||
private int _ColumnCount;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region ColumnCount
|
||||
|
||||
///<summary>
|
||||
///Number of columns
|
||||
///</summary>
|
||||
public int ColumnCount
|
||||
{
|
||||
get { return (_ColumnCount); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentException(@"ColumnCount cannot be negative", "value");
|
||||
|
||||
_ColumnCount = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ColumnEnd
|
||||
|
||||
///<summary>
|
||||
///Ending column display index (exclusive)
|
||||
///</summary>
|
||||
public int ColumnEnd
|
||||
{
|
||||
get { return (_ColumnStart + _ColumnCount); }
|
||||
|
||||
set
|
||||
{
|
||||
int count = value - _ColumnStart;
|
||||
|
||||
if (count < 0)
|
||||
throw new ArgumentException(@"ColumnEnd cannot be less than ColumnStart", "value");
|
||||
|
||||
ColumnCount = count;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ColumnStart
|
||||
|
||||
///<summary>
|
||||
///Starting column display index
|
||||
///</summary>
|
||||
public int ColumnStart
|
||||
{
|
||||
get { return (_ColumnStart); }
|
||||
set { _ColumnStart = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Contains
|
||||
|
||||
internal bool Contains(int rowIndex, int columnIndex)
|
||||
{
|
||||
return ((rowIndex >= _RowStart && rowIndex < RowEnd) &&
|
||||
(columnIndex >= _ColumnStart && columnIndex < ColumnEnd));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RowCount
|
||||
|
||||
///<summary>
|
||||
///Number of rows
|
||||
///</summary>
|
||||
public int RowCount
|
||||
{
|
||||
get { return (_RowCount); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentException(@"RowCount cannot be negative", "value");
|
||||
|
||||
_RowCount = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RowEnd
|
||||
|
||||
///<summary>
|
||||
///Ending row index (exclusive)
|
||||
///</summary>
|
||||
public int RowEnd
|
||||
{
|
||||
get { return (_RowStart + _RowCount); }
|
||||
|
||||
set
|
||||
{
|
||||
int count = value - _RowStart;
|
||||
|
||||
if (count < 0)
|
||||
throw new ArgumentException(@"RowEnd cannot be less than RowStart", "value");
|
||||
|
||||
RowCount = count;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RowStart
|
||||
|
||||
///<summary>
|
||||
///Starting row index
|
||||
///</summary>
|
||||
public int RowStart
|
||||
{
|
||||
get { return (_RowStart); }
|
||||
set { _RowStart = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsRangeEqualTo
|
||||
|
||||
///<summary>
|
||||
///Returns whether the display range is
|
||||
///logically equal to the given item's display range.
|
||||
///</summary>
|
||||
///<param name="dr"></param>
|
||||
///<returns></returns>
|
||||
public bool IsRangeEqualTo(DisplayRange dr)
|
||||
{
|
||||
if (dr != null)
|
||||
{
|
||||
return (dr.RowStart == _RowStart && dr.ColumnStart == _ColumnStart &&
|
||||
dr.RowCount == _RowCount && dr.ColumnCount == _ColumnCount);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToString
|
||||
|
||||
/// <summary>
|
||||
/// ToString
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return ("RowStart = " + RowStart + ", RowEnd = " + RowEnd +
|
||||
" ColStart = " + ColumnStart + " ColEnd = " + ColumnEnd);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
+1041
File diff suppressed because it is too large
Load Diff
+14939
File diff suppressed because it is too large
Load Diff
+40
@@ -0,0 +1,40 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides the rendering information for grid render pass.
|
||||
/// </summary>
|
||||
public class GridRenderInfo
|
||||
{
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reference to Graphics object used for rendering.
|
||||
/// </summary>
|
||||
public readonly Graphics Graphics;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the clip rectangle.
|
||||
/// </summary>
|
||||
public readonly Rectangle ClipRectangle;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether right-to-left layout is in effect.
|
||||
/// </summary>
|
||||
public bool RightToLeft;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the GridRenderInfo class.
|
||||
/// </summary>
|
||||
/// <param name="graphics">Graphics object</param>
|
||||
/// <param name="clipRectangle">Control clip rectangle</param>
|
||||
public GridRenderInfo(Graphics graphics, Rectangle clipRectangle)
|
||||
{
|
||||
Graphics = graphics;
|
||||
ClipRectangle = clipRectangle;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+1549
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
using System.ComponentModel;
|
||||
using DevComponents.DotNetBar.SuperGrid.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the grid title
|
||||
/// </summary>
|
||||
public class GridTitle : GridTextRow
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
///<summary>
|
||||
/// GridHeader
|
||||
///</summary>
|
||||
public GridTitle()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// GridHeader
|
||||
///</summary>
|
||||
///<param name="text"></param>
|
||||
public GridTitle(string text)
|
||||
: base(text)
|
||||
{
|
||||
RowHeaderVisibility = RowHeaderVisibility.Never;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region RowHeaderVisibility
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the RowHeader is displayed
|
||||
/// </summary>
|
||||
[DefaultValue(RowHeaderVisibility.Never), Category("Appearance")]
|
||||
[Description("Indicates whether the RowHeader is displayed")]
|
||||
public override RowHeaderVisibility RowHeaderVisibility
|
||||
{
|
||||
get { return (base.RowHeaderVisibility); }
|
||||
set { base.RowHeaderVisibility = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style support
|
||||
|
||||
/// <summary>
|
||||
/// ApplyStyleEx
|
||||
/// </summary>
|
||||
/// <param name="style"></param>
|
||||
/// <param name="css"></param>
|
||||
protected override void ApplyStyleEx(TextRowVisualStyle style, StyleType[] css)
|
||||
{
|
||||
foreach (StyleType cs in css)
|
||||
{
|
||||
style.ApplyStyle(SuperGrid.BaseVisualStyles.TitleStyles[cs]);
|
||||
style.ApplyStyle(SuperGrid.DefaultVisualStyles.TitleStyles[cs]);
|
||||
style.ApplyStyle(GridPanel.DefaultVisualStyles.TitleStyles[cs]);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+533
@@ -0,0 +1,533 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the collection of Virtual Rows
|
||||
/// </summary>
|
||||
public class GridVirtualRows
|
||||
{
|
||||
#region Private Variables
|
||||
|
||||
private GridContainer _Container;
|
||||
|
||||
private const int MaxRows = 50;
|
||||
private const int MaxBuckets = 100;
|
||||
|
||||
private int _BucketHead;
|
||||
private VPageBucket _LastAccessedBucket;
|
||||
private VPageBucket[] _PageBuckets;
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
/// GridVirtualRowList
|
||||
///</summary>
|
||||
///<param name="container"></param>
|
||||
public GridVirtualRows(GridContainer container)
|
||||
{
|
||||
_Container = container;
|
||||
|
||||
_PageBuckets = new VPageBucket[MaxBuckets];
|
||||
_PageBuckets[0] = new VPageBucket(_Container, 0);
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region MaxRowIndex
|
||||
|
||||
///<summary>
|
||||
/// MaxRowIndex
|
||||
///</summary>
|
||||
///<exception cref="Exception"></exception>
|
||||
public int MaxRowIndex
|
||||
{
|
||||
get { return (GetMaxRowIndex()); }
|
||||
set { TruncateRowIndex(value); }
|
||||
}
|
||||
|
||||
#region TruncateRowIndex
|
||||
|
||||
private void TruncateRowIndex(int index)
|
||||
{
|
||||
_LastAccessedBucket = null;
|
||||
|
||||
for (int i = 0; i < MaxBuckets; i++)
|
||||
{
|
||||
int n = (_BucketHead + i) % MaxBuckets;
|
||||
|
||||
if (_PageBuckets[n] != null)
|
||||
{
|
||||
if (_PageBuckets[n].StartIndex >= index)
|
||||
_PageBuckets[n] = null;
|
||||
|
||||
else if (_PageBuckets[n].EndIndex > index)
|
||||
{
|
||||
for (int j = 0; j < MaxRows; j++)
|
||||
{
|
||||
if (_PageBuckets[n].StartIndex + j > index)
|
||||
_PageBuckets[n].Rows[j] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetMaxRowIndex
|
||||
|
||||
private int GetMaxRowIndex()
|
||||
{
|
||||
int maxIndex = 0;
|
||||
|
||||
for (int i = 0; i < MaxBuckets; i++)
|
||||
{
|
||||
int n = (_BucketHead + i) % MaxBuckets;
|
||||
|
||||
VPageBucket bucket = _PageBuckets[n];
|
||||
|
||||
if (bucket != null)
|
||||
{
|
||||
int index = bucket.StartIndex;
|
||||
|
||||
if (index >= maxIndex)
|
||||
{
|
||||
foreach (GridRow row in bucket.Rows)
|
||||
{
|
||||
if (row != null)
|
||||
{
|
||||
if (row.GridIndex > maxIndex)
|
||||
maxIndex = row.GridIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (maxIndex);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Row Indexer
|
||||
|
||||
///<summary>
|
||||
/// Row indexer
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
public GridRow this[int index]
|
||||
{
|
||||
get { return (GetRow(index)); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region FindBucket
|
||||
|
||||
private VPageBucket FindBucket(int index)
|
||||
{
|
||||
if (_LastAccessedBucket != null)
|
||||
{
|
||||
if (_LastAccessedBucket.Contains(index))
|
||||
return (_LastAccessedBucket);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MaxBuckets; i++)
|
||||
{
|
||||
int n = (_BucketHead + i) % MaxBuckets;
|
||||
|
||||
if (_PageBuckets[n] != null)
|
||||
{
|
||||
if (_PageBuckets[n].Contains(index))
|
||||
return (_PageBuckets[n]);
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FreeRow
|
||||
|
||||
///<summary>
|
||||
/// FreeRow
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
///<returns></returns>
|
||||
///<exception cref="Exception"></exception>
|
||||
public void FreeRow(int index)
|
||||
{
|
||||
VPageBucket bucket = FindBucket(index);
|
||||
|
||||
if (bucket != null)
|
||||
{
|
||||
GridRow[] rows = bucket.Rows;
|
||||
GridRow row = rows[index - bucket.StartIndex];
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
row.Dispose();
|
||||
rows[index - bucket.StartIndex] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsCachedRow
|
||||
|
||||
///<summary>
|
||||
/// Gets whether the row is currently cached
|
||||
///</summary>
|
||||
public bool IsCachedRow(int index)
|
||||
{
|
||||
if (_LastAccessedBucket != null)
|
||||
{
|
||||
if (_LastAccessedBucket.Contains(index) == true)
|
||||
return (_LastAccessedBucket.IsCached(index));
|
||||
}
|
||||
|
||||
for (int i = 0; i < MaxBuckets; i++)
|
||||
{
|
||||
int n = (_BucketHead + i) % MaxBuckets;
|
||||
|
||||
if (_PageBuckets[n] != null)
|
||||
{
|
||||
if (_PageBuckets[n].Contains(index) == true)
|
||||
return (_PageBuckets[n].IsCached(index));
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetRow
|
||||
|
||||
private GridRow GetRow(int index)
|
||||
{
|
||||
if (_LastAccessedBucket != null)
|
||||
{
|
||||
if (_LastAccessedBucket.Contains(index))
|
||||
return (_LastAccessedBucket[index]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MaxBuckets; i++)
|
||||
{
|
||||
int n = (_BucketHead + i) % MaxBuckets;
|
||||
|
||||
if (_PageBuckets[n] == null)
|
||||
return (NewBucketRow(n, index));
|
||||
|
||||
if (_PageBuckets[n].Contains(index))
|
||||
{
|
||||
_LastAccessedBucket = _PageBuckets[n];
|
||||
|
||||
return (_LastAccessedBucket[index]);
|
||||
}
|
||||
}
|
||||
|
||||
int bucket = _BucketHead;
|
||||
|
||||
GridPanel panel = _Container.GridPanel;
|
||||
|
||||
if (panel != null)
|
||||
{
|
||||
for (int i = 0; i < MaxBuckets; i++)
|
||||
{
|
||||
bucket = (_BucketHead + i) % MaxBuckets;
|
||||
|
||||
if (panel.FrozenRowCount > 0)
|
||||
{
|
||||
if (_PageBuckets[bucket].Contains(0))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (panel.ActiveRow != null)
|
||||
{
|
||||
if (_PageBuckets[bucket].Contains(panel.ActiveRow.Index))
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_BucketHead = (bucket + 1) % MaxBuckets;
|
||||
|
||||
return (NewBucketRow(bucket, index));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NewBucketRow
|
||||
|
||||
private GridRow NewBucketRow(int n, int index)
|
||||
{
|
||||
int startIndex = (index / MaxRows) * MaxRows;
|
||||
|
||||
if (_PageBuckets[n] != null)
|
||||
_PageBuckets[n].Reset(_Container, startIndex);
|
||||
else
|
||||
_PageBuckets[n] = new VPageBucket(_Container, startIndex);
|
||||
|
||||
_LastAccessedBucket = _PageBuckets[n];
|
||||
|
||||
return (_LastAccessedBucket[index]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clear
|
||||
|
||||
///<summary>
|
||||
/// Clear
|
||||
///</summary>
|
||||
public void Clear()
|
||||
{
|
||||
for (int i = 0; i < MaxBuckets; i++)
|
||||
{
|
||||
if (_PageBuckets[i] != null)
|
||||
_PageBuckets[i].Reset(null, 0);
|
||||
|
||||
_PageBuckets[i] = null;
|
||||
}
|
||||
|
||||
_BucketHead = 0;
|
||||
_LastAccessedBucket = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VPageBucket
|
||||
|
||||
private class VPageBucket
|
||||
{
|
||||
#region Static data
|
||||
|
||||
static private GridLayoutInfo _layoutInfo = new GridLayoutInfo(null, Rectangle.Empty);
|
||||
static private GridLayoutStateInfo _stateInfo = new GridLayoutStateInfo(null, 0);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private GridContainer _Container;
|
||||
private int _StartIndex;
|
||||
private int _EndIndex;
|
||||
|
||||
private GridRow[] _Rows;
|
||||
|
||||
#endregion
|
||||
|
||||
public VPageBucket(GridContainer container, int startIndex)
|
||||
{
|
||||
_Container = container;
|
||||
_StartIndex = startIndex;
|
||||
_EndIndex = startIndex + MaxRows - 1;
|
||||
|
||||
_Rows = new GridRow[MaxRows];
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region EndIndex
|
||||
|
||||
public int EndIndex
|
||||
{
|
||||
get { return (_EndIndex); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Row Indexer
|
||||
|
||||
///<summary>
|
||||
/// Row indexer
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
public GridRow this[int index]
|
||||
{
|
||||
get { return (GetRow(index)); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Rows
|
||||
|
||||
public GridRow[] Rows
|
||||
{
|
||||
get { return (_Rows); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StartIndex
|
||||
|
||||
public int StartIndex
|
||||
{
|
||||
get { return (_StartIndex); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Contains
|
||||
|
||||
public bool Contains(int index)
|
||||
{
|
||||
return (index >= _StartIndex && index <= _EndIndex);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsCached
|
||||
|
||||
public bool IsCached(int index)
|
||||
{
|
||||
if (Contains(index) == true)
|
||||
return (_Rows[index - _StartIndex] != null);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetRow
|
||||
|
||||
private GridRow GetRow(int index)
|
||||
{
|
||||
int n = index - _StartIndex;
|
||||
|
||||
if (_Rows[n] == null)
|
||||
_Rows[n] = AllocNewGridRow(index);
|
||||
|
||||
GridRow row = _Rows[n];
|
||||
|
||||
if (row.ArrangeLayoutCount != row.SuperGrid.ArrangeLayoutCount)
|
||||
ArrangeRow(row.GridPanel, row);
|
||||
|
||||
return (row);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Reset
|
||||
|
||||
public void Reset(GridContainer container, int startIndex)
|
||||
{
|
||||
for (int i = 0; i < MaxRows; i++)
|
||||
{
|
||||
GridRow row = _Rows[i];
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
row.Dispose();
|
||||
|
||||
_Rows[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
_Container = container;
|
||||
_StartIndex = startIndex;
|
||||
_EndIndex = startIndex + MaxRows - 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AllocNewGridRow
|
||||
|
||||
private GridRow AllocNewGridRow(int index)
|
||||
{
|
||||
GridPanel panel = _Container.GridPanel;
|
||||
|
||||
if (panel != null)
|
||||
{
|
||||
GridRow row = new GridRow();
|
||||
|
||||
row.Parent = _Container;
|
||||
|
||||
row.GridIndex = index;
|
||||
row.Index = index;
|
||||
row.RowIndex = index;
|
||||
row.FullIndex = index;
|
||||
|
||||
row.MergeUpdateCount = _Container.MergeUpdateCount;
|
||||
row.MergeUpdateCount--;
|
||||
|
||||
row.Loading = true;
|
||||
|
||||
try
|
||||
{
|
||||
GridColumnCollection columns = panel.Columns;
|
||||
|
||||
if (columns.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < columns.Count; i++)
|
||||
{
|
||||
GridColumn col = panel.Columns[i];
|
||||
|
||||
GridCell cell = new GridCell(col.DefaultNewRowCellValue);
|
||||
|
||||
cell.Parent = row;
|
||||
cell.ColumnIndex = i;
|
||||
|
||||
row.Cells.Add(cell);
|
||||
}
|
||||
}
|
||||
|
||||
ArrangeRow(panel, row);
|
||||
|
||||
if (columns.Count > 0)
|
||||
{
|
||||
_Container.SuperGrid.DoLoadVirtualRowEvent(panel, row);
|
||||
_Container.SuperGrid.DoVirtualRowLoadedEvent(panel, row);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
row.Loading = false;
|
||||
}
|
||||
|
||||
return (row);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#region ArrangeRow
|
||||
|
||||
private void ArrangeRow(GridPanel panel, GridRow row)
|
||||
{
|
||||
Rectangle r = panel.BoundsRelative;
|
||||
|
||||
int vrh = Dpi.Height(panel.VirtualRowHeight);
|
||||
|
||||
r.Y += (panel.FixedRowHeight - (panel.FrozenRowCount * vrh));
|
||||
r.Y += (row.Index * vrh);
|
||||
|
||||
r.Size = new Size(panel.ColumnHeader.Size.Width, vrh);
|
||||
|
||||
_layoutInfo.ClientBounds = r;
|
||||
_stateInfo.GridPanel = panel;
|
||||
|
||||
row.FixedRowHeight = r.Size.Height;
|
||||
row.Arrange(_layoutInfo, _stateInfo, r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
internal class NativeFunctions
|
||||
{
|
||||
#region Licensing
|
||||
#if !TRIAL
|
||||
internal static bool keyValidated = false;
|
||||
internal static int keyValidated2 = 0;
|
||||
internal static bool ValidateLicenseKey(string key)
|
||||
{
|
||||
bool ret = false;
|
||||
string[] parts = key.Split('-');
|
||||
int i = 10;
|
||||
foreach (string s in parts)
|
||||
{
|
||||
if (s == "88405280")
|
||||
i++;
|
||||
else if (s == "D06E")
|
||||
i += 10;
|
||||
else if (s == "4617")
|
||||
i += 8;
|
||||
else if (s == "8810")
|
||||
i += 12;
|
||||
else if (s == "64462F60FA93")
|
||||
i += 3;
|
||||
}
|
||||
if (i == 29)
|
||||
return true;
|
||||
keyValidated = true;
|
||||
return ret;
|
||||
}
|
||||
internal static bool CheckLicenseKey(string key)
|
||||
{
|
||||
// F962CEC7-CD8F-4911-A9E9-CAB39962FC1F, 189, 266
|
||||
string[] parts = key.Split('-');
|
||||
int test = 0;
|
||||
for (int i = parts.Length - 1; i >= 0; i--)
|
||||
{
|
||||
if (parts[i] == "A9E9")
|
||||
test += 11;
|
||||
else if (parts[i] == "F962CEC7")
|
||||
test += 12;
|
||||
else if (parts[i] == "CAB39962FC1F")
|
||||
test += 2;
|
||||
else if (parts[i] == "4911")
|
||||
test += 99;
|
||||
else if (parts[i] == "CD8F")
|
||||
test += 65;
|
||||
}
|
||||
|
||||
keyValidated2 = test + 77;
|
||||
|
||||
if (test == 23)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#if TRIAL
|
||||
private static Color m_ColorExpFlag=Color.Empty;
|
||||
internal static bool CheckedThrough = false;
|
||||
internal static bool ColorExpAlt()
|
||||
{
|
||||
#if NOTIMELIMIT
|
||||
return false;
|
||||
#else
|
||||
Color clr=SystemColors.Control;
|
||||
Color clr2;
|
||||
Color clr3;
|
||||
clr2=clr;
|
||||
if(clr2.ToArgb()==clr.ToArgb())
|
||||
{
|
||||
clr3=clr2;
|
||||
}
|
||||
else
|
||||
{
|
||||
clr3=clr;
|
||||
}
|
||||
|
||||
if(!m_ColorExpFlag.IsEmpty)
|
||||
{
|
||||
return (m_ColorExpFlag==Color.Black?false:true);
|
||||
}
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.RegistryKey key=Microsoft.Win32.Registry.ClassesRoot;
|
||||
try
|
||||
{
|
||||
key = key.CreateSubKey("CLSID\\{AC49A37B-FD89-4763-AB1B-C6DF6709657F}\\InprocServer32");
|
||||
}
|
||||
catch (System.UnauthorizedAccessException)
|
||||
{
|
||||
key = key.OpenSubKey("CLSID\\{AC49A37B-FD89-4763-AB1B-C6DF6709657F}\\InprocServer32");
|
||||
}
|
||||
try
|
||||
{
|
||||
if(key.GetValue("")==null || key.GetValue("").ToString()=="")
|
||||
{
|
||||
key.SetValue("",DateTime.Today.ToOADate().ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(key.GetValue("").ToString()=="windows3.dll")
|
||||
{
|
||||
m_ColorExpFlag=Color.White;
|
||||
key.Close();
|
||||
key=null;
|
||||
return true;
|
||||
}
|
||||
DateTime date=DateTime.FromOADate(double.Parse(key.GetValue("").ToString()));
|
||||
if(((TimeSpan)DateTime.Today.Subtract(date)).TotalDays>28)
|
||||
{
|
||||
m_ColorExpFlag=Color.White;
|
||||
key.SetValue("","windows4.dll");
|
||||
key.Close();
|
||||
key=null;
|
||||
return true;
|
||||
}
|
||||
if(((TimeSpan)DateTime.Today.Subtract(date)).TotalDays<0)
|
||||
{
|
||||
m_ColorExpFlag=Color.White;
|
||||
key.SetValue("","windows3.dll");
|
||||
key.Close();
|
||||
key=null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(key!=null)
|
||||
key.Close();
|
||||
CheckedThrough = true;
|
||||
}
|
||||
}
|
||||
catch{}
|
||||
m_ColorExpFlag=Color.Black;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+1230
File diff suppressed because it is too large
Load Diff
+476
@@ -0,0 +1,476 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.SuperGrid.Style;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid.Primitives
|
||||
{
|
||||
[TypeConverter(typeof(SymbolDefConvertor))]
|
||||
[Editor(typeof(SymbolDefEditor), typeof(UITypeEditor))]
|
||||
public class SymbolDef : INotifyPropertyChanged, IDisposable
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private string _Symbol = "";
|
||||
private string _SymbolRealized;
|
||||
|
||||
private float _SymbolSize;
|
||||
private Color _SymbolColor = Color.Empty;
|
||||
private eSymbolSet _SymbolSet = eSymbolSet.Awesome;
|
||||
|
||||
private Font _SymbolFont;
|
||||
private Size _RealSymbolSize;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Symbol
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the displayed Symbol. Symbol setting takes precedence over Image setting.
|
||||
/// </summary>
|
||||
[DefaultValue(""), Category("Appearance"), Description("displayed Symbol. Symbol setting takes precedence over Image setting.")]
|
||||
[Editor("DevComponents.DotNetBar.Design.SymbolTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
|
||||
public string Symbol
|
||||
{
|
||||
get { return (_Symbol); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
value = "";
|
||||
|
||||
if (value != _Symbol)
|
||||
{
|
||||
_Symbol = value;
|
||||
_SymbolRealized = null;
|
||||
|
||||
OnPropertyChangedEx("Symbol");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the Symbol.
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates color of the Symbol.")]
|
||||
public Color SymbolColor
|
||||
{
|
||||
get { return (_SymbolColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_SymbolColor != value)
|
||||
{
|
||||
_SymbolColor = value;
|
||||
|
||||
OnPropertyChangedEx("SymbolColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeSymbolColor()
|
||||
{
|
||||
return (_SymbolColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetSymbolColor()
|
||||
{
|
||||
SymbolColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolRealized
|
||||
|
||||
/// <summary>
|
||||
/// Gets the realized symbol string.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string SymbolRealized
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SymbolRealized == null)
|
||||
{
|
||||
if (_Symbol != null)
|
||||
_SymbolRealized = Symbols.GetSymbol(_Symbol);
|
||||
}
|
||||
|
||||
return (_SymbolRealized);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolSet
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the symbol set used to represent the Symbol.
|
||||
/// </summary>
|
||||
[DefaultValue(eSymbolSet.Awesome)]
|
||||
public eSymbolSet SymbolSet
|
||||
{
|
||||
get { return (_SymbolSet); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_SymbolSet != value)
|
||||
{
|
||||
_SymbolSet = value;
|
||||
|
||||
_SymbolRealized = null;
|
||||
_SymbolFont = null;
|
||||
_RealSymbolSize = Size.Empty;
|
||||
|
||||
OnPropertyChangedEx("SymbolSet");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolSize
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the size of the symbol in points.
|
||||
/// </summary>
|
||||
[DefaultValue(0f), Category("Appearance")]
|
||||
[Description("Indicates the size of the symbol in points.")]
|
||||
public float SymbolSize
|
||||
{
|
||||
get { return (_SymbolSize); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _SymbolSize)
|
||||
{
|
||||
_SymbolSize = value;
|
||||
_SymbolFont = null;
|
||||
_RealSymbolSize = Size.Empty;
|
||||
|
||||
OnPropertyChangedEx("SymbolSize");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether SymbolDef is Empty.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((string.IsNullOrEmpty(_Symbol) == true) &&
|
||||
(_SymbolColor.IsEmpty == true) &&
|
||||
(_SymbolSize == 0f));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region SymbolFont
|
||||
|
||||
internal Font SymbolFont
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SymbolFont == null)
|
||||
_SymbolFont = Symbols.GetFont(SymbolSize, SymbolSet);
|
||||
|
||||
return (_SymbolFont);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_SymbolFont = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsValidSymbol
|
||||
|
||||
internal bool IsValidSymbol
|
||||
{
|
||||
get { return (string.IsNullOrEmpty(SymbolRealized) == false); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSymbolSize
|
||||
|
||||
internal Size GetSymbolSize(Control control)
|
||||
{
|
||||
if (_RealSymbolSize == Size.Empty)
|
||||
{
|
||||
if (control != null)
|
||||
{
|
||||
Font font = SymbolFont;
|
||||
|
||||
using (Graphics g = control.CreateGraphics())
|
||||
{
|
||||
Size size = g.MeasureString(SymbolRealized, font).ToSize();
|
||||
|
||||
size.Width++;
|
||||
size.Height++;
|
||||
|
||||
_RealSymbolSize = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (_RealSymbolSize);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the SymbolDef.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the SymbolDef.</returns>
|
||||
public SymbolDef Copy()
|
||||
{
|
||||
SymbolDef style = new SymbolDef();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(SymbolDef style)
|
||||
{
|
||||
style.Symbol = _Symbol;
|
||||
|
||||
style.SymbolColor = _SymbolColor;
|
||||
style.SymbolSet = _SymbolSet;
|
||||
style.SymbolSize = _SymbolSize;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(VisualPropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="s">Event arguments</param>
|
||||
protected virtual void OnPropertyChangedEx(string s)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
{
|
||||
VisualPropertyChangedEventArgs e =
|
||||
new VisualPropertyChangedEventArgs(s);
|
||||
|
||||
eh(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="s">Event arguments</param>
|
||||
protected virtual void OnPropertyChangedEx(string s, VisualChangeType changeType)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
{
|
||||
VisualPropertyChangedEventArgs e =
|
||||
new VisualPropertyChangedEventArgs(s, changeType);
|
||||
|
||||
eh(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateChangeHandler
|
||||
|
||||
private void UpdateChangeHandler(
|
||||
INotifyPropertyChanged oldValue, INotifyPropertyChanged newValue)
|
||||
{
|
||||
if (oldValue != null)
|
||||
oldValue.PropertyChanged -= StyleChanged;
|
||||
|
||||
if (newValue != null)
|
||||
newValue.PropertyChanged += StyleChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleChanged
|
||||
|
||||
/// <summary>
|
||||
/// StyleChanged
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected virtual void StyleChanged(
|
||||
object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged((VisualPropertyChangedEventArgs)e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
SymbolFont = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region SymbolDefConvertor
|
||||
|
||||
///<summary>
|
||||
/// SymbolDefConvertor
|
||||
///</summary>
|
||||
public class SymbolDefConvertor : ExpandableObjectConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// ConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
SymbolDef sd = value as SymbolDef;
|
||||
|
||||
if (sd != null)
|
||||
return (sd.SymbolSet.ToString());
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolDefEditor
|
||||
|
||||
///<summary>
|
||||
/// SymbolDefEditor
|
||||
///</summary>
|
||||
public class SymbolDefEditor : UITypeEditor
|
||||
{
|
||||
#region GetPaintValueSupported
|
||||
|
||||
/// <summary>
|
||||
/// GetPaintValueSupported
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PaintValue
|
||||
|
||||
/// <summary>
|
||||
/// PaintValue
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public override void PaintValue(PaintValueEventArgs e)
|
||||
{
|
||||
SymbolDef sd = e.Value as SymbolDef;
|
||||
|
||||
if (sd != null)
|
||||
{
|
||||
Font font = Symbols.GetFont(10, sd.SymbolSet);
|
||||
|
||||
Color color = sd.SymbolColor;
|
||||
|
||||
if (sd.SymbolColor.IsEmpty || sd.SymbolColor == Color.White)
|
||||
color = Color.Brown;
|
||||
|
||||
using (Brush br = new SolidBrush(color))
|
||||
{
|
||||
using (StringFormat sf = new StringFormat())
|
||||
{
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
|
||||
e.Graphics.DrawString(sd.SymbolRealized, font, br, e.Bounds, sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
+241
@@ -0,0 +1,241 @@
|
||||
using System.Collections.Generic;
|
||||
using DevComponents.DotNetBar.SuperGrid.Primitives;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// SelectedElementCollection
|
||||
///</summary>
|
||||
public class SelectedElementCollection : CustomCollection<GridElement>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
///<summary>
|
||||
/// SelectedElementCollection
|
||||
///</summary>
|
||||
public SelectedElementCollection()
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// SelectedElementCollection
|
||||
///</summary>
|
||||
///<param name="capacity"></param>
|
||||
public SelectedElementCollection(int capacity)
|
||||
: base(capacity)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetCells
|
||||
|
||||
#region GetCells
|
||||
|
||||
///<summary>
|
||||
/// GetCells
|
||||
///</summary>
|
||||
///<returns></returns>
|
||||
public List<GridCell> GetCells()
|
||||
{
|
||||
List<GridCell> cells = new List<GridCell>();
|
||||
|
||||
bool hasRows = AddRowCells(cells);
|
||||
bool hasColumns = AddColumnCells(cells, hasRows);
|
||||
|
||||
AddCellCells(cells, hasRows | hasColumns);
|
||||
|
||||
return (cells);
|
||||
}
|
||||
|
||||
#region AddRowCells
|
||||
|
||||
private bool AddRowCells(List<GridCell> cells)
|
||||
{
|
||||
bool hasRows = false;
|
||||
|
||||
foreach (GridElement item in Items)
|
||||
{
|
||||
GridRow row = item as GridRow;
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
GridPanel panel = row.GridPanel;
|
||||
|
||||
for (int i = 0; i < panel.Columns.Count; i++)
|
||||
{
|
||||
GridCell cell =
|
||||
row.GetCell(i, panel.AllowEmptyCellSelection);
|
||||
|
||||
if (cell != null)
|
||||
{
|
||||
if (cell.AllowSelection == true)
|
||||
cells.Add(cell);
|
||||
}
|
||||
}
|
||||
|
||||
hasRows = true;
|
||||
}
|
||||
}
|
||||
|
||||
return (hasRows);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AddColumnCells
|
||||
|
||||
private bool AddColumnCells(List<GridCell> cells, bool hasRows)
|
||||
{
|
||||
bool hasColumns = false;
|
||||
|
||||
foreach (GridElement item in Items)
|
||||
{
|
||||
GridColumn column = item as GridColumn;
|
||||
|
||||
if (column != null)
|
||||
{
|
||||
GridContainer container =
|
||||
column.Parent as GridContainer;
|
||||
|
||||
if (container != null)
|
||||
{
|
||||
hasColumns = true;
|
||||
|
||||
AddUniqueColumnCells(container,
|
||||
cells, column.ColumnIndex, hasRows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (hasColumns);
|
||||
}
|
||||
|
||||
#region AddUniqueColumnCells
|
||||
|
||||
private void AddUniqueColumnCells(GridContainer container,
|
||||
ICollection<GridCell> cells, int columnIndex, bool hasRows)
|
||||
{
|
||||
if (container != null)
|
||||
{
|
||||
GridPanel panel = container.GridPanel;
|
||||
|
||||
if (panel != null)
|
||||
{
|
||||
if (panel.VirtualMode == true)
|
||||
{
|
||||
for (int i = 0; i < panel.VirtualRowCountEx; i++)
|
||||
{
|
||||
GridRow row = panel.VirtualRows[i];
|
||||
|
||||
if (hasRows == false || row.IsSelected == false)
|
||||
{
|
||||
if (row.Cells[columnIndex].AllowSelection == true)
|
||||
cells.Add(row.Cells[columnIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (GridContainer item in container.Rows)
|
||||
{
|
||||
GridRow row = item as GridRow;
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
if (hasRows == false || row.IsSelected == false)
|
||||
{
|
||||
GridCell cell = row.GetCell(columnIndex,
|
||||
panel.AllowEmptyCellSelection);
|
||||
|
||||
if (cell != null)
|
||||
{
|
||||
if (cell.AllowSelection == true)
|
||||
cells.Add(cell);
|
||||
}
|
||||
}
|
||||
|
||||
if (row.Rows.Count > 0 && row.Expanded == true)
|
||||
AddUniqueColumnCells(item, cells, columnIndex, hasRows);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region AddCellCells
|
||||
|
||||
private void AddCellCells(List<GridCell> cells, bool hasRowCol)
|
||||
{
|
||||
foreach (GridElement item in Items)
|
||||
{
|
||||
GridCell cell = item as GridCell;
|
||||
|
||||
if (cell != null)
|
||||
{
|
||||
if (cell.AllowSelection == true)
|
||||
{
|
||||
if (hasRowCol == true)
|
||||
AddUniqueCells(cells, cell);
|
||||
else
|
||||
cells.Add(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region AddUniqueCells
|
||||
|
||||
private void AddUniqueCells(
|
||||
ICollection<GridCell> cells, GridCell cell)
|
||||
{
|
||||
GridPanel panel = cell.GridColumn.Parent as GridPanel;
|
||||
|
||||
if (panel != null)
|
||||
{
|
||||
if (cell.GridRow.IsSelected == false)
|
||||
{
|
||||
if (cell.GridColumn.IsSelected == false)
|
||||
cells.Add(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Select
|
||||
|
||||
///<summary>
|
||||
///</summary>
|
||||
public void Select(bool value)
|
||||
{
|
||||
foreach (GridElement item in Items)
|
||||
{
|
||||
if (item is GridPanel)
|
||||
((GridPanel)item).IsSelected = value;
|
||||
|
||||
else if (item is GridRow)
|
||||
((GridRow)item).IsSelected = value;
|
||||
|
||||
else if (item is GridColumn)
|
||||
((GridColumn)item).IsSelected = value;
|
||||
|
||||
else if (item is GridCell)
|
||||
((GridCell)item).IsSelected = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+735
@@ -0,0 +1,735 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// SelectedElements
|
||||
///</summary>
|
||||
public class SelectedElements
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private List<SelectedRange> _Ranges;
|
||||
private SelectedElementType _ElementType;
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
/// SelectedElements
|
||||
///</summary>
|
||||
public SelectedElements()
|
||||
{
|
||||
_Ranges = new List<SelectedRange>();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// SelectedElements
|
||||
///</summary>
|
||||
public SelectedElements(SelectedElementType elementType)
|
||||
: this()
|
||||
{
|
||||
ElementType = elementType;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Count
|
||||
|
||||
///<summary>
|
||||
/// Count
|
||||
///</summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
if (_Ranges != null)
|
||||
{
|
||||
foreach (SelectedRange range in _Ranges)
|
||||
count += range.Count;
|
||||
}
|
||||
|
||||
return (count);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ElementType
|
||||
|
||||
/// <summary>
|
||||
/// Element Type
|
||||
/// </summary>
|
||||
public SelectedElementType ElementType
|
||||
{
|
||||
get { return (_ElementType); }
|
||||
set { _ElementType = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FirstIndex
|
||||
|
||||
///<summary>
|
||||
/// FirstIndex
|
||||
///</summary>
|
||||
public int FirstIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Ranges.Count > 0)
|
||||
return (_Ranges[0].StartIndex);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LastIndex
|
||||
|
||||
///<summary>
|
||||
/// LastIndex
|
||||
///</summary>
|
||||
public int LastIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Ranges.Count > 0)
|
||||
return (_Ranges[_Ranges.Count - 1].EndIndex);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Ranges
|
||||
|
||||
///<summary>
|
||||
/// Items
|
||||
///</summary>
|
||||
public List<SelectedRange> Ranges
|
||||
{
|
||||
get { return (_Ranges); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region FindRange
|
||||
|
||||
///<summary>
|
||||
/// FindRange
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
///<param name="selRange"></param>
|
||||
///<returns></returns>
|
||||
public bool FindRange(int index, out SelectedRange selRange)
|
||||
{
|
||||
foreach (SelectedRange range in _Ranges)
|
||||
{
|
||||
if (range.Contains(index) == true)
|
||||
{
|
||||
selRange = range;
|
||||
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
selRange = null;
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AddItem
|
||||
|
||||
///<summary>
|
||||
/// AddItem
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
///<returns></returns>
|
||||
public void AddItem(int index)
|
||||
{
|
||||
for (int i = 0; i < _Ranges.Count; i++)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (index <= range.EndIndex + 1)
|
||||
{
|
||||
AddItem(range, i, index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_Ranges.Add(new SelectedRange(index, index));
|
||||
|
||||
ValidateRanges();
|
||||
}
|
||||
|
||||
private void AddItem(SelectedRange range, int i, int index)
|
||||
{
|
||||
if (range.StartIndex - 1 == index)
|
||||
{
|
||||
range.StartIndex--;
|
||||
}
|
||||
else if (range.EndIndex + 1 == index)
|
||||
{
|
||||
range.EndIndex++;
|
||||
|
||||
if (i + 1 < _Ranges.Count)
|
||||
{
|
||||
if (_Ranges[i + 1].StartIndex == index + 1)
|
||||
{
|
||||
_Ranges[i].EndIndex = _Ranges[i + 1].EndIndex;
|
||||
_Ranges.RemoveAt(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (range.Contains(index) == false)
|
||||
{
|
||||
SelectedRange selRange = new SelectedRange(index, index);
|
||||
|
||||
_Ranges.Insert(i, selRange);
|
||||
}
|
||||
|
||||
ValidateRanges();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AddRange
|
||||
|
||||
///<summary>
|
||||
///</summary>
|
||||
///<param name="startIndex"></param>
|
||||
///<param name="endIndex"></param>
|
||||
public void AddRange(int startIndex, int endIndex)
|
||||
{
|
||||
for (int i = 0; i < _Ranges.Count; i++)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (endIndex == range.StartIndex - 1)
|
||||
{
|
||||
range.StartIndex = startIndex;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
if (_Ranges[i - 1].EndIndex + 1 == startIndex)
|
||||
{
|
||||
_Ranges[i - 1].EndIndex = range.EndIndex;
|
||||
_Ranges.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
CoalesceRanges();
|
||||
ValidateRanges();
|
||||
return;
|
||||
}
|
||||
|
||||
if (startIndex == range.EndIndex + 1)
|
||||
{
|
||||
range.EndIndex = endIndex;
|
||||
|
||||
if (i + 1 < _Ranges.Count)
|
||||
{
|
||||
if (_Ranges[i + 1].StartIndex - 1 == endIndex)
|
||||
{
|
||||
range.EndIndex = _Ranges[i + 1].EndIndex;
|
||||
_Ranges.RemoveAt(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
CoalesceRanges();
|
||||
ValidateRanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SelectedRange selRange = null;
|
||||
|
||||
for (int i = 0; i < _Ranges.Count; i++)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (range.StartIndex > startIndex)
|
||||
{
|
||||
selRange = new SelectedRange(startIndex, endIndex);
|
||||
_Ranges.Insert(i, selRange);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (selRange == null)
|
||||
{
|
||||
selRange = new SelectedRange(startIndex, endIndex);
|
||||
_Ranges.Add(selRange);
|
||||
}
|
||||
|
||||
CoalesceRanges();
|
||||
}
|
||||
|
||||
#region CoalesceRanges
|
||||
|
||||
private void CoalesceRanges()
|
||||
{
|
||||
SelectedRange xRange = _Ranges[0];
|
||||
|
||||
for (int i = 1; i < _Ranges.Count; i++)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (range.StartIndex - 1 <= xRange.EndIndex)
|
||||
{
|
||||
if (range.EndIndex > xRange.EndIndex)
|
||||
xRange.EndIndex = range.EndIndex;
|
||||
|
||||
if (range.StartIndex < xRange.StartIndex)
|
||||
xRange.StartIndex = range.StartIndex;
|
||||
|
||||
range.StartIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
xRange = range;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = _Ranges.Count - 1; i > 0; i--)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (range.StartIndex == -1)
|
||||
_Ranges.RemoveAt(i);
|
||||
}
|
||||
|
||||
ValidateRanges();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RemoveItem
|
||||
|
||||
///<summary>
|
||||
/// RemoveItem
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
public void RemoveItem(int index)
|
||||
{
|
||||
SelectedRange selRange;
|
||||
|
||||
if (FindRange(index, out selRange) == true)
|
||||
RemoveItem(index, selRange);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// RemoveItem
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
///<param name="range"></param>
|
||||
///<returns></returns>
|
||||
public void RemoveItem(int index, SelectedRange range)
|
||||
{
|
||||
if (range.StartIndex == index)
|
||||
{
|
||||
range.StartIndex++;
|
||||
|
||||
if (range.StartIndex > range.EndIndex)
|
||||
_Ranges.Remove(range);
|
||||
}
|
||||
else if (range.EndIndex == index)
|
||||
{
|
||||
range.EndIndex--;
|
||||
|
||||
if (range.StartIndex > range.EndIndex)
|
||||
_Ranges.Remove(range);
|
||||
}
|
||||
else if (range.Contains(index) == true)
|
||||
{
|
||||
int i = _Ranges.IndexOf(range);
|
||||
int endIndex = range.EndIndex;
|
||||
|
||||
range.EndIndex = index - 1;
|
||||
|
||||
_Ranges.Insert(i + 1,
|
||||
new SelectedRange(index + 1, endIndex));
|
||||
}
|
||||
|
||||
ValidateRanges();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RemoveRange
|
||||
|
||||
///<summary>
|
||||
///</summary>
|
||||
///<param name="startIndex"></param>
|
||||
///<param name="endIndex"></param>
|
||||
public bool RemoveRange(int startIndex, int endIndex)
|
||||
{
|
||||
bool itemsRemoved = false;
|
||||
|
||||
for (int i = 0; i < _Ranges.Count; i++)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (range.EndIndex < startIndex)
|
||||
continue;
|
||||
|
||||
if (range.StartIndex > endIndex)
|
||||
break;
|
||||
|
||||
if (range.EndIndex >= startIndex && range.EndIndex <= endIndex)
|
||||
{
|
||||
if (range.StartIndex < startIndex)
|
||||
range.EndIndex = startIndex - 1;
|
||||
else
|
||||
range.StartIndex = -1;
|
||||
|
||||
itemsRemoved = true;
|
||||
}
|
||||
else if (range.StartIndex >= startIndex && range.StartIndex <= endIndex)
|
||||
{
|
||||
if (range.EndIndex > endIndex)
|
||||
range.StartIndex = endIndex + 1;
|
||||
else
|
||||
range.StartIndex = -1;
|
||||
|
||||
itemsRemoved = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = range.EndIndex;
|
||||
range.EndIndex = startIndex - 1;
|
||||
|
||||
_Ranges.Insert(i + 1,
|
||||
new SelectedRange(endIndex + 1, index));
|
||||
|
||||
itemsRemoved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = _Ranges.Count - 1; i >= 0; i--)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (range.StartIndex == -1)
|
||||
_Ranges.RemoveAt(i);
|
||||
}
|
||||
|
||||
ValidateRanges();
|
||||
|
||||
return (itemsRemoved);
|
||||
}
|
||||
|
||||
private void ValidateRanges()
|
||||
{
|
||||
int n = -2;
|
||||
|
||||
for (int i = 0; i < _Ranges.Count; i++)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (range.StartIndex - 1 <= n)
|
||||
throw new Exception("Invalid Range StartIndex!");
|
||||
|
||||
if (range.StartIndex > range.EndIndex)
|
||||
throw new Exception("Invalid Range EndIndex!");
|
||||
|
||||
n = range.EndIndex;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clear
|
||||
|
||||
///<summary>
|
||||
/// Clear
|
||||
///</summary>
|
||||
public void Clear()
|
||||
{
|
||||
_Ranges.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OffsetIndices
|
||||
|
||||
///<summary>
|
||||
/// OffsetIndices
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
///<param name="count"></param>
|
||||
public void OffsetIndices(int index, int count)
|
||||
{
|
||||
for (int i=0; i<_Ranges.Count; i++)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (range.EndIndex >= index)
|
||||
{
|
||||
if (range.StartIndex < index)
|
||||
{
|
||||
SelectedRange range2 = new SelectedRange(index, range.EndIndex);
|
||||
|
||||
range.EndIndex = index - 1;
|
||||
|
||||
_Ranges.Insert(++i, range2);
|
||||
}
|
||||
|
||||
OffsetRanges(i, count);
|
||||
CoalesceRanges();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ValidateRanges();
|
||||
}
|
||||
|
||||
private void OffsetRanges(int n, int count)
|
||||
{
|
||||
for (int i = n; i < _Ranges.Count; i++)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
range.StartIndex += count;
|
||||
range.EndIndex += count;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetNextIndex
|
||||
|
||||
///<summary>
|
||||
/// GetNextIndex
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
///<returns></returns>
|
||||
public bool GetNextIndex(ref int index)
|
||||
{
|
||||
if (Count > 0)
|
||||
{
|
||||
if (index < LastIndex)
|
||||
{
|
||||
index = (index < 0)
|
||||
? FirstIndex : NextIndex(index);
|
||||
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#region NextIndex
|
||||
|
||||
private int NextIndex(int index)
|
||||
{
|
||||
index++;
|
||||
|
||||
foreach (SelectedRange range in _Ranges)
|
||||
{
|
||||
if (range.StartIndex >= index)
|
||||
return (range.StartIndex);
|
||||
|
||||
if (range.EndIndex >= index)
|
||||
return (index);
|
||||
}
|
||||
|
||||
return (LastIndex);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPrevIndex
|
||||
|
||||
///<summary>
|
||||
/// GetPreviousIndex
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
///<returns></returns>
|
||||
public bool GetPrevIndex(ref int index)
|
||||
{
|
||||
if (Count > 0)
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
index = (index > LastIndex)
|
||||
? LastIndex : PrevIndex(index);
|
||||
|
||||
return (index >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#region PrevIndex
|
||||
|
||||
private int PrevIndex(int index)
|
||||
{
|
||||
index--;
|
||||
|
||||
for (int i=_Ranges.Count - 1; i >= 0; --i)
|
||||
{
|
||||
SelectedRange range = _Ranges[i];
|
||||
|
||||
if (range.EndIndex <= index)
|
||||
return (range.EndIndex);
|
||||
|
||||
if (range.StartIndex <= index)
|
||||
return (index);
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Copy
|
||||
|
||||
internal SelectedElements Copy()
|
||||
{
|
||||
SelectedElements copy = new SelectedElements(_ElementType);
|
||||
|
||||
foreach (SelectedRange range in _Ranges)
|
||||
copy.AddRange(range.StartIndex, range.EndIndex);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region SelectedRange class
|
||||
|
||||
///<summary>
|
||||
/// SelectedRange
|
||||
///</summary>
|
||||
public class SelectedRange
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private int _StartIndex;
|
||||
private int _EndIndex;
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
///</summary>
|
||||
///<param name="startIndex"></param>
|
||||
///<param name="endIndex"></param>
|
||||
public SelectedRange(int startIndex, int endIndex)
|
||||
{
|
||||
_StartIndex = startIndex;
|
||||
_EndIndex = endIndex;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Count
|
||||
|
||||
///<summary>
|
||||
/// Count
|
||||
///</summary>
|
||||
public int Count
|
||||
{
|
||||
get { return (_EndIndex - _StartIndex + 1); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EndIndex
|
||||
|
||||
///<summary>
|
||||
/// EndIndex
|
||||
///</summary>
|
||||
public int EndIndex
|
||||
{
|
||||
get { return (_EndIndex); }
|
||||
set { _EndIndex = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StartIndex
|
||||
|
||||
///<summary>
|
||||
/// StartIndex
|
||||
///</summary>
|
||||
public int StartIndex
|
||||
{
|
||||
get { return (_StartIndex); }
|
||||
set { _StartIndex = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Contains
|
||||
|
||||
///<summary>
|
||||
/// Contains
|
||||
///</summary>
|
||||
///<param name="index"></param>
|
||||
///<returns></returns>
|
||||
public bool Contains(int index)
|
||||
{
|
||||
return (index >= _StartIndex && index <= _EndIndex);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region enums
|
||||
|
||||
public enum SelectedElementType
|
||||
{
|
||||
/// <summary>
|
||||
/// Unknown range type
|
||||
/// </summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// Selected Cells
|
||||
/// </summary>
|
||||
SelectedCells,
|
||||
|
||||
/// <summary>
|
||||
/// Selected Columns
|
||||
/// </summary>
|
||||
SelectedColumns,
|
||||
|
||||
/// <summary>
|
||||
/// Selected Rows
|
||||
/// </summary>
|
||||
SelectedRows,
|
||||
|
||||
/// <summary>
|
||||
/// Deleted Rows
|
||||
/// </summary>
|
||||
DeletedRows,
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
+456
@@ -0,0 +1,456 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
///SortableBindingList
|
||||
///</summary>
|
||||
///<typeparam name="T"></typeparam>
|
||||
public class SortableBindingList<T> : BindingList<T>
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private bool _IsSorted;
|
||||
|
||||
private ListSortDirection _ListSortDirection;
|
||||
private PropertyDescriptor _PropertyDescriptor;
|
||||
|
||||
private readonly Dictionary<Type, PropertyComparer<T>> _Comparers;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
///<summary>
|
||||
///SortableBindingList
|
||||
///</summary>
|
||||
public SortableBindingList()
|
||||
: base(new List<T>())
|
||||
{
|
||||
_Comparers = new Dictionary<Type, PropertyComparer<T>>();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///SortableBindingList
|
||||
///</summary>
|
||||
///<param name="enumeration"></param>
|
||||
public SortableBindingList(IEnumerable<T> enumeration)
|
||||
: base(new List<T>(enumeration))
|
||||
{
|
||||
_Comparers = new Dictionary<Type, PropertyComparer<T>>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected properties
|
||||
|
||||
#region Comparers
|
||||
|
||||
/// <summary>
|
||||
/// Comparers
|
||||
/// </summary>
|
||||
protected Dictionary<Type, PropertyComparer<T>> Comparers
|
||||
{
|
||||
get { return (_Comparers); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsSorted
|
||||
|
||||
/// <summary>
|
||||
/// IsSortedCore
|
||||
/// </summary>
|
||||
protected bool IsSorted
|
||||
{
|
||||
get { return (_IsSorted); }
|
||||
set { _IsSorted = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsSortedCore
|
||||
|
||||
/// <summary>
|
||||
/// IsSortedCore
|
||||
/// </summary>
|
||||
protected override bool IsSortedCore
|
||||
{
|
||||
get { return (_IsSorted); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SortDirectionCore
|
||||
|
||||
/// <summary>
|
||||
/// SortDirectionCore
|
||||
/// </summary>
|
||||
protected override ListSortDirection SortDirectionCore
|
||||
{
|
||||
get { return (_ListSortDirection); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SortPropertyCore
|
||||
|
||||
/// <summary>
|
||||
/// SortPropertyCore
|
||||
/// </summary>
|
||||
protected override PropertyDescriptor SortPropertyCore
|
||||
{
|
||||
get { return (_PropertyDescriptor); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SupportsSearchingCore
|
||||
|
||||
/// <summary>
|
||||
/// SupportsSearchingCore
|
||||
/// </summary>
|
||||
protected override bool SupportsSearchingCore
|
||||
{
|
||||
get { return (true); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SupportsSortingCore
|
||||
|
||||
/// <summary>
|
||||
/// SupportsSortingCore
|
||||
/// </summary>
|
||||
protected override bool SupportsSortingCore
|
||||
{
|
||||
get { return (true); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplySortCore
|
||||
|
||||
/// <summary>
|
||||
/// ApplySortCore
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <param name="direction"></param>
|
||||
protected override void ApplySortCore(
|
||||
PropertyDescriptor property, ListSortDirection direction)
|
||||
{
|
||||
List<T> itemsList = (List<T>) Items;
|
||||
|
||||
Type propertyType = property.PropertyType;
|
||||
|
||||
PropertyComparer<T> comparer;
|
||||
if (_Comparers.TryGetValue(propertyType, out comparer) == false)
|
||||
{
|
||||
comparer = new PropertyComparer<T>(property, direction);
|
||||
_Comparers.Add(propertyType, comparer);
|
||||
}
|
||||
|
||||
comparer.SetPropertyAndDirection(property, direction);
|
||||
|
||||
itemsList.Sort(comparer);
|
||||
|
||||
_PropertyDescriptor = property;
|
||||
_ListSortDirection = direction;
|
||||
_IsSorted = true;
|
||||
|
||||
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RemoveSortCore
|
||||
|
||||
/// <summary>
|
||||
/// RemoveSortCore
|
||||
/// </summary>
|
||||
protected override void RemoveSortCore()
|
||||
{
|
||||
_IsSorted = false;
|
||||
_PropertyDescriptor = base.SortPropertyCore;
|
||||
_ListSortDirection = base.SortDirectionCore;
|
||||
|
||||
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FindCore
|
||||
|
||||
/// <summary>
|
||||
/// FindCore
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
protected override int FindCore(PropertyDescriptor property, object key)
|
||||
{
|
||||
int count = Count;
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
object o = property.GetValue(this[i]);
|
||||
|
||||
if (o != null && o.Equals(key))
|
||||
return (i);
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PropertyComparer
|
||||
|
||||
///<summary>
|
||||
///PropertyComparer
|
||||
///</summary>
|
||||
///<typeparam name="T"></typeparam>
|
||||
public class PropertyComparer<T> : IComparer<T>
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private ListSortDirection _SortDirection;
|
||||
private PropertyDescriptor _PropertyDescriptor;
|
||||
private IComparer _Comparer;
|
||||
|
||||
#endregion
|
||||
|
||||
///<summary>
|
||||
///PropertyComparer
|
||||
///</summary>
|
||||
///<param name="property"></param>
|
||||
///<param name="direction"></param>
|
||||
public PropertyComparer(PropertyDescriptor property, ListSortDirection direction)
|
||||
{
|
||||
_PropertyDescriptor = property;
|
||||
_SortDirection = direction;
|
||||
|
||||
Type comparerForPropertyType = typeof(Comparer<>).MakeGenericType(property.PropertyType);
|
||||
|
||||
_Comparer = (IComparer)comparerForPropertyType.InvokeMember(
|
||||
"Default", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.Public, null, null, null);
|
||||
}
|
||||
|
||||
#region IComparer<T> Members
|
||||
|
||||
/// <summary>
|
||||
/// Compare
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns></returns>
|
||||
public int Compare(T x, T y)
|
||||
{
|
||||
int result = _Comparer.Compare(_PropertyDescriptor.GetValue(x),
|
||||
_PropertyDescriptor.GetValue(y));
|
||||
|
||||
if (_SortDirection == ListSortDirection.Descending)
|
||||
return (result * -1);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetPropertyAndDirection
|
||||
|
||||
///<summary>
|
||||
///SetPropertyAndDirection
|
||||
///</summary>
|
||||
///<param name="descriptor"></param>
|
||||
///<param name="direction"></param>
|
||||
public void SetPropertyAndDirection(
|
||||
PropertyDescriptor descriptor, ListSortDirection direction)
|
||||
{
|
||||
_PropertyDescriptor = descriptor;
|
||||
_SortDirection = direction;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///MultipleSortableBindingList
|
||||
///</summary>
|
||||
///<typeparam name="T"></typeparam>
|
||||
public class MultipleSortableBindingList<T> : SortableBindingList<T>, IBindingListView
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private ListSortDescriptionCollection _SortDescriptions;
|
||||
private List<PropertyComparer<T>> _SortComparers;
|
||||
|
||||
const string FilteringNotSupported = "IBindingListView-implementation of filtering is not supported.";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
///<summary>
|
||||
///MultipleSortableBindingList
|
||||
///</summary>
|
||||
public MultipleSortableBindingList()
|
||||
: base(new List<T>())
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///MultipleSortableBindingList
|
||||
///</summary>
|
||||
///<param name="enumeration"></param>
|
||||
public MultipleSortableBindingList(IEnumerable<T> enumeration)
|
||||
: base(new List<T>(enumeration))
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Filter
|
||||
|
||||
/// <summary>
|
||||
/// IsSortedCore
|
||||
/// </summary>
|
||||
public string Filter
|
||||
{
|
||||
get { throw new NotSupportedException(FilteringNotSupported); }
|
||||
set { throw new NotSupportedException(FilteringNotSupported); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SortDescriptions
|
||||
|
||||
/// <summary>
|
||||
/// SortDescriptions
|
||||
/// </summary>
|
||||
public ListSortDescriptionCollection SortDescriptions
|
||||
{
|
||||
get { return (_SortDescriptions); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SupportsAdvancedSorting
|
||||
|
||||
/// <summary>
|
||||
/// SupportsAdvancedSorting
|
||||
/// </summary>
|
||||
public bool SupportsAdvancedSorting
|
||||
{
|
||||
get { return (true); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SupportsFiltering
|
||||
|
||||
/// <summary>
|
||||
/// SupportsFiltering
|
||||
/// </summary>
|
||||
public bool SupportsFiltering
|
||||
{
|
||||
get { return (false); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplySort
|
||||
|
||||
/// <summary>
|
||||
/// Sorts the list based on the given System.ComponentModel.ListSortDescriptionCollection.
|
||||
/// </summary>
|
||||
/// <param name="sorts">The System.ComponentModel.ListSortDescriptionCollection to sort by.</param>
|
||||
public void ApplySort(ListSortDescriptionCollection sorts)
|
||||
{
|
||||
List<T> items = Items as List<T>;
|
||||
|
||||
if (items != null)
|
||||
{
|
||||
_SortDescriptions = sorts;
|
||||
_SortComparers = new List<PropertyComparer<T>>();
|
||||
|
||||
foreach (ListSortDescription sort in sorts)
|
||||
{
|
||||
if (sort != null)
|
||||
{
|
||||
Type propertyType = sort.PropertyDescriptor.PropertyType;
|
||||
PropertyComparer<T> comparer;
|
||||
|
||||
if (Comparers.TryGetValue(propertyType, out comparer) == false)
|
||||
{
|
||||
comparer = new PropertyComparer<T>(sort.PropertyDescriptor, sort.SortDirection);
|
||||
Comparers.Add(propertyType, comparer);
|
||||
}
|
||||
|
||||
_SortComparers.Add(comparer);
|
||||
}
|
||||
}
|
||||
|
||||
items.Sort(CompareValuesByProperties);
|
||||
|
||||
IsSorted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsSorted = false;
|
||||
}
|
||||
}
|
||||
|
||||
#region CompareValuesByProperties
|
||||
|
||||
private int CompareValuesByProperties(T x, T y)
|
||||
{
|
||||
if (x == null)
|
||||
return ((y == null) ? 0 : -1);
|
||||
|
||||
if (y == null)
|
||||
return (1);
|
||||
|
||||
for (int i = 0; i < _SortComparers.Count; i++)
|
||||
{
|
||||
PropertyComparer<T> comparer = _SortComparers[i];
|
||||
ListSortDescription sort = _SortDescriptions[i];
|
||||
|
||||
comparer.SetPropertyAndDirection(sort.PropertyDescriptor, sort.SortDirection);
|
||||
|
||||
int retval = comparer.Compare(x, y);
|
||||
|
||||
if (retval != 0)
|
||||
return (retval);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RemoveFilter
|
||||
|
||||
public void RemoveFilter()
|
||||
{
|
||||
throw new NotSupportedException(FilteringNotSupported);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid.Style
|
||||
{
|
||||
///<summary>
|
||||
/// BackColorBlend
|
||||
///</summary>
|
||||
[TypeConverter(typeof(BackColorBlendConvertor))]
|
||||
public class BackColorBlend : INotifyPropertyChanged
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Color[] _Colors; // Color values
|
||||
private float[] _Positions; // Gradient color positions
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Colors
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ColorBlend Color array
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(null)]
|
||||
[Description("Indicates the ColorBlend Color array")]
|
||||
[TypeConverter(typeof(ArrayConverter))]
|
||||
public Color[] Colors
|
||||
{
|
||||
get { return (_Colors); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != null && value.Length == 0)
|
||||
value = null;
|
||||
|
||||
_Colors = value;
|
||||
|
||||
OnPropertyChangedEx("Colors");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Positions
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ColorBlend Color Positions
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(null)]
|
||||
[Description("Indicates the ColorBlend Color Positions")]
|
||||
[TypeConverter(typeof(ArrayConverter))]
|
||||
public float[] Positions
|
||||
{
|
||||
get { return (_Positions); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != null && value.Length == 0)
|
||||
value = null;
|
||||
|
||||
_Positions = value;
|
||||
|
||||
OnPropertyChangedEx("Positions");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// IsEmpty
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsEmpty
|
||||
{
|
||||
get { return (_Colors == null || _Colors.Length == 1 && _Colors[0].IsEmpty); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the BackColorBlend.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the BackColorBlend.</returns>
|
||||
public BackColorBlend Copy()
|
||||
{
|
||||
BackColorBlend copy = new BackColorBlend();
|
||||
|
||||
if (_Colors != null)
|
||||
{
|
||||
copy.Colors = new Color[_Colors.Length];
|
||||
|
||||
_Colors.CopyTo(copy.Colors, 0);
|
||||
}
|
||||
|
||||
if (_Positions != null)
|
||||
{
|
||||
copy.Positions = new float[_Positions.Length];
|
||||
|
||||
_Positions.CopyTo(copy.Positions, 0);
|
||||
}
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="s">Event arguments</param>
|
||||
protected virtual void OnPropertyChangedEx(string s)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
{
|
||||
VisualPropertyChangedEventArgs e =
|
||||
new VisualPropertyChangedEventArgs(s);
|
||||
|
||||
eh(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region BackColorBlendConvertor
|
||||
|
||||
/// <summary>
|
||||
/// BackColorBlendConvertor
|
||||
/// </summary>
|
||||
public class BackColorBlendConvertor : ExpandableObjectConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// ConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
BackColorBlend cb = value as BackColorBlend;
|
||||
|
||||
if (cb != null)
|
||||
{
|
||||
ColorConverter cvt = new ColorConverter();
|
||||
|
||||
if (cb.Colors != null)
|
||||
{
|
||||
if (cb.Colors[0] != Color.Empty)
|
||||
return (cvt.ConvertToString(cb.Colors[0]));
|
||||
|
||||
if (cb.Colors.Length > 1 && cb.Colors[1] != Color.Empty)
|
||||
return (cvt.ConvertToString(cb.Colors[1]));
|
||||
}
|
||||
}
|
||||
|
||||
return (String.Empty);
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
+766
@@ -0,0 +1,766 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Globalization;
|
||||
using DevComponents.Instrumentation.Primitives;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents background of visual style.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(BackgroundConvertor))]
|
||||
[Editor(typeof(BackgroundEditor), typeof(UITypeEditor))]
|
||||
public class Background : INotifyPropertyChanged, IDisposable
|
||||
{
|
||||
#region Static data
|
||||
|
||||
///<summary>
|
||||
/// Empty
|
||||
///</summary>
|
||||
/// <summary>
|
||||
/// Returns Empty instance of BorderPattern.
|
||||
/// </summary>
|
||||
public static Background Empty
|
||||
{
|
||||
get { return (new Background()); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private Color _Color1 = Color.Empty;
|
||||
private Color _Color2 = Color.Empty;
|
||||
|
||||
private int _GradientAngle = 90;
|
||||
|
||||
private BackFillType _BackFillType = BackFillType.Angle;
|
||||
private BackColorBlend _BackColorBlend;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
public Background() { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">Start color.</param>
|
||||
public Background(Color color1)
|
||||
{
|
||||
_Color1 = color1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">Start color.</param>
|
||||
/// <param name="color2">End color.</param>
|
||||
public Background(Color color1, Color color2)
|
||||
{
|
||||
_Color1 = color1;
|
||||
_Color2 = color2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">Start color in hexadecimal representation like FFFFFF.</param>
|
||||
/// <param name="color2">End color in hexadecimal representation like FFFFFF.</param>
|
||||
public Background(string color1, string color2)
|
||||
{
|
||||
_Color1 = ColorFactory.GetColor(color1);
|
||||
_Color2 = ColorFactory.GetColor(color2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">Start color in 32-bit RGB representation.</param>
|
||||
/// <param name="color2">End color in 32-bit RGB representation.</param>
|
||||
public Background(int color1, int color2)
|
||||
{
|
||||
_Color1 = ColorFactory.GetColor(color1);
|
||||
_Color2 = ColorFactory.GetColor(color2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">Start color in 32-bit RGB representation.</param>
|
||||
/// <param name="color2">End color in 32-bit RGB representation.</param>
|
||||
/// <param name="gradientAngle">Gradient angle.</param>
|
||||
public Background(int color1, int color2, int gradientAngle)
|
||||
{
|
||||
_Color1 = ColorFactory.GetColor(color1);
|
||||
_Color2 = ColorFactory.GetColor(color2);
|
||||
|
||||
GradientAngle = gradientAngle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">Start color.</param>
|
||||
/// <param name="color2">End color.</param>
|
||||
/// <param name="gradientAngle">Gradient angle.</param>
|
||||
public Background(Color color1, Color color2, int gradientAngle)
|
||||
{
|
||||
_Color1 = color1;
|
||||
_Color2 = color2;
|
||||
|
||||
GradientAngle = gradientAngle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">Start color.</param>
|
||||
/// <param name="color2">End color.</param>
|
||||
/// <param name="fillType">Gradient angle.</param>
|
||||
public Background(Color color1, Color color2, BackFillType fillType)
|
||||
{
|
||||
_Color1 = color1;
|
||||
_Color2 = color2;
|
||||
|
||||
_BackFillType = fillType;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Color1
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the start color.
|
||||
/// </summary>
|
||||
[Description("Indicates the Starting Gradient Color.")]
|
||||
public Color Color1
|
||||
{
|
||||
get { return (_Color1); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Color1 != value)
|
||||
{
|
||||
_Color1 = value;
|
||||
|
||||
OnPropertyChangedEx("Color1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal virtual bool ShouldSerializeColor1()
|
||||
{
|
||||
return (_Color1.IsEmpty == false);
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal virtual void ResetColor1()
|
||||
{
|
||||
_Color1 = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Color2
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Ending Gradient Color
|
||||
/// </summary>
|
||||
[Description("Indicates the Ending Gradient Color")]
|
||||
public Color Color2
|
||||
{
|
||||
get { return (_Color2); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Color2 != value)
|
||||
{
|
||||
_Color2 = value;
|
||||
|
||||
OnPropertyChangedEx("Color2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal virtual bool ShouldSerializeColor2()
|
||||
{
|
||||
return (_Color2.IsEmpty == false);
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal virtual void ResetColor2()
|
||||
{
|
||||
_Color2 = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BackColorBlend
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the BackColorBlend.
|
||||
/// </summary>
|
||||
[Description("Indicates the BackColorBlend.")]
|
||||
public BackColorBlend BackColorBlend
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_BackColorBlend == null)
|
||||
{
|
||||
_BackColorBlend = new BackColorBlend();
|
||||
|
||||
UpgateChangeHandler(null, _BackColorBlend);
|
||||
}
|
||||
|
||||
return (_BackColorBlend);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_BackColorBlend != value)
|
||||
{
|
||||
UpgateChangeHandler(_BackColorBlend, value);
|
||||
|
||||
_BackColorBlend = value;
|
||||
|
||||
OnPropertyChangedEx("BackColorBlend");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal virtual bool ShouldSerializeBackColorBlend()
|
||||
{
|
||||
return (_BackColorBlend != null && _BackColorBlend.IsEmpty == false);
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal virtual void ResetBackColorBlend()
|
||||
{
|
||||
BackColorBlend = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GradientAngle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the gradient angle (default is 90)
|
||||
/// </summary>
|
||||
[DefaultValue(90)]
|
||||
[Description("Indicates the Gradient Angle default is 90)")]
|
||||
public int GradientAngle
|
||||
{
|
||||
get { return (_GradientAngle); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_GradientAngle != value)
|
||||
{
|
||||
_GradientAngle = value;
|
||||
|
||||
OnPropertyChangedEx("GradientAngle");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BackFillType
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Gradient BackFillType
|
||||
/// </summary>
|
||||
[DefaultValue(BackFillType.Angle)]
|
||||
[Description("Indicates the Gradient BackFillType.")]
|
||||
public BackFillType BackFillType
|
||||
{
|
||||
get { return (_BackFillType); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_BackFillType != value)
|
||||
{
|
||||
_BackFillType = value;
|
||||
|
||||
OnPropertyChangedEx("BackFillType");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether both colors assigned are empty.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_Color1.IsEmpty && _Color2.IsEmpty &&
|
||||
(_BackColorBlend == null || _BackColorBlend.IsEmpty));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEqualTo
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the Background is equal to the given one
|
||||
/// </summary>
|
||||
/// <param name="background">Background to compare</param>
|
||||
/// <returns>true if equal</returns>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsEqualTo(Background background)
|
||||
{
|
||||
return (_Color1 == background.Color1 &&
|
||||
_Color2 == background.Color2 &&
|
||||
_BackColorBlend.Equals(background._BackColorBlend) &&
|
||||
_GradientAngle == background.GradientAngle &&
|
||||
_BackFillType == background.BackFillType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetBrush
|
||||
|
||||
///<summary>
|
||||
/// GetBrush
|
||||
///</summary>
|
||||
///<param name="r"></param>
|
||||
///<returns></returns>
|
||||
public Brush GetBrush(Rectangle r)
|
||||
{
|
||||
if (_BackColorBlend != null && _BackColorBlend.IsEmpty == false)
|
||||
{
|
||||
if (_BackColorBlend.Colors.Length == 1)
|
||||
return (new SolidBrush(_BackColorBlend.Colors[0]));
|
||||
|
||||
Brush br = GetLinearBrush(r);
|
||||
|
||||
if (br is LinearGradientBrush)
|
||||
{
|
||||
ColorBlend cb = GetColorBlend();
|
||||
|
||||
if (cb != null)
|
||||
((LinearGradientBrush) br).InterpolationColors = cb;
|
||||
}
|
||||
|
||||
return (br);
|
||||
}
|
||||
|
||||
if (_Color2.IsEmpty == true)
|
||||
return (new SolidBrush(_Color1));
|
||||
|
||||
return (GetLinearBrush(r));
|
||||
}
|
||||
|
||||
#region GetLinearBrush
|
||||
|
||||
private Brush GetLinearBrush(Rectangle r)
|
||||
{
|
||||
LinearGradientBrush lbr = null;
|
||||
|
||||
if (r.Width > 0 && r.Height > 0)
|
||||
{
|
||||
switch (_BackFillType)
|
||||
{
|
||||
case BackFillType.Angle:
|
||||
lbr = new LinearGradientBrush(r, _Color1, _Color2, _GradientAngle);
|
||||
break;
|
||||
|
||||
case BackFillType.HorizontalCenter:
|
||||
r.Width /= 2;
|
||||
r.Width = Math.Max(1, r.Width);
|
||||
|
||||
lbr = new LinearGradientBrush(r, _Color1, _Color2, 0f);
|
||||
break;
|
||||
|
||||
case BackFillType.VerticalCenter:
|
||||
r.Height /= 2;
|
||||
r.Height = Math.Max(1, r.Height);
|
||||
|
||||
lbr = new LinearGradientBrush(r, _Color1, _Color2, 90f);
|
||||
break;
|
||||
|
||||
case BackFillType.ForwardDiagonal:
|
||||
lbr = new LinearGradientBrush(r, _Color1, _Color2, LinearGradientMode.ForwardDiagonal);
|
||||
break;
|
||||
|
||||
case BackFillType.BackwardDiagonal:
|
||||
lbr = new LinearGradientBrush(r, _Color1, _Color2, LinearGradientMode.BackwardDiagonal);
|
||||
break;
|
||||
|
||||
case BackFillType.ForwardDiagonalCenter:
|
||||
r.Width /= 2;
|
||||
r.Height /= 2;
|
||||
lbr = new LinearGradientBrush(r, _Color1, _Color2, LinearGradientMode.ForwardDiagonal);
|
||||
break;
|
||||
|
||||
case BackFillType.BackwardDiagonalCenter:
|
||||
r.Width /= 2;
|
||||
r.Height /= 2;
|
||||
r.X += r.Width;
|
||||
|
||||
lbr = new LinearGradientBrush(r, _Color1, _Color2, LinearGradientMode.BackwardDiagonal);
|
||||
break;
|
||||
|
||||
case BackFillType.Center:
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
path.AddRectangle(r);
|
||||
|
||||
PathGradientBrush pbr = new PathGradientBrush(path);
|
||||
|
||||
pbr.CenterColor = _Color1;
|
||||
pbr.SurroundColors = new Color[] {_Color2};
|
||||
|
||||
ColorBlend cb = GetColorBlend();
|
||||
|
||||
if (cb != null)
|
||||
pbr.InterpolationColors = cb;
|
||||
|
||||
return (pbr);
|
||||
}
|
||||
|
||||
case BackFillType.Radial:
|
||||
int n = (int) Math.Sqrt(r.Width*r.Width + r.Height*r.Height) + 4;
|
||||
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
path.AddEllipse(r.X - (n - r.Width)/2, r.Y - (n - r.Height)/2, n, n);
|
||||
|
||||
PathGradientBrush pbr = new PathGradientBrush(path);
|
||||
|
||||
pbr.CenterColor = _Color1;
|
||||
pbr.SurroundColors = new Color[] {_Color2};
|
||||
|
||||
ColorBlend cb = GetColorBlend();
|
||||
|
||||
if (cb != null)
|
||||
pbr.InterpolationColors = cb;
|
||||
|
||||
return (pbr);
|
||||
}
|
||||
}
|
||||
|
||||
if (lbr != null)
|
||||
lbr.WrapMode = WrapMode.TileFlipXY;
|
||||
}
|
||||
|
||||
return (lbr);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetColorBlend
|
||||
|
||||
private ColorBlend GetColorBlend()
|
||||
{
|
||||
if (_BackColorBlend != null &&
|
||||
_BackColorBlend.Colors != null && _BackColorBlend.Colors.Length > 0)
|
||||
{
|
||||
ColorBlend cb = new ColorBlend(_BackColorBlend.Colors.Length);
|
||||
|
||||
cb.Colors = _BackColorBlend.Colors;
|
||||
cb.Positions = GetPositions();
|
||||
|
||||
return (cb);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPositions
|
||||
|
||||
private float[] GetPositions()
|
||||
{
|
||||
float[] cp = _BackColorBlend.Positions;
|
||||
|
||||
if (cp == null || cp.Length != _BackColorBlend.Colors.Length)
|
||||
{
|
||||
cp = new float[_BackColorBlend.Colors.Length];
|
||||
|
||||
float f = 1f / _BackColorBlend.Colors.Length;
|
||||
|
||||
for (int i = 0; i < cp.Length; i++)
|
||||
cp[i] = i * f;
|
||||
|
||||
cp[_BackColorBlend.Colors.Length - 1] = 1;
|
||||
}
|
||||
|
||||
return (cp);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the background.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the background.</returns>
|
||||
public Background Copy()
|
||||
{
|
||||
Background copy = new Background();
|
||||
|
||||
copy.Color1 = _Color1;
|
||||
copy.Color2 = _Color2;
|
||||
|
||||
copy.GradientAngle = _GradientAngle;
|
||||
copy.BackFillType = _BackFillType;
|
||||
|
||||
if (_BackColorBlend != null)
|
||||
copy.BackColorBlend = _BackColorBlend.Copy();
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(VisualPropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="s">Event arguments</param>
|
||||
protected virtual void OnPropertyChangedEx(string s)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
{
|
||||
VisualPropertyChangedEventArgs e =
|
||||
new VisualPropertyChangedEventArgs(s);
|
||||
|
||||
eh(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpgateChangeHandler
|
||||
|
||||
private void UpgateChangeHandler(
|
||||
INotifyPropertyChanged oldValue, INotifyPropertyChanged newValue)
|
||||
{
|
||||
if (oldValue != null)
|
||||
oldValue.PropertyChanged -= StyleChanged;
|
||||
|
||||
if (newValue != null)
|
||||
newValue.PropertyChanged += StyleChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StyleChanged
|
||||
|
||||
/// <summary>
|
||||
/// StyleChanged
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected virtual void StyleChanged(
|
||||
object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged((VisualPropertyChangedEventArgs)e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
BackColorBlend = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
///<summary>
|
||||
/// BackFillType
|
||||
///</summary>
|
||||
public enum BackFillType
|
||||
{
|
||||
///<summary>
|
||||
/// Angle
|
||||
///</summary>
|
||||
Angle,
|
||||
|
||||
///<summary>
|
||||
/// Center
|
||||
///</summary>
|
||||
Center,
|
||||
|
||||
///<summary>
|
||||
/// HorizontalCenter
|
||||
///</summary>
|
||||
HorizontalCenter,
|
||||
|
||||
///<summary>
|
||||
/// VerticalCenter
|
||||
///</summary>
|
||||
VerticalCenter,
|
||||
|
||||
///<summary>
|
||||
/// ForwardDiagonal
|
||||
///</summary>
|
||||
ForwardDiagonal,
|
||||
|
||||
///<summary>
|
||||
/// BackwardDiagonal
|
||||
///</summary>
|
||||
BackwardDiagonal,
|
||||
|
||||
///<summary>
|
||||
/// ForwardDiagonalCenter
|
||||
///</summary>
|
||||
ForwardDiagonalCenter,
|
||||
|
||||
///<summary>
|
||||
/// BackwardDiagonalCenter
|
||||
///</summary>
|
||||
BackwardDiagonalCenter,
|
||||
|
||||
///<summary>
|
||||
/// Radial
|
||||
///</summary>
|
||||
Radial,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BackgroundConvertor
|
||||
|
||||
///<summary>
|
||||
/// BackgroundConvertor
|
||||
///</summary>
|
||||
public class BackgroundConvertor : ExpandableObjectConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// ConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
Background gc = value as Background;
|
||||
|
||||
if (gc != null)
|
||||
{
|
||||
if (gc.BackColorBlend != null && gc.BackColorBlend.IsEmpty == false)
|
||||
return ("Blended");
|
||||
|
||||
ColorConverter cvt = new ColorConverter();
|
||||
|
||||
string s = gc.Color1.IsEmpty ? "(Empty)" : cvt.ConvertToString(gc.Color1);
|
||||
|
||||
if (gc.Color2 != Color.Empty)
|
||||
s += ", " + cvt.ConvertToString(gc.Color2);
|
||||
|
||||
return (s);
|
||||
}
|
||||
}
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BackgroundEditor
|
||||
|
||||
///<summary>
|
||||
/// BackgroundEditor
|
||||
///</summary>
|
||||
public class BackgroundEditor : UITypeEditor
|
||||
{
|
||||
#region GetPaintValueSupported
|
||||
|
||||
/// <summary>
|
||||
/// GetPaintValueSupported
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PaintValue
|
||||
|
||||
/// <summary>
|
||||
/// PaintValue
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public override void PaintValue(PaintValueEventArgs e)
|
||||
{
|
||||
Background b = e.Value as Background;
|
||||
|
||||
if (b != null)
|
||||
{
|
||||
using (Brush br = b.GetBrush(e.Bounds))
|
||||
e.Graphics.FillRectangle(br, e.Bounds);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
+414
@@ -0,0 +1,414 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the visual style of a Row.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public class BaseRowHeaderVisualStyle : BaseVisualStyle
|
||||
{
|
||||
#region Static data
|
||||
|
||||
///<summary>
|
||||
/// Empty
|
||||
///</summary>
|
||||
public static BaseRowHeaderVisualStyle Empty
|
||||
{
|
||||
get { return (new BaseRowHeaderVisualStyle()); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private Background _Background;
|
||||
private Color _BorderHighlightColor = Color.Empty;
|
||||
|
||||
private Font _Font;
|
||||
private Color _TextColor = Color.Empty;
|
||||
private Tbool _AllowWrap = Tbool.NotSet;
|
||||
private Alignment _TextAlignment = Alignment.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AllowWrap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether text wrapping is permitted
|
||||
/// </summary>
|
||||
[DefaultValue(Tbool.NotSet), Category("Appearance")]
|
||||
[Description("Indicates whether text wrapping is permitted.")]
|
||||
public Tbool AllowWrap
|
||||
{
|
||||
get { return (_AllowWrap); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_AllowWrap != value)
|
||||
{
|
||||
_AllowWrap = value;
|
||||
|
||||
OnPropertyChangedEx("AllowWrap", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Background
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style background.
|
||||
/// </summary>
|
||||
[Description("Indicates whether the style background")]
|
||||
public Background Background
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Background == null)
|
||||
{
|
||||
_Background = Background.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _Background);
|
||||
}
|
||||
|
||||
return (_Background);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_Background != value)
|
||||
{
|
||||
UpdateChangeHandler(_Background, value);
|
||||
|
||||
_Background = value;
|
||||
|
||||
OnPropertyChangedEx("Background", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeBackground()
|
||||
{
|
||||
return (_Background != null && _Background.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetBackground()
|
||||
{
|
||||
Background = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BorderHighlightColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the border Highlight color.
|
||||
/// </summary>
|
||||
[Description("Indicates whether the border Highlight color")]
|
||||
public Color BorderHighlightColor
|
||||
{
|
||||
get { return (_BorderHighlightColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_BorderHighlightColor != value)
|
||||
{
|
||||
_BorderHighlightColor = value;
|
||||
|
||||
OnPropertyChangedEx("BorderHighlightColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeBorderHighlightColor()
|
||||
{
|
||||
return (_BorderHighlightColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetBorderHighlightColor()
|
||||
{
|
||||
_BorderHighlightColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Font
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style Font.
|
||||
/// </summary>
|
||||
[DefaultValue(null)]
|
||||
[Description("Indicates the RowHeader Font")]
|
||||
public Font Font
|
||||
{
|
||||
get { return (_Font); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Font != value)
|
||||
{
|
||||
_Font = value;
|
||||
|
||||
OnPropertyChangedEx("Font", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
///<summary>
|
||||
/// IsEmpty
|
||||
///</summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((_Background == null || _Background.IsEmpty) &&
|
||||
_BorderHighlightColor == Color.Empty &&
|
||||
_Font == null && TextColor == Color.Empty && base.IsEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextAlignment
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alignment of the header text
|
||||
/// </summary>
|
||||
[DefaultValue(Alignment.NotSet), Category("Appearance")]
|
||||
[Description("Indicates the alignment of the header text.")]
|
||||
public Alignment TextAlignment
|
||||
{
|
||||
get { return (_TextAlignment); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextAlignment != value)
|
||||
{
|
||||
_TextAlignment = value;
|
||||
|
||||
OnPropertyChangedEx("TextAlignment", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Text color
|
||||
/// </summary>
|
||||
[Description("Indicates the Text color")]
|
||||
public Color TextColor
|
||||
{
|
||||
get { return (_TextColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextColor != value)
|
||||
{
|
||||
_TextColor = value;
|
||||
|
||||
OnPropertyChangedEx("TextColor", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeTextColor()
|
||||
{
|
||||
return (_TextColor.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetTextColor()
|
||||
{
|
||||
_TextColor = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetTextFormatFlags
|
||||
|
||||
internal eTextFormat GetTextFormatFlags()
|
||||
{
|
||||
eTextFormat tf = eTextFormat.WordEllipsis |
|
||||
eTextFormat.NoPadding | eTextFormat.NoPrefix;
|
||||
|
||||
if (AllowWrap == Tbool.True)
|
||||
tf |= eTextFormat.WordBreak;
|
||||
|
||||
switch (TextAlignment)
|
||||
{
|
||||
case Alignment.TopCenter:
|
||||
tf |= eTextFormat.HorizontalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.TopRight:
|
||||
tf |= eTextFormat.Right;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleLeft:
|
||||
tf |= eTextFormat.VerticalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.NotSet:
|
||||
case Alignment.MiddleCenter:
|
||||
tf |= eTextFormat.HorizontalCenter;
|
||||
tf |= eTextFormat.VerticalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleRight:
|
||||
tf |= eTextFormat.Right;
|
||||
tf |= eTextFormat.VerticalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.BottomLeft:
|
||||
tf |= eTextFormat.Bottom;
|
||||
break;
|
||||
|
||||
case Alignment.BottomCenter:
|
||||
tf |= eTextFormat.Bottom;
|
||||
tf |= eTextFormat.HorizontalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.BottomRight:
|
||||
tf |= eTextFormat.Bottom;
|
||||
tf |= eTextFormat.Right;
|
||||
break;
|
||||
}
|
||||
|
||||
return (tf);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(BaseRowHeaderVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.Font != null)
|
||||
_Font = style.Font;
|
||||
|
||||
if (style.TextColor.IsEmpty == false)
|
||||
_TextColor = style._TextColor;
|
||||
|
||||
if (style.Background != null && style.Background.IsEmpty == false)
|
||||
Background = style.Background.Copy();
|
||||
|
||||
if (style.BorderHighlightColor.IsEmpty == false)
|
||||
BorderHighlightColor = style.BorderHighlightColor;
|
||||
|
||||
if (style.AllowWrap != Tbool.NotSet)
|
||||
_AllowWrap = style.AllowWrap;
|
||||
|
||||
if (style.TextAlignment != Alignment.NotSet)
|
||||
_TextAlignment = style.TextAlignment;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new BaseRowHeaderVisualStyle Copy()
|
||||
{
|
||||
BaseRowHeaderVisualStyle style = new BaseRowHeaderVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(BaseRowHeaderVisualStyle copy)
|
||||
{
|
||||
base.CopyTo(copy);
|
||||
|
||||
if (_Font != null)
|
||||
copy.Font = (Font)_Font.Clone();
|
||||
|
||||
if (_TextColor.IsEmpty == false)
|
||||
copy.TextColor = _TextColor;
|
||||
|
||||
copy.BorderHighlightColor = BorderHighlightColor;
|
||||
|
||||
if (_Background != null)
|
||||
copy.Background = _Background.Copy();
|
||||
|
||||
copy.TextAlignment = _TextAlignment;
|
||||
copy.AllowWrap = _AllowWrap;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
Background = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+451
@@ -0,0 +1,451 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the base visual style.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false)]
|
||||
public class BaseVisualStyle : INotifyPropertyChanged, IDisposable
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private string _Class = "";
|
||||
private object _Tag;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Class
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the class style belongs to.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public string Class
|
||||
{
|
||||
get { return (_Class); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Class != value)
|
||||
{
|
||||
_Class = value;
|
||||
|
||||
OnPropertyChangedEx("Class", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the style is logically Empty.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
[Description("Gets whether the style is logically Empty.")]
|
||||
public virtual bool IsEmpty
|
||||
{
|
||||
get { return (_Tag == null); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tag
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user defined reference Tag.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
[Description("User defined reference Tag.")]
|
||||
public object Tag
|
||||
{
|
||||
get { return (_Tag); }
|
||||
set { _Tag = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(BaseVisualStyle style)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetApplyStyleTypes
|
||||
|
||||
internal StyleType[] GetApplyStyleTypes(StyleType e)
|
||||
{
|
||||
StyleType[] css = null;
|
||||
|
||||
switch (e)
|
||||
{
|
||||
case StyleType.Default:
|
||||
css = new StyleType[] { StyleType.Default};
|
||||
break;
|
||||
|
||||
case StyleType.Empty:
|
||||
case StyleType.MouseOver:
|
||||
case StyleType.ReadOnly:
|
||||
case StyleType.Selected:
|
||||
case StyleType.NotSelectable:
|
||||
css = new StyleType[] { StyleType.Default, e };
|
||||
break;
|
||||
|
||||
case StyleType.SelectedMouseOver:
|
||||
css = new StyleType[] { StyleType.Default, StyleType.Selected, e };
|
||||
break;
|
||||
|
||||
case StyleType.ReadOnlyMouseOver:
|
||||
css = new StyleType[] { StyleType.Default, StyleType.ReadOnly, e };
|
||||
break;
|
||||
|
||||
case StyleType.ReadOnlySelected:
|
||||
css = new StyleType[] { StyleType.Default, StyleType.Selected, StyleType.ReadOnly, e };
|
||||
break;
|
||||
|
||||
case StyleType.ReadOnlySelectedMouseOver:
|
||||
css = new StyleType[] { StyleType.Default, StyleType.Selected, StyleType.ReadOnly, StyleType.ReadOnlySelected, e };
|
||||
break;
|
||||
}
|
||||
|
||||
return (css);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public BaseVisualStyle Copy()
|
||||
{
|
||||
BaseVisualStyle style = new BaseVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(BaseVisualStyle copy)
|
||||
{
|
||||
copy.Class = _Class;
|
||||
copy.Tag = _Tag;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
protected void OnPropertyChanged(string s)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs(s));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <param name="changeType">invalidate</param>
|
||||
protected void OnPropertyChangedEx(string s, VisualChangeType changeType)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs(s, changeType));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateChangeHandler
|
||||
|
||||
/// <summary>
|
||||
/// UpdateChangeHandler
|
||||
/// </summary>
|
||||
/// <param name="oldValue"></param>
|
||||
/// <param name="newValue"></param>
|
||||
protected void UpdateChangeHandler(
|
||||
INotifyPropertyChanged oldValue, INotifyPropertyChanged newValue)
|
||||
{
|
||||
if (oldValue != null)
|
||||
oldValue.PropertyChanged -= ValuePropertyChanged;
|
||||
|
||||
if (newValue != null)
|
||||
newValue.PropertyChanged += ValuePropertyChanged;
|
||||
}
|
||||
|
||||
void ValuePropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region Alignment
|
||||
|
||||
///<summary>
|
||||
/// Alignment of the content
|
||||
///</summary>
|
||||
public enum Alignment
|
||||
{
|
||||
///<summary>
|
||||
///</summary>
|
||||
NotSet = -1,
|
||||
|
||||
///<summary>
|
||||
/// TopLeft
|
||||
///</summary>
|
||||
TopLeft,
|
||||
|
||||
///<summary>
|
||||
/// TopCenter
|
||||
///</summary>
|
||||
TopCenter,
|
||||
|
||||
///<summary>
|
||||
/// TopRight
|
||||
///</summary>
|
||||
TopRight,
|
||||
|
||||
///<summary>
|
||||
/// MiddleLeft
|
||||
///</summary>
|
||||
MiddleLeft,
|
||||
|
||||
///<summary>
|
||||
/// MiddleCenter
|
||||
///</summary>
|
||||
MiddleCenter,
|
||||
|
||||
/// <summary>
|
||||
/// MiddleRight
|
||||
/// </summary>
|
||||
MiddleRight,
|
||||
|
||||
/// <summary>
|
||||
/// BottomLeft
|
||||
/// </summary>
|
||||
BottomLeft,
|
||||
|
||||
/// <summary>
|
||||
/// BottomCenter
|
||||
/// </summary>
|
||||
BottomCenter,
|
||||
|
||||
/// <summary>
|
||||
/// BottomRight
|
||||
/// </summary>
|
||||
BottomRight,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BorderSide
|
||||
|
||||
internal enum BorderSide
|
||||
{
|
||||
Top,
|
||||
Left,
|
||||
Bottom,
|
||||
Right
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CellHighlightMode
|
||||
|
||||
///<summary>
|
||||
/// Specifies the mode of cell highlighting
|
||||
/// to employ when a grid cell is selected
|
||||
///</summary>
|
||||
public enum CellHighlightMode
|
||||
{
|
||||
///<summary>
|
||||
/// No highlighting
|
||||
///</summary>
|
||||
None,
|
||||
|
||||
///<summary>
|
||||
/// Entire cell will be Highlighted
|
||||
///</summary>
|
||||
Full,
|
||||
|
||||
///<summary>
|
||||
/// Partial cell will be Highlighted
|
||||
///</summary>
|
||||
Partial,
|
||||
|
||||
///<summary>
|
||||
/// Cell content only will be Highlighted
|
||||
///</summary>
|
||||
Content,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ImageHighlightMode
|
||||
|
||||
///<summary>
|
||||
/// ImageHighlightMode
|
||||
///</summary>
|
||||
public enum ImageHighlightMode
|
||||
{
|
||||
///<summary>
|
||||
/// NotSet
|
||||
///</summary>
|
||||
NotSet = -1,
|
||||
|
||||
///<summary>
|
||||
/// Default
|
||||
///</summary>
|
||||
Default,
|
||||
|
||||
///<summary>
|
||||
/// Always
|
||||
///</summary>
|
||||
Always,
|
||||
|
||||
///<summary>
|
||||
/// Never
|
||||
///</summary>
|
||||
Never,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ImageOverlay
|
||||
|
||||
///<summary>
|
||||
/// How to Overlay the Image with
|
||||
/// respect to the content
|
||||
///</summary>
|
||||
public enum ImageOverlay
|
||||
{
|
||||
///<summary>
|
||||
///</summary>
|
||||
NotSet = -1,
|
||||
|
||||
///<summary>
|
||||
/// None
|
||||
///</summary>
|
||||
None,
|
||||
|
||||
///<summary>
|
||||
/// Top
|
||||
///</summary>
|
||||
Top,
|
||||
|
||||
///<summary>
|
||||
/// Bottom
|
||||
///</summary>
|
||||
Bottom,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tbool
|
||||
|
||||
///<summary>
|
||||
/// TBool - Three state boolean
|
||||
///</summary>
|
||||
public enum Tbool
|
||||
{
|
||||
///<summary>
|
||||
/// NotSet
|
||||
///</summary>
|
||||
NotSet,
|
||||
|
||||
///<summary>
|
||||
/// True
|
||||
///</summary>
|
||||
True,
|
||||
|
||||
///<summary>
|
||||
/// False
|
||||
///</summary>
|
||||
False
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VisualChangeType
|
||||
|
||||
/// <summary>
|
||||
/// Defines visual property change type.
|
||||
/// </summary>
|
||||
public enum VisualChangeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Visual style has changed so layout is impacted
|
||||
/// </summary>
|
||||
Layout,
|
||||
|
||||
/// <summary>
|
||||
/// Visual style has changed so visuals are impacted, but not layout
|
||||
/// </summary>
|
||||
Render
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
+460
@@ -0,0 +1,460 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents style border color.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(BorderColorConverter))]
|
||||
public class BorderColor : INotifyPropertyChanged
|
||||
{
|
||||
#region Static data
|
||||
|
||||
///<summary>
|
||||
/// Empty
|
||||
///</summary>
|
||||
/// <summary>
|
||||
/// Returns Empty instance of BorderColor.
|
||||
/// </summary>
|
||||
public static BorderColor Empty
|
||||
{
|
||||
get { return (new BorderColor()); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private Color _Top = Color.Empty;
|
||||
private Color _Left = Color.Empty;
|
||||
private Color _Bottom = Color.Empty;
|
||||
private Color _Right = Color.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the BorderColor object.
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="top"></param>
|
||||
/// <param name="right"></param>
|
||||
/// <param name="bottom"></param>
|
||||
public BorderColor(Color left, Color top, Color right, Color bottom)
|
||||
{
|
||||
_Top = top;
|
||||
_Bottom = bottom;
|
||||
_Left = left;
|
||||
_Right = right;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the BorderColor object.
|
||||
/// </summary>
|
||||
public BorderColor(Color all)
|
||||
: this(all, all, all, all)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the BorderColor object.
|
||||
/// </summary>
|
||||
public BorderColor()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region All
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of all borders.
|
||||
/// </summary>
|
||||
//[Browsable(false)]
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Color All
|
||||
{
|
||||
set { _Top = _Left = _Bottom = _Right = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bottom
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the bottom border
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the color of the bottom border")]
|
||||
public Color Bottom
|
||||
{
|
||||
get { return (_Bottom); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Bottom != value)
|
||||
{
|
||||
_Bottom = value;
|
||||
|
||||
OnVisualPropertyChanged("Bottom");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeBottom()
|
||||
{
|
||||
return (_Bottom.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetBottom()
|
||||
{
|
||||
_Bottom = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Left
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the left border
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the color of the left border")]
|
||||
public Color Left
|
||||
{
|
||||
get { return (_Left); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Left != value)
|
||||
{
|
||||
_Left = value;
|
||||
|
||||
OnVisualPropertyChanged("Left");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLeft()
|
||||
{
|
||||
return (_Left.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLeft()
|
||||
{
|
||||
_Left = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Right
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the right border
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the color of the right border")]
|
||||
public Color Right
|
||||
{
|
||||
get { return (_Right); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Right != value)
|
||||
{
|
||||
_Right = value;
|
||||
|
||||
OnVisualPropertyChanged("Right");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeRight()
|
||||
{
|
||||
return (_Right.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetRight()
|
||||
{
|
||||
_Right = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Top
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the top border
|
||||
/// </summary>
|
||||
[Category("Appearance")]
|
||||
[Description("Indicates the color of the top border")]
|
||||
public Color Top
|
||||
{
|
||||
get { return (_Top); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Top != value)
|
||||
{
|
||||
_Top = value;
|
||||
|
||||
OnVisualPropertyChanged("Top");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeTop()
|
||||
{
|
||||
return (_Top.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetTop()
|
||||
{
|
||||
_Top = Color.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
internal bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_Left.IsEmpty && _Top.IsEmpty &&
|
||||
_Right.IsEmpty && _Bottom.IsEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsUniform
|
||||
|
||||
internal bool IsUniform
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_Left == _Top &&
|
||||
_Left == _Right && _Left == _Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
#region '==' operator
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances.
|
||||
/// </summary>
|
||||
/// <param name="t1">Instance 1</param>
|
||||
/// <param name="t2">Instance 2</param>
|
||||
/// <returns>true if same</returns>
|
||||
public static bool operator ==(BorderColor t1, BorderColor t2)
|
||||
{
|
||||
// If both are null, or both are same instance, return true.
|
||||
|
||||
if (ReferenceEquals(t1, t2))
|
||||
return (true);
|
||||
|
||||
// If one is null, but not both, return false.
|
||||
|
||||
if (((object)t1 == null) || ((object)t2 == null))
|
||||
return (false);
|
||||
|
||||
return (t1._Left == t2._Left && t1._Right == t2._Right &&
|
||||
t1._Top == t2._Top && t1._Bottom == t2._Bottom);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region "!=" operator
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances.
|
||||
/// </summary>
|
||||
/// <param name="t1">Instance 1</param>
|
||||
/// <param name="t2">Instance 2</param>
|
||||
/// <returns>true if different.</returns>
|
||||
public static bool operator !=(BorderColor t1, BorderColor t2)
|
||||
{
|
||||
return ((t1 == t2) == false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetHashCode
|
||||
|
||||
/// <summary>
|
||||
/// Returns hash-code for object.
|
||||
/// </summary>
|
||||
/// <returns>Hash-code value.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (((_Left.GetHashCode() ^ _Top.GetHashCode()) ^
|
||||
_Right.GetHashCode()) ^ _Bottom.GetHashCode());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Equals
|
||||
|
||||
/// <summary>
|
||||
/// Compares object to this instance.
|
||||
/// </summary>
|
||||
/// <param name="obj">Object to compare.</param>
|
||||
/// <returns>true if same.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is BorderColor)
|
||||
return ((BorderColor) obj == this);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares object to this instance.
|
||||
/// </summary>
|
||||
/// <param name="borderColor">Border color</param>
|
||||
/// <returns>true if same</returns>
|
||||
public bool Equals(BorderColor borderColor)
|
||||
{
|
||||
return (this == borderColor);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the BorderColor.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the BorderColor.</returns>
|
||||
public BorderColor Copy()
|
||||
{
|
||||
BorderColor copy = new BorderColor(_Left, _Top, _Right, _Bottom);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
protected void OnPropertyChanged(string s)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(s));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default PropertyChanged processing
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
protected void OnVisualPropertyChanged(string s)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs(s));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region BorderColorConverter
|
||||
|
||||
/// <summary>
|
||||
/// BorderColorConverter
|
||||
/// </summary>
|
||||
public class BorderColorConverter : ExpandableObjectConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// ConvertTo
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(
|
||||
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
return (String.Empty);
|
||||
|
||||
return (base.ConvertTo(context, culture, value, destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
+418
@@ -0,0 +1,418 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines Thickness class.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
||||
public class BorderPattern : IEquatable<BorderPattern>, INotifyPropertyChanged
|
||||
{
|
||||
#region Static data
|
||||
|
||||
/// <summary>
|
||||
/// Returns Empty instance of BorderPattern.
|
||||
/// </summary>
|
||||
public static BorderPattern Empty
|
||||
{
|
||||
get { return (new BorderPattern()); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private LinePattern _Bottom = LinePattern.NotSet;
|
||||
private LinePattern _Left = LinePattern.NotSet;
|
||||
private LinePattern _Right = LinePattern.NotSet;
|
||||
private LinePattern _Top = LinePattern.NotSet;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="left">Left BorderPatternStyle.</param>
|
||||
/// <param name="top">Top BorderPatternStyle.</param>
|
||||
/// <param name="right">Right BorderPatternStyle.</param>
|
||||
/// <param name="bottom">Bottom BorderPatternStyle.</param>
|
||||
public BorderPattern(LinePattern left,
|
||||
LinePattern top, LinePattern right, LinePattern bottom)
|
||||
{
|
||||
_Left = left;
|
||||
_Top = top;
|
||||
_Right = right;
|
||||
_Bottom = bottom;
|
||||
|
||||
PropertyChanged = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="all">Specifies uniform Thickness.</param>
|
||||
public BorderPattern(LinePattern all)
|
||||
: this(all, all, all, all)
|
||||
{
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Creates new instance of the object.
|
||||
///</summary>
|
||||
public BorderPattern()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region All
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the thickness of all sides.
|
||||
/// </summary>
|
||||
//[Browsable(false)]
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public LinePattern All
|
||||
{
|
||||
set { _Top = _Left = _Bottom = _Right = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bottom
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bottom Border Pattern
|
||||
/// </summary>
|
||||
[DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the bottom Border Pattern")]
|
||||
public LinePattern Bottom
|
||||
{
|
||||
get { return (_Bottom); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Bottom != value)
|
||||
{
|
||||
_Bottom = value;
|
||||
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs("Bottom"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Left
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the left Border Pattern
|
||||
/// </summary>
|
||||
[DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the left Border Pattern")]
|
||||
public LinePattern Left
|
||||
{
|
||||
get { return (_Left); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Left != value)
|
||||
{
|
||||
_Left = value;
|
||||
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs("Left"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Right
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Right Border Pattern
|
||||
/// </summary>
|
||||
[DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the Right Border Pattern")]
|
||||
public LinePattern Right
|
||||
{
|
||||
get { return (_Right); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Right != value)
|
||||
{
|
||||
_Right = value;
|
||||
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs("Right"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Top
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Top Border Pattern
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(LinePattern.NotSet)]
|
||||
[Description("Indicates the Top Border Pattern")]
|
||||
public LinePattern Top
|
||||
{
|
||||
get { return (_Top); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Top != value)
|
||||
{
|
||||
_Top = value;
|
||||
|
||||
OnPropertyChanged(new VisualPropertyChangedEventArgs("Top"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the item is empty
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_Left == LinePattern.NotSet &&
|
||||
_Right == LinePattern.NotSet &&
|
||||
_Top == LinePattern.NotSet &&
|
||||
_Bottom == LinePattern.NotSet);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region IsUniform
|
||||
|
||||
internal bool IsUniform
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_Left == _Top &&
|
||||
_Left == _Right && _Left == _Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Equals
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether two instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="obj">Instance to compare to.</param>
|
||||
/// <returns>true if equal otherwise false.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is BorderPattern)
|
||||
return (this == (BorderPattern)obj);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether two instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="borderPattern">Instance to compare to</param>
|
||||
/// <returns>true if equal otherwise false</returns>
|
||||
public bool Equals(BorderPattern borderPattern)
|
||||
{
|
||||
return (this == borderPattern);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetHashCode
|
||||
|
||||
/// <summary>
|
||||
/// Returns hash-code.
|
||||
/// </summary>
|
||||
/// <returns>hash-code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (((_Left.GetHashCode() ^ _Top.GetHashCode()) ^
|
||||
_Right.GetHashCode()) ^ _Bottom.GetHashCode());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
#region "==" operator
|
||||
|
||||
/// <summary>
|
||||
/// Implements == operator.
|
||||
/// </summary>
|
||||
/// <param name="t1">Object 1</param>
|
||||
/// <param name="t2">Object 2</param>
|
||||
/// <returns>true if equals</returns>
|
||||
public static bool operator ==(BorderPattern t1, BorderPattern t2)
|
||||
{
|
||||
if (ReferenceEquals(t1, t2))
|
||||
return (true);
|
||||
|
||||
if (((object)t1 == null) || ((object)t2 == null))
|
||||
return (false);
|
||||
|
||||
return (t1._Left == t2._Left && t1._Right == t2._Right &&
|
||||
t1._Top == t2._Top && t1._Bottom == t2._Bottom);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region "!=" operator
|
||||
|
||||
/// <summary>
|
||||
/// Implements != operator
|
||||
/// </summary>
|
||||
/// <param name="t1">Object 1</param>
|
||||
/// <param name="t2">Object 2</param>
|
||||
/// <returns>true if different</returns>
|
||||
public static bool operator !=(BorderPattern t1, BorderPattern t2)
|
||||
{
|
||||
return ((t1 == t2) == false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyPattern
|
||||
|
||||
/// <summary>
|
||||
/// Applies the pattern to instance of this pattern.
|
||||
/// </summary>
|
||||
/// <param name="pattern">Pattern to apply.</param>
|
||||
public void ApplyPattern(BorderPattern pattern)
|
||||
{
|
||||
if (pattern != null)
|
||||
{
|
||||
if (pattern.Top != LinePattern.NotSet)
|
||||
_Top = pattern.Top;
|
||||
|
||||
if (pattern.Left != LinePattern.NotSet)
|
||||
_Left = pattern.Left;
|
||||
|
||||
if (pattern.Bottom != LinePattern.NotSet)
|
||||
_Bottom = pattern.Bottom;
|
||||
|
||||
if (pattern.Right != LinePattern.NotSet)
|
||||
_Right = pattern.Right;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Creates an exact copy of the BorderPattern.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the BorderPattern.</returns>
|
||||
public BorderPattern Copy()
|
||||
{
|
||||
BorderPattern copy = new BorderPattern(_Left, _Top, _Right, _Bottom);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
void OnPropertyChanged(VisualPropertyChangedEventArgs e)
|
||||
{
|
||||
PropertyChangedEventHandler eh = PropertyChanged;
|
||||
|
||||
if (eh != null)
|
||||
eh(this, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region LinePattern
|
||||
|
||||
///<summary>
|
||||
/// LinePattern
|
||||
///</summary>
|
||||
public enum LinePattern
|
||||
{
|
||||
///<summary>
|
||||
/// None
|
||||
///</summary>
|
||||
None = -2,
|
||||
|
||||
///<summary>
|
||||
/// NotSet
|
||||
///</summary>
|
||||
NotSet = -1,
|
||||
|
||||
///<summary>
|
||||
/// Solid
|
||||
///</summary>
|
||||
Solid = DashStyle.Solid,
|
||||
|
||||
///<summary>
|
||||
/// Dash
|
||||
///</summary>
|
||||
Dash = DashStyle.Dash,
|
||||
|
||||
///<summary>
|
||||
/// Dot
|
||||
///</summary>
|
||||
Dot = DashStyle.Dot,
|
||||
|
||||
///<summary>
|
||||
/// DashDot
|
||||
///</summary>
|
||||
DashDot = DashStyle.DashDot,
|
||||
|
||||
///<summary>
|
||||
/// DashDotDot
|
||||
///</summary>
|
||||
DashDotDot = DashStyle.DashDotDot,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
+898
@@ -0,0 +1,898 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.SuperGrid.Primitives;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid.Style
|
||||
{
|
||||
///<summary>
|
||||
/// CellVisualStyles
|
||||
///</summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class CellVisualStyles : VisualStyles<CellVisualStyle>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the visual style of an element.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(VisualStylesConverter))]
|
||||
public class CellVisualStyle : VisualStyle
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Tbool _AllowWrap = Tbool.NotSet;
|
||||
private Tbool _AllowMultiLine = Tbool.NotSet;
|
||||
private Alignment _Alignment = Alignment.NotSet;
|
||||
|
||||
private Image _Image;
|
||||
private int _ImageIndex = -1;
|
||||
private Padding _ImagePadding;
|
||||
private Alignment _ImageAlignment = Alignment.NotSet;
|
||||
private ImageHighlightMode _ImageHighlightMode = ImageHighlightMode.NotSet;
|
||||
private ImageOverlay _ImageOverlay = ImageOverlay.NotSet;
|
||||
|
||||
private SymbolDef _SymbolDef;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Alignment
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alignment of the content within the cell
|
||||
/// </summary>
|
||||
[DefaultValue(Alignment.NotSet), Category("Appearance")]
|
||||
[Description("Indicates the alignment of the content within the cell.")]
|
||||
public Alignment Alignment
|
||||
{
|
||||
get { return (_Alignment); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Alignment != value)
|
||||
{
|
||||
_Alignment = value;
|
||||
|
||||
OnPropertyChangedEx("Alignment", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AllowMultiLine
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether multiple text lines (via "\r\n" inclusion)
|
||||
/// are displayed when text wrapping (AllowWrap) is disabled.
|
||||
/// </summary>
|
||||
[DefaultValue(Tbool.NotSet), Category("Appearance")]
|
||||
[Description("Indicates whether multiple text lines (via '\r\n' inclusion) are displayed when text wrapping (AllowWrap) is disabled.")]
|
||||
public Tbool AllowMultiLine
|
||||
{
|
||||
get { return (_AllowMultiLine); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_AllowMultiLine != value)
|
||||
{
|
||||
_AllowMultiLine = value;
|
||||
|
||||
OnPropertyChangedEx("AllowMultiLine", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AllowWrap
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether text wrapping is permitted
|
||||
/// </summary>
|
||||
[DefaultValue(Tbool.NotSet), Category("Appearance")]
|
||||
[Description("Indicates whether text wrapping is permitted.")]
|
||||
public Tbool AllowWrap
|
||||
{
|
||||
get { return (_AllowWrap); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_AllowWrap != value)
|
||||
{
|
||||
_AllowWrap = value;
|
||||
|
||||
OnPropertyChangedEx("AllowWrap", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Image
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element Image
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance")]
|
||||
[Description("Indicates the element image")]
|
||||
public Image Image
|
||||
{
|
||||
get { return (_Image); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Image != value)
|
||||
{
|
||||
_Image = value;
|
||||
|
||||
OnPropertyChangedEx("Image", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ImageAlignment
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alignment of the Image within the cell
|
||||
/// </summary>
|
||||
[DefaultValue(Alignment.NotSet), Category("Appearance")]
|
||||
[Description("Indicates the alignment of the Image within the cell.")]
|
||||
public Alignment ImageAlignment
|
||||
{
|
||||
get { return (_ImageAlignment); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ImageAlignment != value)
|
||||
{
|
||||
_ImageAlignment = value;
|
||||
|
||||
OnPropertyChangedEx("ImageAlignment", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ImageHighlightMode
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how cell images are
|
||||
/// highlighted when the cell is selected
|
||||
/// </summary>
|
||||
[DefaultValue(ImageHighlightMode.NotSet), Category("Style")]
|
||||
[Description("Indicates how cell images are highlighted when the cell is selected")]
|
||||
public ImageHighlightMode ImageHighlightMode
|
||||
{
|
||||
get { return (_ImageHighlightMode); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _ImageHighlightMode)
|
||||
{
|
||||
_ImageHighlightMode = value;
|
||||
|
||||
OnPropertyChangedEx("ImageHighlightMode", VisualChangeType.Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ImageIndex
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the image index
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(-1)]
|
||||
[Category("Appearance"), Description("Indicates the image index")]
|
||||
[Editor("DevComponents.SuperGrid.Design.ImageIndexEditor, DevComponents.SuperGrid.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=26d81176cfa2b486", typeof(UITypeEditor))]
|
||||
[TypeConverter(typeof(ImageIndexConverter))]
|
||||
public int ImageIndex
|
||||
{
|
||||
get { return (_ImageIndex); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ImageIndex != value)
|
||||
{
|
||||
_ImageIndex = value;
|
||||
|
||||
OnPropertyChangedEx("ImageIndex", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetImageIndex()
|
||||
{
|
||||
ImageIndex = -1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ImageOverlay
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how to overlay the cell image with respect to cell content
|
||||
/// </summary>
|
||||
[DefaultValue(ImageOverlay.NotSet), Category("Appearance")]
|
||||
[Description("Indicates how to overlay the cell image with respect to cell content.")]
|
||||
public ImageOverlay ImageOverlay
|
||||
{
|
||||
get { return (_ImageOverlay); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ImageOverlay != value)
|
||||
{
|
||||
_ImageOverlay = value;
|
||||
|
||||
OnPropertyChangedEx("ImageOverlay", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ImagePadding
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the spacing between content and edges of the Image
|
||||
/// </summary>
|
||||
[Description("Indicates the spacing between content and edges of the Image")]
|
||||
public Padding ImagePadding
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ImagePadding == null)
|
||||
{
|
||||
_ImagePadding = Padding.Empty;
|
||||
|
||||
UpdateChangeHandler(null, _ImagePadding);
|
||||
}
|
||||
|
||||
return (_ImagePadding);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_ImagePadding != value)
|
||||
{
|
||||
UpdateChangeHandler(_ImagePadding, value);
|
||||
|
||||
_ImagePadding = value;
|
||||
|
||||
OnPropertyChangedEx("ImagePadding", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeImagePadding()
|
||||
{
|
||||
return (_ImagePadding != null && _ImagePadding.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetImagePadding()
|
||||
{
|
||||
ImagePadding = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SymbolDef
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element Symbol Definition. Note that
|
||||
/// Symbol definition takes precedence over Image definition.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
[Description("Indicates the element Symbol Definition. Note that Symbol definition takes precedence over Image definition.")]
|
||||
public SymbolDef SymbolDef
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SymbolDef == null)
|
||||
{
|
||||
_SymbolDef = new SymbolDef();
|
||||
|
||||
UpdateChangeHandler(null, _SymbolDef);
|
||||
}
|
||||
|
||||
return (_SymbolDef);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_SymbolDef != value)
|
||||
{
|
||||
UpdateChangeHandler(_SymbolDef, value);
|
||||
|
||||
_SymbolDef = value;
|
||||
|
||||
OnPropertyChangedEx("SymbolDef", VisualChangeType.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private bool ShouldSerializeSymbolDef()
|
||||
{
|
||||
return (_SymbolDef != null && _SymbolDef.IsEmpty == false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private void ResetSymbolDef()
|
||||
{
|
||||
SymbolDef = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsEmpty
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the style is logically Empty.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
[Description("Gets whether the style is logically Empty.")]
|
||||
public override bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((_Alignment == Alignment.NotSet) &&
|
||||
(_AllowWrap == Tbool.NotSet) &&
|
||||
(_Image == null) &&
|
||||
(_ImageAlignment == Alignment.NotSet) &&
|
||||
(_ImageHighlightMode == ImageHighlightMode.NotSet) &&
|
||||
(_ImageIndex == -1) &&
|
||||
(_ImageOverlay == ImageOverlay.NotSet) &&
|
||||
(_ImagePadding == null || _ImagePadding.IsEmpty == true) &&
|
||||
|
||||
(base.IsEmpty == true));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region IsOverlayImage
|
||||
|
||||
internal bool IsOverlayImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_ImageOverlay == ImageOverlay.Top ||
|
||||
_ImageOverlay == ImageOverlay.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsSymbolFigure
|
||||
|
||||
internal bool IsSymbolFigure
|
||||
{
|
||||
get { return (_SymbolDef != null && _SymbolDef.IsValidSymbol == true); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyStyle
|
||||
|
||||
/// <summary>
|
||||
/// Applies the style to instance of this style.
|
||||
/// </summary>
|
||||
/// <param name="style">Style to apply.</param>
|
||||
public void ApplyStyle(CellVisualStyle style)
|
||||
{
|
||||
if (style != null)
|
||||
{
|
||||
base.ApplyStyle(style);
|
||||
|
||||
if (style.Alignment != Alignment.NotSet)
|
||||
_Alignment = style.Alignment;
|
||||
|
||||
if (style.AllowWrap != Tbool.NotSet)
|
||||
_AllowWrap = style.AllowWrap;
|
||||
|
||||
if (style.AllowMultiLine != Tbool.NotSet)
|
||||
_AllowMultiLine = style.AllowMultiLine;
|
||||
|
||||
if (style.ImageIndex >= 0)
|
||||
{
|
||||
_Image = null;
|
||||
_ImageIndex = style.ImageIndex;
|
||||
}
|
||||
|
||||
if (style.Image != null)
|
||||
{
|
||||
_Image = style.Image;
|
||||
_ImageIndex = -1;
|
||||
}
|
||||
|
||||
if (style.ImageAlignment != Alignment.NotSet)
|
||||
_ImageAlignment = style.ImageAlignment;
|
||||
|
||||
if (style.ImageHighlightMode != ImageHighlightMode.NotSet)
|
||||
_ImageHighlightMode = style.ImageHighlightMode;
|
||||
|
||||
if (style._ImagePadding != null && style._ImagePadding.IsEmpty == false)
|
||||
_ImagePadding = style._ImagePadding.Copy();
|
||||
|
||||
if (style.ImageOverlay != ImageOverlay.NotSet)
|
||||
_ImageOverlay = style.ImageOverlay;
|
||||
|
||||
if (style._SymbolDef != null && style._SymbolDef.IsEmpty == false)
|
||||
_SymbolDef = style._SymbolDef.Copy();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ApplyDefaults
|
||||
|
||||
internal void ApplyDefaults()
|
||||
{
|
||||
if (_SymbolDef != null && _SymbolDef.IsValidSymbol == true)
|
||||
{
|
||||
if (_SymbolDef.SymbolSize == 0)
|
||||
{
|
||||
if (Font != null)
|
||||
_SymbolDef.SymbolSize = Font.SizeInPoints;
|
||||
}
|
||||
|
||||
if (_SymbolDef.SymbolColor.IsEmpty == true)
|
||||
{
|
||||
_SymbolDef.SymbolColor =
|
||||
(TextColor.IsEmpty == false) ? TextColor : Color.Black;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetTextFormatFlags
|
||||
|
||||
internal virtual eTextFormat GetTextFormatFlags()
|
||||
{
|
||||
eTextFormat tf = eTextFormat.WordEllipsis |
|
||||
eTextFormat.NoPadding | eTextFormat.NoPrefix;
|
||||
|
||||
if (AllowWrap == Tbool.True)
|
||||
{
|
||||
tf |= eTextFormat.WordBreak;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AllowMultiLine != Tbool.True)
|
||||
tf |= eTextFormat.SingleLine;
|
||||
}
|
||||
|
||||
switch (Alignment)
|
||||
{
|
||||
case Alignment.TopCenter:
|
||||
tf |= eTextFormat.HorizontalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.TopRight:
|
||||
tf |= eTextFormat.Right;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleLeft:
|
||||
tf |= eTextFormat.VerticalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleCenter:
|
||||
tf |= eTextFormat.HorizontalCenter;
|
||||
tf |= eTextFormat.VerticalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleRight:
|
||||
tf |= eTextFormat.Right;
|
||||
tf |= eTextFormat.VerticalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.BottomLeft:
|
||||
tf |= eTextFormat.Bottom;
|
||||
break;
|
||||
|
||||
case Alignment.BottomCenter:
|
||||
tf |= eTextFormat.Bottom;
|
||||
tf |= eTextFormat.HorizontalCenter;
|
||||
break;
|
||||
|
||||
case Alignment.BottomRight:
|
||||
tf |= eTextFormat.Bottom;
|
||||
tf |= eTextFormat.Right;
|
||||
break;
|
||||
}
|
||||
|
||||
return (tf);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsValidFigure
|
||||
|
||||
internal bool IsValidFigure(GridPanel panel)
|
||||
{
|
||||
if (IsSymbolFigure == true)
|
||||
return (true);
|
||||
|
||||
return (GetImage(panel) != null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetFigure
|
||||
|
||||
internal object GetFigure(GridPanel panel)
|
||||
{
|
||||
if (_SymbolDef != null && _SymbolDef.IsEmpty == false)
|
||||
return (_SymbolDef);
|
||||
|
||||
return (GetImage(panel));
|
||||
}
|
||||
|
||||
#region GetImage
|
||||
|
||||
private Image GetImage(GridPanel panel)
|
||||
{
|
||||
if (_Image != null)
|
||||
return (_Image);
|
||||
|
||||
if (_ImageIndex >= 0 && panel != null)
|
||||
{
|
||||
ImageList imageList = panel.ImageList;
|
||||
|
||||
if (imageList != null && _ImageIndex < imageList.Images.Count)
|
||||
return (imageList.Images[_ImageIndex]);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetSymbol
|
||||
|
||||
private string GetSymbol()
|
||||
{
|
||||
if (_SymbolDef != null && _SymbolDef.IsEmpty == false)
|
||||
return (_SymbolDef.SymbolRealized);
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetFigureSize
|
||||
|
||||
internal Size GetFigureSize(GridPanel panel)
|
||||
{
|
||||
Size size = GetFigureSizeEx(panel);
|
||||
|
||||
if (size.IsEmpty == false)
|
||||
{
|
||||
size.Width += Dpi.Width(ImagePadding.Horizontal);
|
||||
size.Height += Dpi.Height(ImagePadding.Vertical);
|
||||
}
|
||||
|
||||
return (size);
|
||||
}
|
||||
|
||||
internal Size GetFigureSizeEx(GridPanel panel)
|
||||
{
|
||||
Size size = Size.Empty;
|
||||
|
||||
if (IsSymbolFigure == true)
|
||||
{
|
||||
size = _SymbolDef.GetSymbolSize(panel.SuperGrid);
|
||||
}
|
||||
else
|
||||
{
|
||||
Image image = GetImage(panel);
|
||||
|
||||
if (image != null)
|
||||
size = Dpi.Size(image.Size);
|
||||
}
|
||||
|
||||
return (size);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetFigureBounds
|
||||
|
||||
internal Rectangle GetFigureBounds(GridPanel panel, Rectangle r)
|
||||
{
|
||||
Size size = GetFigureSize(panel);
|
||||
|
||||
return (GetSizeBounds(panel, r, size));
|
||||
}
|
||||
|
||||
#region GetSizeBounds
|
||||
|
||||
private Rectangle GetSizeBounds(GridPanel panel, Rectangle r, Size size)
|
||||
{
|
||||
bool overlay = IsOverlayImage;
|
||||
|
||||
switch (ImageAlignment)
|
||||
{
|
||||
case Alignment.TopLeft:
|
||||
if (overlay == false)
|
||||
r.X -= size.Width;
|
||||
break;
|
||||
|
||||
case Alignment.NotSet:
|
||||
case Alignment.MiddleLeft:
|
||||
if (overlay == false)
|
||||
r.X -= size.Width;
|
||||
|
||||
r.Y += (r.Height - size.Height) / 2;
|
||||
break;
|
||||
|
||||
case Alignment.BottomLeft:
|
||||
if (overlay == false)
|
||||
r.X -= size.Width;
|
||||
|
||||
r.Y = r.Bottom - size.Height;
|
||||
break;
|
||||
|
||||
case Alignment.TopCenter:
|
||||
r.X += (r.Width - size.Width) / 2;
|
||||
|
||||
if (overlay == false)
|
||||
r.Y -= size.Height;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleCenter:
|
||||
r.X += (r.Width - size.Width) / 2;
|
||||
r.Y += (r.Height - size.Height) / 2;
|
||||
break;
|
||||
|
||||
case Alignment.BottomCenter:
|
||||
r.X += (r.Width - size.Width) / 2;
|
||||
r.Y = r.Bottom;
|
||||
|
||||
if (overlay == true)
|
||||
r.Y -= size.Height;
|
||||
break;
|
||||
|
||||
case Alignment.TopRight:
|
||||
r.X = r.Right;
|
||||
|
||||
if (overlay == true)
|
||||
r.X -= size.Width;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleRight:
|
||||
r.X = r.Right;
|
||||
|
||||
if (overlay == true)
|
||||
r.X -= size.Width;
|
||||
|
||||
r.Y += (r.Height - size.Height) / 2;
|
||||
|
||||
break;
|
||||
|
||||
case Alignment.BottomRight:
|
||||
r.X = r.Right;
|
||||
r.Y = r.Bottom - size.Height;
|
||||
|
||||
if (overlay == true)
|
||||
r.X -= size.Width;
|
||||
break;
|
||||
}
|
||||
|
||||
r.Size = GetFigureSizeEx(panel);
|
||||
|
||||
r.X += ImagePadding.Left;
|
||||
r.Y += ImagePadding.Top;
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetNonFigureBounds
|
||||
|
||||
internal Rectangle GetNonFigureBounds(GridPanel panel, Rectangle r)
|
||||
{
|
||||
object figure = GetFigure(panel);
|
||||
|
||||
if (figure != null)
|
||||
{
|
||||
if (IsOverlayImage == false)
|
||||
{
|
||||
Size size = GetFigureSize(panel);
|
||||
|
||||
switch (ImageAlignment)
|
||||
{
|
||||
case Alignment.TopCenter:
|
||||
r.Y += size.Height;
|
||||
r.Height -= size.Height;
|
||||
break;
|
||||
|
||||
case Alignment.MiddleCenter:
|
||||
break;
|
||||
|
||||
case Alignment.BottomCenter:
|
||||
r.Height -= size.Height;
|
||||
break;
|
||||
|
||||
case Alignment.TopRight:
|
||||
case Alignment.MiddleRight:
|
||||
case Alignment.BottomRight:
|
||||
r.Width -= size.Width;
|
||||
break;
|
||||
|
||||
default:
|
||||
r.X += size.Width;
|
||||
r.Width -= size.Width;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderFigure
|
||||
|
||||
internal void RenderFigure(Graphics g, GridPanel panel, Rectangle r)
|
||||
{
|
||||
RenderFigure(g, GetFigure(panel), r);
|
||||
}
|
||||
|
||||
internal void RenderFigure(Graphics g, object figure, Rectangle r)
|
||||
{
|
||||
if (r.Width > 0 && r.Height > 0)
|
||||
{
|
||||
if (figure is Image)
|
||||
{
|
||||
g.DrawImageUnscaledAndClipped((Image)figure, r);
|
||||
}
|
||||
else if (figure is SymbolDef)
|
||||
{
|
||||
SymbolDef sd = (SymbolDef)figure;
|
||||
|
||||
using (Brush br = new SolidBrush(sd.SymbolColor))
|
||||
g.DrawString(sd.SymbolRealized, sd.SymbolFont, br, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public new CellVisualStyle Copy()
|
||||
{
|
||||
CellVisualStyle style = new CellVisualStyle();
|
||||
|
||||
CopyTo(style);
|
||||
|
||||
return (style);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyTo
|
||||
|
||||
/// <summary>
|
||||
/// Returns the copy of the style.
|
||||
/// </summary>
|
||||
/// <returns>Copy of the style.</returns>
|
||||
public void CopyTo(CellVisualStyle style)
|
||||
{
|
||||
base.CopyTo(style);
|
||||
|
||||
style.Alignment = _Alignment;
|
||||
style.AllowWrap = _AllowWrap;
|
||||
style.AllowMultiLine = _AllowMultiLine;
|
||||
|
||||
style.Image = _Image;
|
||||
style.ImageAlignment = _ImageAlignment;
|
||||
style.ImageHighlightMode = _ImageHighlightMode;
|
||||
style.ImageIndex = _ImageIndex;
|
||||
style.ImageOverlay = _ImageOverlay;
|
||||
style.ImagePadding = (_ImagePadding != null) ? _ImagePadding.Copy() : null;
|
||||
|
||||
style.SymbolDef = (_SymbolDef != null) ? _SymbolDef.Copy() : null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
ImagePadding = null;
|
||||
SymbolDef = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region VisualPropertyChangedEventArgs
|
||||
|
||||
/// <summary>
|
||||
/// Represents visual property changed event arguments.
|
||||
/// </summary>
|
||||
public class VisualPropertyChangedEventArgs : PropertyChangedEventArgs
|
||||
{
|
||||
#region Public data
|
||||
|
||||
/// <summary>
|
||||
/// Gets the change type.
|
||||
/// </summary>
|
||||
public readonly VisualChangeType ChangeType;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the VisualPropertyChangedEventArgs class.
|
||||
/// </summary>
|
||||
public VisualPropertyChangedEventArgs(string propertyName)
|
||||
: base(propertyName)
|
||||
{
|
||||
ChangeType = VisualChangeType.Layout;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the VisualPropertyChangedEventArgs class.
|
||||
/// </summary>
|
||||
public VisualPropertyChangedEventArgs(string propertyName, VisualChangeType changeType)
|
||||
: base(propertyName)
|
||||
{
|
||||
ChangeType = changeType;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user